Class: RubyCode::Views::Adapter::DebugResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/rubycode/views/adapter/debug_response.rb

Overview

Builds debug response text for adapter API responses

Class Method Summary collapse

Class Method Details

.build(adapter_name:, body:) ⇒ Object



11
12
13
14
15
# File 'lib/rubycode/views/adapter/debug_response.rb', line 11

def self.build(adapter_name:, body:)
  pastel = Pastel.new
  content = build_content_lines(pastel, adapter_name, body)
  content.join("\n")
end

.build_content_lines(pastel, adapter_name, body) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rubycode/views/adapter/debug_response.rb', line 17

def self.build_content_lines(pastel, adapter_name, body)
  [
    "",
    pastel.green.bold("=== DEBUG RESPONSE ==="),
    "#{pastel.bold("Adapter:")} #{adapter_name}",
    "",
    pastel.bold("Response:"),
    JSON.pretty_generate(body),
    pastel.green.bold("=" * 22)
  ]
end