exvo-auth 0.7.3 → 0.7.4

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.3
1
+ 0.7.4
data/exvo-auth.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{exvo-auth}
8
- s.version = "0.7.3"
8
+ s.version = "0.7.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jacek Becela"]
@@ -28,6 +28,7 @@ Gem::Specification.new do |s|
28
28
  "lib/exvo_auth/autonomous/base.rb",
29
29
  "lib/exvo_auth/autonomous/cache.rb",
30
30
  "lib/exvo_auth/autonomous/consumer.rb",
31
+ "lib/exvo_auth/autonomous/http.rb",
31
32
  "lib/exvo_auth/autonomous/provider.rb",
32
33
  "lib/exvo_auth/config.rb",
33
34
  "lib/exvo_auth/controllers/base.rb",
data/lib/exvo-auth.rb CHANGED
@@ -24,6 +24,7 @@ module ExvoAuth
24
24
  autoload :Provider, 'exvo_auth/autonomous/provider'
25
25
  autoload :Cache, 'exvo_auth/autonomous/cache'
26
26
  autoload :Auth, 'exvo_auth/autonomous/auth'
27
+ autoload :Http, 'exvo_auth/autonomous/http'
27
28
  end
28
29
 
29
30
  module OAuth2
@@ -1,6 +1,15 @@
1
1
  class ExvoAuth::Autonomous::Auth
2
- include HTTParty
3
-
4
- base_uri(ExvoAuth::Config.host)
5
- basic_auth(ExvoAuth::Config.client_id, ExvoAuth::Config.client_secret)
2
+ include ExvoAuth::Autonomous::Http
3
+
4
+ def base_uri
5
+ ExvoAuth::Config.host
6
+ end
7
+
8
+ def username
9
+ ExvoAuth::Config.client_id
10
+ end
11
+
12
+ def password
13
+ ExvoAuth::Config.client_secret
14
+ end
6
15
  end
@@ -20,6 +20,6 @@ class ExvoAuth::Autonomous::Base
20
20
 
21
21
  # Makes testing easy
22
22
  def auth
23
- ExvoAuth::Autonomous::Auth
23
+ ExvoAuth::Autonomous::Auth.new
24
24
  end
25
25
  end
@@ -1,46 +1,21 @@
1
1
  class ExvoAuth::Autonomous::Consumer < ExvoAuth::Autonomous::Base
2
+ include ExvoAuth::Autonomous::Http
3
+
2
4
  def initialize(params = {})
3
5
  super
4
6
  validate_params!(:provider_id)
5
7
  end
6
-
7
- def get(*args)
8
- http.get(*args)
9
- end
10
-
11
- def post(*args)
12
- http.post(*args)
13
- end
14
-
15
- def put(*args)
16
- http.put(*args)
17
- end
18
-
19
- def delete(*args)
20
- http.delete(*args)
21
- end
22
-
23
- def head(*args)
24
- http.head(*args)
25
- end
26
-
27
- def options(*args)
28
- http.options(*args)
29
- end
30
8
 
31
- protected
9
+ def base_uri
10
+ authorization["url"]
11
+ end
32
12
 
33
- # Url and Token set on each request so expired authorization will cause re-authorization.
34
- def http
35
- basement.base_uri(authorization["url"])
36
- basement.basic_auth(params[:client_id], authorization["access_token"])
37
- basement
13
+ def username
14
+ params[:client_id]
38
15
  end
39
16
 
40
- def basement
41
- @basement ||= Class.new do
42
- include HTTParty
43
- end
17
+ def password
18
+ authorization["access_token"]
44
19
  end
45
20
 
46
21
  def authorization
@@ -0,0 +1,39 @@
1
+ module ExvoAuth::Autonomous::Http
2
+ def get(*args)
3
+ http.get(*args)
4
+ end
5
+
6
+ def post(*args)
7
+ http.post(*args)
8
+ end
9
+
10
+ def put(*args)
11
+ http.put(*args)
12
+ end
13
+
14
+ def delete(*args)
15
+ http.delete(*args)
16
+ end
17
+
18
+ def head(*args)
19
+ http.head(*args)
20
+ end
21
+
22
+ def options(*args)
23
+ http.options(*args)
24
+ end
25
+
26
+ protected
27
+
28
+ def http
29
+ basement.base_uri(base_uri)
30
+ basement.basic_auth(username, password)
31
+ basement
32
+ end
33
+
34
+ def basement
35
+ @basement ||= Class.new do
36
+ include HTTParty
37
+ end
38
+ end
39
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 7
8
- - 3
9
- version: 0.7.3
8
+ - 4
9
+ version: 0.7.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jacek Becela
@@ -94,6 +94,7 @@ files:
94
94
  - lib/exvo_auth/autonomous/base.rb
95
95
  - lib/exvo_auth/autonomous/cache.rb
96
96
  - lib/exvo_auth/autonomous/consumer.rb
97
+ - lib/exvo_auth/autonomous/http.rb
97
98
  - lib/exvo_auth/autonomous/provider.rb
98
99
  - lib/exvo_auth/config.rb
99
100
  - lib/exvo_auth/controllers/base.rb