class Gemdiff::BundleInspector

Public Instance Methods

get(gem_name) click to toggle source
# File lib/gemdiff/bundle_inspector.rb, line 17
def get(gem_name)
  list.detect { |gem| gem.name == gem_name }
end
list() click to toggle source
# File lib/gemdiff/bundle_inspector.rb, line 5
def list
  @list ||=
    outdated
      .split("\n")
      .map { |line| new_outdated_gem(line) }
      .compact
end
outdated() click to toggle source
# File lib/gemdiff/bundle_inspector.rb, line 13
def outdated
  @outdated ||= bundle_outdated_strict
end

Private Instance Methods

bundle_outdated_strict() click to toggle source
# File lib/gemdiff/bundle_inspector.rb, line 23
def bundle_outdated_strict
  `bundle outdated --strict`
end
new_outdated_gem(line) click to toggle source
# File lib/gemdiff/bundle_inspector.rb, line 27
def new_outdated_gem(line)
  return unless line.start_with?("  * ")

  # clean & convert new & old output to same format
  items = line.delete("*")
              .gsub("(newest", "")
              .gsub(", installed", " >")
              .gsub(/([(),])/, "")
              .split

  # ["haml", "4.0.5", ">", "4.0.4"]
  # ["a_forked_gem", "0.7.0", "99ddbc9", ">", "0.7.0", "1da2295"]

  return if items[3] == ">" # skip non-gems for now
  OutdatedGem.new(items[0], items[3], items[1])
end