Class: RubyGems
- Inherits:
-
Object
- Object
- RubyGems
- Defined in:
- lib/ruby_gems.rb
Instance Method Summary collapse
- #authors ⇒ Object
- #dependencies ⇒ Object
- #description ⇒ Object
- #downloads ⇒ Object
-
#initialize(gem_name) ⇒ RubyGems
constructor
A new instance of RubyGems.
- #licenses ⇒ Object
- #name ⇒ Object
- #platform ⇒ Object
- #status ⇒ Object
- #urls ⇒ Object
- #version ⇒ Object
- #version_downloads ⇒ Object
Constructor Details
#initialize(gem_name) ⇒ RubyGems
Returns a new instance of RubyGems.
6 7 8 9 |
# File 'lib/ruby_gems.rb', line 6 def initialize(gem_name) @response = Faraday.get "https://rubygems.org/api/v1/gems/#{gem_name}.json" @body = JSON.parse(@response.body) end |
Instance Method Details
#authors ⇒ Object
54 55 56 |
# File 'lib/ruby_gems.rb', line 54 def @body["authors"].split(",").map { || .strip } end |
#dependencies ⇒ Object
46 47 48 |
# File 'lib/ruby_gems.rb', line 46 def dependencies Hash[@body["dependencies"].map{|(k,v)| [k.to_sym,[Hash[v.first.map{|(k,v)| [k.to_sym,v]}]]]}] end |
#description ⇒ Object
42 43 44 |
# File 'lib/ruby_gems.rb', line 42 def description @body["info"] end |
#downloads ⇒ Object
15 16 17 |
# File 'lib/ruby_gems.rb', line 15 def downloads @body["downloads"] end |
#licenses ⇒ Object
50 51 52 |
# File 'lib/ruby_gems.rb', line 50 def licenses @body["licenses"] end |
#name ⇒ Object
58 59 60 |
# File 'lib/ruby_gems.rb', line 58 def name @body["name"] end |
#platform ⇒ Object
62 63 64 |
# File 'lib/ruby_gems.rb', line 62 def platform @body["platform"] end |
#status ⇒ Object
11 12 13 |
# File 'lib/ruby_gems.rb', line 11 def status @response.status end |
#urls ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ruby_gems.rb', line 27 def urls url_hash = {} url_hash[:bug_tracker_uri] = @body["bug_tracker_uri"] if @body["bug_tracker_uri"] url_hash[:documentation_uri] = @body["documentation_uri"] if @body["documentation_uri"] url_hash[:gem_uri] = @body["gem_uri"] if @body["gem_uri"] url_hash[:homepage_uri] = @body["homepage_uri"] if @body["homepage_uri"] url_hash[:mailing_list_uri] = @body["mailing_list_uri"] if @body["mailing_list_uri"] url_hash[:project_uri] = @body["project_uri"] if @body["project_uri"] url_hash[:source_code_uri] = @body["source_code_uri"] if @body["source_code_uri"] url_hash[:wiki_uri] = @body["wiki_uri"] if @body["wiki_uri"] url_hash end |
#version ⇒ Object
19 20 21 |
# File 'lib/ruby_gems.rb', line 19 def version @body["version"] end |
#version_downloads ⇒ Object
23 24 25 |
# File 'lib/ruby_gems.rb', line 23 def version_downloads @body["version_downloads"] end |