summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSutou Kouhei <kou@clear-code.com>2020-01-09 14:49:17 +0900
committerSutou Kouhei <kou@clear-code.com>2020-01-15 06:27:03 +0900
commit500bb685cd75b919e72f0068565fd6112f33ce09 (patch)
tree86e70693e8d3bf3d3247225767904d59d3203183
parente008edb4873aca89fe4aee079a89bd9b2dcdcfd4 (diff)
downloadbundler-500bb685cd75b919e72f0068565fd6112f33ce09.tar.gz
Add SpecGroup#copy_for
-rw-r--r--lib/bundler/resolver.rb15
-rw-r--r--lib/bundler/resolver/spec_group.rb9
2 files changed, 12 insertions, 12 deletions
diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb
index b23947f32c..a2ac4ef4ab 100644
--- a/lib/bundler/resolver.rb
+++ b/lib/bundler/resolver.rb
@@ -153,12 +153,8 @@ module Bundler
if spec_platform && spec_platform != Gem::Platform::RUBY
# Add a spec group for "non platform specific spec" as the fallback
# spec group.
- sg_ruby = SpecGroup.new(sg.all_specs)
- sg_ruby.ignores_bundler_dependencies = sg.ignores_bundler_dependencies
- if sg_ruby.for?(Gem::Platform::RUBY)
- sg_ruby.activate_platform!(Gem::Platform::RUBY)
- selected_sgs << sg_ruby
- end
+ sg_ruby = sg.copy_for(Gem::Platform::RUBY)
+ selected_sgs << sg_ruby if sg_ruby
end
if platform != Gem::Platform::RUBY
# Add a spec group for ["non platform specific spec", "platform
@@ -170,11 +166,8 @@ module Bundler
# specs:
# ffi (1.9.14)
# ffi (1.9.14-x86-mingw32)
- sg_ruby_platform = SpecGroup.new(sg.all_specs)
- sg_ruby_platform.ignores_bundler_dependencies =
- sg.ignores_bundler_dependencies
- if sg_ruby_platform.for?(Gem::Platform::RUBY)
- sg_ruby_platform.activate_platform!(Gem::Platform::RUBY)
+ sg_ruby_platform = sg.copy_for(Gem::Platform::RUBY)
+ if sg_ruby_platform
sg_ruby_platform.activate_platform!(platform)
selected_sgs << sg_ruby_platform
end
diff --git a/lib/bundler/resolver/spec_group.rb b/lib/bundler/resolver/spec_group.rb
index 1e2a9f5929..70c6de9e0c 100644
--- a/lib/bundler/resolver/spec_group.rb
+++ b/lib/bundler/resolver/spec_group.rb
@@ -5,7 +5,6 @@ module Bundler
class SpecGroup
include GemHelpers
- attr_reader :all_specs
attr_accessor :name, :version, :source
attr_accessor :ignores_bundler_dependencies
@@ -39,6 +38,14 @@ module Bundler
@activated_platforms << platform
end
+ def copy_for(platform)
+ copied_sg = self.class.new(@all_specs)
+ copied_sg.ignores_bundler_dependencies = @ignores_bundler_dependencies
+ return nil unless copied_sg.for?(platform)
+ copied_sg.activate_platform!(platform)
+ copied_sg
+ end
+
def spec(platform)
@specs[platform]
end