virtuatable-core 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/lib/core/models/account.rb +102 -0
  3. data/lib/core/models/authentication/session.rb +30 -0
  4. data/lib/core/models/authentication.rb +9 -0
  5. data/lib/core/models/campaign.rb +110 -0
  6. data/lib/core/models/campaigns/invitation.rb +31 -0
  7. data/lib/core/models/campaigns/tag.rb +23 -0
  8. data/lib/core/models/campaigns.rb +10 -0
  9. data/lib/core/models/chatrooms/base.rb +16 -0
  10. data/lib/core/models/chatrooms/campaign.rb +13 -0
  11. data/lib/core/models/chatrooms/conversation.rb +9 -0
  12. data/lib/core/models/chatrooms/membership.rb +17 -0
  13. data/lib/core/models/chatrooms/message.rb +33 -0
  14. data/lib/core/models/chatrooms.rb +13 -0
  15. data/lib/core/models/concerns/activable.rb +20 -0
  16. data/lib/core/models/concerns/diagnosticable.rb +24 -0
  17. data/lib/core/models/concerns/enumerable.rb +50 -0
  18. data/lib/core/models/concerns/historizable.rb +64 -0
  19. data/lib/core/models/concerns/mime_typable.rb +44 -0
  20. data/lib/core/models/concerns/premiumable.rb +17 -0
  21. data/lib/core/models/concerns/sluggable.rb +29 -0
  22. data/lib/core/models/concerns/typable.rb +19 -0
  23. data/lib/core/models/concerns.rb +16 -0
  24. data/lib/core/models/decorators/errors/env_variable_missing.rb +16 -0
  25. data/lib/core/models/decorators/errors.rb +11 -0
  26. data/lib/core/models/decorators/gateway.rb +111 -0
  27. data/lib/core/models/event.rb +31 -0
  28. data/lib/core/models/factories/errors/gateway_not_found.rb +16 -0
  29. data/lib/core/models/factories/errors.rb +11 -0
  30. data/lib/core/models/factories.rb +10 -0
  31. data/lib/core/models/files/document.rb +52 -0
  32. data/lib/core/models/files/permission.rb +24 -0
  33. data/lib/core/models/files.rb +8 -0
  34. data/lib/core/models/monitoring/route.rb +44 -0
  35. data/lib/core/models/monitoring/service.rb +33 -0
  36. data/lib/core/models/monitoring.rb +10 -0
  37. data/lib/core/models/notification.rb +24 -0
  38. data/lib/core/models/oauth/access_token.rb +34 -0
  39. data/lib/core/models/oauth/application.rb +58 -0
  40. data/lib/core/models/oauth/authorization.rb +33 -0
  41. data/lib/core/models/oauth/refresh_token.rb +20 -0
  42. data/lib/core/models/oauth.rb +12 -0
  43. data/lib/core/models/permissions/category.rb +17 -0
  44. data/lib/core/models/permissions/group.rb +32 -0
  45. data/lib/core/models/permissions/right.rb +21 -0
  46. data/lib/core/models/permissions.rb +12 -0
  47. data/lib/core/models/ruleset.rb +32 -0
  48. data/lib/core/models.rb +27 -0
  49. data/lib/core/version.rb +3 -0
  50. data/lib/core.rb +10 -0
  51. metadata +329 -0
