Class: Spud::TaskRunners::SpudTaskRunner::TaskDSL

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/spud/task_runners/spud_task_runner/task_dsl.rb

Instance Method Summary collapse

Constructor Details

#initialize(driver, filename) ⇒ TaskDSL

Returns a new instance of TaskDSL.



15
16
17
18
# File 'lib/spud/task_runners/spud_task_runner/task_dsl.rb', line 15

def initialize(driver, filename)
  @__filename = filename
  @__driver = driver
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(symbol, *ordered, **named) ⇒ Object



74
75
76
77
78
# File 'lib/spud/task_runners/spud_task_runner/task_dsl.rb', line 74

def method_missing(symbol, *ordered, **named)
  task = symbol.to_s
  task = task.include?('.') ? task : Task.qualified_name(@__filename, task)
  @__driver.invoke(task, ordered, named)
end

Instance Method Details

#invoke(task, *ordered, **named) ⇒ Object



59
60
61
62
63
64
65
# File 'lib/spud/task_runners/spud_task_runner/task_dsl.rb', line 59

def invoke(task, *ordered, **named)
  task = task.to_s
  task = task.include?('.') ? task : Task.qualified_name(@__filename, task)
  @__driver.invoke(task, ordered, named)
rescue Error => error
  puts error.message
end

#invoke!(task, *ordered, **named) ⇒ Object



68
69
70
71
72
# File 'lib/spud/task_runners/spud_task_runner/task_dsl.rb', line 68

def invoke!(task, *ordered, **named)
  task = task.to_s
  task = task.include?('.') ? task : Task.qualified_name(@__filename, task)
  @__driver.invoke(task, ordered, named)
end

#sh(command) ⇒ Object



21
22
23
24
# File 'lib/spud/task_runners/spud_task_runner/task_dsl.rb', line 21

def sh(command)
  puts command
  Shell::Command.(@__driver, command)
end

#sh!(command) ⇒ Object

Raises:



37
38
39
40
41
42
# File 'lib/spud/task_runners/spud_task_runner/task_dsl.rb', line 37

def sh!(command)
  puts command
  result = Shell::Command.(@__driver, command)
  raise Error, "sh failed for '#{command}'" unless result.success?
  result
end

#shh(command) ⇒ Object



27
28
29
# File 'lib/spud/task_runners/spud_task_runner/task_dsl.rb', line 27

def shh(command)
  Shell::Command.(@__driver, command)
end

#shh!(command) ⇒ Object

Raises:



45
46
47
48
49
# File 'lib/spud/task_runners/spud_task_runner/task_dsl.rb', line 45

def shh!(command)
  result = Shell::Command.(@__driver, command)
  raise Error, "sh failed for '#{command}'" unless result.success?
  result
end

#shhh(command) ⇒ Object



32
33
34
# File 'lib/spud/task_runners/spud_task_runner/task_dsl.rb', line 32

def shhh(command)
  Shell::Command.(@__driver, command, silent: true)
end

#shhh!(command) ⇒ Object

Raises:



52
53
54
55
56
# File 'lib/spud/task_runners/spud_task_runner/task_dsl.rb', line 52

def shhh!(command)
  result = Shell::Command.(@__driver, command, silent: true)
  raise Error, "sh failed for '#{command}'" unless result.success?
  result
end