Class: Diff::Strategy::Bundler

Inherits:
Base
  • Object
show all
Defined in:
lib/diff/strategy/bundler.rb

Constant Summary collapse

UPDATES_LINE =
/^\+\s+(?<name>[0-9a-zA-Z\-_]+)\s\((?<version>[0-9\.]+)\)$/
OLDS_LINE =
/^\-\s+(?<name>[0-9a-zA-Z\-_]+)\s\((?<version>[0-9\.]+)\)$/

Instance Attribute Summary

Attributes inherited from Base

#diff

Instance Method Summary collapse

Methods inherited from Base

#exists?, #initialize, #output, #to_hash

Constructor Details

This class inherits a constructor from Diff::Strategy::Base

Instance Method Details

#oldsObject



16
17
18
# File 'lib/diff/strategy/bundler.rb', line 16

def olds
  @olds ||= extract(OLDS_LINE)
end

#to_markdown(gem_name, old, updated) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# 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

#updatesObject



12
13
14
# File 'lib/diff/strategy/bundler.rb', line 12

def updates
  @updates ||= extract(UPDATES_LINE)
end