diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-11-02 23:07:56 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-11-02 23:07:56 +0000 |
commit | 59c8d50653480bef3f24517296e6ddf937fdf6bc (patch) | |
tree | df10aaf4f3307837fe3d1d129d66f6c0c7586bc5 /lib/bundler/feature_flag.rb | |
parent | 7deb37777a230837e865e0a11fb8d7c1dc6d03ce (diff) | |
download | ruby-59c8d50653480bef3f24517296e6ddf937fdf6bc.tar.gz |
Added bundler as default gems. Revisit [Feature #12733]
* bin/*, lib/bundler/*, lib/bundler.rb, spec/bundler, man/*:
Merge from latest stable branch of bundler/bundler repository and
added workaround patches. I will backport them into upstream.
* common.mk, defs/gmake.mk: Added `test-bundler` task for test suite
of bundler.
* tool/sync_default_gems.rb: Added sync task for bundler.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/bundler/feature_flag.rb')
-rw-r--r-- | lib/bundler/feature_flag.rb | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/lib/bundler/feature_flag.rb b/lib/bundler/feature_flag.rb new file mode 100644 index 0000000000..83e7ff0389 --- /dev/null +++ b/lib/bundler/feature_flag.rb @@ -0,0 +1,72 @@ +# frozen_string_literal: true + +module Bundler + class FeatureFlag + def self.settings_flag(flag, &default) + 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 + + settings_method("#{flag}?", flag, &default) + end + private_class_method :settings_flag + + def self.settings_option(key, &default) + settings_method(key, key, &default) + end + private_class_method :settings_option + + def self.settings_method(name, key, &default) + define_method(name) do + value = Bundler.settings[key] + value = instance_eval(&default) if value.nil? && !default.nil? + value + end + end + private_class_method :settings_method + + (1..10).each {|v| define_method("bundler_#{v}_mode?") { major_version >= v } } + + settings_flag(:allow_bundler_dependency_conflicts) { bundler_2_mode? } + settings_flag(:allow_offline_install) { bundler_2_mode? } + settings_flag(:auto_clean_without_path) { bundler_2_mode? } + settings_flag(:auto_config_jobs) { bundler_2_mode? } + settings_flag(:cache_all) { bundler_2_mode? } + settings_flag(:cache_command_is_package) { bundler_2_mode? } + settings_flag(:console_command) { !bundler_2_mode? } + settings_flag(:default_install_uses_path) { bundler_2_mode? } + settings_flag(:deployment_means_frozen) { bundler_2_mode? } + settings_flag(:disable_multisource) { bundler_2_mode? } + settings_flag(:error_on_stderr) { bundler_2_mode? } + settings_flag(:forget_cli_options) { bundler_2_mode? } + settings_flag(:global_path_appends_ruby_scope) { bundler_2_mode? } + settings_flag(:global_gem_cache) { bundler_2_mode? } + settings_flag(:init_gems_rb) { bundler_2_mode? } + settings_flag(:list_command) { bundler_2_mode? } + settings_flag(:lockfile_uses_separate_rubygems_sources) { bundler_2_mode? } + settings_flag(:only_update_to_newer_versions) { bundler_2_mode? } + settings_flag(:path_relative_to_cwd) { bundler_2_mode? } + settings_flag(:plugins) { @bundler_version >= Gem::Version.new("1.14") } + settings_flag(:prefer_gems_rb) { bundler_2_mode? } + settings_flag(:print_only_version_number) { bundler_2_mode? } + settings_flag(:setup_makes_kernel_gem_public) { !bundler_2_mode? } + settings_flag(:skip_default_git_sources) { bundler_2_mode? } + settings_flag(:specific_platform) { bundler_2_mode? } + settings_flag(:suppress_install_using_messages) { bundler_2_mode? } + settings_flag(:unlock_source_unlocks_spec) { !bundler_2_mode? } + settings_flag(:update_requires_all_flag) { bundler_2_mode? } + settings_flag(:use_gem_version_promoter_for_major_updates) { bundler_2_mode? } + settings_flag(:viz_command) { !bundler_2_mode? } + + settings_option(:default_cli_command) { bundler_2_mode? ? :cli_help : :install } + + def initialize(bundler_version) + @bundler_version = Gem::Version.create(bundler_version) + end + + def major_version + @bundler_version.segments.first + end + private :major_version + end +end |