class FlayTask

def define

def define
  desc "Analyze for code duplication in: #{dirs.join(", ")}"
  task name do
    require "flay"
    flay = Flay.run(dirs)
    flay.report if verbose
    raise "Flay total too high! #{flay.total} > #{threshold}" if
      flay.total > threshold
  end
  self
end

def initialize name = :flay, threshold = 200, dirs = nil

def initialize name = :flay, threshold = 200, dirs = nil
  @name      = name
  @dirs      = dirs || %w(app bin lib spec test)
  @threshold = threshold
  @verbose   = Rake.application.options.trace
  yield self if block_given?
  @dirs.reject! { |f| ! File.directory? f }
  define
end