arkaan 2.5.1 → 2.7.3

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: 80b65e16a31919ea1c4b6958699a8f04761f2c3274295bcaac34fc70a46fabed
4
- data.tar.gz: 2e3373367d3d606bb3428071019ab3855c48fbbc046b493389854fa194d65f0e
3
+ metadata.gz: a83c8382a59bc6c36c6d3e57fec6e1b36ae844b11236a33ef648d0e01b96a516
4
+ data.tar.gz: 7de1e0cc0429fd5c45a5742ebf3a88edf71be48c8231140a51ec691e074a970e
5
5
  SHA512:
6
- metadata.gz: aecaa05461f94dcd92e220a8c190cf2f63128c9a5d452f8e439e9ac6364484895b7c539db63ed3cdcbc2c77aef6d4f2a8499bb7fa5486f708b829b629ed42927
7
- data.tar.gz: '09c8362fabd66d216e7f22b20d2792ed5071c255ad356a39c222422eefeb013f0c9b0c68d100461980e05522d3e34b8263ef53eee410c9c04392d48b6a9dbe04'
6
+ metadata.gz: ac529b127c994f01ce22bc1f25695effe0849b2b3ddb69e407b79b83178edd601467741d37210c331a60490550c3a1225c161912e9d18a1fb2fbe282ac3570f3
7
+ data.tar.gz: 5f5dac519c25cad9aae2e55db96caee89eb9f239e289470dede24c42dd5b38068b7e1e1d2cd00b2facc196c29e50c3e79957379085fd3f0e26fdde5efc952a95
@@ -13,6 +13,7 @@ module Arkaan
13
13
  autoload :Chatroom , 'arkaan/chatroom'
14
14
  autoload :Chatrooms , 'arkaan/chatrooms'
15
15
  autoload :Concerns , 'arkaan/concerns'
16
+ autoload :Event , 'arkaan/event'
16
17
  autoload :Factories , 'arkaan/factories'
17
18
  autoload :Files , 'arkaan/files'
18
19
  autoload :Monitoring , 'arkaan/monitoring'
@@ -57,9 +57,6 @@ module Arkaan
57
57
  # @!attribute [rw] invitations
58
58
  # @return [Array<Arkaan::Campaigns::Invitation>] the invitations you've issued yourself to other players.
59
59
  has_many :created_invitations, class_name: 'Arkaan::Campaigns::Invitation', inverse_of: :creator
60
- # @!attribute [rw] websockets
61
- # @return [Array<Arkaan::Monitoring::Websocket>] the websockets created by the owner of this account.
62
- has_many :websockets, class_name: 'Arkaan::Monitoring::Websocket', inverse_of: :creator
63
60
  # @!attribute [rw] permissions
64
61
  # @return [Array<Arkaan::Files::Permission>] the file access permissions granted to this account.
65
62
  has_many :permissions, class_name: 'Arkaan::Files::Permission', inverse_of: :account
@@ -51,14 +51,18 @@ module Arkaan
51
51
  # @param account [Arkaan::Account] the account of the creator for this campaign.
52
52
  def creator=(account)
53
53
  if !invitations.where(account: account).exists?
54
- Arkaan::Campaigns::Invitation.create(campaign: self, account: account, enum_status: :creator)
54
+ invitation = Arkaan::Campaigns::Invitation.create(
55
+ campaign: self,
56
+ account: account,
57
+ status: :creator
58
+ )
55
59
  end
56
60
  end
57
61
 
58
62
  # Getter for the creator account of this campaign.
59
63
  # @return [Arkaan::Account] the account of the player creating this campaign.
60
64
  def creator
61
- return invitations.where(enum_status: :creator).first.account
65
+ invitations.to_a.find(&:status_creator?).account
62
66
  end
63
67
 
64
68
  # Adds an error message if the account creating this campaign already has a campaign with the very same name.
@@ -83,7 +87,9 @@ module Arkaan
83
87
 
84
88
  # @return [Array<Arkaan::Campaigns::Invitation>] the players in this campaign.
85
89
  def players
86
- invitations.where(enum_status: :accepted)
90
+ invitations.to_a.select do |invitation|
91
+ [:creator, :accepted].include? invitation.enum_status
92
+ end
87
93
  end
88
94
 
89
95
  # @return [Integer] the number of players in this campaign.
@@ -1,15 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Arkaan
2
4
  module Campaigns
3
- # An invitation is the linked between a player and a campaign, accepted or not.
5
+ # An invitation is the linked between a player and a campaign.
6
+ # It keeps the history of the interaction between the player and the campaign.
7
+ #
4
8
  # @author Vincent Courtois <courtois.vincent@outlook.com>
5
9
  class Invitation
