<commit_before># Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
#     http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.

module Seahorse
  class Client
    # @api private
    class HandlerList

      include Enumerable

      # @api private
      def initialize
        @handlers = Hash.new do |hash, key|
          raise ArgumentError, "invalid priority #{key.inspect}"
        end
        @handlers[:send] = SendHandlers.new
        @handlers[:before_send] = []
        @handlers[:after_sign] = []
        @handlers[:sign] = []
        @handlers[:before_sign] = []
        @handlers[:after_build] = []
        @handlers[:build] = []
        @handlers[:before_build] = []
        @handlers[:after_validate] = []
        @handlers[:validate] = []
        @handlers[:before_validate] = []
      end

      # @param [Class] handler
      # @option options [Symbol] priority (:build)
      def add(handler, options = {})
        @handlers[options[:priority] || :build] << handler
      end

      # Yields the handlers.
      def each(&block)
        @handlers.values.each do |handlers|
          handlers.each(&block)
        end
      end

      # There can only be a single send handler.  This provides the same
      # interface plus a helpful warning message.
      # @api private
      class SendHandlers

        def <<(handler)
          @handler = handler
        end

        def each(&block)
          yield(@handler) if @handler
        end

      end
    end
  end
end
<commit_msg>HandlerList is now publically documented.<commit_after># Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
#     http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.

module Seahorse
  class Client
    class HandlerList

      include Enumerable

      # @api private
      def initialize
        @handlers = Hash.new do |hash, key|
          raise ArgumentError, "invalid priority #{key.inspect}"
        end
        @handlers[:send] = SendHandlers.new
        @handlers[:before_send] = []
        @handlers[:after_sign] = []
        @handlers[:sign] = []
        @handlers[:before_sign] = []
        @handlers[:after_build] = []
        @handlers[:build] = []
        @handlers[:before_build] = []
        @handlers[:after_validate] = []
        @handlers[:validate] = []
        @handlers[:before_validate] = []
      end

      # @param [Class] handler
      # @option options [Symbol] priority (:build)
      def add(handler, options = {})
        @handlers[options[:priority] || :build] << handler
      end

      # Yields the handlers.
      def each(&block)
        @handlers.values.each do |handlers|
          handlers.each(&block)
        end
      end

      # There can only be a single send handler.  This provides the same
      # interface plus a helpful warning message.
      # @api private
      class SendHandlers

        def <<(handler)
          @handler = handler
        end

        def each(&block)
          yield(@handler) if @handler
        end

      end
    end
  end
end

{'fraction_non_alphanumeric': 0.10150856558424955, 'fraction_numerical': 0.004091025313219126, 'mean_word_length': 2.3637145313843506, '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': '5881981', 'n_tokens_mistral': 1095, 'n_tokens_neox': 1060, 'n_words': 370}