<commit_before>module ParserExampleGroup

  def load_part(path)
    Whois::Answer::Part.new(File.read(fixture("responses", @host.to_s, @suffix.to_s, @schema.to_s, path)), @host)
  end

  def _part
    Whois::Answer::Part
  end

  def _registrar
    Whois::Answer::Registrar
  end

  def _contact
    Whois::Answer::Contact
  end

  def _nameserver
    Whois::Answer::Nameserver
  end

end

RSpec::Matchers.define :cache_property do |property|
  match do |instance|
    cache = instance.instance_eval do
      @cached_properties = {}
      @cached_properties
    end

    cache.key?(property).should be_false
    value = instance.send(property)

    cache.key?(property).should be_true
    cache[property].should == value

    true
  end

  failure_message_for_should do |instance|
    "expected parser to cache property #{property}"
  end
  failure_message_for_should_not do |instance|
    "expected parser to not cache property #{property}"
  end
end

RSpec::configure do |c|
  def c.escaped_path(*parts)
    Regexp.compile(parts.join('[\\\/]'))
  end

  c.include ParserExampleGroup, :type => :controller, :example_group => {
    :file_path => c.escaped_path(%w( spec whois answer parser ))
  }
end<commit_msg>Fixed incompatibility with JRuby 1.6.0<commit_after>module ParserExampleGroup

  def load_part(path)
    Whois::Answer::Part.new(File.read(fixture("responses", @host.to_s, @suffix.to_s, @schema.to_s, path)), @host)
  end

  def _part
    Whois::Answer::Part
  end

  def _registrar
    Whois::Answer::Registrar
  end

  def _contact
    Whois::Answer::Contact
  end

  def _nameserver
    Whois::Answer::Nameserver
  end

end

RSpec::Matchers.define :cache_property do |property|
  match do |instance|
    cache = instance.instance_eval do
      @cached_properties = {}
      @cached_properties
    end

    cache.key?(property).should be_false
    value = instance.send(property)

    cache.key?(property).should be_true
    cache[property].should == value

    true
  end

  failure_message_for_should do |instance|
    "expected parser to cache property #{property}"
  end
  failure_message_for_should_not do |instance|
    "expected parser to not cache property #{property}"
  end
end

RSpec::configure do |c|
  def c.escaped_path(*parts)
    /#{parts.join('\/')}/
  end

  c.include ParserExampleGroup, :example_group => {
    :file_path => c.escaped_path(%w( spec whois answer parser ))
  }
end
{'fraction_non_alphanumeric': 0.11235489220563848, 'fraction_numerical': 0.0012437810945273632, 'mean_word_length': 3.7406679764243616, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '518547', 'n_tokens_mistral': 833, 'n_tokens_neox': 793, 'n_words': 185}