Class: LibyearBundler::BundleOutdated

Inherits:
Object
  • Object
show all
Defined in:
lib/libyear_bundler/bundle_outdated.rb

Overview

Responsible for getting all the data that goes into the ‘Report`.

Constant Summary collapse

BOP_FMT =

Format of ‘bundle outdated –parseable` (BOP)

/\A(?<name>[^ ]+) \(newest (?<newest>[^,]+), installed (?<installed>[^,)]+)/

Instance Method Summary collapse

Constructor Details

#initialize(gemfile_path, release_date_cache) ⇒ BundleOutdated

Returns a new instance of BundleOutdated.



14
15
16
17
# File 'lib/libyear_bundler/bundle_outdated.rb', line 14

def initialize(gemfile_path, release_date_cache)
  @gemfile_path = gemfile_path
  @release_date_cache = release_date_cache
end

Instance Method Details

#executeObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/libyear_bundler/bundle_outdated.rb', line 19

def execute
  bundle_outdated.lines.each_with_object([]) do |line, gems|
    match = BOP_FMT.match(line)
    next if match.nil?
    if malformed_version_strings?(match)
      warn "Skipping #{match['name']} because of a malformed version string"
      next
    end

    gem = ::LibyearBundler::Models::Gem.new(
      match['name'],
      match['installed'],
      match['newest'],
      @release_date_cache
    )
    gems.push(gem)
  end
end