hobby-auth 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/hobby-auth.gemspec +7 -0
- data/lib/hobby/auth.rb +6 -1
- data/spec/http_spec.rb +1 -1
- data/spec/seed_users.rb +5 -3
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a695f776bd20babf3742458ff066a82b5afafe90
|
4
|
+
data.tar.gz: 625b7448fe38eb6e59abb4b29f6dac9f75113694
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb4684a95506dead682cb9b696f41f2a980723e69aa420dcc9d9b188135fdbc4aa80fffd1e9a31e965eae2f04e082809ccde27a98bcd33827a12d97638fa1ace
|
7
|
+
data.tar.gz: e72b29085e987c5c16ce5a83b2e0839baa3f716a0ecde1cf4bec877e10f0ed7eb5672cecbb762958a8528a31a58063d9ce2119d53ae74870410fe657e0ad6e09
|
data/Gemfile
CHANGED
data/hobby-auth.gemspec
ADDED
data/lib/hobby/auth.rb
CHANGED
@@ -4,7 +4,7 @@ module Hobby
|
|
4
4
|
Module.new do
|
5
5
|
define_singleton_method :included do |app|
|
6
6
|
user_models.each do |user_model|
|
7
|
-
app.define_singleton_method user_model
|
7
|
+
app.define_singleton_method short_name_of user_model do |route|
|
8
8
|
action = route.action
|
9
9
|
route.action = -> do
|
10
10
|
if user = (user_model.find_by_token env['HTTP_AUTHORIZATION'])
|
@@ -18,6 +18,11 @@ module Hobby
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
21
|
+
|
22
|
+
def self.short_name_of user_model
|
23
|
+
user_model.name.split('::').last.downcase
|
24
|
+
end
|
25
|
+
|
21
26
|
attr_reader :user
|
22
27
|
end
|
23
28
|
end
|
data/spec/http_spec.rb
CHANGED
data/spec/seed_users.rb
CHANGED
@@ -14,10 +14,12 @@ end
|
|
14
14
|
class Getter < User
|
15
15
|
end
|
16
16
|
|
17
|
-
|
17
|
+
module Namespaced
|
18
|
+
class Poster < User
|
19
|
+
end
|
18
20
|
end
|
19
21
|
|
20
22
|
Getter.new 'first valid getter token'
|
21
23
|
Getter.new 'second valid getter token'
|
22
|
-
Poster.new 'first valid poster token'
|
23
|
-
Poster.new 'second valid poster token'
|
24
|
+
Namespaced::Poster.new 'first valid poster token'
|
25
|
+
Namespaced::Poster.new 'second valid poster token'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hobby-auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anatoly Chernow
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -18,6 +18,7 @@ extra_rdoc_files: []
|
|
18
18
|
files:
|
19
19
|
- ".gitignore"
|
20
20
|
- Gemfile
|
21
|
+
- hobby-auth.gemspec
|
21
22
|
- lib/hobby/auth.rb
|
22
23
|
- spec/helper.rb
|
23
24
|
- spec/http/getter.yml
|