Class: Jisota::ScriptBlock

Inherits:
Object
  • Object
show all
Defined in:
lib/jisota/script_block.rb

Overview

DSL for creating a CompositeScript

Methods in the DSL:

cmd

Add a CommandScript

upload

Add a FileScript

<arg name>

The value of the argument

<package name>

Add a PackageScript

Defined Under Namespace

Classes: DSL

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}, &block) ⇒ ScriptBlock

Returns a new instance of ScriptBlock.



14
15
16
# File 'lib/jisota/script_block.rb', line 14

def initialize(options = {}, &block)
  @block = block
end

Instance Attribute Details

#blockObject

Returns the value of attribute block.



12
13
14
# File 'lib/jisota/script_block.rb', line 12

def block
  @block
end

Instance Method Details

#evaluate(context = ScriptContext.new) ⇒ Object



18
19
20
21
22
23
# File 'lib/jisota/script_block.rb', line 18

def evaluate(context = ScriptContext.new)
  CompositeScript.new.tap do |script|
    dsl = DSL.new(script, context)
    dsl.evaluate(&block)
  end
end