ethon 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,24 @@
1
+ # Changelog
2
+
3
+ ## 0.0.3
4
+
5
+ [Full Changelog](http://github.com/typhoeus/ethon/compare/v0.0.2...master)
6
+
7
+ Enhancements:
8
+
9
+ * Documentation
10
+ ( [Alex P](https://github.com/ifesdjeen), [\#13](https://github.com/typhoeus/ethon/issues/13) )
11
+ * New libcurl option dns_cache_timeout
12
+ ( [Chris Heald](https://github.com/cheald), [\#192](https://github.com/typhoeus/typhoeus/pull/192) )
13
+
14
+ Bugfixes:
15
+
16
+ * Libcurl option ssl_verifyhost takes an integer.
17
+ * Add space between header key and value.
18
+
1
19
  ## 0.0.2
2
20
 
3
- ### Resolved Issues
21
+ Bugfixes:
4
22
 
5
23
  * Add libcurl.so.4 to ffi_lib in order to load correct lib on Debian.
6
24
  * Escape zero bytes.
data/README.md CHANGED
@@ -5,10 +5,6 @@ In the modern world Ethon is a very basic libcurl wrapper using ffi.
5
5
 
6
6
  * [Documentation](http://rubydoc.info/github/typhoeus/ethon)
7
7
 
8
- ## Caution
9
-
10
- This is __alpha__!
11
-
12
8
  ## Installation
13
9
 
14
10
  With bundler:
@@ -19,43 +15,50 @@ With bundler:
19
15
 
20
16
  Making the first request is realy simple:
21
17
 
22
- easy = Ethon::Easy.new(:url => "www.google.de")
23
- easy.prepare
24
- easy.perform
25
- #=> :ok
18
+ ```ruby
19
+ easy = Ethon::Easy.new(:url => "www.google.de")
20
+ easy.prepare
21
+ easy.perform
22
+ #=> :ok
23
+ ```
26
24
 
27
25
  You have access to various options like following redirects:
28
26
 
29
- easy = Ethon::Easy.new(:url => "www.google.com", :follow_location => true)
30
- easy.prepare
31
- easy.perform
32
- #=> :ok
33
-
27
+ ```ruby
28
+ easy = Ethon::Easy.new(:url => "www.google.com", :follow_location => true)
29
+ easy.prepare
30
+ easy.perform
31
+ #=> :ok
32
+ ```
34
33
  Once you're done you can look at the response code and body:
35
34
 
36
- easy = Ethon::Easy.new(:url => "www.google.de")
37
- easy.prepare
38
- easy.perform
39
- easy.response_code
40
- #=> 200
41
- easy.response_body
42
- #=> "<!doctype html><html ..."
35
+ ```ruby
36
+ easy = Ethon::Easy.new(:url => "www.google.de")
37
+ easy.prepare
38
+ easy.perform
39
+ easy.response_code
40
+ #=> 200
41
+ easy.response_body
42
+ #=> "<!doctype html><html ..."
43
+ ```
43
44
 
44
45
  ## Http
45
46
 
46
47
  In order to make life easier there are some helpers for doing http requests:
47
48
 
48
- easy = Ethon::Easy.new
49
- easy.http_request("www.google.de", :get, { :params => {:a => 1} })
50
- easy.prepare
51
- easy.perform
52
- #=> :ok
53
-
54
- easy = Ethon::Easy.new
55
- easy.http_request("www.google.de", :post, { :params => { :a => 1 }, :body => { :b => 2 } })
56
- easy.prepare
57
- easy.perform
58
- #=> :ok
49
+ ```ruby
50
+ easy = Ethon::Easy.new
51
+ easy.http_request("www.google.de", :get, { :params => {:a => 1} })
52
+ easy.prepare
53
+ easy.perform
54
+ #=> :ok
55
+
56
+ easy = Ethon::Easy.new
57
+ easy.http_request("www.google.de", :post, { :params => { :a => 1 }, :body => { :b => 2 } })
58
+ easy.prepare
59
+ easy.perform
60
+ #=> :ok
61
+ ```
59
62
 
60
63
  This really handy when doing requests since you don't have to care about setting
61
64
  everything up correct.
@@ -1,5 +1,6 @@
1
1
  module Ethon
2
- # :nodoc:
2
+
3
+ # FFI Wrapper module for Curl. Holds constants and required initializers.
3
4
  module Curl
4
5
  # :nodoc:
5
6
  def Curl.windows?
@@ -11,16 +12,17 @@ module Ethon
11
12
  # :nodoc:
12
13
  VERSION_NOW = 3
13
14
 
14
- # :nodoc:
15
+ # Flag. Initialize SSL.
15
16
  GLOBAL_SSL = 0x01
16
- # :nodoc:
17
+ # Flag. Initialize win32 socket libraries.
17
18
  GLOBAL_WIN32 = 0x02
18
- # :nodoc:
19
+ # Flag. Initialize everything possible.
19
20
  GLOBAL_ALL = (GLOBAL_SSL | GLOBAL_WIN32)
20
- # :nodoc:
21
+ # Flag. Initialize everything by default.
21
22
  GLOBAL_DEFAULT = GLOBAL_ALL
22
23
 
23
- # :nodoc:
24
+ # Libcurl error codes, refer
25
+ # https://github.com/bagder/curl/blob/master/include/curl/curl.h for details
24
26
  EasyCode = enum :easy_code, [
25
27
  :ok,
26
28
  :unsupported_protocol,
@@ -113,7 +115,8 @@ module Ethon
113
115
  :chunk_failed,
114
116
  :last]
115
117
 
116
- # :nodoc:
118
+ # Curl-Multi socket error codes, refer
119
+ # https://github.com/bagder/curl/blob/master/include/curl/multi.h for details
117
120
  MultiCode = enum :multi_code, [
118
121
  :call_multi_perform, -1,
119
122
  :ok,
@@ -132,7 +135,8 @@ module Ethon
132
135
  :function_point, 20000,
133
136
  :off_t, 30000]
134
137
 
135
- # :nodoc:
138
+ # Curl options, refer
139
+ # https://github.com/bagder/curl/blob/master/src/tool_cfgable.h for details
136
140
  Option = enum :option, [
137
141
  :file, OptionType[:object_point] + 1,
138
142
  :writedata, OptionType[:object_point] + 1,
@@ -282,7 +286,8 @@ module Ethon
282
286
  :double, 0x300000,
283
287
  :slist, 0x400000]
284
288
 
285
- # :nodoc:
289
+ # Info details, refer
290
+ # https://github.com/bagder/curl/blob/master/src/tool_writeout.c#L66 for details
286
291
  Info = enum :info, [
287
292
  :effective_url, InfoType[:string] + 1,
288
293
  :response_code, InfoType[:long] + 2,
@@ -328,7 +333,8 @@ module Ethon
328
333
  :local_port, InfoType[:long] + 42,
329
334
  :last, 42]
330
335
 
331
- # :nodoc:
336
+ # Form options, used by FormAdd for temporary storage, refer
337
+ # https://github.com/bagder/curl/blob/master/lib/formdata.h#L51 for details
332
338
  FormOption = enum :form_option, [
333
339
  :none,
334
340
  :copyname,
@@ -5,6 +5,10 @@ module Ethon
5
5
  # which are needed to interact with libcurl.
6
6
  module Callbacks
7
7
 
8
+ def self.included(base)
9
+ base.send(:attr_accessor, *[:response_body, :response_header])
10
+ end
11
+
8
12
  # Set writefunction and headerfunction callback.
9
13
  # They are called by libcurl in order to provide the header and
10
14
  # the body from the request.
@@ -71,7 +71,7 @@ module Ethon
71
71
  #
72
72
  # @return [ Array ] The query pairs.
73
73
  def query_pairs
74
- @query_pairs ||= build_query_pairs_from_hash(@params)
74
+ @query_pairs ||= build_query_pairs(@params)
75
75
  end
76
76
 
77
77
  # Return the string representation of the form. This makes only
@@ -58,7 +58,7 @@ module Ethon
58
58
  #
59
59
  # @return [ String ] The composed header.
60
60
  def compose_header(key, value)
61
- Util.escape_zero_byte("#{key}:#{value}")
61
+ Util.escape_zero_byte("#{key}: #{value}")
62
62
  end
63
63
  end
64
64
  end
@@ -8,38 +8,61 @@ module Ethon
8
8
  # for more real actions like GET, HEAD, POST and PUT.
9
9
  module Actionable
10
10
 
11
+ # Create a new action.
12
+ #
13
+ # @example Create a new action.
14
+ # Action.new("www.example.com", {})
15
+ #
16
+ # @param [ String ] url The url.
17
+ # @param [ Hash ] options The options.
18
+ #
19
+ # @return [ Action ] A new action.
20
+ def initialize(url, options)
21
+ @url = url
22
+ @options = options
23
+ end
24
+
25
+ # Return the url.
26
+ #
27
+ # @example Return url.
28
+ # action.url
29
+ #
30
+ # @return [ String ] The url.
11
31
  def url
12
32
  @url
13
33
  end
14
34
 
35
+ # Return the options hash.
36
+ #
37
+ # @example Return options.
38
+ # action.options
39
+ #
40
+ # @return [ Hash ] The options.
15
41
  def options
16
42
  @options
17
43
  end
18
44
 
45
+ # Return the params.
46
+ #
47
+ # @example Return params.
48
+ # action.params
49
+ #
50
+ # @return [ Params ] The params.
19
51
  def params
20
52
  @params ||= Params.new(options[:params])
21
53
  end
22
54
 
23
- def form
24
- @form ||= Form.new(options[:body])
25
- end
26
-
27
- # Create a new action.
28
- #
29
- # @example Create a new action.
30
- # Action.new("www.example.com", {})
55
+ # Return the form.
31
56
  #
32
- # @param [ String ] url The url.
33
- # @param [ Hash ] options The options.
57
+ # @example Return form.
58
+ # action.form
34
59
  #
35
- # @return [ Action ] A new action.
36
- def initialize(url, options)
37
- @url = url
38
- @options = options
60
+ # @return [ Form ] The form.
61
+ def form
62
+ @form ||= Form.new(options[:body])
39
63
  end
40
64
 
41
- # Setup everything what is necessary for a proper
42
- # request.
65
+ # Setup everything necessary for a proper request.
43
66
  #
44
67
  # @example setup.
45
68
  # action.setup(easy)
@@ -49,7 +72,6 @@ module Ethon
49
72
  set_nothing(easy) if params.empty? && form.empty?
50
73
  set_params(easy) unless params.empty?
51
74
  set_form(easy) unless form.empty?
52
- set_customs(easy)
53
75
  easy.set_attributes(options)
54
76
  end
55
77
 
@@ -63,7 +85,7 @@ module Ethon
63
85
  easy.url = url
64
86
  end
65
87
 
66
- # Setup request as with params.
88
+ # Setup request with params.
67
89
  #
68
90
  # @example Setup nothing.
69
91
  # action.set_params(easy)
@@ -74,7 +96,7 @@ module Ethon
74
96
  easy.url = "#{url}?#{params.to_s}"
75
97
  end
76
98
 
77
- # Setup request as with form.
99
+ # Setup request with form.
78
100
  #
79
101
  # @example Setup nothing.
80
102
  # action.set_form(easy)
@@ -82,16 +104,6 @@ module Ethon
82
104
  # @param [ Easy ] easy The easy to setup.
83
105
  def set_form(easy)
84
106
  end
85
-
86
- # Setup custom things eg. override the i
87
- # action for delete.
88
- #
89
- # @example Setup custom things.
90
- # action.set_customs(easy)
91
- #
92
- # @param [ Easy ] easy The easy to setup.
93
- def set_customs(easy)
94
- end
95
107
  end
96
108
  end
97
109
  end
@@ -7,13 +7,14 @@ module Ethon
7
7
  include Ethon::Easies::Http::Actionable
8
8
  include Ethon::Easies::Http::Postable
9
9
 
10
- # Setup customrequest in order to make a delete.
10
+ # Setup easy to make a DELETE request.
11
11
  #
12
12
  # @example Setup customrequest.
13
13
  # delete.setup(easy)
14
14
  #
15
15
  # @param [ Easy ] easy The easy to setup.
16
- def set_customs(easy)
16
+ def setup(easy)
17
+ super
17
18
  easy.customrequest = "DELETE"
18
19
  end
19
20
  end
@@ -7,13 +7,14 @@ module Ethon
7
7
  include Ethon::Easies::Http::Actionable
8
8
  include Ethon::Easies::Http::Postable
9
9
 
10
- # Setup url with escaped params and httpget.
10
+ # Setup easy to make a GET request.
11
11
  #
12
12
  # @example Setup.
13
13
  # get.set_params(easy)
14
14
  #
15
15
  # @param [ Easy ] easy The easy to setup.
16
- def set_customs(easy)
16
+ def setup(easy)
17
+ super
17
18
  easy.customrequest = "GET"
18
19
  end
19
20
  end
@@ -7,13 +7,14 @@ module Ethon
7
7
  include Ethon::Easies::Http::Actionable
8
8
  include Ethon::Easies::Http::Postable
9
9
 
10
- # Setup url with escaped params and nobody.
10
+ # Setup easy to make a HEAD request.
11
11
  #
12
12
  # @example Setup.
13
13
  # get.set_params(easy)
14
14
  #
15
15
  # @param [ Easy ] easy The easy to setup.
16
- def set_customs(easy)
16
+ def setup(easy)
17
+ super
17
18
  easy.nobody = true
18
19
  end
19
20
  end
@@ -2,18 +2,19 @@ module Ethon
2
2
  module Easies
3
3
  module Http
4
4
 
5
- # This class knows everything about making GET requests.
5
+ # This class knows everything about making OPTIONS requests.
6
6
  class Options
7
7
  include Ethon::Easies::Http::Actionable
8
8
  include Ethon::Easies::Http::Postable
9
9
 
10
- # Setup url with escaped params and httpget.
10
+ # Setup easy to make a OPTIONS request.
11
11
  #
12
12
  # @example Setup.
13
- # get.set_params(easy)
13
+ # options.setup(easy)
14
14
  #
15
15
  # @param [ Easy ] easy The easy to setup.
16
- def set_customs(easy)
16
+ def setup(easy)
17
+ super
17
18
  easy.customrequest = "OPTIONS"
18
19
  end
19
20
  end
@@ -7,13 +7,14 @@ module Ethon
7
7
  include Ethon::Easies::Http::Actionable
8
8
  include Ethon::Easies::Http::Postable
9
9
 
10
- # Setup url with escaped params and httpget.
10
+ # Setup easy to make a PATCH request.
11
11
  #
12
12
  # @example Setup.
13
- # get.set_params(easy)
13
+ # patch.setup(easy)
14
14
  #
15
15
  # @param [ Easy ] easy The easy to setup.
16
- def set_customs(easy)
16
+ def setup(easy)
17
+ super
17
18
  easy.customrequest = "PATCH"
18
19
  end
19
20
  end
@@ -6,7 +6,14 @@ module Ethon
6
6
  include Ethon::Easies::Http::Actionable
7
7
  include Ethon::Easies::Http::Postable
8
8
 
9
- def set_customs(easy)
9
+ # Setup easy to make a POST request.
10
+ #
11
+ # @example Setup.
12
+ # post.setup(easy)
13
+ #
14
+ # @param [ Easy ] easy The easy to setup.
15
+ def setup(easy)
16
+ super
10
17
  if form.empty?
11
18
  easy.postfieldsize = 0
12
19
  easy.copypostfields = ""
@@ -1,6 +1,8 @@
1
1
  module Ethon
2
2
  module Easies
3
3
  module Http
4
+
5
+ # This module contains logic for setting up a [multipart] POST body.
4
6
  module Postable
5
7
  # Set things up when form is provided.
6
8
  # Deals with multipart forms.
@@ -7,7 +7,14 @@ module Ethon
7
7
  include Ethon::Easies::Http::Actionable
8
8
  include Ethon::Easies::Http::Putable
9
9
 
10
- def set_customs(easy)
10
+ # Setup easy to make a PUT request.
11
+ #
12
+ # @example Setup.
13
+ # put.setup(easy)
14
+ #
15
+ # @param [ Easy ] easy The easy to setup.
16
+ def setup(easy)
17
+ super
11
18
  if form.empty?
12
19
  easy.upload = true
13
20
  easy.infilesize = 0
@@ -1,6 +1,8 @@
1
1
  module Ethon
2
2
  module Easies
3
3
  module Http
4
+
5
+ # This module contains logic about setting up a PUT body.
4
6
  module Putable
5
7
  # Set things up when form is provided.
6
8
  # Deals with multipart forms.
@@ -9,8 +9,8 @@ module Ethon
9
9
  def self.included(base)
10
10
  base.extend ClassMethods
11
11
  base.const_set(:AVAILABLE_OPTIONS, [
12
- :httppost, :put, :httpget, :nobody, :upload, :customrequest,
13
- :cainfo, :capath, :connecttimeout,
12
+ :dns_cache_timeout, :httppost, :put, :httpget, :nobody, :upload,
13
+ :customrequest, :cainfo, :capath, :connecttimeout,
14
14
  :followlocation, :httpauth, :infilesize, :interface,
15
15
  :maxredirs, :nosignal, :postfieldsize, :copypostfields, :proxy,
16
16
  :proxyauth, :proxytype, :timeout, :readdata, :sslcert, :ssl_verifypeer, :ssl_verifyhost,
@@ -40,7 +40,7 @@ module Ethon
40
40
  # @return [ Array ] The bool options.
41
41
  def bool_options
42
42
  [
43
- :followlocation, :nosignal, :ssl_verifypeer, :ssl_verifyhost,
43
+ :followlocation, :nosignal, :ssl_verifypeer,
44
44
  :verbose, :httpget, :nobody, :upload
45
45
  ]
46
46
  end
@@ -62,7 +62,10 @@ module Ethon
62
62
  #
63
63
  # @return [ Array ] The int options.
64
64
  def int_options
65
- [ :connecttimeout, :infilesize, :maxredirs, :postfieldsize, :timeout ]
65
+ [
66
+ :connecttimeout, :dns_cache_timeout, :infilesize, :maxredirs,
67
+ :postfieldsize, :ssl_verifyhost, :timeout
68
+ ]
66
69
  end
67
70
  end
68
71
 
@@ -37,7 +37,7 @@ module Ethon
37
37
  #
38
38
  # @return [ Array ] The query pairs.
39
39
  def query_pairs
40
- @query_pairs ||= build_query_pairs_from_hash(@params)
40
+ @query_pairs ||= build_query_pairs(@params)
41
41
  end
42
42
 
43
43
  # Return wether there are elements in the params or not.
@@ -4,8 +4,16 @@ module Ethon
4
4
  # This module contains small helpers.
5
5
  module Util
6
6
 
7
- # Return query pairs from hash.
8
- def build_query_pairs_from_hash(hash)
7
+ # Return query pairs build from a hash.
8
+ #
9
+ # @example Build query pairs.
10
+ # action.build_query_pairs({:a => 1, :b => 2})
11
+ # #=> [[:a, 1], [:b, 2]]
12
+ #
13
+ # @param [ Hash ] hash The hash to go through.
14
+ #
15
+ # @return [ Array ] The array of query pairs.
16
+ def build_query_pairs(hash)
9
17
  pairs = []
10
18
  recursive = Proc.new do |h, prefix|
11
19
  h.each_pair do |k,v|
@@ -27,6 +35,13 @@ module Ethon
27
35
  end
28
36
 
29
37
  # Return file info for a file.
38
+ #
39
+ # @example Return file info.
40
+ # action.file_info(File.open('fubar', 'r'))
41
+ #
42
+ # @param [ File ] file The file to handle.
43
+ #
44
+ # @return [ Array ] Array of informations.
30
45
  def file_info(file)
31
46
  filename = File.basename(file.path)
32
47
  types = MIME::Types.type_for(filename)
@@ -37,6 +52,16 @@ module Ethon
37
52
  ]
38
53
  end
39
54
 
55
+ # Escapes zero bytes in strings.
56
+ #
57
+ # @example Escape zero bytes.
58
+ # Util.escape_zero_byte("1\0")
59
+ # #=> "1\\0"
60
+ #
61
+ # @param [ Object ] value The value to escape.
62
+ #
63
+ # @return [ String, Object ] Escaped String if
64
+ # zero byte found, original object if not.
40
65
  def self.escape_zero_byte(value)
41
66
  return value unless value.to_s.include?(0.chr)
42
67
  value.to_s.gsub(0.chr, '\\\0')
@@ -22,7 +22,6 @@ module Ethon
22
22
  include Ethon::Easies::Operations
23
23
  include Ethon::Easies::ResponseCallbacks
24
24
 
25
- attr_reader :response_body, :response_header
26
25
  attr_accessor :return_code
27
26
 
28
27
  class << self
@@ -49,6 +48,77 @@ module Ethon
49
48
  #
50
49
  # @param [ Hash ] options The options to set.
51
50
  #
51
+ # @option options :cainfo [String] See
52
+ # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTCAINFO.
53
+ # @option options :capath [String] See
54
+ # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTCAPATH.
55
+ # @option options :connecttimeout [Integer] See
56
+ # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTCONNECTTIMEOUT.
57
+ # @option options :copypostfields [String] See
58
+ # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTCOPYPOSTFIELDS.
59
+ # @option options :customrequest [String] See
60
+ # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTCUSTOMREQUEST.
61
+ # @option options :dns_cache_timeout [Integer] See
62
+ # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTDNSCACHETIMEOUT.
63
+ # @option options :followlocation [Boolean] See
64
+ # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTFOLLOWLOCATION.
65
+ # @option options :httpauth [String] See
66
+ # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTHTTPAUTH.
67
+ # @option options :httpget [Boolean] See
68
+ # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTHTTPGET.
69
+ # @option options :httppost [String] See
70
+ # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTHTTPPOST.
71
+ # @option options :infilesize [Integer] See
72
+ # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTINFILESIZE.
73
+ # @option options :interface [String] See
74
+ # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTINTERFACE.
75
+ # @option options :maxredirs [Integer] See
76
+ # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTMAXREDIRS.
77
+ # @option options :nobody [Boolean] See
78
+ # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTNOBODY.
79
+ # @option options :nosignal [Boolean] See
80
+ # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTNOSIGNAL.
81
+ # @option options :postfieldsize [Integer] See
82
+ # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPOSTFIELDSIZE.
83
+ # @option options :proxy [String] See
84
+ # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPROXY.
85
+ # @option options :proxyauth [String] See
86
+ # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPROXYAUTH.
87
+ # @option options :proxytype [String] See
88
+ # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPROXYTYPE.
89
+ # @option options :put [String] See
90
+ # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPUT.
91
+ # @option options :readdata [String] See
92
+ # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTREADDATA.
93
+ # @option options :readfunction [String] See
94
+ # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTREADFUNCTION.
95
+ # @option options :ssl_verifyhost [Integer] See
96
+ # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTSSLVERIFYHOST.
97
+ # @option options :ssl_verifypeer [Boolean] See
98
+ # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTSSLVERIFYPEER.
99
+ # @option options :sslcert [String] See
100
+ # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTSSLCERT.
101
+ # @option options :sslcerttype [String] See
102
+ # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTSSLCERTTYPE.
103
+ # @option options :sslkey [String] See
104
+ # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTSSLKEY.
105
+ # @option options :sslkeytype [String] See
106
+ # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTSSLKEYTYPE.
107
+ # @option options :sslversion [String] See
108
+ # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTSSLVERSION.
109
+ # @option options :timeout [Integer] See
110
+ # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTTIMEOUT.
111
+ # @option options :upload [Boolean] See
112
+ # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTUPLOAD.
113
+ # @option options :url [String] See
114
+ # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTURL.
115
+ # @option options :useragent [String] See
116
+ # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTUSERAGENT.
117
+ # @option options :userpwd [String] See
118
+ # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTUSERPWD.
119
+ # @option options :verbose [Boolean] See
120
+ # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTVERBOSE.
121
+ #
52
122
  # @return [ Easy ] A new Easy.
53
123
  def initialize(options = {})
54
124
  Curl.init
@@ -62,6 +132,8 @@ module Ethon
62
132
  # easy.set_attributes(options)
63
133
  #
64
134
  # @param [ Hash ] options The options.
135
+ #
136
+ # @see initialize
65
137
  def set_attributes(options)
66
138
  options.each_pair do |key, value|
67
139
  method("#{key}=").call(value) if respond_to?("#{key}=")
@@ -90,6 +162,10 @@ module Ethon
90
162
  @handle ||= Curl.easy_init
91
163
  end
92
164
 
165
+ # Returns the informations available through libcurl as
166
+ # a hash.
167
+ #
168
+ # @return [ Hash ] The informations hash.
93
169
  def to_hash
94
170
  hash = {}
95
171
  hash[:return_code] = return_code
@@ -1,6 +1,13 @@
1
1
  module Ethon
2
+
3
+ # This module contains all core extensions ethon
4
+ # needs.
2
5
  module Extensions
3
- module String
6
+ module String # :nodoc:
7
+
8
+ # Return part of the string.
9
+ #
10
+ # @return [ String ] Part of the string.
4
11
  def byteslice(*args)
5
12
  self[*args]
6
13
  end
@@ -45,6 +45,8 @@ module Ethon
45
45
  #
46
46
  # @example Get timeout.
47
47
  # multi.get_timeout
48
+ #
49
+ # @raise [Ethon::Errors::MultiTimeout] when getting the timeout failed.
48
50
  def get_timeout
49
51
  code = Curl.multi_timeout(handle, @timeout)
50
52
  raise Errors::MultiTimeout.new(code) unless code == :ok
@@ -67,6 +69,9 @@ module Ethon
67
69
  #
68
70
  # @example Set fds.
69
71
  # multi.set_fds
72
+ #
73
+ # @raise [Ethon::Errors::MultiFdset] when setting the file descriptors failed.
74
+ # @raise [Ethon::Errors::Select] when select failed.
70
75
  def set_fds(timeout)
71
76
  code = Curl.multi_fdset(handle, @fd_read, @fd_write, @fd_excep, @max_fd)
72
77
  raise Errors::MultiFdset.new(code) unless code == :ok
@@ -20,6 +20,8 @@ module Ethon
20
20
  # multi.add(easy)
21
21
  #
22
22
  # @param [ Easy ] easy The easy to add.
23
+ #
24
+ # @raise [Ethon::Errors::MultiAdd] when adding an easy failed.
23
25
  def add(easy)
24
26
  return nil if easy_handles.include?(easy)
25
27
  code = Curl.multi_add_handle(handle, easy.handle)
@@ -32,6 +34,8 @@ module Ethon
32
34
  # @example Delete easy from stack.
33
35
  #
34
36
  # @param [ Easy ] easy The easy to delete.
37
+ #
38
+ # @raise [Ethon::Errors::MultiRemove] when removing an easy failed.
35
39
  def delete(easy)
36
40
  if easy_handles.delete(easy)
37
41
  code = Curl.multi_remove_handle(handle, easy.handle)
@@ -1,5 +1,5 @@
1
1
  module Ethon
2
2
 
3
3
  # Ethon version.
4
- VERSION = '0.0.2'
4
+ VERSION = '0.0.3'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ethon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-21 00:00:00.000000000 Z
12
+ date: 2012-06-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi
@@ -233,7 +233,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
233
233
  version: '0'
234
234
  segments:
235
235
  - 0
236
- hash: 4039343008781597148
236
+ hash: -1256508423117646856
237
237
  required_rubygems_version: !ruby/object:Gem::Requirement
238
238
  none: false
239
239
  requirements: