arkaan 2.4.1 → 2.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6fe7d3eac6402e98bbe2ad5d89304fa3724d3f4ae2cdf34b7d3e39cad91b933a
4
- data.tar.gz: 9133895e88eee313f2c2e6dee1b328a37116d42dfd4f59d8a52631c8cb0206ec
3
+ metadata.gz: 7876afd3de8047883f8c7a4cedd1311c4b40dc3fdd711c3ebfa9b6abd118e330
4
+ data.tar.gz: 975ad0b4de93452222925f704460cb25f8d760cc26643bc2c1cd6377964a7fe4
5
5
  SHA512:
6
- metadata.gz: 5f8582bf8546ea97a51323c48a3e87e536e9c528c67739fa362150f69d56d4579d22e912f850206ab3dafe954365307cfaba70d812ee2702c04f90ae70de442f
7
- data.tar.gz: 1700055797b5790f2fac0cbd40675f351490960ad4149c7f6a237c7774ae970515e165fed7f1e24ff86e82e71b5b2f1b884660aa6e9b93278d2e8dde5ed93c0f
6
+ metadata.gz: 799b4bc8be02916ef27d7e3b99ee57991849450f7b0b2cab54945ebe8863a85a858836de4745725325fa76408b7799b284b7a28e91cc3bf3a294310b02daa314
7
+ data.tar.gz: 9e233034348c67b2a29672e3fe9154e252c5ce42819474c19b68cbf0adec613d1fb2dd9ce86ce3cba4823c46097bc7801a247132361ac2f08991b670f5f20326
@@ -1,12 +1,6 @@
1
1
  require 'mongoid'
2
2
  require 'active_model'
3
3
  require 'active_support'
4
- require 'sinatra/base'
5
- require 'sinatra/config_file'
6
- require 'platform-api'
7
- require 'draper'
8
- require 'faraday'
9
- require 'sinatra/custom_logger'
10
4
  require 'dotenv/load'
11
5
 
12
6
  # Main module of the application, holding all the subsequent classes.
@@ -16,6 +10,8 @@ module Arkaan
16
10
  autoload :Authentication, 'arkaan/authentication'
17
11
  autoload :Campaign , 'arkaan/campaign'
18
12
  autoload :Campaigns , 'arkaan/campaigns'
13
+ autoload :Chatroom , 'arkaan/chatroom'
14
+ autoload :Chatrooms , 'arkaan/chatrooms'
19
15
  autoload :Concerns , 'arkaan/concerns'
20
16
  autoload :Factories , 'arkaan/factories'
21
17
  autoload :Files , 'arkaan/files'
@@ -63,6 +63,11 @@ module Arkaan
63
63
  # @!attribute [rw] permissions
64
64
  # @return [Array<Arkaan::Files::Permission>] the file access permissions granted to this account.
65
65
  has_many :permissions, class_name: 'Arkaan::Files::Permission', inverse_of: :account
66
+ # @!attribute [rw] messages
67
+ # @return [Array<Arkaan::Chatrooms::Messages>] all the messages ever sent by the user.
68
+ has_many :messages, class_name: 'Arkaan::Chatrooms::Message', inverse_of: :account
69
+
70
+ has_many :memberships, class_name: 'Arkaan::Chatrooms::Membership', inverse_of: :account
66
71
 
67
72
  # @!attribute [rw] notifications
68
73
  # @return [Array<Arkaan::Notification>] the notifications linked to this user.
@@ -28,9 +28,9 @@ module Arkaan
28
28
  # @return [Array<Arkaan::Files::Document>] the files uploaded in this campaign.
29
29
  has_many :files, class_name: 'Arkaan::Files::Document'
30
30
 
31
- # @!attribute [rw] messages
32
- # @return [Array<Arkaan::Campaigns::Messages::Base>] the messages sent in the chatroom of the campaign.
33
- embeds_many :messages, class_name: 'Arkaan::Campaigns::Message', inverse_of: :campaign
31
+ # @!attribute [rw] chatroom
32
+ # @return [Arkaan::Chatrooms::Campaign] the chatroom linked to this campaign.
33
+ embeds_one :chatroom, class_name: 'Arkaan::Chatrooms::Campaign', inverse_of: :campaign
34
34
 
35
35
  # @!attribute [rw] ruleset
36
36
  # @return [Arkaan::Ruleset] the set of rules this campaign is based upon.