6
10
  include Mongoid::Document
7
11
  include Mongoid::Timestamps
8
12
  include Arkaan::Concerns::Enumerable
9
-
10
- # @!attribute [rw] status
11
- # @return [Symbol] the current status of the invitation.
12
- enum_field :status, [:accepted, :blocked, :expelled, :ignored, :left, :pending, :refused, :request, :creator], default: :pending
13
+ include Arkaan::Concerns::Historizable
13
14
 
14
15
  # @!attribute [rw] account
15
16
  # @return [Arkaan::Account] the account the invitation has been issued to.
@@ -17,6 +18,12 @@ module Arkaan
17
18
  # @!attribute [rw] campaign
18
19
  # @return [Arkaan::Campaign] the campaign the invitation has been made in.
19
20
  belongs_to :campaign, class_name: 'Arkaan::Campaign', inverse_of: :invitations
21
+
22
+ # @!attribute [rw] status
23
+ # @return [Symbol] the current status of the invitation.
24
+ historize enum_field :status,
25
+ [:pending, :request, :accepted, :refused, :expelled, :left, :master, :creator],
26
+ default: :pending
20
27
  end
21
28
  end
22
- end
29
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Arkaan
2
4
  module Campaigns
3
5
  # A campaign tag is a string describing a characteristic of the campaign it's in.
@@ -13,9 +15,7 @@ module Arkaan
13
15
  # @return [Integer] the number of campaigns this tag is in, avoiding a join.
14
16
  field :count, type: Integer, default: 1
15
17
 
16
- validates :content,
17
- presence: {message: 'required'},
18
- uniqueness: {message: 'uniq'}
18
+ validates :content, presence: { message: 'required' }, uniqueness: { message: 'uniq' }
19
19
  end
20
20
  end
21
- end
21
+ end
@@ -5,6 +5,7 @@ module Arkaan
5
5
  autoload :Activable , 'arkaan/concerns/activable'
6
6
  autoload :Diagnosticable, 'arkaan/concerns/diagnosticable'
7
7
  autoload :Enumerable , 'arkaan/concerns/enumerable'
8
+ autoload :Historizable , 'arkaan/concerns/historizable'
8
9
  autoload :MimeTypable , 'arkaan/concerns/mime_typable'
9
10
  autoload :Premiumable , 'arkaan/concerns/premiumable'
10
11
  autoload :Sluggable , 'arkaan/concerns/sluggable'
@@ -14,7 +14,7 @@ module Arkaan
14
14
  # @param values [Array<Symbol>] the possible values of the enumerated field.
15
15
  # @param options [Hash<Symbol, Any>] the possible options for the field.
16
16
  def enum_field(field_name, values, options = {})
17
- field :"enum_#{field_name}", type: Symbol, default: options[:default]
17
+ returned = field :"enum_#{field_name}", type: Symbol, default: options[:default]
18
18
 
19
19
  validates :"enum_#{field_name}", inclusion: {in: values.map(&:to_sym), message: 'inclusion'}
20
20
 
@@ -37,6 +37,10 @@ module Arkaan
37
37
  self["enum_#{field_name}"] == value
38
38
  end
39
39
  end
40
+
41
+ # This is to make enumerations historizable by
42
+ # returning the field object created by Mongoid.
43
+ returned
40
44
  end
41
45
  end
