Class: Crew::Task::DSL

Inherits:
Object
  • Object
show all
Includes:
Arguments::DSL
Defined in:
lib/crew/task/dsl.rb

Instance Attribute Summary

Attributes included from Arguments::DSL

#_arguments

Instance Method Summary collapse

Methods included from Arguments::DSL

#arg, #args, load, #opt

Constructor Details

#initialize(task, &blk) ⇒ DSL

Returns a new instance of DSL.



6
7
8
9
10
# File 'lib/crew/task/dsl.rb', line 6

def initialize(task, &blk)
  @task = task
  self._arguments = @task.arguments
  instance_eval(&blk) if blk
end

Instance Method Details

#block(opts = {}, &blk) ⇒ Object



42
43
44
# File 'lib/crew/task/dsl.rb', line 42

def block(opts = {}, &blk)
  @task.arguments.define_block(opts, &blk)
end

#desc(val) ⇒ Object



18
19
20
# File 'lib/crew/task/dsl.rb', line 18

def desc(val)
  @task.desc = val
end

#hints(*hints) ⇒ Object



22
23
24
# File 'lib/crew/task/dsl.rb', line 22

def hints(*hints)
  @task.default_hints = hints
end

#load(path) ⇒ Object



12
13
14
15
16
# File 'lib/crew/task/dsl.rb', line 12

def load(path)
  contents = File.read(path)
  instance_eval(contents, path, 1)
  process_templates contents.split("__END__\n", 2)[1]
end

#run(*hints, &blk) ⇒ Object



30
31
32
# File 'lib/crew/task/dsl.rb', line 30

def run(*hints, &blk)
  add_to_task(:run, hints, blk)
end

#setup(*hints, &blk) ⇒ Object



26
27
28
# File 'lib/crew/task/dsl.rb', line 26

def setup(*hints, &blk)
  add_to_task(:setup, hints, blk)
end

#test(*hints, &blk) ⇒ Object



38
39
40
# File 'lib/crew/task/dsl.rb', line 38

def test(*hints, &blk)
  add_to_task(:test, hints, blk)
end

#verify(*hints, &blk) ⇒ Object



34
35
36
# File 'lib/crew/task/dsl.rb', line 34

def verify(*hints, &blk)
  add_to_task(:verify, hints, blk)
end