<commit_before>require 'dry/validation/constants'

module Dry
  module Validation
    class Message
      include Dry::Equalizer(:predicate, :path, :text, :options)

      Index = Class.new {
        def inspect
          "index"
        end
        alias_method :to_s, :inspect
      }.new

      attr_reader :predicate, :path, :text, :rule, :args

      class Each < Message
        def index_path
          @index_path ||= [*path[0..path.size-2], Index]
        end

        def each?
          true
        end
      end

      def self.[](predicate, path, text, options)
        klass = options[:each] ? Message::Each : Message
        klass.new(predicate, path, text, options)
      end

      def initialize(predicate, path, text, options)
        @predicate = predicate
        @path = path
        @text = text
        @options = options
        @rule = options[:rule]
        @each = options[:each] || false
        @args = options[:args] || EMPTY_ARRAY
      end

      alias_method :index_path, :path

      def to_s
        text
      end

      def signature
        @signature ||= [predicate, args, index_path].hash
      end

      def each?
        @each
      end

      def hint?
        false
      end

      def root?
        path.empty?
      end

      def eql?(other)
        other.is_a?(String) ? text == other : super
      end
    end

    class Hint < Message
      def self.[](predicate, path, text, options)
        klass = options[:each] ? Hint::Each : Hint
        klass.new(predicate, path, text, options)
      end

      class Each < Hint
        def index_path
          @index_path ||= [*path, Index]
        end
      end

      def hint?
        true
      end
    end
  end
end
<commit_msg>Add a reader for Message#options for nicer inspect<commit_after>require 'dry/validation/constants'

module Dry
  module Validation
    class Message
      include Dry::Equalizer(:predicate, :path, :text, :options)

      Index = Class.new {
        def inspect
          "index"
        end
        alias_method :to_s, :inspect
      }.new

      attr_reader :predicate, :path, :text, :rule, :args, :options

      class Each < Message
        def index_path
          @index_path ||= [*path[0..path.size-2], Index]
        end

        def each?
          true
        end
      end

      def self.[](predicate, path, text, options)
        klass = options[:each] ? Message::Each : Message
        klass.new(predicate, path, text, options)
      end

      def initialize(predicate, path, text, options)
        @predicate = predicate
        @path = path
        @text = text
        @options = options
        @rule = options[:rule]
        @each = options[:each] || false
        @args = options[:args] || EMPTY_ARRAY
      end

      alias_method :index_path, :path

      def to_s
        text
      end

      def signature
        @signature ||= [predicate, args, index_path].hash
      end

      def each?
        @each
      end

      def hint?
        false
      end

      def root?
        path.empty?
      end

      def eql?(other)
        other.is_a?(String) ? text == other : super
      end
    end

    class Hint < Message
      def self.[](predicate, path, text, options)
        klass = options[:each] ? Hint::Each : Hint
        klass.new(predicate, path, text, options)
      end

      class Each < Hint
        def index_path
          @index_path ||= [*path, Index]
        end
      end

      def hint?
        true
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.09717868338557993, 'fraction_numerical': 0.001139925904816187, 'mean_word_length': 1.661106899166035, 'pattern_counts': {'":': 0, '<': 9, '<?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': '4306506', 'n_tokens_mistral': 1066, 'n_tokens_neox': 1030, 'n_words': 302}