<commit_before># frozen_string_literal: true

require "uri"

module Bundler
  class Settings
    autoload :Mirror,  "bundler/mirror"
    autoload :Mirrors, "bundler/mirror"
    autoload :Validator, "bundler/settings/validator"

    BOOL_KEYS = %w[
      allow_bundler_dependency_conflicts
      allow_deployment_source_credential_changes
      allow_offline_install
      auto_clean_without_path
      auto_install
      auto_config_jobs
      cache_all
      cache_all_platforms
      cache_command_is_package
      console_command
      default_install_uses_path
      deployment
      deployment_means_frozen
      disable_checksum_validation
      disable_exec_load
      disable_local_branch_check
      disable_multisource
      disable_platform_warnings
      disable_shared_gems
      disable_version_check
      error_on_stderr
      force_ruby_platform
      forget_cli_options
      frozen
      gem.coc
      gem.mit
      github.https
      global_path_appends_ruby_scope
      global_gem_cache
      ignore_messages
      init_gems_rb
      list_command
      lockfile_uses_separate_rubygems_sources
      no_install
      no_prune
      only_update_to_newer_versions
      path_relative_to_cwd
      path.system
      plugins
      prefer_gems_rb
      prefer_patch
      print_only_version_number
      setup_makes_kernel_gem_public
      silence_deprecations
      silence_root_warning
      skip_default_git_sources
      specific_platform
      suppress_install_using_messages
      unlock_source_unlocks_spec
      update_requires_all_flag
      use_gem_version_promoter_for_major_updates
      viz_command
    ].freeze

    NUMBER_KEYS = %w[
      jobs
      redirect
      retry
      ssl_verify_mode
      timeout
    ].freeze

    ARRAY_KEYS = %w[
      with
      without
    ].freeze

    DEFAULT_CONFIG = {
      :silence_deprecations => false,
      :disable_version_check => true,
      :prefer_patch => false,
      :redirect => 5,
      :retry => 3,
      :timeout => 10,
    }.freeze

    def initialize(root = nil)
      @root            = root
      @local_config    = load_config(local_config_file)
      @global_config   = load_config(global_config_file)
      @temporary       = {}
    end

    def [](name)
      key = key_for(name)
      value = @temporary.fetch(key) do
              @local_config.fetch(key) do
              ENV.fetch(key) do
              @global_config.fetch(key) do
              DEFAULT_CONFIG.fetch(name) do
                nil
              end end end end end

      converted_value(value, name)
    end

    def set_command_option(key, value)
      if Bundler.feature_flag.forget_cli_options?
        temporary(key => value)
        value
      else
        command = if value.nil?
          "bundle config unset #{key}"
        else
          "bundle config set #{key} #{Array(value).join(":")}"
        end

        Bundler::SharedHelpers.major_deprecation 2,\
          "flags passed to commands " \
          "will no longer be automatically remembered. Instead please set flags " \
          "you want remembered between commands using `bundle config set " \
          "<setting name> <setting value>`, i.e. `#{command}`"

        set_local(key, value)
      end
    end

    def set_command_option_if_given(key, value)
      return if value.nil?
      set_command_option(key, value)
    end

    def set_local(key, value)
      local_config_file || raise(GemfileNotFound, "Could not locate Gemfile")

      set_key(key, value, @local_config, local_config_file)
    end

    def temporary(update)
      existing = Hash[update.map {|k, _| [k, @temporary[key_for(k)]] }]
      update.each do |k, v|
        set_key(k, v, @temporary, nil)
      end
      return unless block_given?
      begin
        yield
      ensure<commit_msg>Teach users how to toggle deprecations off<commit_after># frozen_string_literal: true

require "uri"

module Bundler
  class Settings
    autoload :Mirror,  "bundler/mirror"
    autoload :Mirrors, "bundler/mirror"
    autoload :Validator, "bundler/settings/validator"

    BOOL_KEYS = %w[
      allow_bundler_dependency_conflicts
      allow_deployment_source_credential_changes
      allow_offline_install
      auto_clean_without_path
      auto_install
      auto_config_jobs
      cache_all
      cache_all_platforms
      cache_command_is_package
      console_command
      default_install_uses_path
      deployment
      deployment_means_frozen
      disable_checksum_validation
      disable_exec_load
      disable_local_branch_check
      disable_multisource
      disable_platform_warnings
      disable_shared_gems
      disable_version_check
      error_on_stderr
      force_ruby_platform
      forget_cli_options
      frozen
      gem.coc
      gem.mit
      github.https
      global_path_appends_ruby_scope
      global_gem_cache
      ignore_messages
      init_gems_rb
      list_command
      lockfile_uses_separate_rubygems_sources
      no_install
      no_prune
      only_update_to_newer_versions
      path_relative_to_cwd
      path.system
      plugins
      prefer_gems_rb
      prefer_patch
      print_only_version_number
      setup_makes_kernel_gem_public
      silence_deprecations
      silence_root_warning
      skip_default_git_sources
      specific_platform
      suppress_install_using_messages
      unlock_source_unlocks_spec
      update_requires_all_flag
      use_gem_version_promoter_for_major_updates
      viz_command
    ].freeze

    NUMBER_KEYS = %w[
      jobs
      redirect
      retry
      ssl_verify_mode
      timeout
    ].freeze

    ARRAY_KEYS = %w[
      with
      without
    ].freeze

    DEFAULT_CONFIG = {
      :silence_deprecations => false,
      :disable_version_check => true,
      :prefer_patch => false,
      :redirect => 5,
      :retry => 3,
      :timeout => 10,
    }.freeze

    def initialize(root = nil)
      @root            = root
      @local_config    = load_config(local_config_file)
      @global_config   = load_config(global_config_file)
      @temporary       = {}
    end

    def [](name)
      key = key_for(name)
      value = @temporary.fetch(key) do
              @local_config.fetch(key) do
              ENV.fetch(key) do
              @global_config.fetch(key) do
              DEFAULT_CONFIG.fetch(name) do
                nil
              end end end end end

      converted_value(value, name)
    end

    def set_command_option(key, value)
      if Bundler.feature_flag.forget_cli_options?
        temporary(key => value)
        value
      else
        command = if value.nil?
          "bundle config unset #{key}"
        else
          "bundle config set #{key} #{Array(value).join(":")}"
        end

        Bundler::SharedHelpers.major_deprecation 2,\
          "flags passed to commands " \
          "will no longer be automatically remembered. Instead please set flags " \
          "you want remembered between commands using `bundle config set " \
          "<setting name> <setting value>`, i.e. `#{command}`. Once you are " \
          "ready for the new behavior, use `bundle config set forget_cli_options " \
          "true` to get rid of this message"

        set_local(key, value)
      end
    end

    def set_command_option_if_given(key, value)
      return if value.nil?
      set_command_option(key, value)
    end

    def set_local(key, value)
      local_config_file || raise(GemfileNotFound, "Could not locate Gemfile")

      set_key(key, value, @local_config, local_config_file)
    end

    def temporary(update)
      existing = Hash[update.map {|k, _| [k, @temporary[key_for(k)]] }]
      update.each do |k, v|
        set_key(k, v, @temporary, nil)
      end
      return unless block_given?
      begin
        yield
      ensure
{'fraction_non_alphanumeric': 0.0625, 'fraction_numerical': 0.001286008230452675, 'mean_word_length': 2.284206081081081, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '81951', 'n_tokens_mistral': 2396, 'n_tokens_neox': 2345, 'n_words': 501}