verse-ruby 0.1.4 → 0.2.0

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: 66aa0cfef339a02f2eddb35464aebd1dddae8cb7
4
- data.tar.gz: 2e9942581e183912293c1472418c3c8a302b2020
3
+ metadata.gz: 3ca14379a3dab2da96706c1f8a1c4725cb39ff6c
4
+ data.tar.gz: 0d6edc678b1a64bc3295dc1a45992ed5ca0a19dc
5
5
  SHA512:
6
- metadata.gz: 154fabae3d19ec5f2ad86a27e02aa0f53cfbb20e2bbab84db7e3bb6abc391d16d0e432f25a1e3549a7d31bbd2023eabf59c683ecc14c18dff7cc5ad139641044
7
- data.tar.gz: 0d5263667f18a33102fbc962cc9668d74e9bab60bad6d78c0d0c54bd8637259f693a56bfffb6ea652965386b8b26c2393c2f3c81197dbc278167719347e4f1a9
6
+ metadata.gz: 2589019d44b94ab2518a5b151f74fafea6587a6986a55be1ab3cae775858d67d9af818dbe2b54086d7b93ac4c21858f6b24a436788fa243dd4598e4411ccb8a7
7
+ data.tar.gz: 2cd730c2766a328704c4825fb7f31b7fbcd3ed506dfe20beece494146d8423b40ff38c4652bda1c071428f9cfaeec7c87d46373ce406f4e8fc01acbdb1391e70
data/lib/verse.rb CHANGED
@@ -40,7 +40,7 @@ module Verse
40
40
  c.use Faraday::Request::UrlEncoded
41
41
 
42
42
  # Response
43
- c.use Her::Middleware::DefaultParseJSON
43
+ c.use Her::Middleware::SecondLevelParseJSON
44
44
 
45
45
  # Adapter
46
46
  c.use Faraday::Adapter::NetHttp
data/lib/verse/auth.rb CHANGED
@@ -3,5 +3,6 @@ module Verse
3
3
  end
4
4
  end
5
5
 
6
- require 'verse/auth/core'
7
- require 'verse/auth/confirmable'
6
+ require 'verse/auth/email'
7
+ require 'verse/auth/session'
8
+ require 'verse/auth/user'
@@ -1,4 +1,4 @@
1
- class Verse::Auth::Confirmable::Email < Verse::Contactable::Email
1
+ class Verse::Auth::Email < Verse::Contactable::Email
2
2
  attributes :confirmation_token, :confirmed_at
3
3
 
4
4
  custom_patch :confirm
@@ -0,0 +1,7 @@
1
+ class Verse::Auth::Session < Verse::Resource
2
+ attributes :login, :password, :jwt
3
+
4
+ def form_attributes
5
+ [:login, :password]
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ class Verse::Auth::User < Verse::Core::Person
2
+ alias_attribute :admin_id, :id
3
+
4
+ attributes :name, :username, :email, :password, :password_confirmation
5
+
6
+ def form_attributes
7
+ [:name, :username, :email, :password, :password_confirmation]
8
+ end
9
+ end
@@ -1,10 +1,14 @@
1
1
  require 'active_support'
2
2
  require 'jwt'
3
3
 
4
+ require 'verse/controller/strong_params'
5
+
4
6
  module Verse
5
7
  module Controller
6
8
  extend ActiveSupport::Concern
7
9
 
10
+ include Verse::Controller::StrongParams
11
+
8
12
  included do
9
13
  before_action :set_user_token
10
14
  helper_method :current_user
@@ -13,9 +17,9 @@ module Verse
13
17
  def current_user
14
18
  if Verse.user_token
15
19
  data = JWT.decode(Verse.user_token, nil, false)[0]['data']
