Class: TachikomaAi::Strategies::Bundler::Gem
- Inherits:
-
Object
- Object
- TachikomaAi::Strategies::Bundler::Gem
- Defined in:
- lib/tachikoma_ai/strategies/bundler/gem.rb
Constant Summary collapse
- SPECS_PATH =
"vendor/bundle/ruby/#{major}.#{minor}.0/specifications/".freeze
- GITHUB_URLS =
File.read(File.('github_urls.json', __dir__))
- GITHUB_URL_JSON =
JSON.parse(GITHUB_URLS)
Instance Attribute Summary collapse
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #compare_url ⇒ Object
- #github_url ⇒ Object
- #github_url? ⇒ Boolean
- #homepage ⇒ Object
-
#initialize(name, from, version) ⇒ Gem
constructor
A new instance of Gem.
Constructor Details
#initialize(name, from, version) ⇒ Gem
Returns a new instance of Gem.
15 16 17 18 19 |
# File 'lib/tachikoma_ai/strategies/bundler/gem.rb', line 15 def initialize(name, from, version) @name = name @from = from @version = version end |
Instance Attribute Details
#from ⇒ Object (readonly)
Returns the value of attribute from.
13 14 15 |
# File 'lib/tachikoma_ai/strategies/bundler/gem.rb', line 13 def from @from end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
13 14 15 |
# File 'lib/tachikoma_ai/strategies/bundler/gem.rb', line 13 def name @name end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
13 14 15 |
# File 'lib/tachikoma_ai/strategies/bundler/gem.rb', line 13 def version @version end |
Instance Method Details
#compare_url ⇒ Object
41 42 43 44 45 |
# File 'lib/tachikoma_ai/strategies/bundler/gem.rb', line 41 def compare_url Repository.new(github_url).compare(from, version) rescue => e "#{github_url}/compare/v#{from}...v#{version} (#{e.class} #{e})" end |
#github_url ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/tachikoma_ai/strategies/bundler/gem.rb', line 25 def github_url if homepage.include?('github.com') homepage elsif GITHUB_URL_JSON.key?(name) "https://github.com/#{GITHUB_URL_JSON[name]}" end end |
#github_url? ⇒ Boolean
21 22 23 |
# File 'lib/tachikoma_ai/strategies/bundler/gem.rb', line 21 def github_url? !github_url.nil? end |
#homepage ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/tachikoma_ai/strategies/bundler/gem.rb', line 33 def homepage @homepage ||= if spec spec.homepage else "#{name}-#{version}" end end |