Class: Larrow::Runner::Manifest::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/larrow/runner/manifest/configuration.rb

Overview

The top of manifest model which store Steps information

Constant Summary collapse

DEFINED_GROUPS =
{
  all:[
    :init,
    :source_sync, #inner step
    :prepare, 
    :compile, :unit_test,
    :before_install, #inner_step
    :install, :functional_test, 
    :before_start, #inner_step
    :start, :integration_test,
    :after_start, :complete #inner_step
  ],
  custom: [
    :init,
    :prepare, 
    :compile, :unit_test,
    :install, :functional_test, 
    :start, :integration_test,
  ],
  deploy: [
    :init,:source_sync,:prepare, 
    :compile,:before_install,:install,
    :before_start,:start,:after_start,
    :complete
  ],
  image: [:init]
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



34
35
36
37
# File 'lib/larrow/runner/manifest/configuration.rb', line 34

def initialize
  self.steps = {}
  self.source_dir = '$HOME/source'
end

Instance Attribute Details

#imageObject

Returns the value of attribute image.



33
34
35
# File 'lib/larrow/runner/manifest/configuration.rb', line 33

def image
  @image
end

#source_dirObject

Returns the value of attribute source_dir.



33
34
35
# File 'lib/larrow/runner/manifest/configuration.rb', line 33

def source_dir
  @source_dir
end

#stepsObject

Returns the value of attribute steps.



33
34
35
# File 'lib/larrow/runner/manifest/configuration.rb', line 33

def steps
  @steps
end

Instance Method Details

#add_source_sync(source_accessor) ⇒ Object



51
52
53
54
55
# File 'lib/larrow/runner/manifest/configuration.rb', line 51

def add_source_sync source_accessor
  steps[:source_sync] = FunctionStep.new(:source_sync) do |node|
    source_accessor.update_source node,source_dir
  end
end

#dumpObject



66
67
68
69
70
71
72
73
# File 'lib/larrow/runner/manifest/configuration.rb', line 66

def dump
  data = DEFINED_GROUPS[:all].reduce({}) do |sum,title|
    next sum if steps[title].nil?
    scripts_data = steps[title].scripts.map(&:dump).compact
    sum.update title.to_s => scripts_data
  end
  YAML.dump data
end

#insert_to_step(title, *scripts) ⇒ Object



45
46
47
48
49
# File 'lib/larrow/runner/manifest/configuration.rb', line 45

def insert_to_step title, *scripts
  steps[title] ||= CmdStep.new(nil, title)
  steps[title].scripts.unshift *scripts.flatten
  self
end

#put_to_step(title, *scripts) ⇒ Object



39
40
41
42
43
# File 'lib/larrow/runner/manifest/configuration.rb', line 39

def put_to_step title, *scripts
  steps[title] ||= CmdStep.new(nil, title)
  steps[title].scripts += scripts.flatten
  self
end

#steps_for(type) ⇒ Object



57
58
59
60
61
62
63
64
# File 'lib/larrow/runner/manifest/configuration.rb', line 57

def steps_for type
  groups = DEFINED_GROUPS[type]
  # ignore init when image id is specified
  groups = groups - [:init] if image
  groups.each do |title|
    yield steps[title] if steps[title]
  end
end