This repository has been archived by the owner on Apr 14, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #4891 - bundler:seg-feature-flag, r=indirect
Add FeatureFlag class Main use will be code showing what is true setting vs what is flagged Also can be used to develop for future major versions without needing a separate dev branch
- Loading branch information
Showing
9 changed files
with
40 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
module Bundler | ||
class FeatureFlag | ||
def self.settings_flag(flag) | ||
unless Bundler::Settings::BOOL_KEYS.include?(flag.to_s) | ||
raise "Cannot use `#{flag}` as a settings feature flag since it isn't a bool key" | ||
end | ||
define_method("#{flag}?") { Bundler.settings[flag] } | ||
end | ||
|
||
(1..10).each {|v| define_method("bundler_#{v}_mode?") { major_version >= v } } | ||
|
||
settings_flag :allow_offline_install | ||
settings_flag :plugins | ||
|
||
def initialize(bundler_version) | ||
@bundler_version = Gem::Version.create(bundler_version) | ||
end | ||
|
||
def major_version | ||
@bundler_version.segments.first | ||
end | ||
private :major_version | ||
|
||
class << self; private :settings_flag; end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters