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:



15
16
17
18
# File 'lib/taza/tasks.rb', line 15

def initialize
  yield self if block_given?
  define
end

Instance Attribute Details

#spec_optsObject

Returns the value of attribute spec_opts.



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

def spec_opts
  @spec_opts
end

Instance Method Details

#defineObject



27
28
29
30
31
32
33
# File 'lib/taza/tasks.rb', line 27

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



20
21
22
23
24
25
# File 'lib/taza/tasks.rb', line 20

def define_spec_task(name,glob_path)
  Spec::Rake::SpecTask.new name do |t|
    t.spec_files = Dir.taglob(glob_path,tags)
    t.spec_opts << spec_opts
  end
end

#recurse_to_create_rake_tasks(dir) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/taza/tasks.rb', line 35

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