@@ -90,5 +90,13 @@ module Arkaan
90
90
  def players_count
91
91
  players.count
92
92
  end
93
+
94
+ def messages
95
+ chatroom.messages
96
+ end
97
+
98
+ after_initialize do
99
+ self.chatroom = Arkaan::Chatrooms::Campaign.new(campaign: self)
100
+ end
93
101
  end
94
102
  end
@@ -3,7 +3,6 @@ module Arkaan
3
3
  # @author Vincent Courtois <courtois.vincent@outlook.com>
4
4
  module Campaigns
5
5
  autoload :Invitation, 'arkaan/campaigns/invitation'
6
- autoload :Message , 'arkaan/campaigns/message'
7
6
  autoload :Tag , 'arkaan/campaigns/tag'
8
7
  end
9
8
  end
@@ -0,0 +1,11 @@
1
+ module Arkaan
2
+ # The chatrooms modules regroup all classes concerning messages between players.
3
+ # @author Vincent Courtois <courtois.vincent@outlook.com>
4
+ module Chatrooms
5
+ autoload :Base , 'arkaan/chatrooms/base'
6
+ autoload :Campaign , 'arkaan/chatrooms/campaign'
7
+ autoload :Conversation, 'arkaan/chatrooms/conversation'
8
+ autoload :Message , 'arkaan/chatrooms/message'
9
+ autoload :Membership , 'arkaan/chatrooms/membership'
10
+ end
11
+ end
@@ -0,0 +1,14 @@
1
+ module Arkaan
2
+ module Chatrooms
3
+ # The base chatroom class, made to be subclassed in campaign and personal chatrooms.
4
+ # @author Vincent Courtois <courtois.vincent@outlook.com>
5
+ class Base
6
+ include Mongoid::Document
7
+ include Mongoid::Timestamps
8
+
9
+ # @!attribute [rw] messages
10
+ # @return [Array<Arkaan::Chatrooms::Message>] the messages sent in this chatroom.
11
+ has_many :messages, class_name: 'Arkaan::Chatrooms::Message', inverse_of: :chatroom
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,11 @@
1
+ module Arkaan
2
+ module Chatrooms
3
+ # Represents the chatroom embedded in a campaign.
4
+ # @author Vincent Courtois <courtois.vincent@outlook.com>
5
+ class Campaign < Arkaan::Chatrooms::Base
6
+ # @!attribute [rw] campaign
7
+ # @return [Arkaan::Campaign] the campaign the chatroom is linked to.
8
+ embedded_in :campaign, class_name: 'Arkaan::Campaign', inverse_of: :chatroom
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ module Arkaan
2
+ module Chatrooms
3
+ class Conversation < Arkaan::Chatrooms::Base
4
+ has_many :memberships, class_name: 'Arkaan::Chatrooms::Membership', inverse_of: :chatroom
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ module Arkaan
2
+ module Chatrooms
3
+ class Membership
4
+ include Mongoid::Document
5
+ include Mongoid::Timestamps
6
+ include Arkaan::Concerns::Enumerable
7
+
8
+ enum_field :status, [:shown, :hidden], default: :shown
9
+
10
+ belongs_to :chatroom, class_name: 'Arkaan::Chatrooms::Private', inverse_of: :memberships
11
+
12
+ belongs_to :account, class_name: 'Arkaan::Account', inverse_of: :memberships
13
+ end
14
+ end
15
+ end
@@ -1,5 +1,5 @@
1
1
  module Arkaan
2
- module Campaigns
2
+ module Chatrooms
3
3
  # This model represents an in-game tchat message sent in the tchat of a campaign.
4
4
  # @author Vincent Courtois <courtois.vincent@outlook.com>
5
5
  class Message
@@ -13,16 +13,19 @@ module Arkaan
13
13
  # @!attribute [rw] data
14
14
  # @return [Hash] the additional data passed to the message (arguments of the command, or content of the text)
15
15
  field :data, type: Hash, default: {}
16
+ # @!attribute {rw} raw
17
+ # @return [String] the content as typed by the user, without any parsing or transformation.
18
+ field :raw, type: String, default: ''
16
19
  # @!attribute [rw] deleted
17
20
  # @return [Boolean] TRUE if the message has been marked as deleted by its user, FALSE otherwise.
18
21
  field :deleted, type: Boolean, default: false
