ey_api_hmac 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/ey_api_hmac.rb
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'ey_api_hmac/base_connection'
|
2
|
+
|
3
|
+
module EY
|
4
|
+
module ApiHMAC
|
5
|
+
class AuthedConnection < BaseConnection
|
6
|
+
attr_reader :auth_id, :auth_key
|
7
|
+
|
8
|
+
def initialize(auth_id, auth_key, user_agent = nil)
|
9
|
+
@auth_id = auth_id
|
10
|
+
@auth_key = auth_key
|
11
|
+
super(user_agent)
|
12
|
+
end
|
13
|
+
|
14
|
+
protected
|
15
|
+
|
16
|
+
def client
|
17
|
+
bak = self.backend
|
18
|
+
#damn you scope!
|
19
|
+
auth_id_arg = auth_id
|
20
|
+
auth_key_arg = auth_key
|
21
|
+
@client ||= Rack::Client.new do
|
22
|
+
use EY::ApiHMAC::ApiAuth::Client, auth_id_arg, auth_key_arg
|
23
|
+
run bak
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -5,11 +5,8 @@ require 'time'
|
|
5
5
|
module EY
|
6
6
|
module ApiHMAC
|
7
7
|
class BaseConnection
|
8
|
-
attr_reader :auth_id, :auth_key
|
9
8
|
|
10
|
-
def initialize(
|
11
|
-
@auth_id = auth_id
|
12
|
-
@auth_key = auth_key
|
9
|
+
def initialize(user_agent = nil)
|
13
10
|
@standard_headers = {
|
14
11
|
'Accept' => 'application/json',
|
15
12
|
'HTTP_DATE' => Time.now.httpdate,
|
@@ -41,7 +38,10 @@ module EY
|
|
41
38
|
end
|
42
39
|
|
43
40
|
class UnknownError < StandardError
|
41
|
+
attr_reader :response
|
42
|
+
|
44
43
|
def initialize(response)
|
44
|
+
@response = response
|
45
45
|
super("unknown error(#{response.status}): #{response.body}")
|
46
46
|
end
|
47
47
|
end
|
@@ -75,11 +75,7 @@ module EY
|
|
75
75
|
|
76
76
|
def client
|
77
77
|
bak = self.backend
|
78
|
-
#damn you scope!
|
79
|
-
auth_id_arg = auth_id
|
80
|
-
auth_key_arg = auth_key
|
81
78
|
@client ||= Rack::Client.new do
|
82
|
-
use EY::ApiHMAC::ApiAuth::Client, auth_id_arg, auth_key_arg
|
83
79
|
run bak
|
84
80
|
end
|
85
81
|
end
|
data/lib/ey_api_hmac/version.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
require 'ey_api_hmac'
|
3
3
|
|
4
|
-
describe EY::ApiHMAC::
|
4
|
+
describe EY::ApiHMAC::AuthedConnection do
|
5
5
|
before do
|
6
|
-
@connection = EY::ApiHMAC::
|
6
|
+
@connection = EY::ApiHMAC::AuthedConnection.new("123", "456")
|
7
7
|
end
|
8
8
|
describe "handle_error" do
|
9
9
|
describe "on 500" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ey_api_hmac
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-12-15 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack-client
|
16
|
-
requirement: &
|
16
|
+
requirement: &70125212725320 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70125212725320
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: json
|
27
|
-
requirement: &
|
27
|
+
requirement: &70125212724900 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70125212724900
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &70125212724480 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70125212724480
|
47
47
|
description: basic wrapper for rack-client + middlewares for HMAC auth + helpers for
|
48
48
|
SSO auth
|
49
49
|
email:
|
@@ -62,11 +62,12 @@ files:
|
|
62
62
|
- ey_api_hmac.gemspec
|
63
63
|
- lib/ey_api_hmac.rb
|
64
64
|
- lib/ey_api_hmac/api_auth.rb
|
65
|
+
- lib/ey_api_hmac/authed_connection.rb
|
65
66
|
- lib/ey_api_hmac/base_connection.rb
|
66
67
|
- lib/ey_api_hmac/sso.rb
|
67
68
|
- lib/ey_api_hmac/version.rb
|
68
69
|
- spec/api_auth_spec.rb
|
69
|
-
- spec/
|
70
|
+
- spec/authed_connection_spec.rb
|
70
71
|
- spec/spec_helper.rb
|
71
72
|
- spec/sso_spec.rb
|
72
73
|
homepage: ''
|
@@ -89,12 +90,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
90
|
version: '0'
|
90
91
|
requirements: []
|
91
92
|
rubyforge_project: ey_api_hmac
|
92
|
-
rubygems_version: 1.8.
|
93
|
+
rubygems_version: 1.8.10
|
93
94
|
signing_key:
|
94
95
|
specification_version: 3
|
95
96
|
summary: HMAC Rack basic implementation for Engine Yard services
|
96
97
|
test_files:
|
97
98
|
- spec/api_auth_spec.rb
|
98
|
-
- spec/
|
99
|
+
- spec/authed_connection_spec.rb
|
99
100
|
- spec/spec_helper.rb
|
100
101
|
- spec/sso_spec.rb
|