class Diff::Strategy::Bundler

Constants

OLDS_LINE
UPDATES_LINE

Public Instance Methods

olds() click to toggle source
# File lib/diff/strategy/bundler.rb, line 16
def olds
  @olds ||= extract(OLDS_LINE)
end
to_markdown(gem_name, old, updated) click to toggle source
Calls superclass method Diff::Strategy::Base#to_markdown
# File lib/diff/strategy/bundler.rb, line 20
def to_markdown(gem_name, old, updated)
  gem = Gems.info(gem_name)
  sleep 0.1 # rate limit
  if gem.empty?
    super
  else
    source_code_uri = gem["source_code_uri"] || gem["homepage_uri"]
    compare_uri = "#{source_code_uri}/compare/v#{old}...v#{updated}"
    [
      "- Updated:",
      "[`#{gem_name}`](#{source_code_uri})",
      "[#{old} => #{updated}](#{compare_uri})"
    ].join(' ')
  end
end
updates() click to toggle source
# File lib/diff/strategy/bundler.rb, line 12
def updates
  @updates ||= extract(UPDATES_LINE)
end

Private Instance Methods

extract(regex) click to toggle source
# File lib/diff/strategy/bundler.rb, line 38
def extract(regex)
  diff.split("\n").each_with_object({}) do |line, hash|
    if matched = line.match(regex)
      hash[matched[:name]] = matched[:version]
    end
  end
end