Class: FlayTask
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- FlayTask
- Defined in:
- lib/flay_task.rb
Instance Attribute Summary collapse
-
#dirs ⇒ Object
What directories to operate on.
-
#name ⇒ Object
The name of the task.
-
#threshold ⇒ Object
Threshold to fail the task at.
-
#verbose ⇒ Object
Verbosity of output.
Instance Method Summary collapse
-
#define ⇒ Object
Defines the flay task.
-
#initialize(name = :flay, threshold = 200, dirs = nil) {|_self| ... } ⇒ FlayTask
constructor
Creates a new FlayTask instance with given
name
,threshold
, anddirs
.
Constructor Details
#initialize(name = :flay, threshold = 200, dirs = nil) {|_self| ... } ⇒ FlayTask
Creates a new FlayTask instance with given name
, threshold
, and dirs
.
28 29 30 31 32 33 34 35 36 37 38 39 |
# 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..trace yield self if block_given? @dirs.reject! { |f| ! File.directory? f } define end |
Instance Attribute Details
#dirs ⇒ Object
What directories to operate on. Sensible defaults.
12 13 14 |
# File 'lib/flay_task.rb', line 12 def dirs @dirs end |
#name ⇒ Object
The name of the task. Defaults to :flay
7 8 9 |
# File 'lib/flay_task.rb', line 7 def name @name end |
#threshold ⇒ Object
Threshold to fail the task at. Default 200.
17 18 19 |
# File 'lib/flay_task.rb', line 17 def threshold @threshold end |
#verbose ⇒ Object
Verbosity of output. Defaults to rake’s trace (-t) option.
22 23 24 |
# File 'lib/flay_task.rb', line 22 def verbose @verbose end |
Instance Method Details
#define ⇒ Object
Defines the flay task.
44 45 46 47 48 49 50 51 52 53 54 55 |
# 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(dirs) flay.report if verbose raise "Flay total too high! #{flay.total} > #{threshold}" if flay.total > threshold end self end |