Top Level Namespace

Defined Under Namespace

Modules: Must, NotDefined, RubyExt Classes: AssertionError, Class, Factory, GemHelper, Module, NilClass, OpenObject, String, Time, TrueClass, Tuple, UserError

Instance Method Summary collapse

Instance Method Details

#after(task_name, &block) ⇒ Object



61
62
63
# File 'lib/rake_ext.rb', line 61

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

#before(task_name, &block) ⇒ Object

before, after and remove task



50
51
52
53
54
55
56
57
58
59
# File 'lib/rake_ext.rb', line 50

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

#factory(*args) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/rspec_ext.rb', line 11

def factory *args
  if args.empty?
    $factory ||= Factory.new
  else
    factory.auto *args
  end
end

#project(options = nil) ⇒ Object



82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/rake_ext.rb', line 82

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

#project_dirObject



78
79
80
# File 'lib/rake_ext.rb', line 78

def project_dir
  $_project_dir
end

#remove_task(task_name) ⇒ Object Also known as: delete_task



65
66
67
# File 'lib/rake_ext.rb', line 65

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

#rspec(&block) ⇒ Object

Shortcut for extending RSpec.



8
9
10
11
# File 'lib/rspec_ext/rspec.rb', line 8

def rspec &block
  RSpec::Core::ExampleGroup.class_eval &block if block
  return RSpec::Core::ExampleGroup
end