Class: RspecApiDocumentation::Curl

Inherits:
Struct
  • Object
show all
Defined in:
lib/rspec_api_documentation/curl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dataObject

Returns the value of attribute data

Returns:

  • (Object)

    the current value of data



5
6
7
# File 'lib/rspec_api_documentation/curl.rb', line 5

def data
  @data
end

#headersObject

Returns the value of attribute headers

Returns:

  • (Object)

    the current value of headers



5
6
7
# File 'lib/rspec_api_documentation/curl.rb', line 5

def headers
  @headers
end

#hostObject

Returns the value of attribute host.



6
7
8
# File 'lib/rspec_api_documentation/curl.rb', line 6

def host
  @host
end

#methodObject

Returns the value of attribute method

Returns:

  • (Object)

    the current value of method



5
6
7
# File 'lib/rspec_api_documentation/curl.rb', line 5

def method
  @method
end

#pathObject

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



5
6
7
# File 'lib/rspec_api_documentation/curl.rb', line 5

def path
  @path
end

Instance Method Details

#deleteObject



30
31
32
# File 'lib/rspec_api_documentation/curl.rb', line 30

def delete
  "curl \"#{url}\" #{post_data} -X DELETE #{headers}"
end

#getObject



18
19
20
# File 'lib/rspec_api_documentation/curl.rb', line 18

def get
  "curl \"#{url}#{get_data}\" -X GET #{headers}"
end

#get_dataObject



52
53
54
# File 'lib/rspec_api_documentation/curl.rb', line 52

def get_data
  "?#{data}" unless data.blank?
end

#headObject



22
23
24
# File 'lib/rspec_api_documentation/curl.rb', line 22

def head
  "curl \"#{url}#{get_data}\" -X HEAD #{headers}"
end

#output(config_host, config_headers_to_filer = nil) ⇒ Object



8
9
10
11
12
# File 'lib/rspec_api_documentation/curl.rb', line 8

def output(config_host, config_headers_to_filer = nil)
  self.host = config_host
  @config_headers_to_filer = Array(config_headers_to_filer)
  send(method.downcase)
end

#patchObject



34
35
36
# File 'lib/rspec_api_documentation/curl.rb', line 34

def patch
  "curl \"#{url}\" #{post_data} -X PATCH #{headers}"
end

#postObject



14
15
16
# File 'lib/rspec_api_documentation/curl.rb', line 14

def post
  "curl \"#{url}\" #{post_data} -X POST #{headers}"
end

#post_dataObject



56
57
58
59
# File 'lib/rspec_api_documentation/curl.rb', line 56

def post_data
  escaped_data = data.to_s.gsub("'", "\\u0027")
  "-d '#{escaped_data}'"
end

#putObject



26
27
28
# File 'lib/rspec_api_documentation/curl.rb', line 26

def put
  "curl \"#{url}\" #{post_data} -X PUT #{headers}"
end

#urlObject



38
39
40
# File 'lib/rspec_api_documentation/curl.rb', line 38

def url
  "#{host}#{path}"
end