jeff 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,14 +1,14 @@
1
1
  # Jeff
2
2
 
3
- **Jeff** is a light-weight module that mixes in client behaviour for
4
- [Amazon Web Services (AWS)][aws]. It wraps [Excon][excon] and implements
5
- [Signature Version 2][sign].
3
+ [![travis][stat]][trav]
4
+
5
+ **Jeff** adds [authentication][sign] behaviour for some [Amazon Web Services (AWS)][aws].
6
6
 
7
7
  ![jeff][jeff]
8
8
 
9
9
  ## Usage
10
10
 
11
- Build a hypothetical client.
11
+ Mix in.
12
12
 
13
13
  ```ruby
14
14
  class Client
@@ -16,40 +16,24 @@ class Client
16
16
  end
17
17
  ```
18
18
 
19
- Customise default headers and parameters.
19
+ Set endpoint and credentials.
20
20
 
21
21
  ```ruby
22
- class Client
23
- params 'Service' => 'Service',
24
- 'Tag' => -> { tag }
25
-
26
- attr_accessor :tag
27
- end
28
- ```
22
+ client = Client.new
29
23
 
30
- Set AWS endpoint and credentials.
31
-
32
- ```ruby
33
- client = Client.new.tap do |config|
34
- config.endpoint = 'http://example.com/path'
35
- config.key = 'key'
36
- config.secret = 'secret'
37
- end
24
+ client.endpoint = 'http://example.com/path'
25
+ client.key = 'key'
26
+ client.secret = 'secret'
38
27
  ```
39
28
 
40
- You should now be able to access the endpoint.
29
+ Request.
41
30
 
42
31
  ```ruby
43
- client.post query: { 'Foo' => 'Bar' },
44
- body: 'data'
32
+ client.get query: { 'Foo' => 'Bar' }
45
33
  ```
46
34
 
47
- ## Compatibility
48
-
49
- **Jeff** is compatible with [Ruby 1.9 flavours][travis].
50
-
51
- [aws]: http://aws.amazon.com/
52
- [excon]: https://github.com/geemus/excon
53
- [jeff]: http://f.cl.ly/items/0a3R3J0k1R2f423k1q2l/jeff.jpg
54
- [sign]: http://docs.amazonwebservices.com/general/latest/gr/signature-version-2.html
55
- [travis]: http://travis-ci.org/#!/hakanensari/jeff
35
+ [stat]: https://secure.travis-ci.org/papercavalier/jeff.png
36
+ [trav]: http://travis-ci.org/papercavalier/jeff
37
+ [aws]: http://aws.amazon.com/
38
+ [jeff]: http://f.cl.ly/items/0a3R3J0k1R2f423k1q2l/jeff.jpg
39
+ [sign]: http://docs.amazonwebservices.com/general/latest/gr/signature-version-2.html
@@ -17,7 +17,8 @@ Gem::Specification.new do |gem|
17
17
  gem.version = Jeff::VERSION
18
18
 
19
19
  gem.add_dependency 'excon', '~> 0.16.0'
20
- gem.add_development_dependency 'guard-rspec'
21
20
  gem.add_development_dependency 'rake'
22
21
  gem.add_development_dependency 'rspec'
22
+
23
+ gem.required_ruby_version = '>= 1.9'
23
24
  end
@@ -41,8 +41,7 @@ module Jeff
41
41
 
42
42
  # Internal: Returns an Excon::Connection.
43
43
  def connection
44
- @connection ||= Excon.new endpoint, headers: headers,
45
- idempotent: true
44
+ @connection ||= Excon.new endpoint, headers: headers, expects: 200
46
45
  end
47
46
 
48
47
  # Internal: Gets the String AWS endpoint.
@@ -73,7 +72,7 @@ module Jeff
73
72
  # Internal: Returns the Hash default request parameters.
74
73
  def params
75
74
  self.class.params.reduce({}) do |a, (k, v)|
76
- a.update k => (v.is_a?(Proc) ? instance_exec(&v) : v)
75
+ a.update k => (v.respond_to?(:call) ? instance_exec(&v) : v)
77
76
  end
78
77
  end
79
78
 
@@ -124,7 +123,10 @@ module Jeff
124
123
  end
125
124
 
126
125
  def connection_host
127
- [connection.connection[:host], connection.connection[:port]].join ':'
126
+ [
127
+ connection.connection[:host],
128
+ connection.connection[:port]
129
+ ].join ':'
128
130
  end
129
131
 
130
132
  def connection_path
@@ -1,3 +1,3 @@
1
1
  module Jeff
2
- VERSION = '0.4.1'
2
+ VERSION = '0.4.2'
3
3
  end
@@ -134,23 +134,19 @@ describe Jeff do
134
134
  end
135
135
  end
136
136
 
137
- context 'given a temporary failure' do
137
+ context 'given an HTTP status error' do
138
138
  before do
139
- has_run = false
140
- Excon.stub({ method: :get }) do |params|
141
- if has_run
142
- { body: 'ok', status: 200 }
143
- else
144
- has_run = true
145
- raise Excon::Errors::SocketError.new Exception.new 'Mock Error'
146
- end
139
+ Excon.stub({ method: :get }) do
140
+ { status: 503 }
147
141
  end
148
142
  end
149
143
 
150
144
  after { Excon.stubs.clear }
151
145
 
152
- it 'should retry' do
153
- client.get(mock: true).body.should eq 'ok'
146
+ it "should raise an error" do
147
+ expect {
148
+ client.get mock: true
149
+ }.to raise_error Excon::Errors::HTTPStatusError
154
150
  end
155
151
  end
156
152
  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.4.1
4
+ version: 0.4.2
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-08-22 00:00:00.000000000 Z
12
+ date: 2012-08-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: excon
@@ -27,22 +27,6 @@ dependencies:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
29
  version: 0.16.0
30
- - !ruby/object:Gem::Dependency
31
- name: guard-rspec
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '0'
38
- type: :development
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
46
30
  - !ruby/object:Gem::Dependency
47
31
  name: rake
48
32
  requirement: !ruby/object:Gem::Requirement
@@ -85,7 +69,6 @@ files:
85
69
  - .gitignore
86
70
  - .travis.yml
87
71
  - Gemfile
88
- - Guardfile
89
72
  - LICENSE
90
73
  - README.md
91
74
  - Rakefile
@@ -107,7 +90,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
90
  requirements:
108
91
  - - ! '>='
109
92
  - !ruby/object:Gem::Version
110
- version: '0'
93
+ version: '1.9'
111
94
  required_rubygems_version: !ruby/object:Gem::Requirement
112
95
  none: false
113
96
  requirements:
data/Guardfile DELETED
@@ -1,6 +0,0 @@
1
- guard 'rspec', :cli => '-fd' do
2
- notification :off
3
- watch(%r{^spec/.+_spec\.rb$})
4
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
5
- watch('spec/spec_helper.rb') { 'spec' }
6
- end