Class: Pennyworth::Presenters::Gem

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

Overview

Shapes a RubyGems record for serialization.

Instance Method Summary collapse

Constructor Details

#initialize(record, inflector: Inflector.new) ⇒ Gem

Returns a new instance of Gem.



12
13
14
15
# File 'lib/pennyworth/presenters/gem.rb', line 12

def initialize record, inflector: Inflector.new
  @record = record
  @inflector = inflector
end

Instance Method Details

#downloadsObject



27
# File 'lib/pennyworth/presenters/gem.rb', line 27

def downloads = record.fetch(__method__)

#idObject



17
# File 'lib/pennyworth/presenters/gem.rb', line 17

def id = record.fetch(:name)

#issues_urlObject



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

def issues_url = record.fetch(:bug_tracker_uri)

#labelObject



19
# File 'lib/pennyworth/presenters/gem.rb', line 19

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

#licensesObject



25
# File 'lib/pennyworth/presenters/gem.rb', line 25

def licenses = Array(record.fetch(__method__)).to_sentence

#site_urlObject



29
# File 'lib/pennyworth/presenters/gem.rb', line 29

def site_url = record.fetch(:homepage_uri)

#source_urlObject



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

def source_url = record.fetch(:source_code_uri)

#subtitleObject



21
# File 'lib/pennyworth/presenters/gem.rb', line 21

def subtitle = "Downloads: #{downloads}. Licenses: #{licenses}. Updated: #{updated_at[..9]}."

#updated_atObject



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

def updated_at = record.fetch(:version_created_at)

#versionObject



23
# File 'lib/pennyworth/presenters/gem.rb', line 23

def version = record.fetch(__method__)

#versions_urlObject



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

def versions_url = record.fetch(:changelog_uri)