Class: Patch::Report
- Inherits:
-
Object
- Object
- Patch::Report
- Defined in:
- lib/patch/report.rb
Overview
Terminal/Console output explaining the hub configuration
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(hub) ⇒ Report
constructor
A new instance of Report.
-
#print ⇒ Report
Print a report to standard out.
-
#report ⇒ Hash
Construct the report hash.
Constructor Details
#initialize(hub) ⇒ Report
Returns a new instance of Report.
13 14 15 |
# File 'lib/patch/report.rb', line 13 def initialize(hub) @hub = hub end |
Class Method Details
.print(hub) ⇒ Report
8 9 10 |
# File 'lib/patch/report.rb', line 8 def self.print(hub) new(hub).print end |
Instance Method Details
#print ⇒ Report
Print a report to standard out
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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/patch/report.rb', line 19 def print report = self.report puts print_logo puts puts Rainbow("IPs").cyan puts Rainbow("———").cyan report[:ips].each { |ip| puts ip } puts puts Rainbow("Nodes").cyan puts Rainbow("———").cyan report[:nodes].each do |node| puts "#{node[:id]}: #{node[:name]}" end puts if report[:patches].count > 0 puts Rainbow("Patches").cyan puts Rainbow("———").cyan report[:patches].each_with_index do |patch, i| puts "#{i+1}. #{patch[:name]}" puts Rainbow("|").cyan puts Rainbow("| Node Map").cyan puts Rainbow("| ———").cyan patch[:maps].each { |map| puts Rainbow("| ").cyan + map } puts Rainbow("|").cyan puts Rainbow("| Actions").cyan puts Rainbow("| ———").cyan chunked_actions(patch[:actions]).each do |chunk| puts Rainbow("| ").cyan + chunk end puts Rainbow("|").cyan puts end else puts end unless report[:log].nil? puts "Logging to #{report[:log]}" puts end self end |
#report ⇒ Hash
Construct the report hash
64 65 66 67 68 69 70 71 |
# File 'lib/patch/report.rb', line 64 def report report = {} report[:ips] = @hub.ips report[:nodes] = @hub.nodes.sort_by(&:id).map { |node| node_report(node) } report[:patches] = @hub.patches.map { |patch| patch_report(patch) } report[:log] = @hub.log.path unless @hub.log.nil? report end |