Class: DDSL::Command::Base

Inherits:
Object
  • Object
show all
Includes:
DSL
Defined in:
lib/ddsl/command/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DSL

included

Constructor Details

#initialize(shell = DDSL::Shell.new) ⇒ Base

Returns a new instance of Base.



12
13
14
# File 'lib/ddsl/command/base.rb', line 12

def initialize(shell = DDSL::Shell.new)
  @shell = shell
end

Instance Attribute Details

#shellObject (readonly)

Returns the value of attribute shell.



10
11
12
# File 'lib/ddsl/command/base.rb', line 10

def shell
  @shell
end

Instance Method Details

#exec_after_block(spec) ⇒ Object



36
37
38
# File 'lib/ddsl/command/base.rb', line 36

def exec_after_block(spec)
  instance_exec(spec, &after_block) unless after_block.nil?
end

#exec_before_block(spec) ⇒ Object



32
33
34
# File 'lib/ddsl/command/base.rb', line 32

def exec_before_block(spec)
  instance_exec(spec, &before_block) unless before_block.nil?
end

#run(spec) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/ddsl/command/base.rb', line 16

def run(spec)
  exec_before_block(spec)

  argv = [
    executable,
    executable_options.call(spec),
    command,
    options.call(spec),
    arguments.call(spec).values
  ].flatten

  @shell.call!(argv)

  exec_after_block(spec)
end