42
46
  end
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Arkaan
4
+ module Concerns
5
+ # This module is what I call "a beautiful piece of Ruby engineering"
6
+ # It takes any mongoid field that you may have declared, and historizes
7
+ # it in a dedicated relation if this relation does not already exists.
8
+ #
9
+ # What it does exactly :
10
+ # - Creates the :history relation if it does not already exists.
11
+ # - Creates a method to check for changes of a specific attribute.
12
+ # - Check for changes at initialization to insert the first value.
13
+ # - Check for changes at update/save to store the history.
14
+ #
15
+ # @author Vincent Courtois <courtois.vincent@outlook.com>
16
+ module Historizable
17
+ extend ActiveSupport::Concern
18
+
19
+ # Adds an entry in the history table for the given field.
20
+ # It checks several things to make the history entry valid :
21
+ # - the new value is different from the old value
22
+ # - the old value is identical to the last recorded new value.
23
+ #
24
+ # @param field [String] the name of the field to historize
25
+ # @param from [Any] the old value before update
26
+ # @param to [Any] the new value after update.
27
+ def add_history(field:, from:, to:)
28
+ return if from == to
29
+ return if !history.empty? && history.order_by(:created_at.desc).first.to != from
30
+
31
+ event = Arkaan::Event.create(field: field, from: from, to: to, document: self)
32
+ event.save
33
+ end
34
+
35
+ # Submodule holding all the static methods add to the current subclass.
36
+ # @author Vincent Courtois <courtois.vincent@outlook.com>
37
+ module ClassMethods
38
+
39
+ # Takes the Mongoid declared field and creates the callbacks
40
+ # to intercept any value change and add it to the history.
41
+ # @field field [Mongoid::Fields::Standard] the Mongoid field to historize.
42
+ def historize(field)
43
+
44
+ unless relations.key?('history')
45
+ embeds_many :history, class_name: 'Arkaan::Event'
46
+ end
47
+
48
+ after_initialize do |doc|
49
+ add_history(field: field.name, from: nil, to: doc[field.name])
50
+ end
51
+
52
+ after_save do |doc|
53
+ if doc.changed_attributes.key?(field.name)
54
+ from = doc.changed_attributes[field.name]
55
+ add_history(field: field.name, from: from, to: doc[field.name])
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Arkaan
4
+ # An event is symbolizing a timestamped change in a model.
5
+ # It is recommended NOT to use this class directly but to use
6
+ # the Arkaan::Concerns::Historizable concern in a model.
7
+ #
8
+ # @author Vincent Courtois <courtois.vincent@outlook.com>
9
+ class Event
10
+ include Mongoid::Document
11
+ include Mongoid::Timestamps
12
+
13
+ # @!attribute [rw] field
14
+ # @return [String] the name of the field being historized
15
+ field :field, type: String
16
+ # @!attribute [rw] from
17
+ # @return [Any] the value of the field before update
18
+ field :from
19
+ # @!attribute [rw] to
20
+ # @return [Any] the value of the field after update
21
+ field :to
22
+
23
+ # @!attribute [rw] document
24
+ # @return [Any] the model in which the history is embedded
25
+ embedded_in :document, polymorphic: true, inverse_of: :history
26
+
27
+ validates :field, presence: { message: 'required' }
28
+ end
29
+ end
@@ -2,12 +2,7 @@ module Arkaan
2
2
  # The monitoring module holds all the logic about the services so they can be activated or deactivated.
3
3
  # @author Vincent Courtois <courtois.vincent@outlook.com>
4
4
  module Monitoring
5
- autoload :Action , 'arkaan/monitoring/action'
6
- autoload :Instance , 'arkaan/monitoring/instance'
7
- autoload :Results , 'arkaan/monitoring/results'
8
- autoload :Route , 'arkaan/monitoring/route'
9
- autoload :Service , 'arkaan/monitoring/service'
10
- autoload :Vigilante, 'arkaan/monitoring/vigilante'
11
- autoload :Websocket, 'arkaan/monitoring/websocket'
5
+ autoload :Route , 'arkaan/monitoring/route'
6
+ autoload :Service, 'arkaan/monitoring/service'
12
7
  end
13
8
  end
@@ -10,21 +10,15 @@ module Arkaan
10
10
  include Arkaan::Concerns::Premiumable
11
11
 
12
12
  # @!attribute [rw] key
13
- # @return [String] the name, or title of the service, optionally given to identify it more easily.
13
+ # @return [String] the name of the service, used as a namespace on the Kubernetes side.
14
14
  field :key, type: String
15
15
  # @!attribute [rw] path
16
- # @return [String] the path the service will be mapped on in the API.
16
+ # @return [String] the path the service will be mapped on in the API. This will be used in the Ingress.
17
17
  field :path, type: String, default: '/'
18
- # @!attribute [rw] test_mode
19
- # @return [Boolean] TRUE if the service is currently in test mode and thus the gateway shall only qurty local instances.
20
- field :test_mode, type: Boolean, default: false
21
18
 
22
19
  # @!attribute [rw] creator
23
20
  # @return [Arkaan::Account] the creator of this service.
24
21
  belongs_to :creator, class_name: 'Arkaan::Account', optional: true, inverse_of: :services
25
- # @!attribute [rw] instances
26
- # @return [Array<Arkaan::Monitoring::Instance>] the instances of this service currently deployed.
27
- embeds_many :instances, class_name: 'Arkaan::Monitoring::Instance', inverse_of: :service
28
22
  # @!attribute [rw] routes
29
23
  # @return [Array<Arkaan::Monitoring::Route>] the routes associated to this service, accessible from the gateway.
30
24
  has_many :routes, class_name: 'Arkaan::Monitoring::Route', inverse_of: :service
@@ -1,6 +1,7 @@
1
1
  module Arkaan
2
2
  module OAuth
3
- # An access token is the value assigned to the application to access the private data of an account.
3
+ # An access token is the value assigned to the application
4
+ # to access the data the user is allowed to access.
4
5
  # @author Vincent Courtois <courtois.vincent@outlook.com>
