Class: CurlBackend
- Inherits:
-
Object
- Object
- CurlBackend
- Defined in:
- lib/curl_backend.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(prepared_request, options = {}) ⇒ CurlBackend
constructor
A new instance of CurlBackend.
- #parse_curl_options(options) ⇒ Object
Constructor Details
#initialize(prepared_request, options = {}) ⇒ CurlBackend
Returns a new instance of CurlBackend.
3 4 5 6 |
# File 'lib/curl_backend.rb', line 3 def initialize(prepared_request, ={}) @request = prepared_request = () end |
Instance Method Details
#execute ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/curl_backend.rb', line 8 def execute header_string = @request.headers.map {|key, val| "-H '#{key}: #{val}'"}.join ' ' data_string = @request.data ? "-d '#{@request.data}'" : "" curl_command = "curl -X #{@request.method.upcase} #{header_string} #{data_string} #{@curl_options} #{@request.uri}" system curl_command end |
#parse_curl_options(options) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/curl_backend.rb', line 16 def () opts = '' if .has_key? 'verbose' opts += '--verbose ' end if .has_key? 'head' opts += ' --head ' end opts end |