<commit_before>require File.expand_path("payload.rb", File.dirname(__FILE__))

module Gwooks
  class Base

    DSL_METHODS = %w(
      after
      before
      branch
      commits_added
      commits_author_email
      commits_author_name
      commits_id
      commits_message
      commits_modified
      commits_removed
      commits_timestamp
      commits_url
      ref
      repository_description
      repository_forks
      repository_homepage
      repository_name
      repository_owner_email
      repository_owner_name
      repository_pledgie
      repository_private
      repository_url
      repository_watchers
    )

    class << self
      def call(payload)
        new(payload).call
      end

      def hooks
        @_hooks ||= []
      end

      def payload_matches(key, pattern, &block)
        @_hooks ||= []
        @_hooks << [key, pattern, block]
      end

      def ref(pattern, &block)
        payload_matches("ref", pattern, &block)
      end

      DSL_METHODS.each do |method_name|
        key = method_name.gsub("_", ".")

        define_method(method_name.to_sym) do |pattern, &block|
          payload_matches(key, pattern, &block)
        end
      end

      to_be_aliased = DSL_METHODS.select do |n|
        n.start_with? "commits_", "repository_"
      end

      to_be_aliased.each do |method_name|
        alias_name = method_name.gsub /^(commits|repository)_/ do
          if $1 == "commits"
            "commit_"
          else
            "repo_"
          end
        end
        alias_method alias_name, method_name
      end

    end

    attr_reader :payload

    def initialize(payload)<commit_msg>remove redundant method definition<commit_after>require File.expand_path("payload.rb", File.dirname(__FILE__))

module Gwooks
  class Base

    DSL_METHODS = %w(
      after
      before
      branch
      commits_added
      commits_author_email
      commits_author_name
      commits_id
      commits_message
      commits_modified
      commits_removed
      commits_timestamp
      commits_url
      ref
      repository_description
      repository_forks
      repository_homepage
      repository_name
      repository_owner_email
      repository_owner_name
      repository_pledgie
      repository_private
      repository_url
      repository_watchers
    )

    class << self
      def call(payload)
        new(payload).call
      end

      def hooks
        @_hooks ||= []
      end

      def payload_matches(key, pattern, &block)
        @_hooks ||= []
        @_hooks << [key, pattern, block]
      end

      DSL_METHODS.each do |method_name|
        key = method_name.gsub("_", ".")

        define_method(method_name.to_sym) do |pattern, &block|
          payload_matches(key, pattern, &block)
        end
      end

      to_be_aliased = DSL_METHODS.select do |n|
        n.start_with? "commits_", "repository_"
      end

      to_be_aliased.each do |method_name|
        alias_name = method_name.gsub /^(commits|repository)_/ do
          if $1 == "commits"
            "commit_"
          else
            "repo_"
          end
        end
        alias_method alias_name, method_name
      end

    end

    attr_reader :payload

    def initialize(payload)
{'fraction_non_alphanumeric': 0.07017001545595054, 'fraction_numerical': 0.0006182380216383308, 'mean_word_length': 1.9962962962962962, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, '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': '2532172', 'n_tokens_mistral': 987, 'n_tokens_neox': 956, 'n_words': 205}