19
22
 
20
23
  # @!attribute [rw] campaign
21
- # @return [Arkaan::Campaign] the campaign in which the message has been emitted.
22
- embedded_in :campaign, class_name: 'Arkaan::Campaign', inverse_of: :messages
24
+ # @return [Arkaan::Chatrooms::Campaign] the chatroom in which the message has been emitted.
25
+ belongs_to :chatroom, class_name: 'Arkaan::Chatrooms::Campaign', inverse_of: :messages
23
26
  # @!attribute [rw] player
24
27
  # @return [Arkaan::Account] the account that has emitted the message in the campaign.
25
- belongs_to :player, class_name: 'Arkaan::Campaigns::Invitation'
28
+ belongs_to :account, class_name: 'Arkaan::Account', inverse_of: :messages
26
29
  end
27
30
  end
28
31
  end
@@ -1,3 +1,3 @@
1
1
  module Arkaan
2
- VERSION = '2.4.1'
2
+ VERSION = '2.5.0'
3
3
  end
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.1
4
+ version: 2.5.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: 2020-01-09 00:00:00.000000000 Z
11
+ date: 2020-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -220,90 +220,6 @@ dependencies:
220
220
  - - '='
221
221
  - !ruby/object:Gem::Version
222
222
  version: 3.1.11
223
- - !ruby/object:Gem::Dependency
224
- name: sinatra
225
- requirement: !ruby/object:Gem::Requirement
226
- requirements:
227
- - - '='
228
- - !ruby/object:Gem::Version
229
- version: 2.0.5
230
- type: :runtime
231
- prerelease: false
232
- version_requirements: !ruby/object:Gem::Requirement
233
- requirements:
234
- - - '='
235
- - !ruby/object:Gem::Version
236
- version: 2.0.5
237
- - !ruby/object:Gem::Dependency
238
- name: sinatra-contrib
239
- requirement: !ruby/object:Gem::Requirement
240
- requirements:
241
- - - '='
242
- - !ruby/object:Gem::Version
243
- version: 2.0.5
244
- type: :runtime
245
- prerelease: false
246
- version_requirements: !ruby/object:Gem::Requirement
247
- requirements:
248
- - - '='
249
- - !ruby/object:Gem::Version
250
- version: 2.0.5
251
- - !ruby/object:Gem::Dependency
252
- name: platform-api
253
- requirement: !ruby/object:Gem::Requirement
254
- requirements:
255
- - - '='
256
- - !ruby/object:Gem::Version
257
- version: 2.1.0
258
- type: :runtime
259
- prerelease: false
260
- version_requirements: !ruby/object:Gem::Requirement
261
- requirements:
262
- - - '='
263
- - !ruby/object:Gem::Version
264
- version: 2.1.0
265
- - !ruby/object:Gem::Dependency
266
- name: faraday
267
- requirement: !ruby/object:Gem::Requirement
268
- requirements:
269
- - - '='
270
- - !ruby/object:Gem::Version
271
- version: 0.15.2
272
- type: :runtime
273
- prerelease: false
274
- version_requirements: !ruby/object:Gem::Requirement
275
- requirements:
276
- - - '='
277
- - !ruby/object:Gem::Version
278
- version: 0.15.2
279
- - !ruby/object:Gem::Dependency
280
- name: draper
281
- requirement: !ruby/object:Gem::Requirement
282
- requirements:
283
- - - '='
284
- - !ruby/object:Gem::Version
285
- version: 3.1.0
286
- type: :runtime
287
- prerelease: false
288
- version_requirements: !ruby/object:Gem::Requirement
289
- requirements:
290
- - - '='
291
- - !ruby/object:Gem::Version
292
- version: 3.1.0
293
- - !ruby/object:Gem::Dependency
294
- name: actionview
295
- requirement: !ruby/object:Gem::Requirement
296
- requirements:
297
- - - '='
298
- - !ruby/object:Gem::Version
299
- version: 5.2.3
300
- type: :runtime
301
- prerelease: false
302
- version_requirements: !ruby/object:Gem::Requirement
303
- requirements:
304
- - - '='
305
- - !ruby/object:Gem::Version
306
- version: 5.2.3
307
223
  - !ruby/object:Gem::Dependency
308
224
  name: dotenv
309
225
  requirement: !ruby/object:Gem::Requirement
