Class: Ethon::Easy
- Inherits:
-
Object
- Object
- Ethon::Easy
- Includes:
- Callbacks, Header, Http, Informations, Operations, Options, ResponseCallbacks
- Defined in:
- lib/ethon/easy.rb,
lib/ethon/easy/form.rb,
lib/ethon/easy/http.rb,
lib/ethon/easy/util.rb,
lib/ethon/easy/header.rb,
lib/ethon/easy/mirror.rb,
lib/ethon/easy/params.rb,
lib/ethon/easy/options.rb,
lib/ethon/easy/http/get.rb,
lib/ethon/easy/http/put.rb,
lib/ethon/easy/callbacks.rb,
lib/ethon/easy/http/head.rb,
lib/ethon/easy/http/post.rb,
lib/ethon/easy/queryable.rb,
lib/ethon/easy/debug_info.rb,
lib/ethon/easy/http/patch.rb,
lib/ethon/easy/operations.rb,
lib/ethon/easy/http/custom.rb,
lib/ethon/easy/http/delete.rb,
lib/ethon/easy/http/options.rb,
lib/ethon/easy/http/putable.rb,
lib/ethon/easy/informations.rb,
lib/ethon/easy/http/postable.rb,
lib/ethon/easy/http/actionable.rb,
lib/ethon/easy/response_callbacks.rb
Overview
:nodoc:
Defined Under Namespace
Modules: Callbacks, Header, Http, Informations, Operations, Options, Queryable, ResponseCallbacks, Util Classes: DebugInfo, Form, Mirror, Params
Constant Summary
Constants included from Informations
Informations::AVAILABLE_INFORMATIONS
Instance Attribute Summary collapse
-
#return_code ⇒ Symbol
Returns the curl return code.
Attributes included from Options
Instance Method Summary collapse
-
#escape(value) ⇒ String
private
Url escapes the value.
-
#initialize(options = {}) ⇒ Easy
constructor
Initialize a new Easy.
-
#log_inspect ⇒ String
Return pretty log out.
- #mirror ⇒ Object
-
#reset ⇒ Object
Reset easy.
-
#set_attributes(options) ⇒ Object
Set given options.
-
#to_hash ⇒ Hash
Returns the informations available through libcurl as a hash.
Methods included from ResponseCallbacks
#body, #complete, #headers, #on_body, #on_complete, #on_headers
Methods included from Operations
Methods included from Http
Methods included from Header
#compose_header, #header_list, #headers, #headers=
Methods included from Callbacks
#body_write_callback, #debug_callback, #header_write_callback, included, #read_callback, #set_callbacks, #set_read_callback
Methods included from Informations
Constructor Details
#initialize(options = {}) ⇒ Easy
Initialize a new Easy. It initializes curl, if not already done and applies the provided options. Look into Options to see what you can provide in the options hash.
216 217 218 219 220 |
# File 'lib/ethon/easy.rb', line 216 def initialize( = {}) Curl.init set_attributes() set_callbacks end |
Instance Attribute Details
#return_code ⇒ Symbol
Returns the curl return code.
199 200 201 |
# File 'lib/ethon/easy.rb', line 199 def return_code @return_code end |
Instance Method Details
#escape(value) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Url escapes the value.
269 270 271 272 273 274 |
# File 'lib/ethon/easy.rb', line 269 def escape(value) string_pointer = Curl.easy_escape(handle, value, value.bytesize) returned_string = string_pointer.read_string Curl.free(string_pointer) returned_string end |
#log_inspect ⇒ String
Return pretty log out.
295 296 297 |
# File 'lib/ethon/easy.rb', line 295 def log_inspect "EASY #{mirror.log_informations.map{|k, v| "#{k}=#{v}"}.flatten.join(' ')}" end |
#mirror ⇒ Object
285 286 287 |
# File 'lib/ethon/easy.rb', line 285 def mirror @mirror ||= Mirror.from_easy(self) end |
#reset ⇒ Object
Reset easy. This means resetting all options and instance variables. Also the easy handle is resetted.
247 248 249 250 251 252 253 254 255 256 257 |
# File 'lib/ethon/easy.rb', line 247 def reset @url = nil @hash = nil @on_complete = nil @on_headers = nil @on_body = nil @procs = nil @mirror = nil Curl.easy_reset(handle) set_callbacks end |
#set_attributes(options) ⇒ Object
Set given options.
232 233 234 235 236 237 238 239 240 |
# File 'lib/ethon/easy.rb', line 232 def set_attributes() .each_pair do |key, value| method = "#{key}=" unless respond_to?(method) raise Errors::InvalidOption.new(key) end send(method, value) end end |
#to_hash ⇒ Hash
Returns the informations available through libcurl as a hash.
280 281 282 283 |
# File 'lib/ethon/easy.rb', line 280 def to_hash Kernel.warn("Ethon: Easy#to_hash is deprecated and will be removed, please use #mirror.") mirror.to_hash end |