Class: State
- Inherits:
-
Object
- Object
- State
- Defined in:
- lib/core.rb
Overview
State of the system It should hold all the information we need to build the system, packages, files, changes…etc. everything will run inside an instance of this class
Instance Method Summary collapse
- #apply(block) ⇒ Object
-
#on_configure(id = nil, &block) ⇒ Object
Same as #on_prepare but for configure step.
-
#on_finalize(id = nil, &block) ⇒ Object
Same as #on_prepare but for configure step.
-
#on_install(id = nil, &block) ⇒ Object
Same as #on_prepare but for install step.
-
#on_prepare(id = nil, &block) ⇒ Object
Run block on prepare step.
-
#run_steps ⇒ Object
Run all registered code blocks in the following order: Prepare, Install, Configure, Finalize.
Instance Method Details
#apply(block) ⇒ Object
5 6 7 |
# File 'lib/core.rb', line 5 def apply(block) instance_eval(&block) end |
#on_configure(id = nil, &block) ⇒ Object
Same as #on_prepare but for configure step
26 27 28 29 30 |
# File 'lib/core.rb', line 26 def on_configure(id = nil, &block) id ||= caller_locations(1, 1).first.to_s @configure_steps ||= {} @configure_steps[id] = block end |
#on_finalize(id = nil, &block) ⇒ Object
Same as #on_prepare but for configure step
33 34 35 36 37 |
# File 'lib/core.rb', line 33 def on_finalize(id = nil, &block) id ||= caller_locations(1, 1).first.to_s @finalize_steps ||= {} @finalize_steps[id] = block end |
#on_install(id = nil, &block) ⇒ Object
Same as #on_prepare but for install step
19 20 21 22 23 |
# File 'lib/core.rb', line 19 def on_install(id = nil, &block) id ||= caller_locations(1, 1).first.to_s @install_steps ||= {} @install_steps[id] = block end |
#on_prepare(id = nil, &block) ⇒ Object
Run block on prepare step. id identifies the block uniqueness in the steps. registering a block with same id multiple times replaces old block by new one. if id is nil the block location in source code is used as an id
12 13 14 15 16 |
# File 'lib/core.rb', line 12 def on_prepare(id = nil, &block) id ||= caller_locations(1, 1).first.to_s @prepare_steps ||= {} @prepare_steps[id] = block end |
#run_steps ⇒ Object
Run all registered code blocks in the following order: Prepare, Install, Configure, Finalize
40 41 42 43 44 45 |
# File 'lib/core.rb', line 40 def run_steps run_step("Prepare", @prepare_steps) run_step("Install", @install_steps) run_step("Configure", @configure_steps) run_step("Finalize", @finalize_steps) end |