Class: TachikomaAi::Strategies::Bundler::Gem

Inherits:
Object
  • Object
show all
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.expand_path('github_urls.json', __dir__))
GITHUB_URL_JSON =
JSON.parse(GITHUB_URLS)

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#fromObject (readonly)

Returns the value of attribute from.



13
14
15
# File 'lib/tachikoma_ai/strategies/bundler/gem.rb', line 13

def from
  @from
end

#nameObject (readonly)

Returns the value of attribute name.



13
14
15
# File 'lib/tachikoma_ai/strategies/bundler/gem.rb', line 13

def name
  @name
end

#versionObject (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_urlObject



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_urlObject



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

Returns:

  • (Boolean)


21
22
23
# File 'lib/tachikoma_ai/strategies/bundler/gem.rb', line 21

def github_url?
  !github_url.nil?
end

#homepageObject



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