Class: Bundler::CLI::Outdated
- Inherits:
-
Object
- Object
- Bundler::CLI::Outdated
- Defined in:
- lib/bundler/cli/outdated.rb
Instance Attribute Summary collapse
-
#filter_options_patch ⇒ Object
readonly
Returns the value of attribute filter_options_patch.
-
#gems ⇒ Object
readonly
Returns the value of attribute gems.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#options_include_groups ⇒ Object
readonly
Returns the value of attribute options_include_groups.
-
#outdated_gems_by_groups ⇒ Object
Returns the value of attribute outdated_gems_by_groups.
-
#outdated_gems_list ⇒ Object
Returns the value of attribute outdated_gems_list.
-
#sources ⇒ Object
readonly
Returns the value of attribute sources.
-
#strict ⇒ Object
readonly
Returns the value of attribute strict.
Instance Method Summary collapse
-
#initialize(options, gems) ⇒ Outdated
constructor
A new instance of Outdated.
- #run ⇒ Object
Constructor Details
#initialize(options, gems) ⇒ Outdated
Returns a new instance of Outdated.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/bundler/cli/outdated.rb', line 8 def initialize(, gems) = @gems = gems @sources = Array([:source]) = .keys & %w[filter-major filter-minor filter-patch] @outdated_gems_by_groups = {} @outdated_gems_list = [] = [:group, :groups].any? do |v| .keys.include?(v.to_s) end # the patch level options imply strict is also true. It wouldn't make # sense otherwise. @strict = ["filter-strict"] || Bundler::CLI::Common.().any? end |
Instance Attribute Details
#filter_options_patch ⇒ Object (readonly)
Returns the value of attribute filter_options_patch.
5 6 7 |
# File 'lib/bundler/cli/outdated.rb', line 5 def end |
#gems ⇒ Object (readonly)
Returns the value of attribute gems.
5 6 7 |
# File 'lib/bundler/cli/outdated.rb', line 5 def gems @gems end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/bundler/cli/outdated.rb', line 5 def end |
#options_include_groups ⇒ Object (readonly)
Returns the value of attribute options_include_groups.
5 6 7 |
# File 'lib/bundler/cli/outdated.rb', line 5 def end |
#outdated_gems_by_groups ⇒ Object
Returns the value of attribute outdated_gems_by_groups.
6 7 8 |
# File 'lib/bundler/cli/outdated.rb', line 6 def outdated_gems_by_groups @outdated_gems_by_groups end |
#outdated_gems_list ⇒ Object
Returns the value of attribute outdated_gems_list.
6 7 8 |
# File 'lib/bundler/cli/outdated.rb', line 6 def outdated_gems_list @outdated_gems_list end |
#sources ⇒ Object (readonly)
Returns the value of attribute sources.
5 6 7 |
# File 'lib/bundler/cli/outdated.rb', line 5 def sources @sources end |
#strict ⇒ Object (readonly)
Returns the value of attribute strict.
5 6 7 |
# File 'lib/bundler/cli/outdated.rb', line 5 def strict @strict end |
Instance Method Details
#run ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/bundler/cli/outdated.rb', line 29 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, ) definition_resolution = proc do [:local] ? definition.resolve_with_cache! : definition.resolve_remotely! end if [: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 ["only-explicit"] gemfile_specs else gemfile_specs + dependency_specs end specs.sort_by(&:name).each do |current_spec| next if !gems.empty? && !gems.include?(current_spec.name) dependency = current_dependencies[current_spec.name] active_spec = retrieve_active_spec(definition, current_spec) next if active_spec.nil? next if .any? && !update_present_via_semver_portions(current_spec, active_spec, ) 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) groups = nil if dependency && ![:parseable] groups = dependency.groups.join(", ") end outdated_gems_list << { :active_spec => active_spec, :current_spec => current_spec, :dependency => dependency, :groups => groups } outdated_gems_by_groups[groups] ||= [] outdated_gems_by_groups[groups] << outdated_gems_list[-1] end if outdated_gems_list.empty? else unless [:parseable] Bundler.ui.info() end if ordered_groups = outdated_gems_by_groups.keys.compact.sort ordered_groups.insert(0, nil).each do |groups| gems = outdated_gems_by_groups[groups] contains_group = if groups groups.split(", ").include?([:group]) else [:group] == "group" end next if (![:groups] && !contains_group) || gems.nil? unless [:parseable] Bundler.ui.info((groups)) end print_gems(gems) end else print_gems(outdated_gems_list) end exit 1 end end |