diff options
author | chrismo <chrismo@clabs.org> | 2016-11-14 16:54:17 -0600 |
---|---|---|
committer | chrismo <chrismo@clabs.org> | 2016-11-15 10:26:55 -0600 |
commit | b3ad1702ba4d45df3d0c85c6585b1a60b9001b3a (patch) | |
tree | c0ffa989dc61dd747b770b9c6a5ef7e044518f2e /lib/bundler | |
parent | 291a807c7d6f441253f15a2fda29b2a52035c55a (diff) | |
download | bundler-b3ad1702ba4d45df3d0c85c6585b1a60b9001b3a.tar.gz |
Refactoring of @lucasmazza fix w/ specs.
The only existing spec coverage was essentially integration level and
there was no way either @lucasmazza or myself could find a way to
simulate the bug context.
I extracted some of the code out of outdated into Definition and
SpecSet and added unit specs to those extracted bits.
Diffstat (limited to 'lib/bundler')
-rw-r--r-- | lib/bundler/cli/outdated.rb | 8 | ||||
-rw-r--r-- | lib/bundler/definition.rb | 8 | ||||
-rw-r--r-- | lib/bundler/spec_set.rb | 4 |
3 files changed, 16 insertions, 4 deletions
diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb index a97cfeae..efbfe7f8 100644 --- a/lib/bundler/cli/outdated.rb +++ b/lib/bundler/cli/outdated.rb @@ -32,7 +32,7 @@ module Bundler end Bundler::CLI::Common.configure_gem_version_promoter(Bundler.definition, options) - # the patch level options don't work without strict also being true + # the patch level options imply strict is also true. It wouldn't make sense otherwise. strict = options[:strict] || Bundler::CLI::Common.patch_level_options(options).any? definition_resolution = proc { options[:local] ? definition.resolve_with_cache! : definition.resolve_remotely! } @@ -54,11 +54,11 @@ module Bundler dependency = current_dependencies[current_spec.name] if strict - active_spec = definition.specs.detect {|spec| spec.name == current_spec.name && spec.match_platform(current_spec.platform) } + active_spec = definition.find_resolved_spec(current_spec) else - active_specs = definition.index[current_spec.name].select {|spec| spec.match_platform(current_spec.platform) }.sort_by(&:version) + active_specs = definition.find_indexed_specs(current_spec) if !current_spec.version.prerelease? && !options[:pre] && active_specs.size > 1 - active_spec = active_specs.delete_if {|b| b.respond_to?(:version) && b.version.prerelease? } + active_specs.delete_if {|b| b.respond_to?(:version) && b.version.prerelease? } end active_spec = active_specs.last end diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index b9ac233f..6e3b6557 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -531,6 +531,14 @@ module Bundler add_platform(generic(current_platform)) end + def find_resolved_spec(current_spec) + specs.find_by_name_and_platform(current_spec.name, current_spec.platform) + end + + def find_indexed_specs(current_spec) + index[current_spec.name].select {|spec| spec.match_platform(current_spec.platform) }.sort_by(&:version) + end + attr_reader :sources private :sources diff --git a/lib/bundler/spec_set.rb b/lib/bundler/spec_set.rb index fe31b17f..d3ffa0d5 100644 --- a/lib/bundler/spec_set.rb +++ b/lib/bundler/spec_set.rb @@ -114,6 +114,10 @@ module Bundler SpecSet.new(arr) end + def find_by_name_and_platform(name, platform) + @specs.detect {|spec| spec.name == name && spec.match_platform(platform) } + end + private def sorted |