summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2016-09-27 22:23:57 -0500
committerSamuel Giddins <segiddins@segiddins.me>2016-09-27 22:23:57 -0500
commitcf668f8092be600619fcac5dbcc91072621b0509 (patch)
tree698a980abe526cc3573e592b10000b6de50ef719
parentc3b69668529ff9bbdd923f89fd0758418998dc37 (diff)
downloadbundler-cf668f8092be600619fcac5dbcc91072621b0509.tar.gz
Add a setting for forcing only the ruby platform
-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/settings.rb1
-rw-r--r--spec/cache/gems_spec.rb2
-rw-r--r--spec/commands/install_spec.rb2
-rw-r--r--spec/support/builders.rb4
9 files changed, 16 insertions, 10 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb
index 249c4e2dc6..d0ea501aef 100644
--- a/lib/bundler.rb
+++ b/lib/bundler.rb
@@ -258,6 +258,11 @@ EOF
with_clean_env { Kernel.exec(*args) }
end
+ def local_platform
+ return Gem::Platform::RUBY if settings[:only_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 6c8fc1ddde..449e00fbfd 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/settings.rb b/lib/bundler/settings.rb
index db6a4ab6ad..ebf6dc40fc 100644
--- a/lib/bundler/settings.rb
+++ b/lib/bundler/settings.rb
@@ -17,6 +17,7 @@ module Bundler
major_deprecations
no_install
no_prune
+ only_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/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|