Class: RubyGems

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_gems.rb

Instance Method Summary collapse

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

#authorsObject



68
69
70
# File 'lib/ruby_gems.rb', line 68

def authors
  @body["authors"].split(",").map{|author| author.strip}
end

#dependenciesObject



60
61
62
# File 'lib/ruby_gems.rb', line 60

def dependencies
  @body["dependencies"]
end

#descriptionObject



56
57
58
# File 'lib/ruby_gems.rb', line 56

def description
  @body["info"]
end

#downloadsObject



15
16
17
# File 'lib/ruby_gems.rb', line 15

def downloads
  @body["downloads"]
end

#licensesObject



64
65
66
# File 'lib/ruby_gems.rb', line 64

def licenses
  @body["licenses"]
end

#nameObject



72
73
74
# File 'lib/ruby_gems.rb', line 72

def name
  @body["name"]
end

#platformObject



76
77
78
# File 'lib/ruby_gems.rb', line 76

def platform
  @body["platform"]
end

#statusObject



11
12
13
# File 'lib/ruby_gems.rb', line 11

def status
  @response.status
end

#urlsObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/ruby_gems.rb', line 27

def urls
  url_hash = {}
  if @body["bug_tracker_uri"]
    url_hash[:bug_tracker_uri] = @body["bug_tracker_uri"]
  end
  if @body["documentation_uri"]
    url_hash[:documentation_uri] = @body["documentation_uri"]
  end
  if @body["gem_uri"]
    url_hash[:gem_uri] = @body["gem_uri"]
  end
  if @body["homepage_uri"]
    url_hash[:homepage_uri] = @body["homepage_uri"]
  end
  if @body["mailing_list_uri"]
    url_hash[:mailing_list_uri] = @body["mailing_list_uri"]
  end
  if @body["project_uri"]
    url_hash[:project_uri] = @body["project_uri"]
  end
  if @body["source_code_uri"]
    url_hash[:source_code_uri] = @body["source_code_uri"]
  end
  if @body["wiki_uri"]
    url_hash[:wiki_uri] = @body["wiki_uri"]
  end
  url_hash
end

#versionObject



19
20
21
# File 'lib/ruby_gems.rb', line 19

def version
  @body["version"]
end

#version_downloadsObject



23
24
25
# File 'lib/ruby_gems.rb', line 23

def version_downloads
  @body["version_downloads"]
end