Class: FlayTask
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- FlayTask
- Defined in:
- lib/flay_task.rb
Instance Attribute Summary collapse
-
#dirs ⇒ Object
Returns the value of attribute dirs.
-
#name ⇒ Object
Returns the value of attribute name.
-
#threshold ⇒ Object
Returns the value of attribute threshold.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Instance Method Summary collapse
- #define ⇒ Object
-
#initialize(name = :flay, threshold = 200, dirs = nil) {|_self| ... } ⇒ FlayTask
constructor
A new instance of FlayTask.
Constructor Details
#initialize(name = :flay, threshold = 200, dirs = nil) {|_self| ... } ⇒ FlayTask
Returns a new instance of FlayTask.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/flay_task.rb', line 7 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
Returns the value of attribute dirs.
3 4 5 |
# File 'lib/flay_task.rb', line 3 def dirs @dirs end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/flay_task.rb', line 2 def name @name end |
#threshold ⇒ Object
Returns the value of attribute threshold.
4 5 6 |
# File 'lib/flay_task.rb', line 4 def threshold @threshold end |
#verbose ⇒ Object
Returns the value of attribute verbose.
5 6 7 |
# File 'lib/flay_task.rb', line 5 def verbose @verbose end |
Instance Method Details
#define ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/flay_task.rb', line 20 def define desc "Analyze for code duplication in: #{dirs.join(', ')}" task name do 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 |