@@ -0,0 +1,17 @@
1
+ module Core
2
+ module Models
3
+ module Permissions
4
+ # A category of rights regroups one or several rights for convenience purposes.
5
+ # @author Vincent Courtois <courtois.vincent@outlook.com>
6
+ class Category
7
+ include Mongoid::Document
8
+ include Mongoid::Timestamps
9
+ include Core::Models::Concerns::Sluggable
10
+
11
+ has_many :rights, class_name: 'Core::Models::Permissions::Right', inverse_of: :category
12
+
13
+ make_sluggable 'category'
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,32 @@
1
+ module Core
2
+ module Models
3
+ module Permissions
4
+ # A group gathers one or several users to give them the same rights for conviniency purposes.
5
+ # @author Vincent Courtois <courtois.vincent@outlook.com>
6
+ class Group
7
+ include Mongoid::Document
8
+ include Mongoid::Timestamps
9
+ include Core::Models::Concerns::Sluggable
10
+
11
+ # @!attribute [rw] is_default
12
+ # @return [Boolean] a boolean indicating whether this group is given when a new user registered or not.
13
+ field :is_default, type: Boolean, default: false
14
+ # @!attribute [rw] is_superuser
15
+ # @return [Boolean] a boolean indicating whether this group should have access to all groups and rights or not.
16
+ field :is_superuser, type: Boolean, default: false
17
+
18
+ # @!attribute [rw] accounts
19
+ # @return [Array<Core::Models::Account>] the accounts having the rights granted by this group.
20
+ has_and_belongs_to_many :accounts, class_name: 'Core::Models::Account', inverse_of: :groups
21
+ # @!attribute [rw] rights
22
+ # @return [Array<Core::Models::Permissions::Right>] the rights granted by belonging to this group.
23
+ has_and_belongs_to_many :rights, class_name: 'Core::Models::Permissions::Right', inverse_of: :groups
24
+ # @!attribute [rw] routes
25
+ # @return [Array<Core::Models::Monitoring::Route>] the routes this group can access in the API.
26
+ has_and_belongs_to_many :routes, class_name: 'Core::Models::Monitoring::Route', inverse_of: :groups
27
+
28
+ make_sluggable 'group'
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,21 @@
1
+ module Core
2
+ module Models
3
+ module Permissions
4
+ # A right is the access to one or several features in the application. It's applied to a group, and transitively to an account.
5
+ # @author Vincent Courtois <courtois;vincent@outlook.com>
6
+ class Right
7
+ include Mongoid::Document
8
+ include Mongoid::Timestamps
9
+ include Core::Models::Concerns::Sluggable
10
+
11
+ # @!attribute [rw] groups
12
+ # @return [Array<Core::Models::Permissions::Group>] the groups granted with the permission to access features opened by this right.
13
+ has_and_belongs_to_many :groups, class_name: 'Core::Models::Permissions::Group', inverse_of: :rights
14
+
15
+ belongs_to :category, class_name: 'Core::Models::Permissions::Category', inverse_of: :rights
16
+
17
+ make_sluggable 'right'
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,12 @@
1
+ module Core
2
+ module Models
3
+ # This module holds the logic for all the classes concerning the permissions abd rights for the user.
4
+ # A permission is restricting the access to one or several features to the users having it.
5
+ # @author Vincent Courtois <courtois.vincent@outlook.com>
6
+ module Permissions
7
+ autoload :Right , 'core/models/permissions/right'
8
+ autoload :Group , 'core/models/permissions/group'
9
+ autoload :Category, 'core/models/permissions/category'
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,32 @@
1
+ module Core
2
+ module Models
3
+ # A set of rules is describing how a specific game system works (eg. Dungeons and Dragons 5th Edition, or Fate)
4
+ # @author Vincent Courtois <courtois.vincent@outlook.com>
5
+ class Ruleset
6
+ include Mongoid::Document
7
+ include Mongoid::Timestamps
8
+
9
+ # @!attribute [rw] name
10
+ # @return [String] the name of the ruleset (eq. "Dungeons and Dragons 4th Edition")
11
+ field :name, type: String
12
+ # @!attribute [rw] description
13
+ # @return [String] the complete description of the rule set to quickly have informations on its content.
14
+ field :description, type: String
15
+ # @!attribute [rw] mime_types
16
+ # @return [Array<String>] a list of MIME types accepted as character sheets MIME types.
17
+ field :mime_types, type: Array, default: []
18
+
19
+ # @!attribute [rw] creator
20
+ # @return [Core::Models::Account] the account of the user creating this ruleset.
21
+ belongs_to :creator, class_name: 'Core::Models::Account', inverse_of: :rulesets
22
+ # @!attribute [rw] campaigns
23
+ # @return [Array<Core::Models::Campaign>] the campaigns using this set of rules.
24
+ has_many :campaigns, class_name: 'Core::Models::Campaign', inverse_of: :ruleset
25
+
26
+ validates :name,
27
+ presence: {message: 'required'},
28
+ length: {minimum: 4, message: 'minlength', if: :name?},
29
+ uniqueness: {message: 'uniq', if: :name?}
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,27 @@
1
+ require 'mongoid'
2
+ require 'active_model'
3
+ require 'active_support'
4
+ require 'dotenv/load'
5
+
6
+ # Main module of the application, holding all the subsequent classes.
7
+ # @author Vincent Courtois <courtois.vincent@outlook.com>
8
+ module Core
9
+ module Models
10
+ autoload :Account , 'core/models/account'
11
+ autoload :Authentication, 'core/models/authentication'
12
+ autoload :Campaign , 'core/models/campaign'
13
+ autoload :Campaigns , 'core/models/campaigns'
14
+ autoload :Chatroom , 'core/models/chatroom'
15
+ autoload :Chatrooms , 'core/models/chatrooms'
16
+ autoload :Concerns , 'core/models/concerns'
17
+ autoload :Event , 'core/models/event'
18
+ autoload :Factories , 'core/models/factories'
19
+ autoload :Files , 'core/models/files'
20
+ autoload :Monitoring , 'core/models/monitoring'
21
+ autoload :Notification , 'core/models/notification'
22
+ autoload :OAuth , 'core/models/oauth'
23
+ autoload :Permissions , 'core/models/permissions'
24
+ autoload :Phone , 'core/models/phone'
25
+ autoload :Ruleset , 'core/models/ruleset'
26
+ end
27
+ end
@@ -0,0 +1,3 @@
1
+ module Core
2
+ VERSION = '1.0.0'
3
+ end
data/lib/core.rb ADDED
@@ -0,0 +1,10 @@
1
+ require 'mongoid'
2
+ require 'active_model'
3
+ require 'active_support'
4
+ require 'dotenv/load'
5
+
6
+ # Main module of the application, holding all the subsequent classes.
7
+ # @author Vincent Courtois <courtois.vincent@outlook.com>
8
+ module Core
9
+ autoload :Models, 'core/models'
10
+ end
metadata ADDED
@@ -0,0 +1,329 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: virtuatable-core
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Vincent Courtois
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-04-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: database_cleaner
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 1.6.1
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 1.6.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: factory_bot
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 6.1.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 6.1.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: factory_girl
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 4.8.1
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 4.8.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: faker
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 2.13.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 2.13.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: 0.13.1
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: 0.13.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: rack
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 2.2.3
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 2.2.3
97
+ - !ruby/object:Gem::Dependency
98
+ name: rack-test
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: 1.1.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: 1.1.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '='
116
+ - !ruby/object:Gem::Version
117
+ version: 3.9.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '='
123
+ - !ruby/object:Gem::Version
124
+ version: 3.9.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: rspec-json_expectations
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '='
130
+ - !ruby/object:Gem::Version
131
+ version: 2.1.0
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '='
137
+ - !ruby/object:Gem::Version
138
+ version: 2.1.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '='
144
+ - !ruby/object:Gem::Version
145
+ version: 0.90.0
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '='
151
+ - !ruby/object:Gem::Version
152
+ version: 0.90.0
153
+ - !ruby/object:Gem::Dependency
154
+ name: simplecov
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - '='
158
+ - !ruby/object:Gem::Version
159
+ version: 0.19.0
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - '='
165
+ - !ruby/object:Gem::Version
166
+ version: 0.19.0
167
+ - !ruby/object:Gem::Dependency
168
+ name: yard
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - '='
172
+ - !ruby/object:Gem::Version
173
+ version: 0.9.25
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - '='
179
+ - !ruby/object:Gem::Version
180
+ version: 0.9.25
181
+ - !ruby/object:Gem::Dependency
182
+ name: mongoid
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - '='
186
+ - !ruby/object:Gem::Version
187
+ version: 7.1.0
188
+ type: :runtime
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - '='
193
+ - !ruby/object:Gem::Version
194
+ version: 7.1.0
195
+ - !ruby/object:Gem::Dependency
196
+ name: activemodel
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - '='
200
+ - !ruby/object:Gem::Version
201
+ version: 6.0.3.2
202
+ type: :runtime
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - '='
207
+ - !ruby/object:Gem::Version
208
+ version: 6.0.3.2
209
+ - !ruby/object:Gem::Dependency
210
+ name: activesupport
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - '='
214
+ - !ruby/object:Gem::Version
215
+ version: 6.0.3.2
216
+ type: :runtime
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - '='
221
+ - !ruby/object:Gem::Version
222
+ version: 6.0.3.2
223
+ - !ruby/object:Gem::Dependency
224
+ name: bcrypt
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - '='
228
+ - !ruby/object:Gem::Version
229
+ version: 3.1.13
230
+ type: :runtime
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - '='
235
+ - !ruby/object:Gem::Version
236
+ version: 3.1.13
237
+ - !ruby/object:Gem::Dependency
238
+ name: dotenv
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - '='
242
+ - !ruby/object:Gem::Version
243
+ version: 2.7.6
244
+ type: :runtime
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - '='
249
+ - !ruby/object:Gem::Version
250
+ version: 2.7.6
251
+ description: This gem holds the model layer for my table-top RPG games application.
252
+ email: courtois.vincent@outlook.com
253
+ executables: []
254
+ extensions: []
255
+ extra_rdoc_files: []
256
+ files:
257
+ - lib/core.rb
258
+ - lib/core/models.rb
259
+ - lib/core/models/account.rb
260
+ - lib/core/models/authentication.rb
261
+ - lib/core/models/authentication/session.rb
262
+ - lib/core/models/campaign.rb
263
+ - lib/core/models/campaigns.rb
264
+ - lib/core/models/campaigns/invitation.rb
265
+ - lib/core/models/campaigns/tag.rb
266
+ - lib/core/models/chatrooms.rb
267
+ - lib/core/models/chatrooms/base.rb
268
+ - lib/core/models/chatrooms/campaign.rb
269
+ - lib/core/models/chatrooms/conversation.rb
270
+ - lib/core/models/chatrooms/membership.rb
271
+ - lib/core/models/chatrooms/message.rb
272
+ - lib/core/models/concerns.rb
273
+ - lib/core/models/concerns/activable.rb
274
+ - lib/core/models/concerns/diagnosticable.rb
275
+ - lib/core/models/concerns/enumerable.rb
276
+ - lib/core/models/concerns/historizable.rb
277
+ - lib/core/models/concerns/mime_typable.rb
278
+ - lib/core/models/concerns/premiumable.rb
279
+ - lib/core/models/concerns/sluggable.rb
280
+ - lib/core/models/concerns/typable.rb
281
+ - lib/core/models/decorators/errors.rb
282
+ - lib/core/models/decorators/errors/env_variable_missing.rb
283
+ - lib/core/models/decorators/gateway.rb
284
+ - lib/core/models/event.rb
285
+ - lib/core/models/factories.rb
286
+ - lib/core/models/factories/errors.rb
287
+ - lib/core/models/factories/errors/gateway_not_found.rb
288
+ - lib/core/models/files.rb
289
+ - lib/core/models/files/document.rb
290
+ - lib/core/models/files/permission.rb
291
+ - lib/core/models/monitoring.rb
292
+ - lib/core/models/monitoring/route.rb
293
+ - lib/core/models/monitoring/service.rb
294
+ - lib/core/models/notification.rb
295
+ - lib/core/models/oauth.rb
296
+ - lib/core/models/oauth/access_token.rb
297
+ - lib/core/models/oauth/application.rb
298
+ - lib/core/models/oauth/authorization.rb
299
+ - lib/core/models/oauth/refresh_token.rb
300
+ - lib/core/models/permissions.rb
301
+ - lib/core/models/permissions/category.rb
302
+ - lib/core/models/permissions/group.rb
303
+ - lib/core/models/permissions/right.rb
304
+ - lib/core/models/ruleset.rb
305
+ - lib/core/version.rb
306
+ homepage: https://rubygems.org/gems/virtuatable-core
307
+ licenses:
308
+ - MIT
309
+ metadata: {}
310
+ post_install_message:
311
+ rdoc_options: []
312
+ require_paths:
313
+ - lib
314
+ required_ruby_version: !ruby/object:Gem::Requirement
315
+ requirements:
316
+ - - ">="
317
+ - !ruby/object:Gem::Version
318
+ version: '0'
319
+ required_rubygems_version: !ruby/object:Gem::Requirement
320
+ requirements:
321
+ - - ">="
322
+ - !ruby/object:Gem::Version
323
+ version: '0'
324
+ requirements: []
325
+ rubygems_version: 3.2.3
326
+ signing_key:
327
+ specification_version: 4
328
+ summary: The model layer for my table-RPG application
329
+ test_files: []