Class: RspecApiDocumentation::Curl
- Inherits:
-
Struct
- Object
- Struct
- RspecApiDocumentation::Curl
- Defined in:
- lib/rspec_api_documentation/curl.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#host ⇒ Object
Returns the value of attribute host.
-
#method ⇒ Object
Returns the value of attribute method.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #delete ⇒ Object
- #get ⇒ Object
- #get_data ⇒ Object
- #head ⇒ Object
- #output(config_host, config_headers_to_filer = nil) ⇒ Object
- #patch ⇒ Object
- #post ⇒ Object
- #post_data ⇒ Object
- #put ⇒ Object
- #url ⇒ Object
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data
5 6 7 |
# File 'lib/rspec_api_documentation/curl.rb', line 5 def data @data end |
#headers ⇒ Object
Returns the value of attribute headers
5 6 7 |
# File 'lib/rspec_api_documentation/curl.rb', line 5 def headers @headers end |
#host ⇒ Object
Returns the value of attribute host.
6 7 8 |
# File 'lib/rspec_api_documentation/curl.rb', line 6 def host @host end |
#method ⇒ Object
Returns the value of attribute method
5 6 7 |
# File 'lib/rspec_api_documentation/curl.rb', line 5 def method @method end |
#path ⇒ Object
Returns the value of attribute path
5 6 7 |
# File 'lib/rspec_api_documentation/curl.rb', line 5 def path @path end |
Instance Method Details
#delete ⇒ Object
30 31 32 |
# File 'lib/rspec_api_documentation/curl.rb', line 30 def delete "curl \"#{url}\" #{post_data} -X DELETE #{headers}" end |
#get ⇒ Object
18 19 20 |
# File 'lib/rspec_api_documentation/curl.rb', line 18 def get "curl \"#{url}#{get_data}\" -X GET #{headers}" end |
#get_data ⇒ Object
52 53 54 |
# File 'lib/rspec_api_documentation/curl.rb', line 52 def get_data "?#{data}" unless data.blank? end |
#head ⇒ Object
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 |
#patch ⇒ Object
34 35 36 |
# File 'lib/rspec_api_documentation/curl.rb', line 34 def patch "curl \"#{url}\" #{post_data} -X PATCH #{headers}" end |
#post ⇒ Object
14 15 16 |
# File 'lib/rspec_api_documentation/curl.rb', line 14 def post "curl \"#{url}\" #{post_data} -X POST #{headers}" end |
#post_data ⇒ Object
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 |
#put ⇒ Object
26 27 28 |
# File 'lib/rspec_api_documentation/curl.rb', line 26 def put "curl \"#{url}\" #{post_data} -X PUT #{headers}" end |
#url ⇒ Object
38 39 40 |
# File 'lib/rspec_api_documentation/curl.rb', line 38 def url "#{host}#{path}" end |