Class: Ossert::Fetch::Rubygems
- Inherits:
-
Object
- Object
- Ossert::Fetch::Rubygems
- Extended by:
- Forwardable
- Defined in:
- lib/ossert/fetch/rubygems.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
Instance Method Summary collapse
- #info ⇒ Object
-
#initialize(project) ⇒ Rubygems
constructor
A new instance of Rubygems.
- #process ⇒ Object
- #process_dependencies ⇒ Object
- #process_github_alias ⇒ Object
- #process_links ⇒ Object
- #process_meta ⇒ Object
- #process_releases ⇒ Object
- #releases ⇒ Object
- #reversed_dependencies ⇒ Object
- #version_info ⇒ Object
Constructor Details
#initialize(project) ⇒ Rubygems
Returns a new instance of Rubygems.
10 11 12 13 |
# File 'lib/ossert/fetch/rubygems.rb', line 10 def initialize(project) @client = SimpleClient.new('https://rubygems.org/api/v1/') @project = project end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
5 6 7 |
# File 'lib/ossert/fetch/rubygems.rb', line 5 def client @client end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
5 6 7 |
# File 'lib/ossert/fetch/rubygems.rb', line 5 def project @project end |
Instance Method Details
#info ⇒ Object
15 16 17 |
# File 'lib/ossert/fetch/rubygems.rb', line 15 def info @info ||= client.get("gems/#{project.rubygems_alias}.json") end |
#process ⇒ Object
69 70 71 72 73 74 75 76 77 |
# File 'lib/ossert/fetch/rubygems.rb', line 69 def process process_github_alias process_dependencies process_releases process_links end |
#process_dependencies ⇒ Object
64 65 66 67 |
# File 'lib/ossert/fetch/rubygems.rb', line 64 def process_dependencies agility.total.dependencies = Set.new(info['dependencies']['runtime']).to_a community.total.dependants = Set.new(reversed_dependencies).to_a end |
#process_github_alias ⇒ Object
50 51 52 53 54 55 |
# File 'lib/ossert/fetch/rubygems.rb', line 50 def process_github_alias return unless project.github_alias.blank? match = info['source_code_uri'].try(:match, %r{github.com/([a-zA-Z0-9\.\_\-]+)/([a-zA-Z0-9\.\_\-]+)}) match ||= info['homepage_uri'].try(:match, %r{github.com/([a-zA-Z0-9\.\_\-]+)/([a-zA-Z0-9\.\_\-]+)}) project.github_alias = match ? "#{match[1]}/#{match[2]}" : NO_GITHUB_NAME end |
#process_links ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/ossert/fetch/rubygems.rb', line 37 def process_links .merge!( homepage_url: info['homepage_uri'], docs_url: info['documentation_uri'], wiki_url: info['wiki_uri'], source_url: info['source_code_uri'], issue_tracker_url: info['bug_tracker_uri'], mailing_list_url: info['mailing_list_uri'], rubygems_url: info['project_uri'], github_url: "https://github.com/#{project.github_alias}" # or exception! ) end |
#process_meta ⇒ Object
31 32 33 34 35 |
# File 'lib/ossert/fetch/rubygems.rb', line 31 def [:authors] = info['authors'] [:description] = info['info'] [:current_version] = info['version'] end |
#process_releases ⇒ Object
57 58 59 60 61 62 |
# File 'lib/ossert/fetch/rubygems.rb', line 57 def process_releases releases.each do |release| agility.total.releases_total_rg << release['number'] agility.quarters[release['created_at']].releases_total_rg << release['number'] end end |
#releases ⇒ Object
23 24 25 |
# File 'lib/ossert/fetch/rubygems.rb', line 23 def releases @releases ||= client.get("versions/#{project.rubygems_alias}.json") end |
#reversed_dependencies ⇒ Object
27 28 29 |
# File 'lib/ossert/fetch/rubygems.rb', line 27 def reversed_dependencies client.get("/gems/#{project.rubygems_alias}/reverse_dependencies.json") end |
#version_info ⇒ Object
19 20 21 |
# File 'lib/ossert/fetch/rubygems.rb', line 19 def version_info @info ||= client.get("versions/#{project.rubygems_alias}.json") end |