<commit_before>module Searchlight
  class Search
    extend DSL

    def self.search_target
      return @search_target if defined?(@search_target)
      return superclass.search_target if superclass.respond_to?(:search_target) && superclass != Searchlight::Search
      if self.name.end_with?('Search')
        @search_target = name.sub(/Search$/, '').split('::').inject(Kernel, &:const_get)
      else
        raise MissingSearchTarget, "No search target provided via `search_on` and Searchlight can't guess one."
      end
    rescue NameError => e
      if e.message.start_with?("uninitialized constant")
        raise MissingSearchTarget, "No search target provided; guessed target not found. Error: #{e.message}"
      end
      raise e # unknown error
    end

    def initialize(options = {})
      options.each { |key, value| public_send("#{key}=", value) } if options && options.any?
    rescue NoMethodError => e
      raise UndefinedOption.new(e.name, self.class.name)
    end

    def search
      @search ||= self.class.search_target
    end

    def results
      @results ||= run
    end

    protected

    attr_writer :search<commit_msg>Rubinius exception message differs slightly<commit_after>module Searchlight
  class Search
    extend DSL

    def self.search_target
      return @search_target if defined?(@search_target)
      return superclass.search_target if superclass.respond_to?(:search_target) && superclass != Searchlight::Search
      if self.name.end_with?('Search')
        @search_target = name.sub(/Search$/, '').split('::').inject(Kernel, &:const_get)
      else
        raise MissingSearchTarget, "No search target provided via `search_on` and Searchlight can't guess one."
      end
    rescue NameError => e
      if /uninitialized constant/.match(e.message)
        raise MissingSearchTarget, "No search target provided; guessed target not found. Error: #{e.message}"
      end
      raise e # unknown error
    end

    def initialize(options = {})
      options.each { |key, value| public_send("#{key}=", value) } if options && options.any?
    rescue NoMethodError => e
      raise UndefinedOption.new(e.name, self.class.name)
    end

    def search
      @search ||= self.class.search_target
    end

    def results
      @results ||= run
    end

    protected

    attr_writer :search
{'fraction_non_alphanumeric': 0.1049700085689803, 'fraction_numerical': 0.0, 'mean_word_length': 3.0608695652173914, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '5154153', 'n_tokens_mistral': 667, 'n_tokens_neox': 654, 'n_words': 189}