class Egi::Fedcloud::Cloudhound::Formatter
Constants
- FORMATS
Public Class Methods
as_json(data = [])
click to toggle source
# File lib/egi/fedcloud/cloudhound/formatter.rb, line 27 def as_json(data = []) Egi::Fedcloud::Cloudhound::Log.debug "[#{self}] Transforming #{data.inspect} into a JSON document" return '{}' if data.blank? JSON.generate(data) end
as_plain(data = [])
click to toggle source
# File lib/egi/fedcloud/cloudhound/formatter.rb, line 35 def as_plain(data = []) Egi::Fedcloud::Cloudhound::Log.debug "[#{self}] Transforming #{data.inspect} into plain text" return '' if data.blank? plain = [] data.each do |site| Egi::Fedcloud::Cloudhound::Log.warn "[#{self}] #{site[:name]} doesn't " \ "have a CSIRT e-mail!" if site[:csirt].blank? next if site[:csirt].blank? plain << "#{site[:name]} <#{site[:csirt]}>" end plain.join ', ' end
as_table(data = [])
click to toggle source
# File lib/egi/fedcloud/cloudhound/formatter.rb, line 10 def as_table(data = []) Egi::Fedcloud::Cloudhound::Log.debug "[#{self}] Transforming #{data.inspect} into a table" data ||= [] table = Terminal::Table.new table.add_row [' >>> Site Name <<< ', ' >>> NGI Name <<< ', ' >>> CSIRT Contact(s) <<< '] table.add_separator data.each do |site| table.add_separator table.add_row [site[:name], site[:ngi], site[:csirt]] end table end