Class: RubyCritic::RakeTask

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/rubycritic/rake_task.rb

Overview

A rake task that runs RubyCritic on a set of source files.

This will create a task that can be run with:

rake rubycritic

Example:

require 'rubycritic/rake_task'

RubyCritic::RakeTask.new do |task|
  task.paths = FileList['lib/**/*.rb', 'spec/**/*.rb']
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = :rubycritic, description = 'Run RubyCritic') {|_self| ... } ⇒ RakeTask

Returns a new instance of RakeTask.

Yields:

  • (_self)

Yield Parameters:



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/rubycritic/rake_task.rb', line 43

def initialize(name = :rubycritic, description = 'Run RubyCritic')
  @name           = name
  @description    = description
  @paths          = FileList['.']
  @options        = ''
  @verbose        = false
  @fail_on_error  = true

  yield self if block_given?
  define_task
end

Instance Attribute Details

#fail_on_error=(value) ⇒ Object

Whether or not to fail Rake task when RubyCritic does not pass. Defaults to true.



41
42
43
# File 'lib/rubycritic/rake_task.rb', line 41

def fail_on_error=(value)
  @fail_on_error = value
end

#name=(value) ⇒ Object

Name of RubyCritic task. Defaults to :rubycritic.



26
27
28
# File 'lib/rubycritic/rake_task.rb', line 26

def name=(value)
  @name = value
end

#options=(value) ⇒ Object

You can pass all the options here in that are shown by “rubycritic -h” except for “-p / –path” since that is set separately. Defaults to ”.



37
38
39
# File 'lib/rubycritic/rake_task.rb', line 37

def options=(value)
  @options = value
end

#paths=(value) ⇒ Object

Glob pattern to match source files. Defaults to FileList.



29
30
31
# File 'lib/rubycritic/rake_task.rb', line 29

def paths=(value)
  @paths = value
end

#verbose=(value) ⇒ Object

Use verbose output. If this is set to true, the task will print the rubycritic command to stdout. Defaults to false.



33
34
35
# File 'lib/rubycritic/rake_task.rb', line 33

def verbose=(value)
  @verbose = value
end