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 +16 -32
- data/jeff.gemspec +2 -1
- data/lib/jeff.rb +6 -4
- data/lib/jeff/version.rb +1 -1
- data/spec/jeff_spec.rb +7 -11
- metadata +3 -20
- data/Guardfile +0 -6
data/README.md
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# Jeff
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
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
|
-
|
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
|
-
|
19
|
+
Set endpoint and credentials.
|
20
20
|
|
21
21
|
```ruby
|
22
|
-
|
23
|
-
params 'Service' => 'Service',
|
24
|
-
'Tag' => -> { tag }
|
25
|
-
|
26
|
-
attr_accessor :tag
|
27
|
-
end
|
28
|
-
```
|
22
|
+
client = Client.new
|
29
23
|
|
30
|
-
|
31
|
-
|
32
|
-
|
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
|
-
|
29
|
+
Request.
|
41
30
|
|
42
31
|
```ruby
|
43
|
-
client.
|
44
|
-
body: 'data'
|
32
|
+
client.get query: { 'Foo' => 'Bar' }
|
45
33
|
```
|
46
34
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
[
|
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
|
data/jeff.gemspec
CHANGED
@@ -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
|
data/lib/jeff.rb
CHANGED
@@ -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:
|
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.
|
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
|
-
[
|
126
|
+
[
|
127
|
+
connection.connection[:host],
|
128
|
+
connection.connection[:port]
|
129
|
+
].join ':'
|
128
130
|
end
|
129
131
|
|
130
132
|
def connection_path
|
data/lib/jeff/version.rb
CHANGED
data/spec/jeff_spec.rb
CHANGED
@@ -134,23 +134,19 @@ describe Jeff do
|
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
137
|
-
context 'given
|
137
|
+
context 'given an HTTP status error' do
|
138
138
|
before do
|
139
|
-
|
140
|
-
|
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
|
153
|
-
|
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.
|
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-
|
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: '
|
93
|
+
version: '1.9'
|
111
94
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
95
|
none: false
|
113
96
|
requirements:
|