summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHomu <homu@barosl.com>2016-10-03 20:04:01 +0900
committerHomu <homu@barosl.com>2016-10-03 20:04:01 +0900
commit9f414c55be8b749f46a0470277f14572c5246c03 (patch)
treecfcc7c033469f3945fffdcde7cdc73a79066bb9a
parent81686198476187ab471425146b4b4697f8cbfa3d (diff)
parenta8d140b35c98adf85689bcd7fa5c4ffd5d3064c7 (diff)
downloadbundler-9f414c55be8b749f46a0470277f14572c5246c03.tar.gz
Auto merge of #5028 - bundler:seg-settings-only-ruby-platform, r=indirect
Add a setting for forcing only the ruby platform See https://github.com/bundler/bundler/pull/4895. Closes https://github.com/bundler/bundler/issues/4813.
-rw-r--r--lib/bundler.rb5
-rw-r--r--lib/bundler/current_ruby.rb6
-rw-r--r--lib/bundler/definition.rb2
-rw-r--r--lib/bundler/dsl.rb2
-rw-r--r--lib/bundler/gem_helpers.rb2
-rw-r--r--lib/bundler/lazy_specification.rb2
-rw-r--r--lib/bundler/rubygems_integration.rb1
-rw-r--r--lib/bundler/settings.rb1
-rw-r--r--spec/cache/gems_spec.rb2
-rw-r--r--spec/commands/install_spec.rb2
-rw-r--r--spec/runtime/platform_spec.rb16
-rw-r--r--spec/support/builders.rb4
12 files changed, 34 insertions, 11 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb
index f25d43e001..0dcaa03965 100644
--- a/lib/bundler.rb
+++ b/lib/bundler.rb
@@ -293,6 +293,11 @@ EOF
with_clean_env { Kernel.exec(*args) }
end
+ def local_platform
+ return Gem::Platform::RUBY if settings[:force_ruby_platform]
+ Gem::Platform.local
+ end
+
def default_gemfile
SharedHelpers.default_gemfile
end
diff --git a/lib/bundler/current_ruby.rb b/lib/bundler/current_ruby.rb
index 6180285942..7b3d87e320 100644
--- a/lib/bundler/current_ruby.rb
+++ b/lib/bundler/current_ruby.rb
@@ -57,15 +57,15 @@ module Bundler
end
def mswin64?
- Bundler::WINDOWS && Gem::Platform.local.os == "mswin64" && Gem::Platform.local.cpu == "x64"
+ Bundler::WINDOWS && Bundler.local_platform.os == "mswin64" && Bundler.local_platform.cpu == "x64"
end
def mingw?
- Bundler::WINDOWS && Gem::Platform.local.os == "mingw32" && Gem::Platform.local.cpu != "x64"
+ Bundler::WINDOWS && Bundler.local_platform.os == "mingw32" && Bundler.local_platform.cpu != "x64"
end
def x64_mingw?
- Bundler::WINDOWS && Gem::Platform.local.os == "mingw32" && Gem::Platform.local.cpu == "x64"
+ Bundler::WINDOWS && Bundler.local_platform.os == "mingw32" && Bundler.local_platform.cpu == "x64"
end
(KNOWN_MINOR_VERSIONS + KNOWN_MAJOR_VERSIONS).each do |version|
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 9be8184574..8a6bf0d17c 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -523,7 +523,7 @@ module Bundler
end
def add_current_platform
- current_platform = Bundler.rubygems.platforms.last
+ current_platform = Bundler.local_platform
add_platform(current_platform) if Bundler.settings[:specific_platform]
add_platform(generic(current_platform))
end
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb
index 428ccd4c2d..cdbae076f0 100644
--- a/lib/bundler/dsl.rb
+++ b/lib/bundler/dsl.rb
@@ -65,7 +65,7 @@ module Bundler
case specs_by_name_and_version.size
when 1
specs = specs_by_name_and_version.values.first
- spec = specs.find {|s| s.match_platform(Gem::Platform.local) } || specs.first
+ spec = specs.find {|s| s.match_platform(Bundler.local_platform) } || specs.first
@gemspecs << spec
diff --git a/lib/bundler/gem_helpers.rb b/lib/bundler/gem_helpers.rb
index 6d926ce83f..955834ff01 100644
--- a/lib/bundler/gem_helpers.rb
+++ b/lib/bundler/gem_helpers.rb
@@ -25,7 +25,7 @@ module Bundler
module_function :generic
def generic_local_platform
- generic(Gem::Platform.local)
+ generic(Bundler.local_platform)
end
module_function :generic_local_platform
diff --git a/lib/bundler/lazy_specification.rb b/lib/bundler/lazy_specification.rb
index 13e7f5fc3c..7508347c32 100644
--- a/lib/bundler/lazy_specification.rb
+++ b/lib/bundler/lazy_specification.rb
@@ -69,7 +69,7 @@ module Bundler
end
def __materialize__
- search_object = Bundler.settings[:specific_platform] ? self : Dependency.new(name, version)
+ search_object = Bundler.settings[:specific_platform] || Bundler.settings[:force_ruby_platform] ? self : Dependency.new(name, version)
@specification = if source.is_a?(Source::Gemspec) && source.gemspec.name == name
source.gemspec.tap {|s| s.source = source }
else
diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb
index bfabd96643..90da0b4645 100644
--- a/lib/bundler/rubygems_integration.rb
+++ b/lib/bundler/rubygems_integration.rb
@@ -80,6 +80,7 @@ module Bundler
end
def platforms
+ return [Gem::Platform::RUBY] if Bundler.settings[:force_ruby_platform]
Gem.platforms
end
diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb
index f5d9da9b71..2f532c832f 100644
--- a/lib/bundler/settings.rb
+++ b/lib/bundler/settings.rb
@@ -18,6 +18,7 @@ module Bundler
major_deprecations
no_install
no_prune
+ force_ruby_platform
only_update_to_newer_versions
plugins
silence_root_warning
diff --git a/spec/cache/gems_spec.rb b/spec/cache/gems_spec.rb
index 474233a83c..19dd16e4e9 100644
--- a/spec/cache/gems_spec.rb
+++ b/spec/cache/gems_spec.rb
@@ -238,7 +238,7 @@ describe "bundle cache" do
gem "platform_specific"
G
- expect(cached_gem("platform_specific-1.0-#{Gem::Platform.local}")).to exist
+ expect(cached_gem("platform_specific-1.0-#{Bundler.local_platform}")).to exist
expect(cached_gem("platform_specific-1.0-java")).to exist
end
diff --git a/spec/commands/install_spec.rb b/spec/commands/install_spec.rb
index eb78ced86e..457fec26cb 100644
--- a/spec/commands/install_spec.rb
+++ b/spec/commands/install_spec.rb
@@ -216,7 +216,7 @@ describe "bundle install with gem sources" do
G
run "require 'platform_specific' ; puts PLATFORM_SPECIFIC"
- expect(out).to eq("1.0.0 #{Gem::Platform.local}")
+ expect(out).to eq("1.0.0 #{Bundler.local_platform}")
end
it "falls back on plain ruby" do
diff --git a/spec/runtime/platform_spec.rb b/spec/runtime/platform_spec.rb
index 666864a88c..4fd09cf4b7 100644
--- a/spec/runtime/platform_spec.rb
+++ b/spec/runtime/platform_spec.rb
@@ -88,4 +88,20 @@ describe "Bundler.setup with multi platform stuff" do
expect(the_bundle).to include_gems "nokogiri 1.4.2", "platform_specific 1.0 x86-darwin-100"
end
+
+ it "allows specifying only-ruby-platform" do
+ simulate_platform "java"
+
+ install_gemfile! <<-G
+ source "file://#{gem_repo1}"
+ gem "nokogiri"
+ gem "platform_specific"
+ G
+
+ bundle! "config force_ruby_platform true"
+
+ bundle! "install"
+
+ expect(the_bundle).to include_gems "nokogiri 1.4.2", "platform_specific 1.0 RUBY"
+ end
end
diff --git a/spec/support/builders.rb b/spec/support/builders.rb
index 7436779d15..16ced2b920 100644
--- a/spec/support/builders.rb
+++ b/spec/support/builders.rb
@@ -79,8 +79,8 @@ module Spec
end
build_gem "platform_specific" do |s|
- s.platform = Gem::Platform.local
- s.write "lib/platform_specific.rb", "PLATFORM_SPECIFIC = '1.0.0 #{Gem::Platform.local}'"
+ s.platform = Bundler.local_platform
+ s.write "lib/platform_specific.rb", "PLATFORM_SPECIFIC = '1.0.0 #{Bundler.local_platform}'"
end
build_gem "platform_specific" do |s|