<commit_before>module CarthageCache

  class ConfiguratorWizard

    def initialize(ask_proc, password_proc)
      @ask_proc = ask_proc
      @password_proc = password_proc
    end

    def start
      config = Configuration.new
      config.bucket_name = ask("What is the Amazon S3 bucket name?", ENV["CARTHAGE_CACHE_DEFAULT_BUCKET_NAME"])
      config.prune_on_publish = confirm("Do you want to prune unused framework when publishing?")
      config.aws_region = ask("What is the Amazon S3 region?")
      config.aws_access_key_id = password("What is the AWS access key?")
      config.aws_secret_access_key = password(" What is the AWS secret access key?")
      config
    end

    private

      def ask(message, default_value = nil)
        message = "#{message} [#{default_value}]" if default_value
        answer = @ask_proc.call(message)
        if answer.empty?
          default_value
        else
          answer
        end
      end

      def confirm(message)
        ask("#{message} [N/y]").downcase == 'y'
      end

      def password(message)
        @password_proc.call(message)
      end

  end

end<commit_msg>Fix crash in wizard if prune on publish uses default answer<commit_after>module CarthageCache

  class ConfiguratorWizard

    def initialize(ask_proc, password_proc)
      @ask_proc = ask_proc
      @password_proc = password_proc
    end

    def start
      config = Configuration.new
      config.bucket_name = ask("What is the Amazon S3 bucket name?", ENV["CARTHAGE_CACHE_DEFAULT_BUCKET_NAME"])
      config.prune_on_publish = confirm("Do you want to prune unused framework when publishing?")
      config.aws_region = ask("What is the Amazon S3 region?")
      config.aws_access_key_id = password("What is the AWS access key?")
      config.aws_secret_access_key = password(" What is the AWS secret access key?")
      config
    end

    private

      def ask(message, default_value = nil)
        message = "#{message} [#{default_value}]" if default_value
        answer = @ask_proc.call(message)
        if answer.empty?
          default_value
        else
          answer
        end
      end

      def confirm(message)
        ask("#{message} [N/y]", 'N').downcase == 'y'
      end

      def password(message)
        @password_proc.call(message)
      end

  end

end
{'fraction_non_alphanumeric': 0.08502373759171342, 'fraction_numerical': 0.0017263703064307294, 'mean_word_length': 2.6446540880503147, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1071414', 'n_tokens_mistral': 687, 'n_tokens_neox': 667, 'n_words': 192}