What directories to operate on. Sensible defaults.
The name of the task. Defaults to :flay
Threshold to fail the task at. Default 200.
Verbosity of output. Defaults to rake’s trace (-t) option.
Defines the flay task.
# File lib/flay_task.rb, line 44 def define desc "Analyze for code duplication in: #{dirs.join(", ")}" task name do require "flay" flay = Flay.run flay.report if verbose raise "Flay total too high! #{flay.total} > #{threshold}" if flay.total > threshold end self end
Creates a new FlayTask instance with given
name
, threshold
, and dirs
.
# File lib/flay_task.rb, line 28 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