class AutoGemUpdater::Outdated

Constants

GEM_LINE_REGEX

Attributes

bundle_outdated_command[R]

Public Class Methods

perform() click to toggle source
# File lib/auto_gem_updater/outdated.rb, line 13
def self.perform
  new.perform
end

Private Class Methods

new() click to toggle source
# File lib/auto_gem_updater/outdated.rb, line 8
def initialize
  @bundle_outdated_command =
    "bundle outdated --parseable #{AutoGemUpdater.outdated_options}"
end

Public Instance Methods

perform() click to toggle source
# File lib/auto_gem_updater/outdated.rb, line 19
def perform
  outdated_gems = []

  Open3
    .popen3(bundle_outdated_command) do |_stdin, stdout, _stderr, _wait_thr|
      while (line = stdout.gets)
        parsed_data = parse_line(line)
        next if parsed_data.nil? || AutoGemUpdater.ignore_gems.include?(parsed_data[:name])

        outdated_gems.push(parsed_data)
      end
    end

  outdated_gems
end

Private Instance Methods

parse_line(line) click to toggle source
# File lib/auto_gem_updater/outdated.rb, line 39
def parse_line(line)
  return unless (match_data = line.match(GEM_LINE_REGEX))

  {
    name: match_data[:gem],
    newest: match_data[:newest],
    installed: match_data[:installed]
  }
end