Class: Mikoshi::Plan::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/mikoshi/plan.rb

Direct Known Subclasses

Service, TaskDefinition

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(yaml_path: nil, client: nil) ⇒ Base

Returns a new instance of Base.

Raises:

  • (ArgumentError)


14
15
16
17
18
19
20
# File 'lib/mikoshi/plan.rb', line 14

def initialize(yaml_path: nil, client: nil)
  raise ArgumentError, 'Yaml file path is required.' if yaml_path.nil?
  raise ArgumentError, 'client is required.' if client.nil?

  @data = YAML.safe_load(ERB.new(File.new(yaml_path).read).result).deep_symbolize_keys
  @client = client
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



12
13
14
# File 'lib/mikoshi/plan.rb', line 12

def client
  @client
end

#dataObject (readonly)

Returns the value of attribute data.



12
13
14
# File 'lib/mikoshi/plan.rb', line 12

def data
  @data
end

Instance Method Details

#invoke_hooks(hooks) ⇒ Object



22
23
24
25
26
# File 'lib/mikoshi/plan.rb', line 22

def invoke_hooks(hooks)
  hooks.each do |hook|
    raise(HookExecutionError, hook) unless system(hook)
  end
end