Class: RequestDetailsFormatter

Inherits:
Object
  • Object
show all
Includes:
RequestFormattable
Defined in:
lib/dtracer/request_formatters.rb

Instance Method Summary collapse

Methods included from RequestFormattable

#generate, #to_s

Constructor Details

#initialize(hash, options) ⇒ RequestDetailsFormatter

Returns a new instance of RequestDetailsFormatter.

[View source]

74
75
76
77
# File 'lib/dtracer/request_formatters.rb', line 74

def initialize(hash, options)
  @options = options
  super(hash)
end

Instance Method Details

#begin_section(_) ⇒ Object

[View source]

83
84
85
# File 'lib/dtracer/request_formatters.rb', line 83

def begin_section(_)
  []
end

#body_section(hash) ⇒ Object

[View source]

110
111
112
113
# File 'lib/dtracer/request_formatters.rb', line 110

def body_section(hash)
  return nil unless @options[:b] && hash["body"]
  ["Body:\n  #{hash["body"]}"]
end
[View source]

104
105
106
107
108
# File 'lib/dtracer/request_formatters.rb', line 104

def cookie_section(hash)
  return nil unless @options[:c] && hash["cookies"]

  hash["cookies"].map { |name, value| "  #{name}: #{value}" }.insert(0, "Cookies:")
end

#header_section(hash) ⇒ Object

[View source]

98
99
100
101
102
# File 'lib/dtracer/request_formatters.rb', line 98

def header_section(hash)
  return nil unless @options[:h] && hash["headers"]

  hash["headers"].map { |key, value| "  #{key}: #{value}" }.insert(0, "Headers:")
end

#joining_stringObject

[View source]

79
80
81
# File 'lib/dtracer/request_formatters.rb', line 79

def joining_string
  "\n"
end

#method_section(hash) ⇒ Object

[View source]

87
88
89
90
91
# File 'lib/dtracer/request_formatters.rb', line 87

def method_section(hash)
  return nil unless @options[:m] && hash["method"]

  ["Method:\n  #{hash["method"]}"]
end

#url_section(hash) ⇒ Object

[View source]

93
94
95
96
# File 'lib/dtracer/request_formatters.rb', line 93

def url_section(hash)
  return nil unless @options[:u] && hash["url"]
  ["URL:\n  #{hash["url"]}"]
end