<commit_before>Capistrano::Configuration.instance.load do
  def set_default(name, *args, &block)
    set(name, *args, &block) unless exists?(name)
  end

  def close_sessions
    sessions.values.each { |session| session.close }
    sessions.clear
  end

  def as_user(user_name)
    old_user = user
    set :user, user_name
    close_sessions
    begin
      yield
    ensure
      set :user, old_user
      close_sessions
    end
  end

  def run_interactively(command, server=nil)
    server ||= find_servers_for_task(current_task).first
    exec %Q(ssh #{user}@#{server.host} -p #{port} -t '#{command}')
  end

  set_default(:templates_path, "#{Dir.pwd}/config/deploy/templates")

  def template(from, to)
    erb = File.read(File.expand_path("#{templates_path}/#{from}"))
    put ERB.new(erb).result(binding), to
  end

  def kapify_template(generator, template_name, target)
    config_file = "#{templates_path}/#{template_name}"
    # if no customized file, proceed with default
    unless File.exists?(config_file)
      config_file = File.join(File.dirname(__FILE__), "../generators/kapify/#{generator}/templates/#{template_name}")
    end
    put ERB.new(File.read(config_file)).result(binding), target
  end

end<commit_msg>add ask_with_default helper<commit_after>Capistrano::Configuration.instance.load do
  def set_default(name, *args, &block)
    set(name, *args, &block) unless exists?(name)
  end

  def close_sessions
    sessions.values.each { |session| session.close }
    sessions.clear
  end

  def as_user(user_name)
    old_user = user
    set :user, user_name
    close_sessions
    begin
      yield
    ensure
      set :user, old_user
      close_sessions
    end
  end

  def run_interactively(command, server=nil)
    server ||= find_servers_for_task(current_task).first
    exec %Q(ssh #{user}@#{server.host} -p #{port} -t '#{command}')
  end

  set_default(:templates_path, "#{Dir.pwd}/config/deploy/templates")

  def template(from, to)
    erb = File.read(File.expand_path("#{templates_path}/#{from}"))
    put ERB.new(erb).result(binding), to
  end

  def kapify_template(generator, template_name, target)
    config_file = "#{templates_path}/#{template_name}"
    # if no customized file, proceed with default
    unless File.exists?(config_file)
      config_file = File.join(File.dirname(__FILE__), "../generators/kapify/#{generator}/templates/#{template_name}")
    end
    put ERB.new(File.read(config_file)).result(binding), target
  end

  def ask_with_default(prompt, default_value)
    Capistrano::CLI.ui.ask(prompt) do |q|
      q.default = default_value
      q.answer_type = ->(res) { res.to_s }
    end
  end
end
{'fraction_non_alphanumeric': 0.12861978187288453, 'fraction_numerical': 0.0, 'mean_word_length': 3.7841726618705036, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '7442504', 'n_tokens_mistral': 903, 'n_tokens_neox': 897, 'n_words': 182}