Class: Runbook::Runner
- Inherits:
-
Object
- Object
- Runbook::Runner
- Defined in:
- lib/runbook/errors.rb,
lib/runbook/runner.rb
Constant Summary collapse
- ExecutionError =
Class.new(Runbook::StandardError)
Instance Attribute Summary collapse
-
#book ⇒ Object
readonly
Returns the value of attribute book.
Instance Method Summary collapse
- #_resume_previous_pose?(metadata, pose) ⇒ Boolean
- #_stored_position(metadata) ⇒ Object
- #additional_metadata ⇒ Object
-
#initialize(book) ⇒ Runner
constructor
A new instance of Runner.
- #run(run: :ssh_kit, noop: false, auto: false, paranoid: true, start_at: "0") ⇒ Object
Constructor Details
#initialize(book) ⇒ Runner
Returns a new instance of Runner.
5 6 7 |
# File 'lib/runbook/runner.rb', line 5 def initialize(book) @book = book end |
Instance Attribute Details
#book ⇒ Object (readonly)
Returns the value of attribute book.
3 4 5 |
# File 'lib/runbook/runner.rb', line 3 def book @book end |
Instance Method Details
#_resume_previous_pose?(metadata, pose) ⇒ Boolean
56 57 58 59 60 61 62 |
# File 'lib/runbook/runner.rb', line 56 def _resume_previous_pose?(, pose) return false if [:auto] || [:noop] pose_msg = "Previous position detected: #{pose}" [:toolbox].output(pose_msg) resume_msg = "Do you want to resume at this position?" [:toolbox].yes?(resume_msg) end |
#_stored_position(metadata) ⇒ Object
52 53 54 |
# File 'lib/runbook/runner.rb', line 52 def _stored_position() Runbook::Util::StoredPose.load() end |
#additional_metadata ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/runbook/runner.rb', line 43 def { layout_panes: {}, repo: {}, reverse: Util::Glue.new(false), reversed: Util::Glue.new(false), } end |
#run(run: :ssh_kit, noop: false, auto: false, paranoid: true, start_at: "0") ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/runbook/runner.rb', line 9 def run( run: :ssh_kit, noop: false, auto: false, paranoid: true, start_at: "0" ) run = "Runbook::Runs::#{run.to_s.camelize}".constantize toolbox = Runbook::Toolbox.new = Util::StickyHash.new.merge({ noop: noop, auto: auto, paranoid: Util::Glue.new(paranoid), start_at: Util::Glue.new(start_at || "0"), toolbox: Util::Glue.new(toolbox), book_title: book.title, }). merge(Runbook::Entities::Book.). merge() stored_pose = _stored_position() if [:start_at] == "0" && stored_pose if _resume_previous_pose?(, stored_pose) [:start_at] = stored_pose end end if [:start_at] != "0" Util::Repo.load() end book.run(run, ) end |