<commit_before>require 'rubygems'
require 'spec'
require File.dirname(__FILE__) + '/../lib/rake/dmg'

module RakeTaskMatchers
  class BeDefined
    def matches?(task_name)
      @task_name = task_name
      Rake::Task.task_defined?(task_name)
    end
    def failure_message
      "expected #{@task_name.inspect} to be defined"
    end
    def negative_failure_message
      "expected #{@task_name.inspect} not to be define"
    end
  end

  def be_defined
    BeDefined.new
  end

  class HavePrerequisites
    def initialize(prereq_tasks)
      @prereq_tasks = prereq_tasks
    end
    def matches?(task_name)
      @task_name = task_name
      @prereq_tasks.each do |t|
        return false if !Rake::Task[@task_name].prerequisites.include?(t)
      end
    end
    def failure_message
      "expected #{@prereq_tasks.inspect} to be prerequistes of #{@task_name.inspect}"
    end
    def negative_failure_message
      "expected #{@prereq_tasks.inspect} not to be prerequisites of #{@task_name.inspect}"
    end
  end

  def have_prerequisites(*prereq_tasks)
    HavePrerequisites.new prereq_tasks
  end<commit_msg>Added a bit of doc to the custom matchers.<commit_after>require 'rubygems'
require 'spec'
require File.dirname(__FILE__) + '/../lib/rake/dmg'

module RakeTaskMatchers
  # Custom matcher to check for tasks being defined or not.
  class BeDefined
    def matches?(task_name)
      @task_name = task_name
      Rake::Task.task_defined?(task_name)
    end
    def failure_message
      "expected #{@task_name.inspect} to be defined"
    end
    def negative_failure_message
      "expected #{@task_name.inspect} not to be define"
    end
  end

  # True if the tested string is the name of a Rake task.
  #
  #   'wonderland'.should be_defined
  def be_defined
    BeDefined.new
  end

  # Custom matcher to check if a given task has specific prerequisites.
  class HavePrerequisites
    def initialize(prereq_tasks)
      @prereq_tasks = prereq_tasks
    end
    def matches?(task_name)
      @task_name = task_name
      @prereq_tasks.each do |t|
        return false if !Rake::Task[@task_name].prerequisites.include?(t)
      end
    end
    def failure_message
      "expected #{@prereq_tasks.inspect} to be prerequistes of #{@task_name.inspect}"
    end
    def negative_failure_message
      "expected #{@prereq_tasks.inspect} not to be prerequisites of #{@task_name.inspect}"
    end
  end

  # True if the tested string is the name of a Rake task with some specific
  # prerequisites.
  #
  #   'lock_the_dor'.should have_prerequisites('pick_up_the_keys')
  #   'have_breakfast'.should have_prerequisites('wake_up', 'get_up')
  def have_prerequisites(*prereq_tasks)
    HavePrerequisites.new prereq_tasks
  end
{'fraction_non_alphanumeric': 0.08382137628111273, 'fraction_numerical': 0.0, 'mean_word_length': 3.3449920508744038, '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': '4898836', 'n_tokens_mistral': 928, 'n_tokens_neox': 891, 'n_words': 235}