arkaan 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/arkaan.rb +11 -0
- data/lib/arkaan/account.rb +42 -0
- data/lib/arkaan/concerns.rb +7 -0
- data/lib/arkaan/concerns/sluggable.rb +17 -0
- data/lib/arkaan/permissions.rb +10 -0
- data/lib/arkaan/permissions/category.rb +11 -0
- data/lib/arkaan/permissions/group.rb +18 -0
- data/lib/arkaan/permissions/right.rb +15 -0
- metadata +191 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8c1ec575ec3457e7920d4ba8adc017667cc6703e
|
4
|
+
data.tar.gz: 977526cae9348564d8e3e14674c73646a7b522a5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 28c7cecdc80476e4e624d7b5cbc37a8d12456ef0667a4c01586efcc4146068bc2930f81db9c8a3bb8415930f7e73e44bc8272cfa394246581a668b28c6895d81
|
7
|
+
data.tar.gz: 0126a61e8bc40fc9e8b4172084515a82f08720380f01b49fb1cad9aae2c27de6790939b9a187be620dae92c9d71774f96aceb036496c0cb3009e0acab2b6e874
|
data/lib/arkaan.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'mongoid'
|
2
|
+
require 'active_model'
|
3
|
+
require 'active_support'
|
4
|
+
|
5
|
+
# Main module of the application, holding all the subsequent classes.
|
6
|
+
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
7
|
+
module Arkaan
|
8
|
+
autoload :Account , 'arkaan/account'
|
9
|
+
autoload :Permissions, 'arkaan/permissions'
|
10
|
+
autoload :Concerns , 'arkaan/concerns'
|
11
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Arkaan
|
2
|
+
# A user account with all related attributes. It holds credentials and informations about a designated user.
|
3
|
+
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
4
|
+
class Account
|
5
|
+
include Mongoid::Document
|
6
|
+
include Mongoid::Timestamps
|
7
|
+
include ActiveModel::SecurePassword
|
8
|
+
|
9
|
+
# @!attribute [rw] username
|
10
|
+
# @return [String] the nickname the user chose at subscription, must be given, unique, and 6 or more characters long.
|
11
|
+
field :username, type: String
|
12
|
+
# @!attribute [r] password_digest
|
13
|
+
# @return [String] the password of the user, encrypted with the Blowfish algorithm.
|
14
|
+
field :password_digest, type: String
|
15
|
+
# @!attribute [rw] lastname
|
16
|
+
# @return [String] the last name (family name) of the user.
|
17
|
+
field :lastname, type: String, default: ''
|
18
|
+
# @!attribute [rw] firstname
|
19
|
+
# @return [String] the first name of the user.
|
20
|
+
field :firstname, type: String, default: ''
|
21
|
+
# @!attribute [rw] birthdate
|
22
|
+
# @return [DateTime] the day of birth of the user, as an ISO-8601.
|
23
|
+
field :birthdate, type: DateTime
|
24
|
+
# @!attribute [rw] email
|
25
|
+
# @return [String] the email address of the user, useful to contact them ; it must be given, unique, and have an email format.
|
26
|
+
field :email, type: String
|
27
|
+
|
28
|
+
# @!attribute [rw] groups
|
29
|
+
# @return [Array<Arkaan::Permissions::Group>] the groups giving their corresponding rights to the current account.
|
30
|
+
has_and_belongs_to_many :groups, class_name: 'Arkaan::Permissions::Group', inverse_of: :accounts
|
31
|
+
|
32
|
+
validates :username, length: {minimum: 6}, uniqueness: true
|
33
|
+
|
34
|
+
validates :email, presence: true, format: {with: /\A[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}\z/}, uniqueness: true
|
35
|
+
|
36
|
+
# @!attribute [w] password
|
37
|
+
# @return [String] password, in clear, of the user ; do not attempt to get the value, just set it when changing the password.
|
38
|
+
# @!attribute [w] password_confirmation
|
39
|
+
# @return [String] the confirmation of the password, do not get, just set it ; it must be the same as the password.
|
40
|
+
has_secure_password
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Arkaan
|
2
|
+
module Concerns
|
3
|
+
# Includes the slug field, always the same in all models.
|
4
|
+
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
5
|
+
module Sluggable
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
# @!attribute [rw] slug
|
10
|
+
# @return [String] the slug of the current entity ; it must be snake-cased, longer than four characters, unique for the entity and given.
|
11
|
+
field :slug, type: String
|
12
|
+
|
13
|
+
validates :slug, length: {minimum: 4}, format: {with: /\A[a-z]+(_[a-z]+)*\z/}, uniqueness: true, presence: true
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Arkaan
|
2
|
+
# This module holds the logic for all the classes concerning the permissions abd rights for the user.
|
3
|
+
# A permission is restricting the access to one or several features to the users having it.
|
4
|
+
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
5
|
+
module Permissions
|
6
|
+
autoload :Right , 'arkaan/permissions/right'
|
7
|
+
autoload :Group , 'arkaan/permissions/group'
|
8
|
+
autoload :Category, 'arkaan/permissions/category'
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Arkaan
|
2
|
+
module Permissions
|
3
|
+
# A category of rights regroups one or several rights for convenience purposes.
|
4
|
+
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
5
|
+
class Category
|
6
|
+
include Mongoid::Document
|
7
|
+
include Mongoid::Timestamps
|
8
|
+
include Arkaan::Concerns::Sluggable
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Arkaan
|
2
|
+
module Permissions
|
3
|
+
# A group gathers one or several users to give them the same rights for conviniency purposes.
|
4
|
+
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
5
|
+
class Group
|
6
|
+
include Mongoid::Document
|
7
|
+
include Mongoid::Timestamps
|
8
|
+
include Arkaan::Concerns::Sluggable
|
9
|
+
|
10
|
+
# @!attribute [rw] accounts
|
11
|
+
# @return [Array<Arkaan::Account>] the accounts having the rights granted by this group.
|
12
|
+
has_and_belongs_to_many :accounts, class_name: 'Arkaan::Account', inverse_of: :groups
|
13
|
+
# @!attribute [rw] rights
|
14
|
+
# @return [Array<Arkaan::Permissions::Right>] the rights granted by belonging to this group.
|
15
|
+
has_and_belongs_to_many :rights, class_name: 'Arkaan::Permissions::Right', inverse_of: :groups
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Arkaan
|
2
|
+
module Permissions
|
3
|
+
# A right is the access to one or several features in the application. It's applied to a group, and transitively to an account.
|
4
|
+
# @author Vincent Courtois <courtois;vincent@outlook.com>
|
5
|
+
class Right
|
6
|
+
include Mongoid::Document
|
7
|
+
include Mongoid::Timestamps
|
8
|
+
include Arkaan::Concerns::Sluggable
|
9
|
+
|
10
|
+
# @!attribute [rw] groups
|
11
|
+
# @return [Array<Arkaan::Permissions::Group>] the groups granted with the permission to access features opened by this right.
|
12
|
+
has_and_belongs_to_many :groups, class_name: 'Arkaan::Permissions::Group', inverse_of: :rights
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,191 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: arkaan
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Vincent Courtois
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-09-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.6.0
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.6.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: factory_girl
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 4.8.1
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 4.8.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: database_cleaner
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.6.1
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.6.1
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: simplecov
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.15.1
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.15.1
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: yard
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.9.9
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.9.9
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.11.1
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.11.1
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: mongoid
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 7.0.0.beta
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 7.0.0.beta
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: activemodel
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 5.1.4
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 5.1.4
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: activesupport
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 5.1.4
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 5.1.4
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: bcrypt
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - '='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 3.1.11
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - '='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 3.1.11
|
153
|
+
description: This gem holds the model layer for my table-top RPG games application.
|
154
|
+
email: courtois.vincent@outlook.com
|
155
|
+
executables: []
|
156
|
+
extensions: []
|
157
|
+
extra_rdoc_files: []
|
158
|
+
files:
|
159
|
+
- lib/arkaan.rb
|
160
|
+
- lib/arkaan/account.rb
|
161
|
+
- lib/arkaan/concerns.rb
|
162
|
+
- lib/arkaan/concerns/sluggable.rb
|
163
|
+
- lib/arkaan/permissions.rb
|
164
|
+
- lib/arkaan/permissions/category.rb
|
165
|
+
- lib/arkaan/permissions/group.rb
|
166
|
+
- lib/arkaan/permissions/right.rb
|
167
|
+
homepage: https://rubygems.org/gems/arkaan
|
168
|
+
licenses:
|
169
|
+
- MIT
|
170
|
+
metadata: {}
|
171
|
+
post_install_message:
|
172
|
+
rdoc_options: []
|
173
|
+
require_paths:
|
174
|
+
- lib
|
175
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
176
|
+
requirements:
|
177
|
+
- - ">="
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: '0'
|
180
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
181
|
+
requirements:
|
182
|
+
- - ">="
|
183
|
+
- !ruby/object:Gem::Version
|
184
|
+
version: '0'
|
185
|
+
requirements: []
|
186
|
+
rubyforge_project:
|
187
|
+
rubygems_version: 2.5.1
|
188
|
+
signing_key:
|
189
|
+
specification_version: 4
|
190
|
+
summary: The model layer for my table-RPG application
|
191
|
+
test_files: []
|