Class: Ray::GitHub
Instance Attribute Summary (collapse)
-
- (Object) query
readonly
Returns the value of attribute query.
-
- (Object) results
readonly
Returns the value of attribute results.
-
- (Object) uri
readonly
Returns the value of attribute uri.
Instance Method Summary (collapse)
-
- (GitHub) initialize(query)
constructor
A new instance of GitHub.
- - (Object) normalize(response)
- - (Object) real_name(owner)
Methods included from Search
#cache, #merge, #multiple_choice, #output, #search
Constructor Details
- (GitHub) initialize(query)
A new instance of GitHub
11 12 13 14 15 |
# File 'lib/ray/search/github.rb', line 11 def initialize query @query = query @uri = "#{Ray::GITHUB_V2_API}/repos/search/radiant+#{@query}" @results = search end |
Instance Attribute Details
- (Object) query (readonly)
Returns the value of attribute query
9 10 11 |
# File 'lib/ray/search/github.rb', line 9 def query @query end |
- (Object) results (readonly)
Returns the value of attribute results
9 10 11 |
# File 'lib/ray/search/github.rb', line 9 def results @results end |
- (Object) uri (readonly)
Returns the value of attribute uri
9 10 11 |
# File 'lib/ray/search/github.rb', line 9 def uri @uri end |
Instance Method Details
- (Object) normalize(response)
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ray/search/github.rb', line 17 def normalize response response = MultiJson.decode response results = {} response["repositories"].each do |extension| results[extension["name"].to_extension_name] = { :author => real_name(extension["owner"]), :description => extension["description"], :homepage => extension["url"], :name => extension["name"].to_extension_name, :uri => extension["url"], :version => "master" } end return results end |
- (Object) real_name(owner)
33 34 35 36 |
# File 'lib/ray/search/github.rb', line 33 def real_name owner response = open("#{GITHUB_V3_API}/users/#{owner}").read MultiJson.decode(response)["name"] end |