arkaan 0.7.31 → 0.8.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
  SHA1:
3
- metadata.gz: 77f8d1df2ebb7dc142587208e5a6f30b919cac53
4
- data.tar.gz: 2348657e1481a30f0c5eed27cb348087f35cbe6d
3
+ metadata.gz: 99784662e90ac8d01942af0ff731c8ccdaea5ca7
4
+ data.tar.gz: 24a58fbc83b503391d8e1c2f35fcd9795a18c86c
5
5
  SHA512:
6
- metadata.gz: f2e57b7e8fad3f40ef14012cf50cd9a0faf95736fd85c66742af1d721ada22a55a63983e86ef0fdd1b9d768f30d394552cf91e8845d278667697620249909dcc
7
- data.tar.gz: 855bcb73bd92972d7db34610913f68d1a2f5ace907dda7c89f2228096f292346d46056c057c4bb346bac2275aab17724c16c5401625fbf8a22c85d973acae823
6
+ metadata.gz: 26a4d46f772c44d7a0db3a811d15c7dea4054e2ac70d86dae98d9022fece67c69708f9e43411ebfb7a357174ebc918e577b77ab407283388832c1d2eda341413
7
+ data.tar.gz: 387f9a97be48f491fa70b82a039a257b309778a80caf6f75ac6d06db91c5003ec3b174c2700cfb7c837666066cda1c50cdcedfb67ce1cb30b756cf4a3bdf887e
@@ -8,6 +8,7 @@ require 'sinatra/base'
8
8
  module Arkaan
9
9
  autoload :Account , 'arkaan/account'
10
10
  autoload :Authentication, 'arkaan/authentication'
11
+ autoload :Campaign , 'arkaan/campaign'
11
12
  autoload :Concerns , 'arkaan/concerns'
12
13
  autoload :Monitoring , 'arkaan/monitoring'
13
14
  autoload :OAuth , 'arkaan/oauth'
@@ -41,10 +41,14 @@ module Arkaan
41
41
  # @return [Array<Arkaan::OAuth::Authorization>] the authorization issued by this account to third-party applications to access its data.
42
42
  has_many :authorizations, class_name: 'Arkaan::OAuth::Authorization', inverse_of: :account
43
43
  # @!attribute [rw] services
44
- # @return [Array<Arkaan::Monitoring::Service] the services created by this user.
44
+ # @return [Array<Arkaan::Monitoring::Service>] the services created by this user.
45
45
  has_many :services, class_name: 'Arkaan::Monitoring::Service', inverse_of: :creator
46
-
46
+ # @!attribute [rw] sessions
47
+ # @return [Array<Arkaan::Authentication::Session>] the sessions on which this account is, or has been logged in.
47
48
  has_many :sessions, class_name: 'Arkaan::Authentication::Session', inverse_of: :account
49
+ # @!attribute [rw] campaigns
50
+ # @return [Array<Arkaan::Campaign>] the campaigns this account has created.
51
+ has_many :campaigns, class_name: 'Arkaan::Campaign', inverse_of: :creator
48
52
 
49
53
  attr_readonly :password_digest
50
54
 
@@ -0,0 +1,35 @@
1
+ module Arkaan
2
+ # A campaign is a gathering of accounts playing on the same interface, and interacting in a common game.
3
+ # @author Vincent Courtois <courtois.vincent@outlook.com>
4
+ class Campaign
5
+ include Mongoid::Document
6
+ include Mongoid::Timestamps
7
+
8
+ # @!attribute [rw] title
9
+ # @return [String] the title, or name, of the campaign, used to identify it in the list.
10
+ field :title, type: String
11
+ # @!attribute [rw] description
12
+ # @return [String] a more detailed description, used to give further information about the campaign in general.
13
+ field :description, type: String
14
+ # @!attribute [rw] is_private
15
+ # @return [Boolean] TRUE if the campaign can be joined only by being invited by the creator, FALSE if it's publicly displayed and accessible.
16
+ field :is_private, type: Boolean, default: true
17
+
18
+ # @!attribute [rw] creator
19
+ # @return [Arkaan::Campaign] the account creating the campaign, and considered "game master".
20
+ belongs_to :creator, class_name: 'Arkaan::Account', inverse_of: :campaigns
21
+
22
+ validates :title,
23
+ presence: {message: 'campaign.title.blank'},
24
+ length: {minimum: 4, message: 'campaign.title.short', if: :title?}
25
+
26
+ validate :title_unicity
27
+
28
+ # Adds an error message if the account creating this campaign already has a campaign with the very same name.
29
+ def title_unicity
30
+ if title? && creator.campaigns.where(title: title, :id.ne => _id).exists?
31
+ errors.add(:title, 'campaign.title.uniq')
32
+ end
33
+ end
34
+ end
35
+ 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: 0.7.31
4
+ version: 0.8.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: 2018-03-09 00:00:00.000000000 Z
11
+ date: 2018-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -188,6 +188,7 @@ files:
188
188
  - lib/arkaan/account.rb
189
189
  - lib/arkaan/authentication.rb
190
190
  - lib/arkaan/authentication/session.rb
191
+ - lib/arkaan/campaign.rb
191
192
  - lib/arkaan/concerns.rb
192
193
  - lib/arkaan/concerns/activable.rb
193
194
  - lib/arkaan/concerns/diagnosticable.rb