Class: Pennyworth::Presenters::StandardGem
- Inherits:
-
Object
- Object
- Pennyworth::Presenters::StandardGem
- Defined in:
- lib/pennyworth/presenters/standard_gem.rb
Overview
Shapes a standard gem record for serialization.
Instance Method Summary collapse
- #id ⇒ Object
-
#initialize(record, inflector: Inflector.new) ⇒ StandardGem
constructor
A new instance of StandardGem.
- #issues_url ⇒ Object
- #label ⇒ Object
- #site_url ⇒ Object
- #source_url ⇒ Object
- #subtitle ⇒ Object
- #version ⇒ Object
- #versions_url ⇒ Object
Constructor Details
#initialize(record, inflector: Inflector.new) ⇒ StandardGem
Returns a new instance of StandardGem.
13 14 15 16 |
# File 'lib/pennyworth/presenters/standard_gem.rb', line 13 def initialize record, inflector: Inflector.new @record = record @inflector = inflector end |
Instance Method Details
#id ⇒ Object
18 |
# File 'lib/pennyworth/presenters/standard_gem.rb', line 18 def id = record.fetch :gem |
#issues_url ⇒ Object
35 |
# File 'lib/pennyworth/presenters/standard_gem.rb', line 35 def issues_url = "https://github.com/ruby/#{id}/issues" |
#label ⇒ Object
20 |
# File 'lib/pennyworth/presenters/standard_gem.rb', line 20 def label = "#{inflector.call id.titleize} #{version}" |
#site_url ⇒ Object
31 |
# File 'lib/pennyworth/presenters/standard_gem.rb', line 31 def site_url = record.fetch(:sourceRepository, Core::EMPTY_STRING) |
#source_url ⇒ Object
33 |
# File 'lib/pennyworth/presenters/standard_gem.rb', line 33 def source_url = record.fetch(:sourceRepository, Core::EMPTY_STRING) |
#subtitle ⇒ Object
22 |
# File 'lib/pennyworth/presenters/standard_gem.rb', line 22 def subtitle = record.fetch :description |
#version ⇒ Object
24 25 26 27 28 29 |
# File 'lib/pennyworth/presenters/standard_gem.rb', line 24 def version versions = record.fetch :versions, Core::EMPTY_HASH bundled, defaults = versions.values_at :bundled, :default (bundled || defaults || versions).values.first end |
#versions_url ⇒ Object
37 |
# File 'lib/pennyworth/presenters/standard_gem.rb', line 37 def versions_url = "https://github.com/ruby/#{id}/tags" |