<commit_before>
namespace :slack do
  namespace :deploy do

    task :starting do
      if fetch(:slack_run_starting)
        run_locally do
          Slackistrano.post(
            team: fetch(:slack_team),
            token: fetch(:slack_token),
            payload: {
              channel: fetch(:slack_channel),
              username: fetch(:slack_username),
              icon_url: fetch(:slack_icon_url),
              icon_emoji: fetch(:slack_icon_emoji),
              text: fetch(:slack_msg_starting)
            }
          )
        end
      end
    end

    task :finished do
      if fetch(:slack_run_finished)
        run_locally do
          Slackistrano.post(
            team: fetch(:slack_team),
            token: fetch(:slack_token),
            payload: {
              channel: fetch(:slack_channel),
              username: fetch(:slack_username),
              icon_url: fetch(:slack_icon_url),
              icon_emoji: fetch(:slack_icon_emoji),
              text: fetch(:slack_msg_finished)
            }
          )
        end
      end
    end

    task :failed do
      if fetch(:slack_run_failed)
        run_locally do
          Slackistrano.post(
            team: fetch(:slack_team),
            token: fetch(:slack_token),
            payload: {
              channel: fetch(:slack_channel),
              username: fetch(:slack_username),
              icon_url: fetch(:slack_icon_url),
              icon_emoji: fetch(:slack_icon_emoji),
              text: fetch(:slack_msg_failed)
            }
          )
        end
      end
    end

  end
end

before 'deploy:starting', 'slack:deploy:starting'
after  'deploy:finished', 'slack:deploy:finished'
after  'deploy:failed',   'slack:deploy:failed'

namespace :load do
  task :defaults do
    set :slack_team,         ->{ nil } # If URL is 'team.slack.com', value is 'team'. Required.
    set :slack_token,        ->{ nil } # Token from Incoming WebHooks. Required.
    set :slack_channel,      ->{ nil } # Channel to post to. Optional. Defaults to WebHook setting.
    set :slack_icon_url,     ->{ 'http://gravatar.com/avatar/885e1c523b7975c4003de162d8ee8fee?r=g&s=40' }
    set :slack_icon_emoji,   ->{ nil } # Emoji to use. Overrides icon_url. Must be a string (ex: ':shipit:')
    set :slack_username,     ->{ 'Slackistrano' }
    set :slack_run_starting, ->{ true } # Set to false to disable starting message.
    set :slack_run_finished, ->{ true } # Set to false to disable finished message.
    set :slack_run_failed,   ->{ true } # Set to false to disable failure message.
    set :slack_msg_starting, ->{ "#{ENV['USER'] || ENV['USERNAME']} has started deploying branch #{fetch :branch} of #{fetch :application} to #{fetch :rails_env, 'production'}." }
    set :slack_msg_finished, ->{ "#{ENV['USER'] || ENV['USERNAME']} has finished deploying branch #{fetch :branch} of #{fetch :application} to #{fetch :rails_env, 'production'}." }
    set :slack_msg_failed,   ->{ "*ERROR!* #{ENV['USER'] || ENV['USERNAME']} failed to deploy branch #{fetch :branch} of #{fetch :application} to #{fetch :rails_env, 'production'}." }
  end
end<commit_msg>re-revert messaging to use :state instead of :rails_env. re-fixes #1<commit_after>
namespace :slack do
  namespace :deploy do

    task :starting do
      if fetch(:slack_run_starting)
        run_locally do
          Slackistrano.post(
            team: fetch(:slack_team),
            token: fetch(:slack_token),
            payload: {
              channel: fetch(:slack_channel),
              username: fetch(:slack_username),
              icon_url: fetch(:slack_icon_url),
              icon_emoji: fetch(:slack_icon_emoji),
              text: fetch(:slack_msg_starting)
            }
          )
        end
      end
    end

    task :finished do
      if fetch(:slack_run_finished)
        run_locally do
          Slackistrano.post(
            team: fetch(:slack_team),
            token: fetch(:slack_token),
            payload: {
              channel: fetch(:slack_channel),
              username: fetch(:slack_username),
              icon_url: fetch(:slack_icon_url),
              icon_emoji: fetch(:slack_icon_emoji),
              text: fetch(:slack_msg_finished)
            }
          )
        end
      end
    end

    task :failed do
      if fetch(:slack_run_failed)
        run_locally do
          Slackistrano.post(
            team: fetch(:slack_team),
            token: fetch(:slack_token),
            payload: {
              channel: fetch(:slack_channel),
              username: fetch(:slack_username),
              icon_url: fetch(:slack_icon_url),
              icon_emoji: fetch(:slack_icon_emoji),
              text: fetch(:slack_msg_failed)
            }
          )
        end
      end
    end

  end
end

before 'deploy:starting', 'slack:deploy:starting'
after  'deploy:finished', 'slack:deploy:finished'
after  'deploy:failed',   'slack:deploy:failed'

namespace :load do
  task :defaults do
    set :slack_team,         ->{ nil } # If URL is 'team.slack.com', value is 'team'. Required.
    set :slack_token,        ->{ nil } # Token from Incoming WebHooks. Required.
    set :slack_channel,      ->{ nil } # Channel to post to. Optional. Defaults to WebHook setting.
    set :slack_icon_url,     ->{ 'http://gravatar.com/avatar/885e1c523b7975c4003de162d8ee8fee?r=g&s=40' }
    set :slack_icon_emoji,   ->{ nil } # Emoji to use. Overrides icon_url. Must be a string (ex: ':shipit:')
    set :slack_username,     ->{ 'Slackistrano' }
    set :slack_run_starting, ->{ true } # Set to false to disable starting message.
    set :slack_run_finished, ->{ true } # Set to false to disable finished message.
    set :slack_run_failed,   ->{ true } # Set to false to disable failure message.
    set :slack_msg_starting, ->{ "#{ENV['USER'] || ENV['USERNAME']} has started deploying branch #{fetch :branch} of #{fetch :application} to #{fetch :stage, 'an unknown stage'}." }
    set :slack_msg_finished, ->{ "#{ENV['USER'] || ENV['USERNAME']} has finished deploying branch #{fetch :branch} of #{fetch :application} to #{fetch :stage, 'an unknown stage'}." }
    set :slack_msg_failed,   ->{ "*ERROR!* #{ENV['USER'] || ENV['USERNAME']} failed to deploy branch #{fetch :branch} of #{fetch :application} to #{fetch :stage, 'an unknown stage'}." }
  end
end
{'fraction_non_alphanumeric': 0.12020823473734027, 'fraction_numerical': 0.00709891150023663, 'mean_word_length': 2.345646437994723, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, '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': '5375055', 'n_tokens_mistral': 2013, 'n_tokens_neox': 1953, 'n_words': 488}