Class: Herdic::Printer
- Inherits:
-
Object
- Object
- Herdic::Printer
- Defined in:
- lib/herdic/printer.rb
Instance Method Summary collapse
-
#initialize(options) ⇒ Printer
constructor
A new instance of Printer.
- #request(header, body) ⇒ Object
- #response(response, body) ⇒ Object
- #start_message(config_file = nil) ⇒ Object
- #subtitle(text) ⇒ Object
- #title(meta) ⇒ Object
Constructor Details
#initialize(options) ⇒ Printer
Returns a new instance of Printer.
8 9 10 |
# File 'lib/herdic/printer.rb', line 8 def initialize() @options = end |
Instance Method Details
#request(header, body) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/herdic/printer.rb', line 40 def request(header, body) subtitle 'Request' if header.empty? puts Util.color('no header', :white) else print_header header end hr print_json body end |
#response(response, body) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/herdic/printer.rb', line 54 def response(response, body) subtitle "Response: #{response.code} #{response.}" print_header response.to_hash hr if !body || body.empty? puts Util.color('no body', :white) elsif 'application/json' == response.content_type print_json body else puts body end end |
#start_message(config_file = nil) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/herdic/printer.rb', line 12 def (config_file = nil) if config_file puts "Starting Herdic (#{config_file})" else puts 'Starting Herdic' end end |
#subtitle(text) ⇒ Object
34 35 36 37 38 |
# File 'lib/herdic/printer.rb', line 34 def subtitle(text) puts puts Util.color(text, :green) hr color: :green end |
#title(meta) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/herdic/printer.rb', line 20 def title() puts "\n\n" hr rule: '=', color: :green puts [Util.color(['method'], :green), ['endpoint']].join(' ') if ['title'] indent = ' ' * ['method'].size puts [indent, Util.color(['title'], :white)].join(' ') end hr rule: '=', color: :green end |