dlt / pilha Goto Github PK
View Code? Open in Web Editor NEWA Ruby wrapper to the stack exchange API
A Ruby wrapper to the stack exchange API
So say I do:
q = Question.find_by_user_id(91970)
It returns a long list of stuff,
but if I do:
ruby-1.9.2-p0 > q.count
=> nil
ruby-1.9.2-p0 > q.first
=> nil
At first I thought it was maybe a Ruby 1.9.2 issue, but then I tried it in 1.8.7 and am getting the same issue.
How do I iterate through a collection and get Ruby's array methods to work?
The irony is, that you seem to have used .first in the library of Pilha, so not sure what's happening here.
how I access each of the elements?
For instance:
@questions = Question.find_by_user_id(params[:id], :body => true, :pagesize => 10)
When I do:
@questions.first
It returns blank.
Am I missing something?
I also tried sorting the results, but it is giving me a problem.
I did this in my controller:
@questions = Question.find_by_user_id(params[:id]).order("created_at ASC")
And it produced this error:
undefined method `order' for #<OpenStruct total=254, page=1, pagesize=30, questions=[#<StackExchange::StackOv
Basically, a lot of the regular Rails stuff that I am trying, are giving me problems.
What am I doing wrong? Or is all of this part of the OpenStruct issue?
Edit 1:
Btw, the same applies to other regular Rails functions, e.g.:
@questions = Question.find_by_user_id(params[:id]).limit(5)
Throws the error:
undefined method `limit' for #<OpenStruct total=254, page=1, pagesize=30, questions=[#<StackExc
ruby-1.9.2-p0 > u
=> #<StackExchange::StackOverflow::User:0x00000100e63358 @struct=#<OpenStruct user_id=91970, user_type="registered", creation_date=1239946368, display_name="marcamillion", reputation=1415, email_hash="64aa7d1e0eb006175565adb0a47a4452", age=28, last_access_date=1322958915, website_url="http://marcgayle.com", location="Jamaica", about_me="<p>Geek that loves business & tech.</p>\n", question_count=253, answer_count=30, view_count=315, up_vote_count=316, down_vote_count=4, accept_rate=87, association_id="530c4d1d-a273-401d-9df9-31c08e230fd0", user_questions_url="/users/91970/questions", user_answers_url="/users/91970/answers", user_favorites_url="/users/91970/favorites", user_tags_url="/users/91970/tags", user_badges_url="/users/91970/badges", user_timeline_url="/users/91970/timeline", user_mentioned_url="/users/91970/mentioned", user_comments_url="/users/91970/comments", user_reputation_url="/users/91970/reputation", badge_counts={"gold"=>0, "silver"=>9, "bronze"=>28}>>
ruby-1.9.2-p0 > u.accept_rate
NoMethodError: undefined method `accept_rate' for #<StackExchange::StackOverflow::User:0x00000100e63358>
from (irb):33
Hi All,
I am using your pilha to talk with StackOverfow site in my app I am getting the following exception. Kindly help to solve that issue.
rake aborted!
undefined method request' for nil:NilClass c:/ruby187/lib/ruby/gems/1.8/gems/activesupport-2.3.10/lib/active_support/whiny_ nil.rb:52:in
method_missing'
c:/ruby187/lib/ruby/gems/1.8/gems/pilha-0.2.1/lib/pilha/stack_overflow/base.rb:1
7:in request' c:/ruby187/lib/ruby/gems/1.8/gems/pilha-0.2.1/lib/pilha/stack_overflow/question. rb:15:in
all'
Hi All,
I am using using the following pilha code ,
StackExchange::StackOverflow.config do |options|
options.api_key = 'My Key'
end
questions = StackExchange::StackOverflow::Question.all(:tagged => 'math', :body => true)
I am getting the following exception.
rake aborted!
undefined method request' for nil:NilClass
c:/ruby187/lib/ruby/gems/1.8/gems/activesupport-2.3.10/lib/active_support/whiny_
nil.rb:52:inmethod_missing'
c:/ruby187/lib/ruby/gems/1.8/gems/pilha-0.2.1/lib/pilha/stack_overflow/base.rb:1
7:in request'
c:/ruby187/lib/ruby/gems/1.8/gems/pilha-0.2.1/lib/pilha/stack_overflow/question.
rb:15:inall'
Kindly help me out to resolve the issue.
I am executing it in windows machine.
Thanks
Malligarjunan S.
The options in the query() don't seem to work....when I pass the options as:
@questions = Question.find_by_user_id(params[:id], :body => true, :page => 2, :pagesize => 10)
It still returns something like:
#<OpenStruct total=254, page=1, pagesize=30, questions=[#<Sta
The more I dig into it, the more it seems that the options are not being passed as parameters in the URL.
When I do this:
logger.debug(@questions)
This is the result of my params:
Started GET "/?id=91970" for 127.0.0.1 at 2011-12-05 19:04:26 -0500
Processing by HomeController#index as HTML
Parameters: {"id"=>"91970"}
There is no support for any of the other Stackexchange network sites.
How should this be added? Replicate the StackOverflow
parts, just re-name it to the appropriate SE site name, or do something else? I'm open to working on this.
The body method returns nil.
Should i add Question.add(id, :body = true) ?
There is no search method but /search exist in the original api.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.