Class: RoodiTask

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = :roodi, patterns = nil, config = nil) {|_self| ... } ⇒ RoodiTask

Returns a new instance of RoodiTask.

Yields:

  • (_self)

Yield Parameters:

  • _self (RoodiTask)

    the object that the method was called on



7
8
9
10
11
12
13
14
15
16
# File 'lib/roodi_task.rb', line 7

def initialize name = :roodi, patterns = nil, config = nil
  @name      = name
  @patterns  = patterns || %w(app/**/*.rb lib/**/*.rb spec/**/*.rb test/**/*.rb)
  @config    = config
  @verbose   = Rake.application.options.trace

  yield self if block_given?

  define
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



4
5
6
# File 'lib/roodi_task.rb', line 4

def config
  @config
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/roodi_task.rb', line 2

def name
  @name
end

#patternsObject

Returns the value of attribute patterns.



3
4
5
# File 'lib/roodi_task.rb', line 3

def patterns
  @patterns
end

#verboseObject

Returns the value of attribute verbose.



5
6
7
# File 'lib/roodi_task.rb', line 5

def verbose
  @verbose
end

Instance Method Details

#defineObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/roodi_task.rb', line 18

def define
  desc "Check for design issues in: #{patterns.join(', ')}"
  task name do
    runner = Roodi::Core::Runner.new

    runner.config = config if config

    patterns.each do |pattern|
      Dir.glob(pattern).each { |file| runner.check_file(file) }
    end

    runner.errors.each {|error| puts error}

    raise "Found #{runner.errors.size} errors." unless runner.errors.empty?
  end
  self
end