5
6
  class AccessToken
6
7
  include Mongoid::Document
@@ -15,11 +16,17 @@ module Arkaan
15
16
 
16
17
  # @!attribute [rw] authorization
17
18
  # @return [Arkaan::OAuth::Authorization] the authorization code that issued this token to the application for this user.
18
- belongs_to :authorization, class_name: 'Arkaan::OAuth::Authorization', inverse_of: :access_token
19
+ belongs_to :authorization, class_name: 'Arkaan::OAuth::Authorization', inverse_of: :tokens
19
20
 
20
21
  validates :value,
21
22
  presence: {message: 'required'},
22
23
  uniqueness: {message: 'uniq'}
24
+
25
+ # Checks if the current date is inferior to the creation date + expiration period
26
+ # @return [Boolean] TRUE if the token is expired, FALSE otherwise.
27
+ def expired?
28
+ created_at.to_time.to_i + expiration < Time.now.to_i
29
+ end
23
30
  end
24
31
  end
25
32
  end
@@ -1,6 +1,9 @@
1
1
  module Arkaan
2
2
  module OAuth
3
3
  # An OAuth authorization is granted by a user to an application to access its personal data.
4
+ # The application then transforms it into an access token to be able to send it with
5
+ # further requests, so that we know the user has authorized the application to access its data.
6
+ #
4
7
  # @author Vincent Courtois <courtois.vincent@outlook.com>
5
8
  class Authorization
6
9
  include Mongoid::Document
@@ -18,7 +21,7 @@ module Arkaan
18
21
  belongs_to :application, class_name: 'Arkaan::OAuth::Application', inverse_of: :authorizations
19
22
  # @!attribute [rw] token
20
23
  # @return [Arkaan::OAuth::AccessToken] the access token used further in the application process to access private data of the account.
21
- has_one :token, class_name: 'Arkaan::OAuth::AccessToken', inverse_of: :authorization
24
+ has_many :tokens, class_name: 'Arkaan::OAuth::AccessToken', inverse_of: :authorization
22
25
 
23
26
  validates :code,
24
27
  presence: {message: 'required'},
@@ -1,3 +1,3 @@
1
1
  module Arkaan
2
- VERSION = '2.5.1'
2
+ VERSION = '2.7.2'
3
3
  end
metadata CHANGED
@@ -1,239 +1,309 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arkaan
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.1
4
+ version: 2.7.3
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-03-23 00:00:00.000000000 Z
11
+ date: 2020-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rspec
14
+ name: database_cleaner
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 3.6.0
19
+ version: 1.6.1
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 3.6.0
26
+ version: 1.6.1
27
27
  - !ruby/object:Gem::Dependency
28
- name: rspec-json_expectations
28
+ name: factory_bot
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 2.1.0
33
+ version: 6.1.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 2.1.0
40
+ version: 6.1.0
41
41
  - !ruby/object:Gem::Dependency
42
- name: rack-test
42
+ name: factory_girl
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 0.7.0
47
+ version: 4.8.1
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 0.7.0
54
+ version: 4.8.1
55
55
  - !ruby/object:Gem::Dependency
56
- name: factory_girl
56
+ name: faker
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 4.8.1
61
+ version: 2.13.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: 4.8.1
68
+ version: 2.13.0
69
69
  - !ruby/object:Gem::Dependency
70
- name: factory_bot
70
+ name: gems
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - '='
74
74
  - !ruby/object:Gem::Version
75
- version: 5.1.1
75
+ version: 1.2.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - '='
81
81
  - !ruby/object:Gem::Version
82
- version: 5.1.1
82
+ version: 1.2.0
83
83
  - !ruby/object:Gem::Dependency
84
- name: database_cleaner
84
+ name: gitlab
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - '='
88
88
  - !ruby/object:Gem::Version
89
- version: 1.6.1
89
+ version: 4.16.1
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - '='
95
95
  - !ruby/object:Gem::Version
96
- version: 1.6.1
96
+ version: 4.16.1
97
97
  - !ruby/object:Gem::Dependency
98
- name: simplecov
98
+ name: pry
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - '='
102
102
  - !ruby/object:Gem::Version
103
- version: 0.15.1
103
+ version: 0.13.1
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - '='
109
109
  - !ruby/object:Gem::Version
110
- version: 0.15.1
110
+ version: 0.13.1
111
111
  - !ruby/object:Gem::Dependency
112
- name: yard
112
+ name: rack
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - '='
116
116
  - !ruby/object:Gem::Version
117
- version: 0.9.20
117
+ version: 2.2.3
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - '='
123
123
  - !ruby/object:Gem::Version
