jeff 0.2.2 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -22,7 +22,7 @@ Customise default headers and parameters.
22
22
  class Client
23
23
  headers 'User-Agent' => 'Client'
24
24
  params 'Service' => 'SomeService',
25
- 'Tag' => Proc.new { tag }
25
+ 'Tag' => -> { tag }
26
26
 
27
27
  attr_accessor :tag
28
28
  end
@@ -80,7 +80,7 @@ class Logger
80
80
  $stderr.puts [
81
81
  params[:scheme],
82
82
  '://',
83
- params[:host]
83
+ params[:host],
84
84
  '/',
85
85
  params[:path],
86
86
  '?',
@@ -95,9 +95,21 @@ client.get query: {},
95
95
  instrumentor: Logger
96
96
  ```
97
97
 
98
- For more detailed configuration options, check out the [excon README][excon].
98
+ ### Miscellaneous
99
99
 
100
- [aws]: http://aws.amazon.com/
101
- [excon]: https://github.com/geemus/excon
102
- [sign]: http://docs.amazonwebservices.com/general/latest/gr/signature-version-2.html
103
- [jeff]: http://f.cl.ly/items/0a3R3J0k1R2f423k1q2l/jeff.jpg
100
+ HTTP connections are persistent.
101
+
102
+ By default, Jeff will retry failed requests 4 times.
103
+
104
+ For more detailed configuration options, check out [excon][excon].
105
+
106
+ ## Compatibility
107
+
108
+ **Jeff** is Ruby 1.9-compatible. It is tested against [MRI 1.9.3 plus JRuby and
109
+ Rubinius in 1.9 mode][travis].
110
+
111
+ [aws]: http://aws.amazon.com/
112
+ [excon]: https://github.com/geemus/excon
113
+ [sign]: http://docs.amazonwebservices.com/general/latest/gr/signature-version-2.html
114
+ [jeff]: http://f.cl.ly/items/0a3R3J0k1R2f423k1q2l/jeff.jpg
115
+ [travis]: http://travis-ci.org/#!/hakanensari/jeff
@@ -19,13 +19,14 @@ module Jeff
19
19
 
20
20
  # Returns an Excon::Connection.
21
21
  def connection
22
- @connection ||= Excon.new endpoint, :headers => default_headers
22
+ @connection ||= Excon.new endpoint, headers: default_headers,
23
+ idempotent: true
23
24
  end
24
25
 
25
26
  # Returns the Hash default request parameters.
26
27
  def default_params
27
28
  self.class.params.reduce({}) do |a, (k, v)|
28
- a.update k => (v.is_a?(Proc) ? instance_eval(&v) : v)
29
+ a.update k => (v.is_a?(Proc) ? instance_exec(&v) : v)
29
30
  end
30
31
  end
31
32
 
@@ -138,10 +139,10 @@ module Jeff
138
139
  # Returns the Hash parameters.
139
140
  def params(hsh = nil)
140
141
  @params ||= {
141
- 'AWSAccessKeyId' => Proc.new { key },
142
+ 'AWSAccessKeyId' => -> { key },
142
143
  'SignatureVersion' => '2',
143
144
  'SignatureMethod' => 'HmacSHA256',
144
- 'Timestamp' => Proc.new { Time.now.utc.iso8601 }
145
+ 'Timestamp' => -> { Time.now.utc.iso8601 }
145
146
  }
146
147
  @params.update hsh if hsh
147
148
 
@@ -1,3 +1,3 @@
1
1
  module Jeff
2
- VERSION = '0.2.2'
2
+ VERSION = '0.2.4'
3
3
  end
@@ -137,5 +137,23 @@ describe Jeff do
137
137
  end
138
138
  end
139
139
  end
140
+
141
+ context 'given a failed request' do
142
+ before do
143
+ has_run = false
144
+ Excon.stub({ method: :get }) do |params|
145
+ if has_run
146
+ { status: 200 }
147
+ else
148
+ has_run = true
149
+ raise Excon::Errors::SocketError.new Exception.new 'Mock Error'
150
+ end
151
+ end
152
+ end
153
+
154
+ it 'should retry' do
155
+ client.get(mock: true).status.should be 200
156
+ end
157
+ end
140
158
  end
141
159
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jeff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.4
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-07-04 00:00:00.000000000 Z
12
+ date: 2012-07-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: excon
@@ -122,12 +122,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
122
122
  - - ! '>='
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
+ segments:
126
+ - 0
127
+ hash: 13761434509478082
125
128
  required_rubygems_version: !ruby/object:Gem::Requirement
126
129
  none: false
127
130
  requirements:
128
131
  - - ! '>='
129
132
  - !ruby/object:Gem::Version
130
133
  version: '0'
134
+ segments:
135
+ - 0
136
+ hash: 13761434509478082
131
137
  requirements: []
132
138
  rubyforge_project:
133
139
  rubygems_version: 1.8.23