Class: RequestCurlFormatter

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

Instance Method Summary collapse

Methods included from RequestFormattable

#generate, #initialize, #to_s

Instance Method Details

#begin_section(_) ⇒ Object



38
39
40
# File 'lib/dtracer/request_formatters.rb', line 38

def begin_section(_)
  ["curl"]
end

#body_section(hash) ⇒ Object



62
63
64
65
66
# File 'lib/dtracer/request_formatters.rb', line 62

def body_section(hash)
  return nil unless hash["body"]

  ["-d #{hash["body"]}"]
end


56
57
58
59
60
# File 'lib/dtracer/request_formatters.rb', line 56

def cookie_section(hash)
  return nil unless hash["cookies"]

  hash["cookies"].map { |name, value| "--cookie \"#{name}=#{value}\"" }
end

#header_section(hash) ⇒ Object



50
51
52
53
54
# File 'lib/dtracer/request_formatters.rb', line 50

def header_section(hash)
  return nil unless hash["headers"]

  hash["headers"].map { |key, value| "-H '#{key}: #{value}'" }
end

#joining_stringObject



34
35
36
# File 'lib/dtracer/request_formatters.rb', line 34

def joining_string
  " \\ \n"
end

#method_section(hash) ⇒ Object



42
43
44
# File 'lib/dtracer/request_formatters.rb', line 42

def method_section(hash)
  ["-X #{hash["method"]}"]
end

#url_section(hash) ⇒ Object



46
47
48
# File 'lib/dtracer/request_formatters.rb', line 46

def url_section(hash)
  ["\"#{hash["url"]}\""]
end