lib/quality/rake/task.rb in quality-1.2.0 vs lib/quality/rake/task.rb in quality-1.3.0
- old
+ new
@@ -4,16 +4,14 @@
require 'rake/tasklib'
require 'rbconfig'
require_relative '../quality_checker'
module Quality
-
#
# Defines a task library for running quality's various tools
#
module Rake
-
# A Rake task that run quality tools on a set of source files, and
# enforce a ratcheting quality level.
#
# Example:
#
@@ -24,11 +22,10 @@
#
# This will create a task that can be run with:
#
# rake quality
class Task < ::Rake::TaskLib
-
# Name of quality task.
# Defaults to :quality.
attr_accessor :quality_name
# Name of ratchet task.
@@ -40,11 +37,11 @@
# Defaults to []
attr_accessor :skip_tools
# Array of directory names which contain ruby files to analyze.
#
- # Defaults to %w{lib test spec feature}, which translates to *.rb in
+ # Defaults to %w(lib test spec feature), which translates to *.rb in
# the base directory, as well as lib, test, and feature.
attr_writer :ruby_dirs
# Relative path to output directory where *_high_water_mark
# files will be read/written
@@ -95,18 +92,24 @@
end
private
def define # :nodoc:
- desc 'Verify quality has increased or stayed ' +
+ desc 'Verify quality has increased or stayed ' \
'the same' unless ::Rake.application.last_comment
@dsl.define_task(quality_name) { run_quality }
@dsl.define_task(ratchet_name) { run_ratchet }
+ tools.each do |tool|
+ @dsl.define_task(tool) { run_quality_with_tool(tool) }
+ end
end
+ def tools
+ %w(cane flog flay reek rubocop)
+ end
+
def run_quality
- tools = ['cane', 'flog', 'flay', 'reek', 'rubocop']
tools.each do |tool|
run_quality_with_tool(tool)
end
end
@@ -179,10 +182,10 @@
end
end
end
def ruby_dirs
- @ruby_dirs ||= %w{lib test spec feature}
+ @ruby_dirs ||= %w(lib test spec feature)
end
def ruby_files
@globber.glob('*.rb')
.concat(@globber.glob(File.join("{#{ruby_dirs.join(',')}}",