Class: Cane::RakeTask
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- Cane::RakeTask
- Defined in:
- lib/cane/rake_task.rb
Overview
Instance Attribute Summary collapse
-
#abc_glob ⇒ Object
Glob to run ABC metrics over (default: “lib/*/.rb”).
-
#abc_max ⇒ Object
Max complexity of methods to allow (default: 15).
-
#doc_glob ⇒ Object
Glob to run doc checks over (default: “lib/*/.rb”).
-
#max_violations ⇒ Object
Max violations to tolerate (default: 0).
-
#name ⇒ Object
Returns the value of attribute name.
-
#no_doc ⇒ Object
TRUE to disable doc checks.
-
#no_style ⇒ Object
TRUE to disable style checks.
-
#style_glob ⇒ Object
Glob to run style checks over (default: “lib,spec/*/.rb”).
-
#style_measure ⇒ Object
Max line length (default: 80).
Instance Method Summary collapse
-
#add_threshold(file, operator, value) ⇒ Object
Add a threshold check.
- #default_options ⇒ Object
-
#initialize(task_name = nil) {|_self| ... } ⇒ RakeTask
constructor
A new instance of RakeTask.
- #options ⇒ Object
- #translated_options ⇒ Object
Constructor Details
#initialize(task_name = nil) {|_self| ... } ⇒ RakeTask
Returns a new instance of RakeTask.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/cane/rake_task.rb', line 42 def initialize(task_name = nil) self.name = task_name || :cane @threshold = [] yield self if block_given? unless ::Rake.application.last_comment desc %(Check code quality metrics with cane) end task name do require 'cane/cli' abort unless Cane.run() end end |
Instance Attribute Details
#abc_glob ⇒ Object
Glob to run ABC metrics over (default: “lib/*/.rb”)
20 21 22 |
# File 'lib/cane/rake_task.rb', line 20 def abc_glob @abc_glob end |
#abc_max ⇒ Object
Max complexity of methods to allow (default: 15)
22 23 24 |
# File 'lib/cane/rake_task.rb', line 22 def abc_max @abc_max end |
#doc_glob ⇒ Object
Glob to run doc checks over (default: “lib/*/.rb”)
30 31 32 |
# File 'lib/cane/rake_task.rb', line 30 def doc_glob @doc_glob end |
#max_violations ⇒ Object
Max violations to tolerate (default: 0)
34 35 36 |
# File 'lib/cane/rake_task.rb', line 34 def max_violations @max_violations end |
#name ⇒ Object
Returns the value of attribute name.
17 18 19 |
# File 'lib/cane/rake_task.rb', line 17 def name @name end |
#no_doc ⇒ Object
TRUE to disable doc checks
32 33 34 |
# File 'lib/cane/rake_task.rb', line 32 def no_doc @no_doc end |
#no_style ⇒ Object
TRUE to disable style checks
26 27 28 |
# File 'lib/cane/rake_task.rb', line 26 def no_style @no_style end |
#style_glob ⇒ Object
Glob to run style checks over (default: “lib,spec/*/.rb”)
24 25 26 |
# File 'lib/cane/rake_task.rb', line 24 def style_glob @style_glob end |
#style_measure ⇒ Object
Max line length (default: 80)
28 29 30 |
# File 'lib/cane/rake_task.rb', line 28 def style_measure @style_measure 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.
38 39 40 |
# File 'lib/cane/rake_task.rb', line 38 def add_threshold(file, operator, value) @threshold << [operator, file, value] end |
#default_options ⇒ Object
74 75 76 |
# File 'lib/cane/rake_task.rb', line 74 def Cane::CLI::Spec::DEFAULTS end |
#options ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/cane/rake_task.rb', line 57 def [ :abc_glob, :abc_max, :doc_glob, :no_doc, :max_violations, :style_glob, :no_style, :style_measure ].inject(threshold: @threshold) do |opts, setting| value = self.send(setting) opts[setting] = value unless value.nil? opts end end |
#translated_options ⇒ Object
78 79 80 |
# File 'lib/cane/rake_task.rb', line 78 def Cane::CLI::Translator.new(, ).to_hash end |