Class: Runbook::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/runbook/errors.rb,
lib/runbook/runner.rb

Constant Summary collapse

ExecutionError =
Class.new(Runbook::StandardError)

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#bookObject (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

Returns:

  • (Boolean)


58
59
60
61
62
63
64
# File 'lib/runbook/runner.rb', line 58

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



54
55
56
# File 'lib/runbook/runner.rb', line 54

def _stored_position()
  Runbook::Util::StoredPose.load()
end

#additional_metadataObject



45
46
47
48
49
50
51
52
# File 'lib/runbook/runner.rb', line 45

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, keep_panes: false, 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
42
43
# File 'lib/runbook/runner.rb', line 9

def run(
  run: :ssh_kit,
  noop: false,
  auto: false,
  paranoid: true,
  keep_panes: false,
  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),
    keep_panes: keep_panes,
    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