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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5496a07b70f304e210d3df33809f22fdf8e34210
4
- data.tar.gz: 18d862103f80a6839f946df723937cf623a83eac
3
+ metadata.gz: a695f776bd20babf3742458ff066a82b5afafe90
4
+ data.tar.gz: 625b7448fe38eb6e59abb4b29f6dac9f75113694
5
5
  SHA512:
6
- metadata.gz: 8ab1798d251e0d244a59af1c00cc037641ea06d0875ef3c30510ea9d793717c883a12e708d1db41c52506d26cd7399af1a3a7c79892a858c186dc108393bd30c
7
- data.tar.gz: 99e5028ac1329fc1b00e20bf10eb4f7331418d56fdc56b6369fcd24fdb28a20131671342cd8470e8d5098e7a82ebb94b50b22fc15b9ecea1c89357156f37271a
6
+ metadata.gz: cb4684a95506dead682cb9b696f41f2a980723e69aa420dcc9d9b188135fdbc4aa80fffd1e9a31e965eae2f04e082809ccde27a98bcd33827a12d97638fa1ace
7
+ data.tar.gz: e72b29085e987c5c16ce5a83b2e0839baa3f716a0ecde1cf4bec877e10f0ed7eb5672cecbb762958a8528a31a58063d9ce2119d53ae74870410fe657e0ad6e09
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'hobby-devtools', '>=0.0.5'
3
+ gem 'hobby-devtools', '>=0.0.7'
@@ -0,0 +1,7 @@
1
+ Gem::Specification.new do |g|
2
+ g.name = 'hobby-auth'
3
+ g.files = `git ls-files`.split($/)
4
+ g.version = '0.0.1'
5
+ g.summary = 'Authorize Hobby routes'
6
+ g.authors = ['Anatoly Chernow']
7
+ end
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.name.downcase do |route|
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
@@ -6,7 +6,7 @@ Hobby::Devtools::RSpec.describe do
6
6
  app do
7
7
  Class.new do
8
8
  include Hobby
9
- include Hobby::Auth[Getter, Poster]
9
+ include Hobby::Auth[Getter, Namespaced::Poster]
10
10
 
11
11
  getter get { 'oh my get' }
12
12
  poster post { "the user's token is #{user.token}" }
data/spec/seed_users.rb CHANGED
@@ -14,10 +14,12 @@ end
14
14
  class Getter < User
15
15
  end
16
16
 
17
- class Poster < User
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.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: 2016-12-26 00:00:00.000000000 Z
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