Sha256: 4cd217f58a88a2c8a819e8b07678af096262cb887ff2541284cd6475bd21c0de

Contents?: true

Size: 1.25 KB

Versions: 7

Compression:

Stored size: 1.25 KB

Contents

require 'rubygems'
require 'rake'
require 'taglob'
require 'spec/rake/spectask'

def tags
  ENV['TAGS']
end

module Taza
  module Rake
    class Tasks
      attr_accessor :spec_opts

      def initialize
        yield self if block_given?
        define
      end

      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

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

      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

    end
  end
end

Version data entries

7 entries across 7 versions & 3 rubygems

Version Path
makevoid-taza-0.8.6 lib/taza/tasks.rb
scudco-taza-0.8.5 lib/taza/tasks.rb
scudco-taza-0.8.6 lib/taza/tasks.rb
scudco-taza-0.8.7 lib/taza/tasks.rb
taza-0.8.5 lib/taza/tasks.rb
taza-0.8.7 lib/taza/tasks.rb
taza-0.8.6 lib/taza/tasks.rb