Class: Cane::RakeTask
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- Cane::RakeTask
- Defined in:
- lib/cane/rake_task.rb
Overview
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#add_threshold(file, operator, value) ⇒ Object
Add a threshold check.
- #canefile=(file) ⇒ Object
-
#initialize(task_name = nil) ⇒ RakeTask
constructor
A new instance of RakeTask.
- #use(check, options = {}) ⇒ Object
Constructor Details
#initialize(task_name = nil) ⇒ RakeTask
Returns a new instance of RakeTask.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/cane/rake_task.rb', line 52 def initialize(task_name = nil) self.name = task_name || :cane @gte = [] @options = Cane::CLI. if block_given? yield self else self.canefile = './.cane' end unless ::Rake.application.last_description desc %(Check code quality metrics with cane) end task name do require 'cane/cli' abort unless Cane.run() end end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
20 21 22 |
# File 'lib/cane/rake_task.rb', line 20 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
21 22 23 |
# File 'lib/cane/rake_task.rb', line 21 def @options end |
Instance Method Details
#add_threshold(file, operator, value) ⇒ Object
Add a threshold check. If the file exists and it contains a number, compare that number with the given value using the operator.
35 36 37 38 39 |
# File 'lib/cane/rake_task.rb', line 35 def add_threshold(file, operator, value) if operator == :>= @options[:gte] << [file, value] end end |
#canefile=(file) ⇒ Object
46 47 48 49 50 |
# File 'lib/cane/rake_task.rb', line 46 def canefile=(file) canefile = Cane::CLI::Parser.new canefile.parser.parse!(canefile.(file)) .merge! canefile. end |
#use(check, options = {}) ⇒ Object
41 42 43 44 |
# File 'lib/cane/rake_task.rb', line 41 def use(check, = {}) @options.merge!() @options[:checks] = @options[:checks] + [check] end |