@@ -331,8 +247,13 @@ files:
331
247
  - lib/arkaan/campaign.rb
332
248
  - lib/arkaan/campaigns.rb
333
249
  - lib/arkaan/campaigns/invitation.rb
334
- - lib/arkaan/campaigns/message.rb
335
250
  - lib/arkaan/campaigns/tag.rb
251
+ - lib/arkaan/chatrooms.rb
252
+ - lib/arkaan/chatrooms/base.rb
253
+ - lib/arkaan/chatrooms/campaign.rb
254
+ - lib/arkaan/chatrooms/conversation.rb
255
+ - lib/arkaan/chatrooms/membership.rb
256
+ - lib/arkaan/chatrooms/message.rb
336
257
  - lib/arkaan/concerns.rb
337
258
  - lib/arkaan/concerns/activable.rb
338
259
  - lib/arkaan/concerns/diagnosticable.rb
@@ -347,13 +268,11 @@ files:
347
268
  - lib/arkaan/factories.rb
348
269
  - lib/arkaan/factories/errors.rb
349
270
  - lib/arkaan/factories/errors/gateway_not_found.rb
350
- - lib/arkaan/factories/gateways.rb
351
271
  - lib/arkaan/files.rb
352
272
  - lib/arkaan/files/document.rb
353
273
  - lib/arkaan/files/permission.rb
354
274
  - lib/arkaan/monitoring.rb
355
275
  - lib/arkaan/monitoring/action.rb
356
- - lib/arkaan/monitoring/gateway.rb
357
276
  - lib/arkaan/monitoring/instance.rb
358
277
  - lib/arkaan/monitoring/results.rb
359
278
  - lib/arkaan/monitoring/results/heartbeat.rb
@@ -393,7 +312,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
393
312
  - !ruby/object:Gem::Version
394
313
  version: '0'
395
314
  requirements: []
396
- rubygems_version: 3.0.3
315
+ rubygems_version: 3.1.2
397
316
  signing_key:
398
317
  specification_version: 4
399
318
  summary: The model layer for my table-RPG application
@@ -1,19 +0,0 @@
1
- module Arkaan
2
- module Factories
3
- # This class provides methods to create decorated services.
4
- # @author Vincent Courtois <courtois.vincent@outlook.com>
5
- class Gateways
6
-
7
- # Searches for a gateway via its key and returns it decorated.
8
- # @param key [String] the key of the server you want to find.
9
- # @return [Arkaan::Decorators::Gateway, NilClass] nil if the gateway is not found, or the decorated gateway.
10
- def self.random(action)
11
- gateway = Arkaan::Monitoring::Gateway.where(active: true, running: true).first
12
- if gateway.nil?
13
- raise Arkaan::Factories::Errors::GatewayNotFound.new(action: action)
14
- end
15
- return Arkaan::Decorators::Gateway.new(action, gateway)
16
- end
17
- end
18
- end
19
- end
@@ -1,37 +0,0 @@
1
- module Arkaan
2
- module Monitoring
3
- # A gateway is a portal by which you access the different web services of the application suite.
4
- # @author Vincent Courtois <courtois.vincent@outlook.com>
5
- class Gateway
6
- include Mongoid::Document
7
- include Mongoid::Timestamps
8
- include Arkaan::Concerns::Activable
9
- include Arkaan::Concerns::Diagnosticable
10
- include Arkaan::Concerns::Typable
11
-
12
- # @!attribute [rw] url
13
- # @return [String] the URL of the gateway, where the requests will be issued.
14
- field :url, type: String
15
- # @!attribute [rw] running
16
- # @return [Boolean] the running status of the gateway, indicating if it can be used or not.
17
- field :running, type: Boolean, default: false
18
- # @!attribute [rw] gateways
19
- # @return [String] the uniq token for this gateway, identifying it in the micro services.
20
- field :token, type: String
21
-
22
- scope :running , ->{ where(running: true) }
23
-
24
- validates :url,
25
- presence: {message: 'required'},
26
- format: {
27
- with: /\A(https?:\/\/)((localhost:[0-9]+)|(([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*)|(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b):([0-9]{2,6}))\/?\z/,
28
- message: 'pattern',
29
- if: :url?
30
- }
31
-
32
- validates :token,
33
- presence: {message: 'required'},
34
- uniqueness: {message: 'uniq'}
35
- end
36
- end
37
- end