124
- version: 0.9.20
124
+ version: 2.2.3
125
125
  - !ruby/object:Gem::Dependency
126
- name: pry
126
+ name: rack-test
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - '='
130
130
  - !ruby/object:Gem::Version
131
- version: 0.11.1
131
+ version: 1.1.0
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - '='
137
137
  - !ruby/object:Gem::Version
138
- version: 0.11.1
138
+ version: 1.1.0
139
139
  - !ruby/object:Gem::Dependency
140
- name: rack
140
+ name: rspec
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - '='
144
144
  - !ruby/object:Gem::Version
145
- version: 2.0.8
145
+ version: 3.9.0
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - '='
151
151
  - !ruby/object:Gem::Version
152
- version: 2.0.8
152
+ version: 3.9.0
153
153
  - !ruby/object:Gem::Dependency
154
- name: faker
154
+ name: rspec-json_expectations
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - '='
158
+ - !ruby/object:Gem::Version
159
+ version: 2.1.0
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - '='
165
+ - !ruby/object:Gem::Version
166
+ version: 2.1.0
167
+ - !ruby/object:Gem::Dependency
168
+ name: rspec_junit_formatter
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - '='
172
+ - !ruby/object:Gem::Version
173
+ version: 0.4.1
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - '='
179
+ - !ruby/object:Gem::Version
180
+ version: 0.4.1
181
+ - !ruby/object:Gem::Dependency
182
+ name: rubocop
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - '='
186
+ - !ruby/object:Gem::Version
187
+ version: 0.90.0
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - '='
193
+ - !ruby/object:Gem::Version
194
+ version: 0.90.0
195
+ - !ruby/object:Gem::Dependency
196
+ name: semantic
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - '='
200
+ - !ruby/object:Gem::Version
201
+ version: 1.6.1
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - '='
207
+ - !ruby/object:Gem::Version
208
+ version: 1.6.1
209
+ - !ruby/object:Gem::Dependency
210
+ name: simplecov
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - '='
214
+ - !ruby/object:Gem::Version
215
+ version: 0.19.0
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - '='
221
+ - !ruby/object:Gem::Version
222
+ version: 0.19.0
223
+ - !ruby/object:Gem::Dependency
224
+ name: yard
155
225
  requirement: !ruby/object:Gem::Requirement
156
226
  requirements:
157
227
  - - '='
158
228
  - !ruby/object:Gem::Version
159
- version: 2.10.0
229
+ version: 0.9.25
160
230
  type: :development
161
231
  prerelease: false
162
232
  version_requirements: !ruby/object:Gem::Requirement
163
233
  requirements:
164
234
  - - '='
165
235
  - !ruby/object:Gem::Version
166
- version: 2.10.0
236
+ version: 0.9.25
167
237
  - !ruby/object:Gem::Dependency
168
238
  name: mongoid
169
239
  requirement: !ruby/object:Gem::Requirement
170
240
  requirements:
171
241
  - - '='
172
242
  - !ruby/object:Gem::Version
173
- version: 7.0.1
243
+ version: 7.1.0
174
244
  type: :runtime
175
245
  prerelease: false
176
246
  version_requirements: !ruby/object:Gem::Requirement
177
247
  requirements:
178
248
  - - '='
179
249
  - !ruby/object:Gem::Version
180
- version: 7.0.1
250
+ version: 7.1.0
181
251
  - !ruby/object:Gem::Dependency
182
252
  name: activemodel
183
253
  requirement: !ruby/object:Gem::Requirement
184
254
  requirements:
185
255
  - - '='
186
256
  - !ruby/object:Gem::Version
187
- version: 5.2.3
257
+ version: 6.0.3.2
188
258
  type: :runtime
189
259
  prerelease: false
190
260
  version_requirements: !ruby/object:Gem::Requirement
191
261
  requirements:
192
262
  - - '='
193
263
  - !ruby/object:Gem::Version
194
- version: 5.2.3
264
+ version: 6.0.3.2
195
265
  - !ruby/object:Gem::Dependency
196
266
  name: activesupport
197
267
  requirement: !ruby/object:Gem::Requirement
198
268
  requirements:
199
269
  - - '='
200
270
  - !ruby/object:Gem::Version
201
- version: 5.2.3
271
+ version: 6.0.3.2
202
272
  type: :runtime
203
273
  prerelease: false
204
274
  version_requirements: !ruby/object:Gem::Requirement
205
275
  requirements:
206
276
  - - '='
207
277
  - !ruby/object:Gem::Version
208
- version: 5.2.3
278
+ version: 6.0.3.2
209
279
  - !ruby/object:Gem::Dependency
210
280
  name: bcrypt
211
281
  requirement: !ruby/object:Gem::Requirement
