<commit_before>require 'rbconfig'

module Guard
  module Notifier

    DEFAULTS = {
      :client => 'emacsclient',
      :success => 'ForestGreen',
      :failed => 'Firebrick',
      :default => 'Black',
    }

    # @example Add the `:emacs` notifier to your `Guardfile`
    #   notification :emacs
    #
    module Emacs
      extend self

      # Test if Emacs with running server is available.
      #
      # @param [Boolean] silent true if no error messages should be shown
      # @return [Boolean] the availability status
      #
      def available?(silent = false)
        result = `#{DEFAULTS[:client]} --eval '1' 2> /dev/null || echo 0`

        if result.chomp! == "1"
          true
        else
          false
        end
      end

      # Show a system notification.
      #
      # @param [String] type the notification type. Either 'success', 'pending', 'failed' or 'notify'
      # @param [String] title the notification title
      # @param [String] message the notification message body
      # @param [String] image the path to the notification image
      # @param [Hash] options additional notification library options
      # @option options [Boolean] sticky make the notification sticky
      # @option options [String, Integer] priority specify an int or named key (default is 0)
      #
      def notify(type, title, message, image, options = { })
        system(%(#{DEFAULTS[:client]} --eval "(set-face-background 'modeline \\"#{emacs_color(type)}\\")"))
      end

      def emacs_color(type)
        case type
            when 'success'
              DEFAULTS[:success]
            when 'failed'
              DEFAULTS[:failed]
            else
              DEFAULTS[:default]
        end
      end
    end
  end
end
<commit_msg>Update Emacs client docs.<commit_after>require 'rbconfig'

module Guard
  module Notifier

    # Default options for EmacsClient
    DEFAULTS = {
      :client => 'emacsclient',
      :success => 'ForestGreen',
      :failed => 'Firebrick',
      :default => 'Black',
    }

    # Send a notification to Emacs with emacsclient (http://www.emacswiki.org/emacs/EmacsClient).
    #
    # @example Add the `:emacs` notifier to your `Guardfile`
    #   notification :emacs
    #
    module Emacs
      extend self

      # Test if Emacs with running server is available.
      #
      # @param [Boolean] silent true if no error messages should be shown
      # @return [Boolean] the availability status
      #
      def available?(silent = false)
        result = `#{DEFAULTS[:client]} --eval '1' 2> /dev/null || echo 0`

        if result.chomp! == "1"
          true
        else
          false
        end
      end

      # Show a system notification.
      #
      # @param [String] type the notification type. Either 'success', 'pending', 'failed' or 'notify'
      # @param [String] title the notification title
      # @param [String] message the notification message body
      # @param [String] image the path to the notification image
      # @param [Hash] options additional notification library options
      # @option options [Boolean] sticky make the notification sticky
      # @option options [String, Integer] priority specify an int or named key (default is 0)
      #
      def notify(type, title, message, image, options = { })
        system(%(#{DEFAULTS[:client]} --eval "(set-face-background 'modeline \\"#{emacs_color(type)}\\")"))
      end

      # Get the Emacs color for the notification type.
      # You can configure your own color by overwrite the defaults.
      #
      # @param [String] type the notification type
      # @return [String] the name of the emacs color
      #
      def emacs_color(type)
        case type
            when 'success'
              DEFAULTS[:success]
            when 'failed'
              DEFAULTS[:failed]
            else
              DEFAULTS[:default]
        end
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.1003310415075121, 'fraction_numerical': 0.002546473134708429, 'mean_word_length': 2.144915932746197, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, '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': '5910348', 'n_tokens_mistral': 1073, 'n_tokens_neox': 1066, 'n_words': 383}