Class: Quality::Rake::Task
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- Quality::Rake::Task
- Defined in:
- lib/quality/rake/task.rb
Overview
A Rake task that run quality tools on a set of source files, and enforce a ratcheting quality level.
Example:
require 'quality/rake/task'
Quality::Rake::Task.new do |t|
end
This will create a task that can be run with:
rake quality
Instance Attribute Summary collapse
-
#globber ⇒ Object
readonly
Returns the value of attribute globber.
-
#output_dir ⇒ Object
Relative path to output directory where *_high_water_mark files will be read/written.
-
#quality_name ⇒ Object
Name of quality task.
-
#ratchet_name ⇒ Object
Name of ratchet task.
- #ruby_dirs ⇒ Object
-
#skip_tools ⇒ Object
Array of strings describing tools to be skipped–e.g., [“cane”].
- #source_dirs ⇒ Object
-
#verbose ⇒ Object
Log command executation.
Instance Method Summary collapse
-
#initialize(dsl: ::Rake::Task, cmd_runner: Kernel, count_file: File, count_io: IO, globber: Dir, gem_spec: Gem::Specification, configuration_writer: File, quality_checker_class: Quality::QualityChecker, quality_name: 'quality', ratchet_name: 'ratchet') {|_self| ... } ⇒ Task
constructor
Defines a new task, using the name
name. - #ruby_files ⇒ Object
- #ruby_files_glob ⇒ Object
- #source_files_glob(extensions = 'rb,swift,cpp,c,java,py') ⇒ Object
Constructor Details
#initialize(dsl: ::Rake::Task, cmd_runner: Kernel, count_file: File, count_io: IO, globber: Dir, gem_spec: Gem::Specification, configuration_writer: File, quality_checker_class: Quality::QualityChecker, quality_name: 'quality', ratchet_name: 'ratchet') {|_self| ... } ⇒ Task
Defines a new task, using the name name.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/quality/rake/task.rb', line 65 def initialize(dsl: ::Rake::Task, cmd_runner: Kernel, count_file: File, count_io: IO, globber: Dir, gem_spec: Gem::Specification, configuration_writer: File, quality_checker_class: Quality::QualityChecker, quality_name: 'quality', ratchet_name: 'ratchet') @dsl, @cmd_runner = dsl, cmd_runner @globber = globber @quality_name, @ratchet_name = quality_name, ratchet_name @skip_tools = [] @verbose = false @output_dir = 'metrics' yield self if block_given? @runner = Quality::Runner.new(self, gem_spec: gem_spec, quality_checker_class: quality_checker_class, count_io: count_io, count_file: count_file, configuration_writer: configuration_writer) define end |
Instance Attribute Details
#globber ⇒ Object (readonly)
Returns the value of attribute globber.
99 100 101 |
# File 'lib/quality/rake/task.rb', line 99 def globber @globber end |
#output_dir ⇒ Object
Relative path to output directory where *_high_water_mark files will be read/written
Defaults to .
62 63 64 |
# File 'lib/quality/rake/task.rb', line 62 def output_dir @output_dir end |
#quality_name ⇒ Object
Name of quality task. Defaults to :quality.
30 31 32 |
# File 'lib/quality/rake/task.rb', line 30 def quality_name @quality_name end |
#ratchet_name ⇒ Object
Name of ratchet task. Defaults to :ratchet.
34 35 36 |
# File 'lib/quality/rake/task.rb', line 34 def ratchet_name @ratchet_name end |
#ruby_dirs ⇒ Object
101 102 103 |
# File 'lib/quality/rake/task.rb', line 101 def ruby_dirs @ruby_dirs ||= %w(app lib test spec feature) end |
#skip_tools ⇒ Object
Array of strings describing tools to be skipped–e.g., [“cane”]
Defaults to []
39 40 41 |
# File 'lib/quality/rake/task.rb', line 39 def skip_tools @skip_tools end |
#source_dirs ⇒ Object
105 106 107 |
# File 'lib/quality/rake/task.rb', line 105 def source_dirs @source_dirs ||= ruby_dirs.clone end |
#verbose ⇒ Object
Log command executation
Defaults to false
44 45 46 |
# File 'lib/quality/rake/task.rb', line 44 def verbose @verbose end |
Instance Method Details
#ruby_files ⇒ Object
118 119 120 121 |
# File 'lib/quality/rake/task.rb', line 118 def ruby_files @globber.glob('{*.rb,Rakefile}') .concat(@globber.glob(ruby_files_glob)).join(' ') end |
#ruby_files_glob ⇒ Object
114 115 116 |
# File 'lib/quality/rake/task.rb', line 114 def ruby_files_glob source_files_glob('rb') end |
#source_files_glob(extensions = 'rb,swift,cpp,c,java,py') ⇒ Object
109 110 111 112 |
# File 'lib/quality/rake/task.rb', line 109 def source_files_glob(extensions = 'rb,swift,cpp,c,java,py') File.join("{#{source_dirs.join(',')}}", '**', "*.{#{extensions}}") end |