Class: Falkor::Gem
Instance Attribute Summary collapse
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#info ⇒ Object
readonly
Returns the value of attribute info.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#project_uri ⇒ Object
readonly
Returns the value of attribute project_uri.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(**attrs) ⇒ Gem
constructor
A new instance of Gem.
- #other_versions ⇒ Object
Methods included from Installable
Constructor Details
#initialize(**attrs) ⇒ Gem
Returns a new instance of Gem.
44 45 46 47 48 49 50 |
# File 'lib/falkor/gem.rb', line 44 def initialize(**attrs) @name = attrs[:name] @info = attrs[:info] @created_at = attrs[:created_at] && Time.parse(attrs[:created_at]) @project_uri = attrs[:homepage_uri] @version = ::Gem::Version.new(attrs[:version]) end |
Instance Attribute Details
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
10 11 12 |
# File 'lib/falkor/gem.rb', line 10 def created_at @created_at end |
#info ⇒ Object (readonly)
Returns the value of attribute info.
10 11 12 |
# File 'lib/falkor/gem.rb', line 10 def info @info end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/falkor/gem.rb', line 10 def name @name end |
#project_uri ⇒ Object (readonly)
Returns the value of attribute project_uri.
10 11 12 |
# File 'lib/falkor/gem.rb', line 10 def project_uri @project_uri end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
10 11 12 |
# File 'lib/falkor/gem.rb', line 10 def version @version end |
Class Method Details
.find(query, version = nil) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/falkor/gem.rb', line 21 def find(query, version = nil) gem_info = if version.nil? Gems.info(query) else rubygems_v2_info(query, version) end new(**gem_info.transform_keys(&:to_sym)) end |
.search(query) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/falkor/gem.rb', line 13 def search(query) return [] if query.nil? || query.empty? Gems.search(query).map do |gem| new(**gem.transform_keys(&:to_sym)) end end |
Instance Method Details
#other_versions ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/falkor/gem.rb', line 52 def other_versions @other_versions ||= Gems.versions(name).map do |payload| next if payload["number"] == version self.class.new( name: name, info: payload["summary"], version: payload["number"], created_at: payload["created_at"] ) end.compact end |