<commit_before>require 'active_support/core_ext/string/strip'
require 'slack-notifier'

module RakeNotifier
  class Slack < Base

    START_LABEL   = ":construction: *[START]*"
    SUCCESS_LABEL = ":congratulations: *[SUCCESS]*"
    FAILED_LABEL  = ":x: *[FAILED]*"

    def initialize(webhook_url, channel, icon: nil, username: nil)
      @client = Slack::Notifier.new(webhook_url, channel: channel)
      @client.username = username if username
      @icon = icon
    end
    attr_reader :icon

    def started_task(task)
      notice <<-EOS.strip_heredoc
        #{START_LABEL} `$ #{task.reconstructed_command_line}`
        >>> from #{hostname} at #{Time.now} RAILS_ENV=#{rails_env}
      EOS
    end

    def completed_task(task, system_exit)
      label = system_exit.success? ? SUCCESS_LABEL : FAILED_LABEL
      notice <<-EOS.strip_heredoc
        #{label} `$ #{task.reconstructed_command_line}`
        >>> exit #{system_exit.status} from #{hostname} at #{Time.now} RAILS_ENV=#{rails_env}
      EOS<commit_msg>Find ::Slack from root namespace<commit_after>require 'active_support/core_ext/string/strip'
require 'slack-notifier'

module RakeNotifier
  class Slack < Base

    START_LABEL   = ":construction: *[START]*"
    SUCCESS_LABEL = ":congratulations: *[SUCCESS]*"
    FAILED_LABEL  = ":x: *[FAILED]*"

    def initialize(webhook_url, channel, icon: nil, username: nil)
      @client = ::Slack::Notifier.new(webhook_url, channel: channel)
      @client.username = username if username
      @icon = icon
    end
    attr_reader :icon

    def started_task(task)
      notice <<-EOS.strip_heredoc
        #{START_LABEL} `$ #{task.reconstructed_command_line}`
        >>> from #{hostname} at #{Time.now} RAILS_ENV=#{rails_env}
      EOS
    end

    def completed_task(task, system_exit)
      label = system_exit.success? ? SUCCESS_LABEL : FAILED_LABEL
      notice <<-EOS.strip_heredoc
        #{label} `$ #{task.reconstructed_command_line}`
        >>> exit #{system_exit.status} from #{hostname} at #{Time.now} RAILS_ENV=#{rails_env}
      EOS
{'fraction_non_alphanumeric': 0.12918892666342885, 'fraction_numerical': 0.0, 'mean_word_length': 3.5274725274725274, 'pattern_counts': {'":': 6, '<': 13, '<?xml version=': 0, '>': 15, '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': '3485301', 'n_tokens_mistral': 692, 'n_tokens_neox': 687, 'n_words': 143}