Class: Taza::Rake::Tasks

Inherits:
Object show all
Defined in:
lib/taza/tasks.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Tasks

Returns a new instance of Tasks

Yields:

  • (_self)

Yield Parameters:



11
12
13
14
# File 'lib/taza/tasks.rb', line 11

def initialize
  yield self if block_given?
  define
end

Instance Attribute Details

#spec_optsObject

Returns the value of attribute spec_opts



9
10
11
# File 'lib/taza/tasks.rb', line 9

def spec_opts
  @spec_opts
end

Instance Method Details

#defineObject



23
24
25
26
27
28
29
# File 'lib/taza/tasks.rb', line 23

def define
  namespace :spec do
    Dir.glob('./spec/*/').each do |dir|
      recurse_to_create_rake_tasks(dir)
    end
  end
end

#define_spec_task(name, glob_path) ⇒ Object



16
17
18
19
20
21
# File 'lib/taza/tasks.rb', line 16

def define_spec_task(name,glob_path)
  RSpec::Core::RakeTask.new name do |t|
    t.pattern = Dir.glob(glob_path)
    t.rspec_opts = spec_opts
  end
end

#recurse_to_create_rake_tasks(dir) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/taza/tasks.rb', line 31

def recurse_to_create_rake_tasks(dir)
  basename = File.basename(dir)
  spec_pattern = File.join(dir,"**","*_spec.rb")
  if (not Dir.glob(spec_pattern).empty?)
    define_spec_task(basename,spec_pattern)
    namespace basename do
      Dir.glob(File.join(dir,"*_spec.rb")).each do |spec_file|
        spec_name = File.basename(spec_file,'_spec.rb')
        define_spec_task(spec_name,spec_file)
      end
      Dir.glob(File.join(dir,"*/")).each do |sub_dir|
        recurse_to_create_rake_tasks(sub_dir)
      end
    end
  end
end