Class: Pennyworth::Presenters::StandardGem

Inherits:
Object
  • Object
show all
Defined in:
lib/pennyworth/presenters/standard_gem.rb

Overview

Shapes a standard gem record for serialization.

Instance Method Summary collapse

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

#idObject



18
# File 'lib/pennyworth/presenters/standard_gem.rb', line 18

def id = record.fetch :gem

#issues_urlObject



35
# File 'lib/pennyworth/presenters/standard_gem.rb', line 35

def issues_url = "https://github.com/ruby/#{id}/issues"

#labelObject



20
# File 'lib/pennyworth/presenters/standard_gem.rb', line 20

def label = "#{inflector.call id.titleize} #{version}"

#site_urlObject



31
# File 'lib/pennyworth/presenters/standard_gem.rb', line 31

def site_url = record.fetch(:sourceRepository, Core::EMPTY_STRING)

#source_urlObject



33
# File 'lib/pennyworth/presenters/standard_gem.rb', line 33

def source_url = record.fetch(:sourceRepository, Core::EMPTY_STRING)

#subtitleObject



22
# File 'lib/pennyworth/presenters/standard_gem.rb', line 22

def subtitle = record.fetch :description

#versionObject



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_urlObject



37
# File 'lib/pennyworth/presenters/standard_gem.rb', line 37

def versions_url = "https://github.com/ruby/#{id}/tags"