class Bundler::CLI::Outdated
Attributes
filter_options_patch[R]
gems[R]
options[R]
options_include_groups[R]
outdated_gems[RW]
sources[R]
strict[R]
Public Class Methods
new(options, gems)
click to toggle source
# File bundler/cli/outdated.rb, line 8 def initialize(options, gems) @options = options @gems = gems @sources = Array(options[:source]) @filter_options_patch = options.keys & %w[filter-major filter-minor filter-patch] @outdated_gems = [] @options_include_groups = [:group, :groups].any? do |v| options.keys.include?(v.to_s) end # the patch level options imply strict is also true. It wouldn't make # sense otherwise. @strict = options["filter-strict"] || Bundler::CLI::Common.patch_level_options(options).any? end
Public Instance Methods
run()
click to toggle source
# File bundler/cli/outdated.rb, line 26 def run check_for_deployment_mode! gems.each do |gem_name| Bundler::CLI::Common.select_spec(gem_name) end Bundler.definition.validate_runtime! 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 = if gems.empty? && sources.empty? # We're doing a full update Bundler.definition(true) else Bundler.definition(:gems => gems, :sources => sources) end Bundler::CLI::Common.configure_gem_version_promoter( Bundler.definition, options.merge(:strict => @strict) ) definition_resolution = proc do options[:local] ? definition.resolve_with_cache! : definition.resolve_remotely! end if options[:parseable] Bundler.ui.silence(&definition_resolution) else definition_resolution.call end Bundler.ui.info "" # Loop through the current specs gemfile_specs, dependency_specs = current_specs.partition do |spec| current_dependencies.key? spec.name end specs = if options["only-explicit"] gemfile_specs else gemfile_specs + dependency_specs end specs.sort_by(&:name).uniq(&: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 next unless filter_options_patch.empty? || update_present_via_semver_portions(current_spec, active_spec, options) gem_outdated = Gem::Version.new(active_spec.version) > Gem::Version.new(current_spec.version) next unless gem_outdated || (current_spec.git_version != active_spec.git_version) dependency = current_dependencies[current_spec.name] groups = "" if dependency && !options[:parseable] groups = dependency.groups.join(", ") end outdated_gems << { :active_spec => active_spec, :current_spec => current_spec, :dependency => dependency, :groups => groups, } end if outdated_gems.empty? unless options[:parseable] Bundler.ui.info(nothing_outdated_message) end else if options_include_groups relevant_outdated_gems = outdated_gems.group_by {|g| g[:groups] }.sort.flat_map do |groups, gems| contains_group = groups.split(", ").include?(options[:group]) next unless options[:groups] || contains_group gems end.compact if options[:parseable] print_gems(relevant_outdated_gems) else print_gems_table(relevant_outdated_gems) end elsif options[:parseable] print_gems(outdated_gems) else print_gems_table(outdated_gems) end exit 1 end end