<commit_before>module RubyEventStore

  # Used for building and executing the query specification.
  class Specification
    DEFAULT_BATCH_SIZE = 100
    # @api private
    # @private
    def initialize(reader, result = SpecificationResult.new)
      @reader = reader
      @result = result
    end

    # Limits the query to certain stream.
    # {http://railseventstore.org/docs/read/ Find out more}.
    #
    # @param stream_name [String] name of the stream to get events from
    # @return [Specification]
    def stream(stream_name)
      Specification.new(reader, result.dup { |r| r.stream = Stream.new(stream_name) })
    end

    # Limits the query to events before or after another event.
    # {http://railseventstore.org/docs/read/ Find out more}.
    #
    # @param start [:head, String] id of event to start reading from.
    #   :head can mean the beginning or end of the stream, depending on the
    #   #direction
    # @return [Specification]
    def from(start)
      case start
      when Symbol
        raise InvalidPageStart unless [:head].include?(start)
      else
        raise InvalidPageStart if start.nil? || start.empty?
        raise EventNotFound.new(start) unless reader.has_event?(start)
      end
      Specification.new(reader, result.dup { |r| r.start = start })
    end

    # Limits the query to events before or after another event.
    # {http://railseventstore.org/docs/read/ Find out more}.
    #
    # @param start [:tail, String] id of event to start reading from.
    #   :tail can mean the end or beginning of the stream, depending on the
    #   #direction
    # @return [Specification]
    def to(stop)
      case stop
      when Symbol
        raise InvalidPageStop unless [:tail].include?(stop)
      else
        raise InvalidPageStop if stop.nil? || stop.empty?
        raise EventNotFound.new(stop) unless reader.has_event?(stop)
      end
      Specification.new(reader, result.dup { |r| r.stop = stop })
    end

    # Sets the order of reading events to ascending (forward from the start).
    # {http://railseventstore.org/docs/read/ Find out more}.
    #
    # @return [Specification]
    def forward<commit_msg>Use equal? instead of include?<commit_after>module RubyEventStore

  # Used for building and executing the query specification.
  class Specification
    DEFAULT_BATCH_SIZE = 100
    # @api private
    # @private
    def initialize(reader, result = SpecificationResult.new)
      @reader = reader
      @result = result
    end

    # Limits the query to certain stream.
    # {http://railseventstore.org/docs/read/ Find out more}.
    #
    # @param stream_name [String] name of the stream to get events from
    # @return [Specification]
    def stream(stream_name)
      Specification.new(reader, result.dup { |r| r.stream = Stream.new(stream_name) })
    end

    # Limits the query to events before or after another event.
    # {http://railseventstore.org/docs/read/ Find out more}.
    #
    # @param start [:head, String] id of event to start reading from.
    #   :head can mean the beginning or end of the stream, depending on the
    #   #direction
    # @return [Specification]
    def from(start)
      case start
      when Symbol
        raise InvalidPageStart unless start.equal?(:head)
      else
        raise InvalidPageStart if start.nil? || start.empty?
        raise EventNotFound.new(start) unless reader.has_event?(start)
      end
      Specification.new(reader, result.dup { |r| r.start = start })
    end

    # Limits the query to events before or after another event.
    # {http://railseventstore.org/docs/read/ Find out more}.
    #
    # @param start [:tail, String] id of event to start reading from.
    #   :tail can mean the end or beginning of the stream, depending on the
    #   #direction
    # @return [Specification]
    def to(stop)
      case stop
      when Symbol
        raise InvalidPageStop unless stop.equal?(:tail)
      else
        raise InvalidPageStop if stop.nil? || stop.empty?
        raise EventNotFound.new(stop) unless reader.has_event?(stop)
      end
      Specification.new(reader, result.dup { |r| r.stop = stop })
    end

    # Sets the order of reading events to ascending (forward from the start).
    # {http://railseventstore.org/docs/read/ Find out more}.
    #
    # @return [Specification]
    def forward
{'fraction_non_alphanumeric': 0.09289491837203954, 'fraction_numerical': 0.0013796275005748448, 'mean_word_length': 2.658536585365854, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2976922', 'n_tokens_mistral': 1267, 'n_tokens_neox': 1242, 'n_words': 429}