Class: Bummr::Outdated

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/bummr/outdated.rb

Instance Method Summary collapse

Instance Method Details

#outdated_gems(options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/bummr/outdated.rb', line 8

def outdated_gems(options = {})
  results = []

  bundle_options =  ""
  bundle_options << " --strict" unless options[:all_gems]
  bundle_options << " --group #{options[:group]}" if options[:group]

  Open3.popen2("bundle outdated" + bundle_options) do |_std_in, std_out|
    while line = std_out.gets
      puts line
      gem = parse_gem_from(line)

      if gem && (options[:all_gems] || gemfile_contains(gem[:name]))
        results.push gem
      end
    end
  end

  results
end

#parse_gem_from(line) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/bummr/outdated.rb', line 29

def parse_gem_from(line)
  regex = / \* (.*) \(newest (\d[\d\.]*\d)[,\s] installed (\d[\d\.]*\d)[\),\s]/.match line

  unless regex.nil?
    { name: regex[1], newest: regex[2], installed: regex[3] }
  end
end