arkaan 0.8.21 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 62fc4db782fa9567378e611fe99216336f19be83
4
- data.tar.gz: 72b3b782759418f5b670e5c3ee96b5d06e36e735
3
+ metadata.gz: cc39dec4721b328451c73cde4e780f9917f66b9c
4
+ data.tar.gz: 06c34ff8141b36f29b7400c05e4f6b3d43c71fcc
5
5
  SHA512:
6
- metadata.gz: 7a7083bab94b71ae595ca98197a91ea18c6a046a97009bdce03030a097e132431616e124a75e51228493350ec196d99aa2e7c8358d79e5ed4374c48ce023a1d4
7
- data.tar.gz: ea4c07a5e3be90920febefdf99579fa6e6a0f090565b3c4126eee08550c9d3519c7bd3d17dff2f05a11ca2e8439866b58a7cff2593eb3b2042e494f1bb52ecd9
6
+ metadata.gz: 9364b342574cccb18d98d01513438b04f30a988d7732a94f3d7560b0ce3b2f4339d6ac435fc32f4d69f89d034bc8f48665e4d03570b637f20c0ef874eac50349
7
+ data.tar.gz: 235201b877ff1707df05753b9e61da44e9aa388205d9721e8896043fcc4b27f39005ef545c45ab8acbb9ed92e3d55cdb874df842b99842f6425ad96e4797b101
@@ -15,5 +15,6 @@ module Arkaan
15
15
  autoload :Monitoring , 'arkaan/monitoring'
16
16
  autoload :OAuth , 'arkaan/oauth'
17
17
  autoload :Permissions , 'arkaan/permissions'
18
+ autoload :Phone , 'arkaan/phone'
18
19
  autoload :Utils , 'arkaan/utils'
19
20
  end
@@ -18,9 +18,6 @@ module Arkaan
18
18
  # @!attribute [rw] firstname
19
19
  # @return [String] the first name of the user.
20
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
21
  # @!attribute [rw] email
25
22
  # @return [String] the email address of the user, useful to contact them ; it must be given, unique, and have an email format.
26
23
  field :email, type: String
@@ -57,6 +54,10 @@ module Arkaan
57
54
  # @return [Array<Arkaan::Campaigns::Invitation>] the invitations you've issued yourself to other players.
58
55
  has_many :created_invitations, class_name: 'Arkaan::Campaigns::Invitation', inverse_of: :creator
59
56
 
57
+ # @!attribute [rw] phones
58
+ # @return [Array<Arkaan::Phone>] the phone numbers given by the user.
59
+ embeds_many :phones, class_name: 'Arkaan::Phone', inverse_of: :account
60
+
60
61
  validates :username,
61
62
  presence: {message: 'required'},
62
63
  length: {minimum: 6, message: 'minlength', if: :username?},
@@ -5,13 +5,11 @@ module Arkaan
5
5
  class Invitation
6
6
  include Mongoid::Document
7
7
  include Mongoid::Timestamps
8
+ include Arkaan::Concerns::Enumerable
8
9
 
9
- # @!attribute [rw] accepted
10
- # @return [Boolean] TRUE if the invitation has been accepted, false otherwise.
11
- field :accepted, type: Boolean, default: false
12
- # @!attribute [rw] accepted_at
13
- # @return [DateTime] the date at which the invitation has been accepted.
14
- field :accepted_at, type: DateTime, default: nil
10
+ # @!attribute [rw] status
11
+ # @return [Symbol] the current status of the invitation.
12
+ enum_field :status, [:accepted, :expelled, :ignored, :pending, :refused], default: :pending
15
13
 
16
14
  # @!attribute [rw] account
17
15
  # @return [Arkaan::Account] the account the invitation has been issued to.
@@ -5,6 +5,7 @@ module Arkaan
5
5
  autoload :Sluggable, 'arkaan/concerns/sluggable'
6
6
  autoload :Activable, 'arkaan/concerns/activable'
7
7
  autoload :Diagnosticable, 'arkaan/concerns/diagnosticable'
