arkaan 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/arkaan.rb +1 -0
- data/lib/arkaan/account.rb +3 -0
- data/lib/arkaan/campaign.rb +2 -12
- data/lib/arkaan/campaigns.rb +0 -2
- data/lib/arkaan/campaigns/invitation.rb +0 -23
- data/lib/arkaan/files.rb +6 -0
- data/lib/arkaan/files/document.rb +40 -0
- data/lib/arkaan/files/permission.rb +22 -0
- data/lib/arkaan/version.rb +1 -1
- metadata +35 -10
- data/lib/arkaan/campaigns/character.rb +0 -45
- data/lib/arkaan/campaigns/files.rb +0 -10
- data/lib/arkaan/campaigns/files/concerns.rb +0 -9
- data/lib/arkaan/campaigns/files/concerns/nameable.rb +0 -19
- data/lib/arkaan/campaigns/files/document.rb +0 -64
- data/lib/arkaan/campaigns/files/permission.rb +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88f3666897172e59135de5920b17f9356a7cdcf2877b5f5244eb21b55f95c7c8
|
4
|
+
data.tar.gz: 73c232117a9f905d00d1853d03176460b139a8a8b9b59544a5975d6af825d5c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3035f83abcc6a2970d3fa21b149fe70ab6f9e7908fa124c01917a54c89d087a1239694e82241882df74b672494b3e38d1a9951b83bca512b54ee10134f7e4c6b
|
7
|
+
data.tar.gz: c5529c6c1c9ba7686492379bff4e2ab509d0a0f9515d1c77b190a175000af86ba8bedd22b2a919fa7c6a375253d8c9036fa41d5ab33d14c55a4eaec2a29d55e7
|
data/lib/arkaan.rb
CHANGED
@@ -18,6 +18,7 @@ module Arkaan
|
|
18
18
|
autoload :Campaigns , 'arkaan/campaigns'
|
19
19
|
autoload :Concerns , 'arkaan/concerns'
|
20
20
|
autoload :Factories , 'arkaan/factories'
|
21
|
+
autoload :Files , 'arkaan/files'
|
21
22
|
autoload :Monitoring , 'arkaan/monitoring'
|
22
23
|
autoload :Notification , 'arkaan/notification'
|
23
24
|
autoload :OAuth , 'arkaan/oauth'
|
data/lib/arkaan/account.rb
CHANGED
@@ -60,6 +60,9 @@ module Arkaan
|
|
60
60
|
# @!attribute [rw] websockets
|
61
61
|
# @return [Array<Arkaan::Monitoring::Websocket>] the websockets created by the owner of this account.
|
62
62
|
has_many :websockets, class_name: 'Arkaan::Monitoring::Websocket', inverse_of: :creator
|
63
|
+
# @!attribute [rw] permissions
|
64
|
+
# @return [Array<Arkaan::Files::Permission>] the file access permissions granted to this account.
|
65
|
+
has_many :permissions, class_name: 'Arkaan::Files::Permission', inverse_of: :account
|
63
66
|
|
64
67
|
# @!attribute [rw] notifications
|
65
68
|
# @return [Array<Arkaan::Notification>] the notifications linked to this user.
|
data/lib/arkaan/campaign.rb
CHANGED
@@ -25,8 +25,8 @@ module Arkaan
|
|
25
25
|
# @return [Array<Arkaan::Campaigns::Invitation>] the invitations to players that have been made for this campaign.
|
26
26
|
has_many :invitations, class_name: 'Arkaan::Campaigns::Invitation', inverse_of: :campaign
|
27
27
|
# @!attribute [rw] files
|
28
|
-
# @return [Array<Arkaan::
|
29
|
-
has_many :files, class_name: 'Arkaan::
|
28
|
+
# @return [Array<Arkaan::Files::Document>] the files uploaded in this campaign.
|
29
|
+
has_many :files, class_name: 'Arkaan::Files::Document'
|
30
30
|
|
31
31
|
# @!attribute [rw] messages
|
32
32
|
# @return [Array<Arkaan::Campaigns::Messages::Base>] the messages sent in the chatroom of the campaign.
|
@@ -90,15 +90,5 @@ module Arkaan
|
|
90
90
|
def players_count
|
91
91
|
players.count
|
92
92
|
end
|
93
|
-
|
94
|
-
# @return [Array<Arkaan::Campaigns::Character>] a flattened list of characters for this campaign.
|
95
|
-
def characters
|
96
|
-
players.map(&:characters).flatten
|
97
|
-
end
|
98
|
-
|
99
|
-
# @return [Array<Arkaan::Campaigns::Files::Document>] the document of this campaign as a flattened array.
|
100
|
-
def documents
|
101
|
-
invitations.map(&:documents).flatten
|
102
|
-
end
|
103
93
|
end
|
104
94
|
end
|
data/lib/arkaan/campaigns.rb
CHANGED
@@ -2,8 +2,6 @@ module Arkaan
|
|
2
2
|
# The campaigns module is holding the logic for some objects related to campaigns.
|
3
3
|
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
4
4
|
module Campaigns
|
5
|
-
autoload :Character , 'arkaan/campaigns/character'
|
6
|
-
autoload :Files , 'arkaan/campaigns/files'
|
7
5
|
autoload :Invitation, 'arkaan/campaigns/invitation'
|
8
6
|
autoload :Message , 'arkaan/campaigns/message'
|
9
7
|
autoload :Tag , 'arkaan/campaigns/tag'
|
@@ -17,29 +17,6 @@ module Arkaan
|
|
17
17
|
# @!attribute [rw] campaign
|
18
18
|
# @return [Arkaan::Campaign] the campaign the invitation has been made in.
|
19
19
|
belongs_to :campaign, class_name: 'Arkaan::Campaign', inverse_of: :invitations
|
20
|
-
|
21
|
-
# @!attribute [rw] files
|
22
|
-
# @return [Array<Arkaan::Campaigns::Files::Document>] the files uploaded in this campaign by the user linked to this invitation.
|
23
|
-
has_many :permissions, class_name: 'Arkaan::Campaigns::Files::Permission', inverse_of: :invitation
|
24
|
-
# @!attribute [rw] characters
|
25
|
-
# @return [Array<Arkaan::Campaigns::Character>] the character sheets for this player.
|
26
|
-
has_many :characters, class_name: 'Arkaan::Campaigns::Character', inverse_of: :invitation
|
27
|
-
|
28
|
-
# Gets the currently selected character in a convenient way.
|
29
|
-
# @return [Arkaan::Campaigns::Files::Character] the character currently selected by the player.
|
30
|
-
def character
|
31
|
-
characters.where(selected: true).first
|
32
|
-
end
|
33
|
-
|
34
|
-
def documents
|
35
|
-
permissions.map(&:document)
|
36
|
-
end
|
37
|
-
|
38
|
-
def has_file?(filename)
|
39
|
-
return permissions.map(&:document).map(&:name).any? do |name|
|
40
|
-
name == filename
|
41
|
-
end
|
42
|
-
end
|
43
20
|
end
|
44
21
|
end
|
45
22
|
end
|
data/lib/arkaan/files.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
module Arkaan
|
2
|
+
module Files
|
3
|
+
# a document is an uploaded file in the S3 clone application.
|
4
|
+
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
5
|
+
class Document
|
6
|
+
include Mongoid::Document
|
7
|
+
include Mongoid::Timestamps
|
8
|
+
|
9
|
+
# @!attribute [rw] name
|
10
|
+
# @return [String] the filename the user entered when uploading the file.
|
11
|
+
field :name, type: String
|
12
|
+
|
13
|
+
field :extension, type: String
|
14
|
+
# @!attribute [rw] size
|
15
|
+
# @return [String] the size, in bytes, of the uploaded file.
|
16
|
+
field :size, type: Integer, default: 0
|
17
|
+
# @!attribute [rw] folder
|
18
|
+
# @return [String] the folder in which the file is stored in the S3 clone.
|
19
|
+
field :folder, type: String, default: '/'
|
20
|
+
# @!attribute [rw] mime_type
|
21
|
+
# @return [String] the MIME type of the file. this MAY not correspond to the real
|
22
|
+
# MIME type of the uploaded file, this is just an indication.
|
23
|
+
field :mime_type, type: String
|
24
|
+
|
25
|
+
# @!attribute [rw] creator
|
26
|
+
# @return [Arkaan::Account] the account of the person that uploaded the file.
|
27
|
+
belongs_to :creator, class_name: 'Arkaan::Account', inverse_of: :files
|
28
|
+
|
29
|
+
# @!attribute [rw] permissions
|
30
|
+
# @return [Array<Arkaan::Files::Permission>] the permissions granted to access this file.
|
31
|
+
has_many :permissions, class_name: 'Arkaan::Files::Permission', inverse_of: :file
|
32
|
+
|
33
|
+
validates :name, uniqueness: {message: 'uniq'}
|
34
|
+
|
35
|
+
validates :name, :extension, :folder, :mime_type, presence: {message: 'required'}
|
36
|
+
|
37
|
+
validates :folder, format: {without: /\/\//, message: 'format'}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Arkaan
|
2
|
+
module Files
|
3
|
+
# The permission granted to a user to access and/or delete a file.
|
4
|
+
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
5
|
+
class Permission
|
6
|
+
include Mongoid::Document
|
7
|
+
include Mongoid::Timestamps
|
8
|
+
include Arkaan::Concerns::Enumerable
|
9
|
+
|
10
|
+
# @!attribute [rw] type
|
11
|
+
# @return [Symbol] the type of permission granted (is the user able to delete the file ?)
|
12
|
+
enum_field :type, [:read, :read_write]
|
13
|
+
|
14
|
+
# @!attribute [rw] file
|
15
|
+
# @return [Arkaan::Files::Document] the document the permission is linked to.
|
16
|
+
belongs_to :file, class_name: 'Arkaan::Files::Document', inverse_of: :permissions
|
17
|
+
# @!attribute [rw] account
|
18
|
+
# @return [Arkaan::Account] the user being granted the access to the file.
|
19
|
+
belongs_to :account, class_name: 'Arkaan::Account', inverse_of: :permissions
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/arkaan/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arkaan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vincent Courtois
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 4.8.1
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: factory_bot
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 5.1.1
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 5.1.1
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: database_cleaner
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,14 +142,28 @@ dependencies:
|
|
128
142
|
requirements:
|
129
143
|
- - '='
|
130
144
|
- !ruby/object:Gem::Version
|
131
|
-
version: 2.0.
|
145
|
+
version: 2.0.8
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - '='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 2.0.8
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: faker
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - '='
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 2.10.0
|
132
160
|
type: :development
|
133
161
|
prerelease: false
|
134
162
|
version_requirements: !ruby/object:Gem::Requirement
|
135
163
|
requirements:
|
136
164
|
- - '='
|
137
165
|
- !ruby/object:Gem::Version
|
138
|
-
version: 2.0
|
166
|
+
version: 2.10.0
|
139
167
|
- !ruby/object:Gem::Dependency
|
140
168
|
name: mongoid
|
141
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -302,12 +330,6 @@ files:
|
|
302
330
|
- lib/arkaan/authentication/session.rb
|
303
331
|
- lib/arkaan/campaign.rb
|
304
332
|
- lib/arkaan/campaigns.rb
|
305
|
-
- lib/arkaan/campaigns/character.rb
|
306
|
-
- lib/arkaan/campaigns/files.rb
|
307
|
-
- lib/arkaan/campaigns/files/concerns.rb
|
308
|
-
- lib/arkaan/campaigns/files/concerns/nameable.rb
|
309
|
-
- lib/arkaan/campaigns/files/document.rb
|
310
|
-
- lib/arkaan/campaigns/files/permission.rb
|
311
333
|
- lib/arkaan/campaigns/invitation.rb
|
312
334
|
- lib/arkaan/campaigns/message.rb
|
313
335
|
- lib/arkaan/campaigns/tag.rb
|
@@ -326,6 +348,9 @@ files:
|
|
326
348
|
- lib/arkaan/factories/errors.rb
|
327
349
|
- lib/arkaan/factories/errors/gateway_not_found.rb
|
328
350
|
- lib/arkaan/factories/gateways.rb
|
351
|
+
- lib/arkaan/files.rb
|
352
|
+
- lib/arkaan/files/document.rb
|
353
|
+
- lib/arkaan/files/permission.rb
|
329
354
|
- lib/arkaan/monitoring.rb
|
330
355
|
- lib/arkaan/monitoring/action.rb
|
331
356
|
- lib/arkaan/monitoring/gateway.rb
|
@@ -1,45 +0,0 @@
|
|
1
|
-
module Arkaan
|
2
|
-
module Campaigns
|
3
|
-
# A character sheet represents a character played by a player in a campaign.
|
4
|
-
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
5
|
-
class Character
|
6
|
-
include Mongoid::Document
|
7
|
-
include Mongoid::Timestamps
|
8
|
-
|
9
|
-
# @!attribute [rw] selected
|
10
|
-
# @return [Boolean] TRUE if the sheet is currently selected by the player, FALSE otherwise.
|
11
|
-
field :selected, type: Boolean, default: false
|
12
|
-
|
13
|
-
# @!attribute [rw] data
|
14
|
-
# @return [Hash] the heart of the Arkaan::Campaigns::Character class, the polymorphic
|
15
|
-
# data representing all the fields of a character sheet are validated using the validator
|
16
|
-
# of the associated plugin, and created/updated with the corresponding form.
|
17
|
-
field :data, type: Hash, default: {}
|
18
|
-
|
19
|
-
# @!attribute [rw] invitation
|
20
|
-
# @return [Arkaan::Campaigns::Invitation] the invitation of the player playing this character.
|
21
|
-
belongs_to :invitation, class_name: 'Arkaan::Campaigns::Invitation', inverse_of: :characters
|
22
|
-
|
23
|
-
# Returns the player linked to this character.
|
24
|
-
# @return [Arkaan::Account] the account of the player incarnating this character.
|
25
|
-
def player
|
26
|
-
invitation.account
|
27
|
-
end
|
28
|
-
|
29
|
-
def campaign
|
30
|
-
invitation.campaign
|
31
|
-
end
|
32
|
-
|
33
|
-
# Puts the selected flag to TRUE for this character and to FALSE for all the
|
34
|
-
# other characters for the same player in the same campaign.
|
35
|
-
def select!
|
36
|
-
invitation.characters.each do |character|
|
37
|
-
character.update_attribute(:selected, false)
|
38
|
-
character.save!
|
39
|
-
end
|
40
|
-
update_attribute(:selected, true)
|
41
|
-
save!
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
module Arkaan
|
2
|
-
module Campaigns
|
3
|
-
module Files
|
4
|
-
autoload :Character , 'arkaan/campaigns/files/character'
|
5
|
-
autoload :Concerns , 'arkaan/campaigns/files/concerns'
|
6
|
-
autoload :Document , 'arkaan/campaigns/files/document'
|
7
|
-
autoload :Permission, 'arkaan/campaigns/files/permission'
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module Arkaan
|
2
|
-
module Campaigns
|
3
|
-
module Files
|
4
|
-
module Concerns
|
5
|
-
module Nameable
|
6
|
-
extend ActiveSupport::Concern
|
7
|
-
|
8
|
-
included do
|
9
|
-
# @!attribute [rw] filename
|
10
|
-
# @return [String] the name of the file, corresponding to the AWS name.
|
11
|
-
field :name, type: String
|
12
|
-
|
13
|
-
validates :name, presence: {message: 'required'}
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
module Arkaan
|
2
|
-
module Campaigns
|
3
|
-
module Files
|
4
|
-
# A document is any piece of data added by a user to a campaign. It can either be a direct text note, or an uploaded document for example.
|
5
|
-
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
6
|
-
class Document
|
7
|
-
include Mongoid::Document
|
8
|
-
include Mongoid::Timestamps
|
9
|
-
include Arkaan::Concerns::MimeTypable
|
10
|
-
include Arkaan::Campaigns::Files::Concerns::Nameable
|
11
|
-
|
12
|
-
# @!attribute [rw] size
|
13
|
-
# @return [Integer] the size of the document in bytes.
|
14
|
-
field :size, type: Integer, default: 0
|
15
|
-
|
16
|
-
mime_type ['image/*', 'text/plain']
|
17
|
-
|
18
|
-
# @!attribute [rw] permission
|
19
|
-
# @return [Arkaan::Campaigns::Permission] the permissions granted to the different users of the campaign concerning this document.
|
20
|
-
has_many :permissions, class_name: 'Arkaan::Campaigns::Files::Permission', inverse_of: :document
|
21
|
-
|
22
|
-
# Custom setter for the creator of the document so that it can be used as a normal field.
|
23
|
-
# @param invitation [Arkaan::Campaigns::Invitation] the invitation of the player creating this document.
|
24
|
-
def creator=(invitation)
|
25
|
-
if !permissions.where(invitation: invitation).exists?
|
26
|
-
Arkaan::Campaigns::Files::Permission.create(enum_level: :creator, document: self, invitation: invitation)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
# Custom getter for the creator of the campaign.
|
31
|
-
# @return [Arkaan::Account] the account of the player that created this document.
|
32
|
-
def creator
|
33
|
-
return permissions.where(enum_level: :creator).first.invitation.account
|
34
|
-
end
|
35
|
-
|
36
|
-
# Checks if an account is allowed to access this document, accounts must have one of the following characteristics to read a document :
|
37
|
-
# - Be the creator of the document
|
38
|
-
# - Be the game master of the campaign in which the document is declared
|
39
|
-
# - Have been granted the permission to access the document
|
40
|
-
#
|
41
|
-
# @param account [Arkaan::Account] the account trying to access the document.
|
42
|
-
# @return [Boolean] TRUE if this account has the right to access the document, FALSe otherwise.
|
43
|
-
def is_allowed?(account)
|
44
|
-
return true if campaign.creator.id == account.id
|
45
|
-
return true if creator.id == account.id
|
46
|
-
return true if has_permission?(account)
|
47
|
-
return false
|
48
|
-
end
|
49
|
-
|
50
|
-
# Checks if the account has the permission to access the designated document.
|
51
|
-
# @param account [Arkaan::Account] the account to check the existence of a permission for.
|
52
|
-
# @return [Boolean] TRUE if the account has a permission to access this document, FALSE otherwise.
|
53
|
-
def has_permission?(account)
|
54
|
-
invitation = campaign.invitations.where(account: account).first
|
55
|
-
return !invitation.nil? && permissions.where(invitation: invitation).exists?
|
56
|
-
end
|
57
|
-
|
58
|
-
def campaign
|
59
|
-
permissions.first.invitation.campaign rescue nil
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module Arkaan
|
2
|
-
module Campaigns
|
3
|
-
module Files
|
4
|
-
# A file permission is the permission given by the creator of the file to another player to access it.
|
5
|
-
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
6
|
-
class Permission
|
7
|
-
include Mongoid::Document
|
8
|
-
include Mongoid::Timestamps
|
9
|
-
include Arkaan::Concerns::Enumerable
|
10
|
-
|
11
|
-
# The status of a permission just differenciates the creator and the other players for the moment
|
12
|
-
# But it will later be used to give different access rights like read/write
|
13
|
-
# @!attribute [rw] status
|
14
|
-
# @return [Symbol] the current level of permission for the linked user on the linked file.
|
15
|
-
enum_field :level, [:creator, :read], default: :read
|
16
|
-
|
17
|
-
# @!attribute [rw] invitation
|
18
|
-
# @return [Arkaan::Campaigns::Invitation] the invitation of the player in the campaign where this file was uploaded.
|
19
|
-
belongs_to :invitation, class_name: 'Arkaan::Campaigns::Invitation', inverse_of: :permissions
|
20
|
-
# @!attribute [rw] file
|
21
|
-
# @return [Arkaan::Campaigns::Files::Document] the file on which the permissions are granted.
|
22
|
-
belongs_to :document, class_name: 'Arkaan::Campaigns::Files::Document', inverse_of: :permissions
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|