Sha256: d427e2a27d7aab8110bb9409fde70c571326ad6ec0e9d4144ea5936ecfe994af

Contents?: true

Size: 1.85 KB

Versions: 11

Compression:

Stored size: 1.85 KB

Contents

require 'rake'
require 'fileutils'

# 
# Code Coverage
# 
begin
  require 'class_loader/tasks'
rescue LoadError
end
desc "Clean temporary files"
task clean: 'class_loader:clean' do
  require 'fileutils'
  FileUtils.rm_r '../*/coverage' if File.exist? '../*/coverage'
end


# 
# Spec
# 
begin
  require 'rspec/core/rake_task'
  task default: :spec

  RSpec::Core::RakeTask.new('spec') do |t|
    t.pattern = "spec/**/[^_]*_spec.rb"
  end
  
  namespace :spec do    
    desc "Run RSpec code exapmples in isolated mode (every spec file in another Ruby process)"
    task :isolated do
      Dir.glob("spec/[^_]**/[^_]*_spec.rb").each do |spec_file|
        Kernel.system "rspec #{spec_file}"
      end
    end
  end
rescue LoadError
  task :default do
    puts "default rake task is :rspec but there's no rspec gem installed, install it first"
  end
end

# 
# project_dir
# 
$_project_dir = (
  caller.find{|line| line =~ /\/Rakefile\:/} || 
  raise("You can include the 'rake_ext' only in Rakefile!")
).sub(/\/Rakefile\:.*/, '')
def project_dir
  $_project_dir
end


# 
# before, after and remove task
# 
def before task_name, &block
  $_task_counter ||= {}
  counter = ($_task_counter[task_name] ||= 0)
  before_task_name = "#{task_name}_before_#{counter}"
  
  task before_task_name, &block
  task task_name => before_task_name
  
  $_task_counter[task_name] += 1
end

def after task_name, &block
  task task_name, &block
end

def remove_task(task_name)
  Rake.application.instance_variable_get('@tasks').delete(task_name.to_s)
end
alias :delete_task :remove_task


# 
# project
# 
def project options = nil  
  if options
    $_project = {}
    options.each{|k, v| $_project[k.to_sym] = v}
    
    $_project[:name] || raise("project name not defined")
    $_project[:official_name] ||= $_project[:name]
    
    require 'rake_ext/project'
  end
  $_project || raise("project not defined!")
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
ruby_ext-0.4.24 lib/rake_ext.rb
ruby_ext-0.4.23 lib/rake_ext.rb
ruby_ext-0.4.22 lib/rake_ext.rb
ruby_ext-0.4.21 lib/rake_ext.rb
ruby_ext-0.4.20 lib/rake_ext.rb
ruby_ext-0.4.19 lib/rake_ext.rb
ruby_ext-0.4.18 lib/rake_ext.rb
ruby_ext-0.4.17 lib/rake_ext.rb
ruby_ext-0.4.16 lib/rake_ext.rb
ruby_ext-0.4.15 lib/rake_ext.rb
ruby_ext-0.4.14 lib/rake_ext.rb