class LockfilePreserver::BundledWith

Constants

BUNDLED_WITH
NEW_LINE
REGEXP

Attributes

original[R]
updated[R]

Public Class Methods

new(original, updated) click to toggle source
# File lib/lockfile_preserver/bundled_with.rb, line 3
def initialize(original, updated)
  @original = original
  @updated = updated
end

Public Instance Methods

keep() click to toggle source
# File lib/lockfile_preserver/bundled_with.rb, line 8
def keep
  if original.include? BUNDLED_WITH
    keep_bundled_with
  else
    remove_bundled_with
  end
end

Private Instance Methods

bundled_with() click to toggle source
# File lib/lockfile_preserver/bundled_with.rb, line 36
def bundled_with
  "\n\nBUNDLED WITH\n" \
  "   #{bundler_version}\n"
end
bundler_version() click to toggle source
# File lib/lockfile_preserver/bundled_with.rb, line 41
def bundler_version
  @_bundler_version ||= original.match(REGEXP)[:version]
end
keep_bundled_with() click to toggle source
# File lib/lockfile_preserver/bundled_with.rb, line 28
def keep_bundled_with
  updated.sub(REGEXP, bundled_with)
end
remove_bundled_with() click to toggle source
# File lib/lockfile_preserver/bundled_with.rb, line 32
def remove_bundled_with
  updated.sub(REGEXP, NEW_LINE)
end