212
282
  requirements:
213
283
  - - '='
214
284
  - !ruby/object:Gem::Version
215
- version: 3.1.11
285
+ version: 3.1.13
216
286
  type: :runtime
217
287
  prerelease: false
218
288
  version_requirements: !ruby/object:Gem::Requirement
219
289
  requirements:
220
290
  - - '='
221
291
  - !ruby/object:Gem::Version
222
- version: 3.1.11
292
+ version: 3.1.13
223
293
  - !ruby/object:Gem::Dependency
224
294
  name: dotenv
225
295
  requirement: !ruby/object:Gem::Requirement
226
296
  requirements:
227
297
  - - '='
228
298
  - !ruby/object:Gem::Version
229
- version: 2.7.2
299
+ version: 2.7.6
230
300
  type: :runtime
231
301
  prerelease: false
232
302
  version_requirements: !ruby/object:Gem::Requirement
233
303
  requirements:
234
304
  - - '='
235
305
  - !ruby/object:Gem::Version
236
- version: 2.7.2
306
+ version: 2.7.6
237
307
  description: This gem holds the model layer for my table-top RPG games application.
238
308
  email: courtois.vincent@outlook.com
239
309
  executables: []
@@ -258,6 +328,7 @@ files:
258
328
  - lib/arkaan/concerns/activable.rb
259
329
  - lib/arkaan/concerns/diagnosticable.rb
260
330
  - lib/arkaan/concerns/enumerable.rb
331
+ - lib/arkaan/concerns/historizable.rb
261
332
  - lib/arkaan/concerns/mime_typable.rb
262
333
  - lib/arkaan/concerns/premiumable.rb
263
334
  - lib/arkaan/concerns/sluggable.rb
@@ -265,6 +336,7 @@ files:
265
336
  - lib/arkaan/decorators/errors.rb
266
337
  - lib/arkaan/decorators/errors/env_variable_missing.rb
267
338
  - lib/arkaan/decorators/gateway.rb
339
+ - lib/arkaan/event.rb
268
340
  - lib/arkaan/factories.rb
269
341
  - lib/arkaan/factories/errors.rb
270
342
  - lib/arkaan/factories/errors/gateway_not_found.rb
@@ -272,15 +344,8 @@ files:
272
344
  - lib/arkaan/files/document.rb
273
345
  - lib/arkaan/files/permission.rb
274
346
  - lib/arkaan/monitoring.rb
275
- - lib/arkaan/monitoring/action.rb
276
- - lib/arkaan/monitoring/instance.rb
277
- - lib/arkaan/monitoring/results.rb
278
- - lib/arkaan/monitoring/results/heartbeat.rb
279
- - lib/arkaan/monitoring/results/report.rb
280
347
  - lib/arkaan/monitoring/route.rb
281
348
  - lib/arkaan/monitoring/service.rb
282
- - lib/arkaan/monitoring/vigilante.rb
283
- - lib/arkaan/monitoring/websocket.rb
284
349
  - lib/arkaan/notification.rb
285
350
  - lib/arkaan/oauth.rb
286
351
  - lib/arkaan/oauth/access_token.rb
@@ -312,7 +377,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
312
377
  - !ruby/object:Gem::Version
313
378
  version: '0'
314
379
  requirements: []
315
- rubygems_version: 3.1.2
380
+ rubygems_version: 3.1.4
316
381
  signing_key:
317
382
  specification_version: 4
318
383
  summary: The model layer for my table-RPG application
