<commit_before>set :user, 'rails'
role :production, "hashref.com"

def execute_in_rc(method, command)
  send(method, "export PATH=/opt/ruby-enterprise/bin:/usr/local/bin:/usr/bin:/bin; export RAILS_ENV=production; cd /home/rails/rails-contributors; #{command}")
end

def run_in_rc(command)
  execute_in_rc(:run, command)
end

def stream_in_rc(command)
  execute_in_rc(:stream, command)
end

namespace :rc do
  task :tail, :roles => :production do
    stream_in_rc "tail -f log/production.log"
  end

  task :pull, :roles => :production do
    run_in_rc "git pull"
  end

  task :bundle, :roles => :production do
    run_in_rc 'bundle install --path ~/.bundle'
  end

  task :update_repo, :roles => :production do
    run_in_rc %{bundle exec rails runner 'Repo.update("/home/rails/master", "origin/master", "origin/2-3-stable", "origin/3-0-stable")'}
  end

  task :delete_all_contributions, :roles => :production do
    run_in_rc %{bundle exec rails runner 'Contribution.delete_all'}
  end

  task :restart, :roles => :production do
    run_in_rc "touch tmp/restart.txt"
  end

  task :expire_caches, :roles => :production do
    run_in_rc "rm -f public/stylesheets/all.css"
    run_in_rc "rm -f public/javascripts/all.js"

    # Inspired by <NAME>'s
    # http://blog.brightbox.co.uk/posts/expiring-an-entire-page-cache-tree-atomically
    suffix = Time.now.to_i
    run_in_rc "mv tmp/cache/views tmp/cache/views_#{suffix}"
    run_in_rc "rm -rf tmp/cache/views_#{suffix}"
  end

  task :deploy do
    pull
    bundle
    update_repo
    restart
    expire_caches
  end

  task :maintenance_on, :roles => :production do
    run_in_rc "cp public/system/maintenance.html.deleteme public/system/maintenance.html"
  end<commit_msg>revises rc:expire_caches to match Repo#expire_caches<commit_after>set :user, 'rails'
role :production, "hashref.com"

def execute_in_rc(method, command)
  send(method, "export PATH=/opt/ruby-enterprise/bin:/usr/local/bin:/usr/bin:/bin; export RAILS_ENV=production; cd /home/rails/rails-contributors; #{command}")
end

def run_in_rc(command)
  execute_in_rc(:run, command)
end

def stream_in_rc(command)
  execute_in_rc(:stream, command)
end

namespace :rc do
  task :tail, :roles => :production do
    stream_in_rc "tail -f log/production.log"
  end

  task :pull, :roles => :production do
    run_in_rc "git pull"
  end

  task :bundle, :roles => :production do
    run_in_rc 'bundle install --path ~/.bundle'
  end

  task :update_repo, :roles => :production do
    run_in_rc %{bundle exec rails runner 'Repo.update("/home/rails/master", "origin/master", "origin/2-3-stable", "origin/3-0-stable")'}
  end

  task :delete_all_contributions, :roles => :production do
    run_in_rc %{bundle exec rails runner 'Contribution.delete_all'}
  end

  task :restart, :roles => :production do
    run_in_rc "touch tmp/restart.txt"
  end

  task :expire_caches, :roles => :production do
    run_in_rc "rm -f public/stylesheets/all.css"
    run_in_rc "rm -f public/javascripts/all.js"

    # Inspired by <NAME>
    # http://blog.brightbox.co.uk/posts/expiring-an-entire-page-cache-tree-atomically
    expired_cache = "tmp/expired_cache.#{Time.now.to_f}"
    run_in_rc "mv tmp/cache #{expired_cache}"
    run_in_rc "rm -rf #{expired_cache}"
  end

  task :deploy do
    pull
    bundle
    update_repo
    restart
    expire_caches
  end

  task :maintenance_on, :roles => :production do
    run_in_rc "cp public/system/maintenance.html.deleteme public/system/maintenance.html"
  end
{'fraction_non_alphanumeric': 0.12660760217204917, 'fraction_numerical': 0.002286367533581023, 'mean_word_length': 3.8746518105849583, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4070501', 'n_tokens_mistral': 1318, 'n_tokens_neox': 1265, 'n_words': 291}