class TachikomaAi::Strategies::Bundler

Public Instance Methods

pull_request_body() click to toggle source
# File lib/tachikoma_ai/strategies/bundler.rb, line 9
      def pull_request_body
        <<-EOF
## Compare
#{compare_urls}

## Not found
#{homepage_urls}
        EOF
      end

Private Instance Methods

compare_urls() click to toggle source
# File lib/tachikoma_ai/strategies/bundler.rb, line 39
def compare_urls
  updated_gems.select(&:github_url?).map { |gem| url_with_checkbox(gem.compare_url) }.join("\n")
end
diff_specs(previous, current) click to toggle source
# File lib/tachikoma_ai/strategies/bundler.rb, line 31
def diff_specs(previous, current)
  current.specs.reject { |s| previous.specs.include?(s) }
end
gem(spec, before) click to toggle source
# File lib/tachikoma_ai/strategies/bundler.rb, line 51
def gem(spec, before)
  return if before.nil?
  Gem.new(spec.name, before.version.to_s, spec.version.to_s)
end
homepage_urls() click to toggle source
# File lib/tachikoma_ai/strategies/bundler.rb, line 47
def homepage_urls
  updated_gems.reject(&:github_url?).map(&:homepage).join("\n")
end
lockfile(ref) click to toggle source
# File lib/tachikoma_ai/strategies/bundler.rb, line 35
def lockfile(ref)
  ::Bundler::LockfileParser.new(`git show #{ref}:Gemfile.lock`)
end
updated_gems() click to toggle source
# File lib/tachikoma_ai/strategies/bundler.rb, line 21
def updated_gems
  return @updated_gems if @updated_gems

  previous = lockfile('HEAD^')
  @updated_gems = diff_specs(previous, lockfile('HEAD')).map do |spec|
    before = previous.specs.find { |s| s.name == spec.name }
    gem(spec, before)
  end.compact.uniq(&:name)
end
url_with_checkbox(url) click to toggle source
# File lib/tachikoma_ai/strategies/bundler.rb, line 43
def url_with_checkbox(url)
  "- [ ] #{url}"
end