@@ -1,25 +0,0 @@
1
- module Arkaan
2
- module Monitoring
3
- # An action is made by an authorized user on the instance of a server to perform a task.
4
- # @author Vincent Courtois <courtois.vincent@outlook.com>
5
- class Action
6
- include Mongoid::Document
7
- include Mongoid::Timestamps
8
- include Arkaan::Concerns::Enumerable
9
-
10
- # @!attribute [rw] type
11
- # @return [Symbol] the type of action you're making on this instance
12
- enum_field :type, [:restart]
13
- # @!attribute [rw] success
14
- # @return [Boolean] TRUE if the action succeeded (or at least was successfully launched), FALSE otherwise.
15
- field :success, type: Boolean, default: false
16
-
17
- # @!attribute [rw] user
18
- # @return [Arkaan::Account] the user performing the action on the instance.
19
- belongs_to :user, class_name: 'Arkaan::Account'
20
- # @!attribute [rw] instance
21
- # @return [Arkaan::Monitoring::Instance] the instance of a service on which the action is performed.
22
- embedded_in :instance, class_name: 'Arkaan::Monitoring::Instance', inverse_of: :actions
23
- end
24
- end
25
- end
@@ -1,38 +0,0 @@
1
- module Arkaan
2
- module Monitoring
3
- # An instance is one of the services, deployed on one server. A service may have many instances to balance the load between them all.
4
- # @author Vincent Courtois <courtois.vincent@outlook.com>
5
- class Instance
6
- include Mongoid::Document
7
- include Mongoid::Timestamps
8
- include Arkaan::Concerns::Activable
9
- include Arkaan::Concerns::Typable
10
-
11
- # @!attribute [rw] url
12
- # @return [String] the URL of the instance, where the requests will be issued.
13
- field :url, type: String
14
- # @!attribute [rw] running
15
- # @return [Boolean] the running status of the instance, indicating if it can be used or not.
16
- field :running, type: Boolean, default: false
17
- # @!attribute [rw] data
18
- # @return [Hash] the additional datas for this instance (for example for an Heroku instance it's all the data provided by the API)
19
- field :data, type: Hash, default: {}
20
-
21
- scope :running , ->{ where(running: true) }
22
-
23
- # @!attribute [r] service
24
- # @return [Arkaan::Monitoring::Service] the service this instance is linked to.
25
- embedded_in :service, class_name: 'Arkaan::Monitoring::Service', inverse_of: :instances
26
- # @!attribute [rw] actions
27
- # @return [Arkaan::Monitoring::Action] the actions that has been performed on the service.
28
- embeds_many :actions, class_name: 'Arkaan::Monitoring::Action', inverse_of: :instance
29
-
30
- has_many :heartbeats, class_name: 'Arkaan::Monitoring::Results::Heartbeat', inverse_of: :instance
31
-
32
- validates :url,
33
- presence: {message: 'required'},
34
- format: {with: /\A(https?:\/\/)((([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*)|(localhost:[0-9]{2,4})\/?)\z/, message: 'pattern', if: :url?}
35
- end
36
- end
37
- end
38
-
@@ -1,10 +0,0 @@
1
- module Arkaan
2
- module Monitoring
3
- # The results module handle classes to make results for the vigilante runs.
4
- # @author Vincent Courtois <courtois.vincent@outlook.com>
5
- module Results
6
- autoload :Report, 'arkaan/monitoring/results/report'
7
- autoload :Heartbeat, 'arkaan/monitoring/results/heartbeat'
8
- end
9
- end
10
- end
@@ -1,50 +0,0 @@
1
- module Arkaan
2
- module Monitoring
3
- module Results
4
- # A record is the result of the vigilante asking the health of one instance.
5
- # @author Vincent Courtois <courtois.vincent@outlook.com>
6
- class Heartbeat
7
- include Mongoid::Document
8
-
9
- # @!attribute [rw] status
10
- # @return [Integer] the HTTP status of the request made for this record.
11
- field :status, type: Integer, default: 500
12
- # @!attribute [rw] body
13
- # @return [Hash] the JSON parsed body from the heartbeat request.
14
- field :body, type: Hash, default: {}
15
- # @!attribute [rw] healthy
16
- # @return [Boolean] TRUE if the instance is deemed healthy, FALSE otherwise.
17
- field :healthy, type: Boolean, default: false
18
- # @!attribute [rw] started_at
19
- # @return [DateTime] the date at which the heartbeat request has started.
20
- field :started_at, type: DateTime
21
- # @!attribute [rw] ended_at
22
- # @return [DateTime] the date at which the request was terminated.
23
- field :ended_at, type: DateTime
24
-
25
- # @!attribute [rw] instance
26
- # @return [Arkaan::Monitoring::Instance] the instance on which the record has been done.
27
- belongs_to :instance, class_name: 'Arkaan::Monitoring::Instance', inverse_of: :heartbeats
28
-
29
- # @!attribute [rw] report
30
- # @return [Arkaan::Monitoring::Results::Report] the report made by the vigilante including this record.
31
- belongs_to :report, class_name: 'Arkaan::Monitoring::Results::Report', inverse_of: :heartbeats
32
-
33
- attr_readonly :healthy
34
-
35
- def status=(status)
36
- self[:status] = status
37
- self[:healthy] = status == 200
38
- end
39
-
40
- def start!
41
- self.started_at = DateTime.now
42
- end
43
-
44
- def end!
45
- self.ended_at = DateTime.now
46
- end
47
- end
48
- end
49
- end
50
- end
@@ -1,46 +0,0 @@
1
- module Arkaan
2
- module Monitoring
3
- module Results
4
- # A report is the result of one call to the API on one instance status route.
5
- # @author Vincent Courtois <courtoi.vincent@outlook.com>
6
- class Report
7
- include Mongoid::Document
8
- include Mongoid::Timestamps
9
-
10
- field :started_at, type: DateTime
11
- # @!attribute [rw] ended_at
12
- # @return [DateTime] the timestamp at which the report ends.
13
- field :ended_at, type: DateTime
14
- # @!attribute [rw] total
15
- # @return [Integer] the total number of services monitored.
16
- field :total, type: Integer, default: 0
17
- # @!attribute [rw] healthy
18
- # @return [Integer] the number of healthy services amongst all the monitored services.
19
- field :healthy, type: Integer, default: 0
20
-
21
- # @!attribute [rw] records
22
- # @return [Array<Arkaan::Monitoring::Results::Record>] the records linked to this report.
23
- has_many :heartbeats, class_name: 'Arkaan::Monitoring::Results::Heartbeat', inverse_of: :report
24
- # @!attribute [rw] vigilante
25
- # @return [Arkaan::Monitoring::Vigilante] the vigilante application that has created this report.
26
- belongs_to :vigilante, class_name: 'Arkaan::Monitoring::Vigilante', inverse_of: :reports
27
-
28
- def add_heartbeat(heartbeat)
29
- self.heartbeats << heartbeat
30
- self.total += 1
31
- self.healthy += (heartbeat.healthy ? 1 : 0)
32
- heartbeat.end!
33
- end
34
-
35
- def start!
36
- self.started_at = DateTime.now
37
- end
38
-
39
- def end!
40
- self.ended_at = DateTime.now
41
- self.save!
42
- end
43
- end
44
- end
45
- end
46
- end
@@ -1,48 +0,0 @@
1
- module Arkaan
2
- module Monitoring
3
- # A vigilante is a specific type of service that watches over the
4
- # infrastructure and give a clear look at its global state.
5
- # @author Vincent Courtois <courtois.vincent@outlook.com>
6
- class Vigilante
7
- include Mongoid::Document
8
- include Mongoid::Timestamps
9
-
10
- # @!attribute [rw] token
11
- # @return [String] the token the vigilante uses to identify himself in the services
12
- field :token, type: String
13
- # @!attribute [rw] max_results
14
- # @return [Integer] the number of results the vigilante should be keeping at any time.
15
- # The oldest result should be erased to not go over the limit
16
- field :max_results, type: Integer, default: 20
17
-
18
- # @!attribute [rw] reports
19
- # @return [Array<Arkaan::monitoring::Results::Report>] the report generated by running this vigilante.
20
- has_many :reports, class_name: 'Arkaan::Monitoring::Results::Report', inverse_of: :vigilante
21
-
22
- validates :token, presence: {message: 'required'}
23
-
24
- validates :max_results,
25
- numericality: {greater_than: 0, message: 'minimum'}
26
-
27
- # Adds a report to the collection of reports by eventually deleting the oldest one.
28
- # @param report [Arkaan::Monitoring::Results::Report] the report to add to the vigilante,
29
- # added only if it does not exceed the max number of reports the vigilante can store.
30
- def add_report(report)
31
- erase_oldest_result if result_full?
32
- reports << report
33
- end
34
-
35
- # Checks if the list of reports is already full, or if more can be added.
36
- # @return [Boolean] TRUE if the number of reports already exceeds the max number.
37
- def results_full?
38
- reports.to_a.count >= max_results
39
- end
40
-
41
- # Erases the oldest results to keep only MAX - 1 results in the list.
42
- def erase_oldest_result
43
- limit = reports.count + 1 - vigilante.max_results
44
- reports.sort_by(created_at: :asc).limit(limit).each(&:delete)
45
- end
46
- end
47
- end
48
- end
@@ -1,25 +0,0 @@
1
- module Arkaan
2
- module Monitoring
3
- # The websocket is a particular kind of service, just like the gateway. It always has the same signature.
4
- # A websocket document is a particular instance of websocket, located on a server and answering to a URL.
5
- # @author Vincent Courtois <courtois.vincent@outlook.com>
6
- class Websocket
7
- include Mongoid::Document
8
- include Mongoid::Timestamps
9
- include Arkaan::Concerns::Activable
10
- include Arkaan::Concerns::Diagnosticable
11
-
12
- # @!attribute [rw] url
13
- # @return [String] the URL of the websocket to be contacted on.
14
- field :url, type: String
15
-
16
- # @!attribute [rw] creator
17
- # @return [Arkaan::Account] the account that created this web socket instance in the database.
18
- belongs_to :creator, class_name: 'Arkaan::Account', inverse_of: :web_sockets, optional: true
19
-
20
- validates :url,
21
- presence: {message: 'required'},
22
- format: {with: /\A(ws:\/\/)([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?\z/, message: 'pattern', if: :url?}
23
- end
24
- end
25
- end