class Bundler::CLI::Outdated

Public Instance Methods

print_gem(current_spec, active_spec, dependency) click to toggle source
print_gems(gems_list) click to toggle source
run() click to toggle source
# File lib/dependency_bumper/bundler/cli/outdated.rb, line 5
def run
  check_for_deployment_mode!

  Bundler.definition.validate_runtime!
  # this commands gets current gems
  current_specs = Bundler.ui.silence { Bundler.definition.resolve }

  current_dependencies = Bundler.ui.silence do
    Bundler.load.dependencies.map { |dep| [dep.name, dep] }.to_h
  end

  definition = gems.empty? && sources.empty? ? Bundler.definition(true) : Bunder.definition(gems: gems, sources: sources)

  Bundler::CLI::Common.configure_gem_version_promoter(
    Bundler.definition,
    options
  )

  options[:local] ? definition.resolve_with_cache! : definition.resolve_remotely!

  # Loop through the current specs
  gemfile_specs, dependency_specs = current_specs.partition do |spec|
    current_dependencies.key? spec.name
  end

  specs = gemfile_specs + dependency_specs

  specs.sort_by(&:name).each do |current_spec|
    next unless gems.empty? || gems.include?(current_spec.name)

    active_spec = retrieve_active_spec(definition, current_spec)
    next unless active_spec

    unless filter_options_patch.empty? || update_present_via_semver_portions(current_spec, active_spec, options)
      next
    end

    gem_outdated = Gem::Version.new(active_spec.version) > Gem::Version.new(current_spec.version)
    unless gem_outdated || (current_spec.git_version != active_spec.git_version)
      next
    end

    dependency = current_dependencies[current_spec.name]

    outdated_gems_list << {
      active_spec: active_spec,
      current_spec: current_spec,
      dependency: dependency
    }
  end

  return [] if outdated_gems_list.empty?

  print_gems(outdated_gems_list)

  outdated_gems_list
end