Class: Quality::Rake::Task

Inherits:
Rake::TaskLib
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) {|_self| ... } ⇒ Task

Defines a new task, using the name name.

Yields:

  • (_self)

Yield Parameters:



56
57
58
59
60
61
62
63
64
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
# File 'lib/quality/rake/task.rb', line 56

def initialize(args = {})
  @quality_name = args[:quality_name] || 'quality'

  @ratchet_name = args[:ratchet_name] || 'ratchet'

  # allow unit tests to override the class that Rake DSL
  # messages are sent to.
  @dsl = args[:dsl] || ::Rake::Task

  # likewise, but for system()
  @cmd_runner = args[:cmd_runner] || Kernel

  # likewise, but for File.open() on the count files
  @count_file = args[:count_file] || File

  # likewise, but for IO.read()/IO.exist? on the count files
  @count_io = args[:count_io] || IO

  # likewise, but for Dir.glob() on target Ruby files
  @globber = args[:globber] || Dir

  # likewise, but for checking whether a gem is installed
  @gem_spec = args[:gem_spec] || Gem::Specification

  # uses exist?() and open() to write out configuration files
  # for tools if needed (e.g., .cane file)
  @configuration_writer = args[:configuration_writer] || File

  # Class which actually runs the quality check commands
  @quality_checker_class =
    args[:quality_checker_class] || Quality::QualityChecker

  @skip_tools = []

  @output_dir = '.'

  yield self if block_given?

  define
end

Instance Attribute Details

#output_dir=(value) ⇒ Object (writeonly)

Relative path to output directory where *_high_water_mark files will be read/written

Defaults to .



53
54
55
# File 'lib/quality/rake/task.rb', line 53

def output_dir=(value)
  @output_dir = value
end

#quality_nameObject

Name of quality task. Defaults to :quality.



32
33
34
# File 'lib/quality/rake/task.rb', line 32

def quality_name
  @quality_name
end

#ratchet_nameObject

Name of ratchet task. Defaults to :ratchet.



36
37
38
# File 'lib/quality/rake/task.rb', line 36

def ratchet_name
  @ratchet_name
end

#ruby_dirs=(value) ⇒ Object

Array of directory names which contain ruby files to analyze.

Defaults to %wtest spec feature, which translates to *.rb in the base directory, as well as lib, test, and feature.



47
48
49
# File 'lib/quality/rake/task.rb', line 47

def ruby_dirs=(value)
  @ruby_dirs = value
end

#skip_toolsObject

Array of strings describing tools to be skipped–e.g., [“cane”]

Defaults to []



41
42
43
# File 'lib/quality/rake/task.rb', line 41

def skip_tools
  @skip_tools
end