class Bummr::Outdated
Public Instance Methods
outdated_gems(options = {})
click to toggle source
# File lib/bummr/outdated.rb, line 9 def outdated_gems(options = {}) results = [] bundle_options = "" bundle_options << " --parseable" if Gem::Version.new(Bundler::VERSION) >= Gem::Version.new("2") bundle_options << " --strict" unless options[:all_gems] bundle_options << " --group #{options[:group]}" if options[:group] bundle_options << " #{options[:gem]}" if options[:gem] 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)
click to toggle source
# File lib/bummr/outdated.rb, line 32 def parse_gem_from(line) regex = /(?:\s+\* )?(.*) \(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
Private Instance Methods
gemfile()
click to toggle source
# File lib/bummr/outdated.rb, line 46 def gemfile @gemfile ||= `cat Gemfile` end
gemfile_contains(gem_name)
click to toggle source
# File lib/bummr/outdated.rb, line 42 def gemfile_contains(gem_name) /gem ['"]#{gem_name}['"]/.match gemfile end