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
.
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/flay_task.rb', line 26 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.
10 11 12 |
# File 'lib/flay_task.rb', line 10 def dirs @dirs end |
#name ⇒ Object
The name of the task. Defaults to :flay
5 6 7 |
# File 'lib/flay_task.rb', line 5 def name @name end |
#threshold ⇒ Object
Threshold to fail the task at. Default 200.
15 16 17 |
# File 'lib/flay_task.rb', line 15 def threshold @threshold end |
#verbose ⇒ Object
Verbosity of output. Defaults to rake’s trace (-t) option.
20 21 22 |
# File 'lib/flay_task.rb', line 20 def verbose @verbose end |
Instance Method Details
#define ⇒ Object
Defines the flay task.
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/flay_task.rb', line 42 def define desc "Analyze for code duplication in: #{dirs.join(', ')}" task name do require "flay" flay = Flay.new flay.process(*Flay.(dirs)) flay.report if verbose raise "Flay total too high! #{flay.total} > #{threshold}" if flay.total > threshold end self end |