Class: Jisota::PackageScript

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

Overview

Part of the Script duck type

Executes an entire package, which in turn might execute other packages. The args are parsed with the ParamParser to match args with params.

If the package has a verify_block, that will be executed first. If the result of verify is success, the run_block will not be executed.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(package, args = []) ⇒ PackageScript

Returns a new instance of PackageScript.



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

def initialize(package, args = [])
  @package = package
  @args = args
end

Instance Attribute Details

#argsObject

Returns the value of attribute args.



11
12
13
# File 'lib/jisota/package_script.rb', line 11

def args
  @args
end

#packageObject

Returns the value of attribute package.



11
12
13
# File 'lib/jisota/package_script.rb', line 11

def package
  @package
end

Instance Method Details

#execute(context) ⇒ Object



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

def execute(context)
  context.param_scope(parse_params) do
    context.logger.system_message("Package #{self}") do
      execute_package(context)
    end
  end
end

#to_sObject



26
27
28
29
30
31
32
33
34
# File 'lib/jisota/package_script.rb', line 26

def to_s
  result = ""
  result << package.name.to_s
  if args.any?
    result << " "
    result << args.map(&:inspect).join(", ")
  end
  result
end