<commit_before>require "capistrano/dotenv/version"
require "capistrano/dotenv/config"

set :capistrano_dotenv_role, -> { :app }
set :capistrano_dotenv_path, -> { shared_path.join('.env') }
set :capistrano_dotenv_path_exists, -> { "[ -f #{fetch(:capistrano_dotenv_path).shellescape} ]" }

namespace :config do
  desc "fetch existing environments variables from .env config file"
  task :show do
    dotenv_path = fetch(:capistrano_dotenv_path).shellescape

    on roles(fetch(:capistrano_dotenv_role)) do
      info capture(:cat, dotenv_path) if test fetch(:capistrano_dotenv_path_exists)
    end
  end

  desc "Set an environment variable in .env config file"
  task :set do
    dotenv_path = fetch(:capistrano_dotenv_path)

    on roles(fetch(:capistrano_dotenv_role)) do
      contents = capture(:cat, dotenv_path) if test fetch(:capistrano_dotenv_path_exists)
      config = Capistrano::Dotenv::Config.new(contents)

      config.add(*ARGV[2..-1])

      upload!(config.to_io, dotenv_path)
    end
  end

  desc "Removes an environment variable from the .env config file"
  task :remove do |t, args|
    unless ENV['key']
      raise "You need to set `key=KEY_TO_BE_REMOVED` to remove a key"
    end

    dotenv_path = fetch(:capistrano_dotenv_path)

    on roles(fetch(:capistrano_dotenv_role)) do
      contents = capture(:cat, dotenv_path) if test fetch(:capistrano_dotenv_path_exists)
      config = Capistrano::Dotenv::Config.new(contents)

      config.remove(ENV['key'])
      upload!(config.to_io, dotenv_path)
    end
  end
end

namespace :dotenv do
  desc 'create the .env in shared directory'
  task :touch do
    on release_roles :all do # same as deploy:check:linked_files
      execute :touch, fetch(:capistrano_dotenv_path).shellescape
    end
  end
end<commit_msg>escape dotenv path<commit_after>require "capistrano/dotenv/version"
require "capistrano/dotenv/config"

set :capistrano_dotenv_role, -> { :app }
set :capistrano_dotenv_path, -> { shared_path.join('.env') }
set :capistrano_dotenv_path_escaped, -> {fetch(:capistrano_dotenv_path).to_s.shellescape }
set :capistrano_dotenv_path_exists, -> { "[ -f #{fetch(:capistrano_dotenv_path_escaped)} ]" }

namespace :config do
  desc "fetch existing environments variables from .env config file"
  task :show do
    dotenv_path = fetch(:capistrano_dotenv_path_escaped)

    on roles(fetch(:capistrano_dotenv_role)) do
      info capture(:cat, dotenv_path) if test fetch(:capistrano_dotenv_path_exists)
    end
  end

  desc "Set an environment variable in .env config file"
  task :set do
    dotenv_path = fetch(:capistrano_dotenv_path_escaped)

    on roles(fetch(:capistrano_dotenv_role)) do
      contents = capture(:cat, dotenv_path) if test fetch(:capistrano_dotenv_path_exists)
      config = Capistrano::Dotenv::Config.new(contents)

      config.add(*ARGV[2..-1])

      upload!(config.to_io, dotenv_path)
    end
  end

  desc "Removes an environment variable from the .env config file"
  task :remove do |t, args|
    unless ENV['key']
      raise "You need to set `key=KEY_TO_BE_REMOVED` to remove a key"
    end

    dotenv_path = fetch(:capistrano_dotenv_path_escaped)

    on roles(fetch(:capistrano_dotenv_role)) do
      contents = capture(:cat, dotenv_path) if test fetch(:capistrano_dotenv_path_exists)
      config = Capistrano::Dotenv::Config.new(contents)

      config.remove(ENV['key'])
      upload!(config.to_io, dotenv_path)
    end
  end
end

namespace :dotenv do
  desc 'create the .env in shared directory'
  task :touch do
    on release_roles :all do # same as deploy:check:linked_files
      execute :touch, fetch(:capistrano_dotenv_path_escaped)
    end
  end
end
{'fraction_non_alphanumeric': 0.10092744135297327, 'fraction_numerical': 0.0010911074740861974, 'mean_word_length': 4.283861671469741, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, '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': '1184785', 'n_tokens_mistral': 1249, 'n_tokens_neox': 1222, 'n_words': 294}