16
- Verse::Auth::Core::User.new(
20
+ Verse::Auth::User.new(
17
21
  id: data['user_id'],
18
- display_name: data['display_name'],
22
+ name: data['name'],
19
23
  email: data['email'],
20
24
  username: data['username']
21
25
  )
@@ -0,0 +1,37 @@
1
+ module Verse
2
+ module Controller
3
+ module StrongParams
4
+ # Verse::Auth / Verse::Contactable
5
+ def email_attributes; end
6
+
7
+ # Verse::Auth
8
+ def session_attributes
9
+ params.require(:session).permit(:login, :password)
10
+ end
11
+
12
+ def user_attributes
13
+ params.require(:user).permit(:name, :username, :email, :password, :password_confirmation)
14
+ end
15
+
16
+ # Verse::Core
17
+ def entity_attributes
18
+ params.require(:entity).permit(:name, :slug, { admins_attributes: [:admin_id] })
19
+ end
20
+
21
+ def person_attributes
22
+ params.require(:person).permit(:name, :slug, { admins_attributes: [:admin_id] })
23
+ end
24
+
25
+ def business_attributes
26
+ params.require(:business).permit(:name, :slug, { admins_attributes: [:admin_id] })
27
+ end
28
+
29
+ def household_attributes
30
+ params.require(:household).permit(:name, { admins_attributes: [:admin_id] })
31
+ end
32
+
33
+ # Verse::Relatable
34
+ def admin_attributes; end
35
+ end
36
+ end
37
+ end
data/lib/verse/core.rb CHANGED
@@ -5,3 +5,5 @@ end
5
5
 
6
6
  require 'verse/core/entity'
7
7
  require 'verse/core/person'
8
+ require 'verse/core/business'
9
+ require 'verse/core/household'
@@ -0,0 +1,2 @@
1
+ class Verse::Core::Business < Verse::Core::Entity
2
+ end
@@ -1,3 +1,11 @@
1
1
  class Verse::Core::Entity < Verse::Resource
2
- attributes :slug
2
+ attributes :name, :slug
3
+
4
+ has_many :admins, class_name: 'Verse::Auth::User'
5
+ has_many :owners, class_name: 'Verse::Core::Entity'
6
+ has_many :members, class_name: 'Verse::Core::Person'
7
+
8
+ def form_attributes
9
+ [:name, :slug, admins: [:admin_id]]
10
+ end
3
11
  end
@@ -0,0 +1,5 @@
1
+ class Verse::Core::Household < Verse::Core::Entity
2
+ def form_attributes
3
+ [:name, admins: [:admin_id]]
4
+ end
5
+ end
@@ -1,2 +1,14 @@
1
1
  class Verse::Core::Person < Verse::Core::Entity
2
+ has_many :entities, class_name: 'Verse::Core::Entity'
3
+ has_many :businesses, class_name: 'Verse::Core::Business'
4
+ has_many :households, class_name: 'Verse::Core::Household'
5
+ has_many :people, class_name: 'Verse::Core::Person'
6
+
7
+ # has_many :administrated_entities
8
+
9
+ # has_many :administrated_businesses
10
+
11
+ # has_many :administrated_people
12
+
13
+ # has_many :administrated_softwares
2
14
  end
@@ -0,0 +1,6 @@
1
+ module Verse
2
+ module Graph
3
+ end
4
+ end
5
+
6
+ require 'verse/relatable'
data/lib/verse/models.rb CHANGED
@@ -2,3 +2,4 @@ require 'verse/resource'
2
2
  require 'verse/core'
3
3
  require 'verse/contactable'
4
4
  require 'verse/auth'
5
+ require 'verse/graph'
@@ -0,0 +1,6 @@
1
+ module Verse
2
+ module Relatable
3
+ end
4
+ end
5
+
6
+ require 'verse/relatable/admin'
@@ -0,0 +1,5 @@
1
+ class Verse::Relatable::Admin < Verse::Resource
2
+ attributes :admin_id, :resource_id
3
+ belongs_to :admin, class_name: 'Verse::Core::Person'
4
+ belongs_to :resource, class_name: 'Verse::Core::Entity'
5
+ end
@@ -4,9 +4,16 @@ module Verse
4
4
 
5
5
  include_root_in_json true
6
6
 
7
+ def specific
8
+ type = attributes[:type]
9
+ if type
10
+ "Verse::#{type}".constantize.new(attributes)
11
+ end
12
+ end
13
+
7
14
  # Demodulizes model_name e.g. for use in route helpers.
8
- def self.model_name
9
- ActiveModel::Name.new(self, nil, name.split('::').last)
15
+ def self.model_name
16
+ ActiveModel::Name.new(self, nil, name.split('::').last)
10
17
  end
11
18
  end
12
19
  end
data/lib/verse/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Verse
2
- VERSION = "0.1.4"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: verse-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thom Bruce
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-09-24 00:00:00.000000000 Z
11
+ date: 2017-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -188,19 +188,23 @@ files:
188
188
  - lib/verse-ruby.rb
189
189
  - lib/verse.rb
190
190
  - lib/verse/auth.rb
191
- - lib/verse/auth/confirmable.rb
192
- - lib/verse/auth/confirmable/email.rb
193
- - lib/verse/auth/core.rb
194
- - lib/verse/auth/core/session.rb
195
- - lib/verse/auth/core/user.rb
191
+ - lib/verse/auth/email.rb
192
+ - lib/verse/auth/session.rb
193
+ - lib/verse/auth/user.rb
196
194
  - lib/verse/configuration.rb
197
195
  - lib/verse/contactable.rb
198
196
  - lib/verse/contactable/email.rb
199
197
  - lib/verse/controller.rb
198
+ - lib/verse/controller/strong_params.rb
200
199
  - lib/verse/core.rb
200
+ - lib/verse/core/business.rb
201
201
  - lib/verse/core/entity.rb
202
+ - lib/verse/core/household.rb
202
203
  - lib/verse/core/person.rb
204
+ - lib/verse/graph.rb
203
205
  - lib/verse/models.rb
206
+ - lib/verse/relatable.rb
207
+ - lib/verse/relatable/admin.rb
204
208
  - lib/verse/resource.rb
205
209
  - lib/verse/version.rb
206
210
  - verse-ruby.gemspec
@@ -1,8 +0,0 @@
1
- module Verse
2
- module Auth
3
- module Confirmable
4
- end
5
- end
6
- end
7
-
8
- require 'verse/auth/confirmable/email'
@@ -1,9 +0,0 @@
1
- module Verse
2
- module Auth
3
- module Core
4
- end
5
- end
6
- end
7
-
8
- require 'verse/auth/core/session'
9
- require 'verse/auth/core/user'
@@ -1,3 +0,0 @@
1
- class Verse::Auth::Core::Session < Verse::Resource
2
- attributes :login, :password, :jwt
3
- end
@@ -1,3 +0,0 @@
1
- class Verse::Auth::Core::User < Verse::Resource
2
- attributes :display_name, :username, :email, :password, :password_confirmation
3
- end