Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Enable specific_platform by default on 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
segiddins committed Jun 25, 2017
1 parent a14b5c0 commit 8720a9a
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/bundler/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ def remove_platform(platform)

def add_current_platform
current_platform = Bundler.local_platform
add_platform(current_platform) if Bundler.settings[:specific_platform]
add_platform(current_platform) if Bundler.feature_flag.specific_platform?
add_platform(generic(current_platform))
end

Expand Down
1 change: 1 addition & 0 deletions lib/bundler/feature_flag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def self.settings_method(name, key, &default)
settings_flag(:only_update_to_newer_versions) { bundler_2_mode? }
settings_flag(:plugins) { @bundler_version >= Gem::Version.new("1.14") }
settings_flag(:prefer_gems_rb) { bundler_2_mode? }
settings_flag(:specific_platform) { bundler_2_mode? }
settings_flag(:unlock_source_unlocks_spec) { !bundler_2_mode? }
settings_flag(:update_requires_all_flag) { bundler_2_mode? }

Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/lazy_specification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def to_lock
end

def __materialize__
search_object = Bundler.settings[:specific_platform] || Bundler.settings[:force_ruby_platform] ? self : Dependency.new(name, version)
search_object = Bundler.feature_flag.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
Expand Down
1 change: 1 addition & 0 deletions lib/bundler/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Settings
plugins
prefer_gems_rb
silence_root_warning
specific_platform
unlock_source_unlocks_spec
update_requires_all_flag
].freeze
Expand Down
2 changes: 1 addition & 1 deletion spec/install/gemfile/platform_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
expect(the_bundle).to include_gems "nokogiri 1.4.2 JAVA", "weakling 0.0.3"
end

it "works with gems that have extra platform-specific runtime dependencies" do
it "works with gems that have extra platform-specific runtime dependencies", :bundler => "< 2" do
simulate_platform x64_mac

update_repo2 do
Expand Down
14 changes: 10 additions & 4 deletions spec/other/platform_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

RSpec.describe "bundle platform" do
context "without flags" do
let(:bundle_platform_platforms_string) do
platforms = [rb]
platforms.unshift(specific_local_platform) if Bundler.feature_flag.bundler_2_mode?
platforms.map {|pl| "* #{pl}" }.join("\n")
end

it "returns all the output" do
gemfile <<-G
source "file://#{gem_repo1}"
Expand All @@ -16,7 +22,7 @@
Your platform is: #{RUBY_PLATFORM}
Your app has gems that work on these platforms:
* ruby
#{bundle_platform_platforms_string}
Your Gemfile specifies a Ruby version requirement:
* ruby #{RUBY_VERSION}
Expand All @@ -39,7 +45,7 @@
Your platform is: #{RUBY_PLATFORM}
Your app has gems that work on these platforms:
* ruby
#{bundle_platform_platforms_string}
Your Gemfile specifies a Ruby version requirement:
* ruby #{RUBY_VERSION}p#{RUBY_PATCHLEVEL}
Expand All @@ -60,7 +66,7 @@
Your platform is: #{RUBY_PLATFORM}
Your app has gems that work on these platforms:
* ruby
#{bundle_platform_platforms_string}
Your Gemfile does not specify a Ruby version requirement.
G
Expand All @@ -80,7 +86,7 @@
Your platform is: #{RUBY_PLATFORM}
Your app has gems that work on these platforms:
* ruby
#{bundle_platform_platforms_string}
Your Gemfile specifies a Ruby version requirement:
* ruby #{not_local_ruby_version}
Expand Down
4 changes: 4 additions & 0 deletions spec/support/platforms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ def local
generic_local_platform
end

def specific_local_platform
Bundler.local_platform
end

def not_local
all_platforms.find {|p| p != generic_local_platform }
end
Expand Down

0 comments on commit 8720a9a

Please sign in to comment.