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__step(object, output, metadata) ⇒ Object



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

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



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

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



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/runbook/views/markdown.rb', line 29

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
    giveup_msg = "after #{[timeout_msg, attempts_msg].compact.join(" or ")}, give up..."
    output << "   #{giveup_msg}\n\n"
    if object.timeout_statement
      object.timeout_statement.render(self, output, .dup)
    end
    output << "   and exit\n\n"
  end
end

.runbook__statements__capture(object, output, metadata) ⇒ Object



43
44
45
# File 'lib/runbook/views/markdown.rb', line 43

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



47
48
49
# File 'lib/runbook/views/markdown.rb', line 47

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



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

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

.runbook__statements__confirm(object, output, metadata) ⇒ Object



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

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

.runbook__statements__description(object, output, metadata) ⇒ Object



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

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

.runbook__statements__download(object, output, metadata) ⇒ Object



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

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



70
71
72
73
# File 'lib/runbook/views/markdown.rb', line 70

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

.runbook__statements__note(object, output, metadata) ⇒ Object



75
76
77
# File 'lib/runbook/views/markdown.rb', line 75

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

.runbook__statements__notice(object, output, metadata) ⇒ Object



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

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

.runbook__statements__ruby_command(object, output, metadata) ⇒ Object



83
84
85
86
87
88
89
90
91
92
# File 'lib/runbook/views/markdown.rb', line 83

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



94
95
96
# File 'lib/runbook/views/markdown.rb', line 94

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



98
99
100
101
102
103
# File 'lib/runbook/views/markdown.rb', line 98

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



105
106
107
# File 'lib/runbook/views/markdown.rb', line 105

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