8
+ autoload :Enumerable, 'arkaan/concerns/enumerable'
8
9
  autoload :Premiumable, 'arkaan/concerns/premiumable'
9
10
  end
10
11
  end
@@ -0,0 +1,44 @@
1
+ module Arkaan
2
+ module Concerns
3
+ # Defines enumerations for the Mongoid models. An enumeration is a field that can only use a given set of values.
4
+ # @author Vincent Courtois <courtois.vincent@outlook.com>
5
+ module Enumerable
6
+ extend ActiveSupport::Concern
7
+
8
+ # Submodule holding all the static methods add to the current subclass.
9
+ # @author Vincent Courtois <courtois.vincent@outlook.com>
10
+ module ClassMethods
11
+
12
+ # Creates the field with the given name, set of possible values, and options.
13
+ # @param name [String] the name of the enumerated field.
14
+ # @param values [Array<Symbol>] the possible values of the enumerated field.
15
+ # @param options [Hash<Symbol, Any>] the possible options for the field.
16
+ def enum_field(field_name, values, options = {})
17
+ field :"enum_#{field_name}", type: Symbol, default: options[:default]
18
+
19
+ validates :"enum_#{field_name}", inclusion: {in: values.map(&:to_sym), message: 'inclusion'}
20
+
21
+ define_method field_name do
22
+ return self["enum_#{field_name}"]
23
+ end
24
+
25
+ define_method "#{field_name}=" do |value|
26
+ if values.include? value
27
+ self["enum_#{field_name}"] = value.to_sym
28
+ end
29
+ end
30
+
31
+ values.map(&:to_sym).each do |value|
32
+ define_method "#{field_name}_#{value}!" do
33
+ self["enum_#{field_name}"] = value
34
+ end
35
+
36
+ define_method "#{field_name}_#{value}?" do
37
+ self["enum_#{field_name}"] == value
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,24 @@
1
+ module Arkaan
2
+ # A phone number is given by a user so that the persons he has selected can have it to contact him.
3
+ # @author Vincent Courtois <courtois.vincent@outlook.com>
4
+ class Phone
5
+ include Mongoid::Document
6
+ include Mongoid::Timestamps
7
+ include Arkaan::Concerns::Enumerable
8
+
9
+ # @!attribute [rw] privacy
10
+ # @return [Symbol] the level of privacy you want for this phone number.
11
+ enum_field :privacy, [:players, :public, :private], default: :private
12
+ # @!attribute [rw] number
13
+ # @return [Integer] the phone number the user has given.
14
+ field :number, type: Integer
15
+
16
+ # @!attribute [rw] account
17
+ # @return [Arkaan::Account] the account the phone number is associated to.
18
+ embedded_in :account, class_name: 'Arkaan::Account', inverse_of: :phones
19
+
20
+ validates :number,
21
+ presence: {message: 'required'},
22
+ format: {with: /\A[0-9\-\._\/]+\z/, message: 'pattern'}
23
+ end
24
+ 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.8.21
4
+ version: 0.9.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-04-12 00:00:00.000000000 Z
11
+ date: 2018-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -209,6 +209,7 @@ files:
209
209
  - lib/arkaan/concerns.rb
210
210
  - lib/arkaan/concerns/activable.rb
211
211
  - lib/arkaan/concerns/diagnosticable.rb
212
+ - lib/arkaan/concerns/enumerable.rb
212
213
  - lib/arkaan/concerns/premiumable.rb
213
214
  - lib/arkaan/concerns/sluggable.rb
214
215
  - lib/arkaan/monitoring.rb
@@ -225,6 +226,7 @@ files:
225
226
  - lib/arkaan/permissions/category.rb
226
227
  - lib/arkaan/permissions/group.rb
227
228
  - lib/arkaan/permissions/right.rb
229
+ - lib/arkaan/phone.rb
228
230
  - lib/arkaan/specs.rb
229
231
  - lib/arkaan/utils.rb
230
232
  - lib/arkaan/utils/controller.rb