Module: Runbook::Views::Markdown

Extended by:
Helpers::FormatHelper, Helpers::SSHKitHelper
Includes:
Runbook::View
Defined in:
lib/runbook/views/markdown.rb

Class Method Summary collapse

Methods included from Helpers::FormatHelper

deindent

Methods included from Helpers::SSHKitHelper

_as_block, _coordinator_options, _servers, _with_block, _with_umask, _within_block, find_ssh_config, render_ssh_config_output, ssh_kit_command, ssh_kit_command_options, with_ssh_config

Methods included from Runbook::View

included

Class Method Details

.runbook__entities__book(object, output, metadata) ⇒ Object



7
8
9
# File 'lib/runbook/views/markdown.rb', line 7

def self.runbook__entities__book(object, output, )
  output << "# #{object.title}\n\n"
end

.runbook__entities__section(object, output, metadata) ⇒ Object



11
12
13
14
# File 'lib/runbook/views/markdown.rb', line 11

def self.runbook__entities__section(object, output, )
  heading = "#"*[:depth]
  output << "#{heading} #{[:index]+1}. #{object.title}\n\n"
end

.runbook__entities__setup(object, output, metadata) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/runbook/views/markdown.rb', line 16

def self.runbook__entities__setup(object, output, )
  output << "[] #{object.title}\n\n"

  ssh_config = find_ssh_config(object)
  ssh_config_output = render_ssh_config_output(ssh_config)
  output << "#{ssh_config_output}\n" unless ssh_config_output.empty?
end

.runbook__entities__step(object, output, metadata) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/runbook/views/markdown.rb', line 24

def self.runbook__entities__step(object, output, )
  output << "#{[:index]+1}. [] #{object.title}\n\n"

  ssh_config = find_ssh_config(object)
  ssh_config_output = render_ssh_config_output(ssh_config)
  output << "#{ssh_config_output}\n" unless ssh_config_output.empty?
end

.runbook__statements__ask(object, output, metadata) ⇒ Object



32
33
34
35
# File 'lib/runbook/views/markdown.rb', line 32

def self.runbook__statements__ask(object, output, )
  default_msg = object.default ?  " (default: #{object.default})" : ""
  output << "   #{object.prompt} into `#{object.into}`#{default_msg}\n\n"
end

.runbook__statements__assert(object, output, metadata) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/runbook/views/markdown.rb', line 37

def self.runbook__statements__assert(object, output, )
  output << "   run: `#{object.cmd}` every #{object.interval} seconds until it returns 0\n\n"
  if object.timeout > 0 || object.attempts > 0
    timeout_msg = object.timeout > 0 ? "#{object.timeout} second(s)" : nil
    attempts_msg = object.attempts > 0 ? "#{object.attempts} attempts" : nil
    abort_msg = "after #{[timeout_msg, attempts_msg].compact.join(" or ")}, abort..."
    output << "   #{abort_msg}\n\n"
    if object.abort_statement
      object.abort_statement.render(self, output, .dup)
    end
    output << "   and exit\n\n"
  end
end

.runbook__statements__capture(object, output, metadata) ⇒ Object



51
52
53
# File 'lib/runbook/views/markdown.rb', line 51

def self.runbook__statements__capture(object, output, )
  output << "   capture: `#{object.cmd}` into `#{object.into}`\n\n"
end

.runbook__statements__capture_all(object, output, metadata) ⇒ Object



55
56
57
# File 'lib/runbook/views/markdown.rb', line 55

def self.runbook__statements__capture_all(object, output, )
  output << "   capture_all: `#{object.cmd}` into `#{object.into}`\n\n"
end

.runbook__statements__command(object, output, metadata) ⇒ Object



59
60
61
# File 'lib/runbook/views/markdown.rb', line 59

def self.runbook__statements__command(object, output, )
  output << "   run: `#{object.cmd}`\n\n"
end

.runbook__statements__confirm(object, output, metadata) ⇒ Object



63
64
65
# File 'lib/runbook/views/markdown.rb', line 63

def self.runbook__statements__confirm(object, output, )
  output << "   confirm: #{object.prompt}\n\n"
end

.runbook__statements__description(object, output, metadata) ⇒ Object



67
68
69
# File 'lib/runbook/views/markdown.rb', line 67

def self.runbook__statements__description(object, output, )
  output << "#{object.msg}\n"
end

.runbook__statements__download(object, output, metadata) ⇒ Object



71
72
73
74
75
76
# File 'lib/runbook/views/markdown.rb', line 71

def self.runbook__statements__download(object, output, )
  options = object.options
  to = " to #{object.to}" if object.to
  opts = " with options #{options}" unless options == {}
  output << "   download: #{object.from}#{to}#{opts}\n\n"
end

.runbook__statements__layout(object, output, metadata) ⇒ Object



78
79
80
81
# File 'lib/runbook/views/markdown.rb', line 78

def self.runbook__statements__layout(object, output, )
  output << "layout:\n"
  output << "#{object.structure.inspect}\n\n"
end

.runbook__statements__note(object, output, metadata) ⇒ Object



83
84
85
# File 'lib/runbook/views/markdown.rb', line 83

def self.runbook__statements__note(object, output, )
  output << "   #{object.msg}\n\n"
end

.runbook__statements__notice(object, output, metadata) ⇒ Object



87
88
89
# File 'lib/runbook/views/markdown.rb', line 87

def self.runbook__statements__notice(object, output, )
  output << "   **#{object.msg}**\n\n"
end

.runbook__statements__ruby_command(object, output, metadata) ⇒ Object



91
92
93
94
95
96
97
98
99
100
# File 'lib/runbook/views/markdown.rb', line 91

def self.runbook__statements__ruby_command(object, output, )
  output << "   run:\n"
  output << "   ```ruby\n"
  begin
    output << "#{deindent(object.block.source, padding: 3)}\n"
  rescue ::MethodSource::SourceNotFoundError => e
    output << "   Unable to retrieve source code\n"
  end
  output << "   ```\n\n"
end

.runbook__statements__tmux_command(object, output, metadata) ⇒ Object



102
103
104
# File 'lib/runbook/views/markdown.rb', line 102

def self.runbook__statements__tmux_command(object, output, )
  output << "   run: `#{object.cmd}` in pane #{object.pane}\n\n"
end

.runbook__statements__upload(object, output, metadata) ⇒ Object



106
107
108
109
110
111
# File 'lib/runbook/views/markdown.rb', line 106

def self.runbook__statements__upload(object, output, )
  options = object.options
  to = " to #{object.to}" if object.to
  opts = " with options #{options}" unless options == {}
  output << "   upload: #{object.from}#{to}#{opts}\n\n"
end

.runbook__statements__wait(object, output, metadata) ⇒ Object



113
114
115
# File 'lib/runbook/views/markdown.rb', line 113

def self.runbook__statements__wait(object, output, )
  output << "   wait: #{object.time} seconds\n\n"
end