class Pvcglue::Docs
Constants
- ROLLS
Attributes
collecting[RW]
current_minion[RW]
data[RW]
enabled[RW]
Public Class Methods
new(enabled)
click to toggle source
# File lib/pvcglue/docs.rb, line 7 def initialize(enabled) @enabled = enabled @data = [] end
Public Instance Methods
add(s)
click to toggle source
# File lib/pvcglue/docs.rb, line 14 def add(s) return unless collecting data << s end
add_annotation(text)
click to toggle source
# File lib/pvcglue/docs.rb, line 25 def add_annotation(text) add('') add("> #{text}") add('') end
add_block(options)
click to toggle source
# File lib/pvcglue/docs.rb, line 88 def add_block(options) options = ::SafeMash.new(options) add("```#{options.style}") add(options.data) add('```') end
add_header(level, heading)
click to toggle source
# File lib/pvcglue/docs.rb, line 53 def add_header(level, heading) return unless enabled add('') add("#{'#'*level} #{heading}") end
add_paragraph(text)
click to toggle source
# File lib/pvcglue/docs.rb, line 19 def add_paragraph(text) add('') add(text) add('') end
done()
click to toggle source
# File lib/pvcglue/docs.rb, line 95 def done return unless enabled File.write('/home/andrew/projects/slate-pvc/source/includes/_logs.md', data.join("\n")) end
level_1(heading)
click to toggle source
# File lib/pvcglue/docs.rb, line 43 def level_1(heading) return unless enabled add_header(1, heading) end
level_1_roles(minion)
click to toggle source
# File lib/pvcglue/docs.rb, line 32 def level_1_roles(minion) return unless enabled self.current_minion = minion if minion self.collecting = true level_1(minion.roles.map { |role| ROLLS[role.to_sym] || role }.join(', ')) else self.collecting = false end end
level_2(heading)
click to toggle source
# File lib/pvcglue/docs.rb, line 48 def level_2(heading) return unless enabled add_header(2, heading) end
log_cmd(cmd)
click to toggle source
# File lib/pvcglue/docs.rb, line 82 def log_cmd(cmd) return unless enabled # add_block(data: cmd, style: 'shell') add("> `> #{cmd}`<br />") end
log_file_write(options)
click to toggle source
# File lib/pvcglue/docs.rb, line 75 def log_file_write(options) return unless enabled options = ::SafeMash.new(options) add_annotation("Write data to `#{options.file}`") add_block(options) end
set_item(options) { || ... }
click to toggle source
# File lib/pvcglue/docs.rb, line 59 def set_item(options) unless enabled yield return end options = ::SafeMash.new(options) add_header(3, options.heading) add('----') yield add_paragraph(options.body) if options.body && options.body.present? if options.reference && options.reference.present? add('') add("See also: [#{options.reference}](#{options.reference})") end end