arkaan 0.10.25 → 0.10.26

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: d2ef14b2c1f588710861147b8caec88e963f6c77
4
- data.tar.gz: f7f72fbd08d32e782c247153f8b6d4c160ba1c35
3
+ metadata.gz: a37206a363fbd1abfd39eaf523806cc5333be64a
4
+ data.tar.gz: ee2630ff98416b797383e412d3a2914144a4ecb9
5
5
  SHA512:
6
- metadata.gz: bde03c13292ac906a29bcde791e165ddd11490c9e86945e2cdf8eb1a0ad5bf38d85c68a49d1574fa444b5bb431102031eec9d119d52b278741fdd044b37ddd07
7
- data.tar.gz: cacde25515002f9bc1c06dd6858ec2060f0ab2d491d006da27c930d634f5ee9d9c0ab267ada31ad45e07a76daad3a6767b8d37cd4256258e4484287aa311ecfe
6
+ metadata.gz: 8893753ce12fb24b6b79dfa29b3a146a8550a63cfc95550538f2c791678e1519855a931483f83b7b88ddb0378ca8bae42b7ec3fa4ea152648aa79f190c03c1f9
7
+ data.tar.gz: e998007ef7567d3ec439cf1cf29b9c3388aedc434e63a39d95352189307b4fc5435a0f5cc404fcc96b821fa41e1714184c07bfc57f343f18c01c355cca3c2f91
@@ -15,6 +15,9 @@ module Arkaan
15
15
  # @!attribute [rw] path
16
16
  # @return [String] the path the service will be mapped on in the API.
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
18
21
 
19
22
  # @!attribute [rw] creator
20
23
  # @return [Arkaan::Account] the creator of this service.
@@ -5,17 +5,7 @@ module Arkaan
5
5
  class Controller < Arkaan::Utils::ControllerWithoutFilter
6
6
 
7
7
  before do
8
- add_body_to_params
9
- check_presence('token', 'app_key', route: 'common')
10
-
11
- gateway = Arkaan::Monitoring::Gateway.where(token: params['token']).first
12
- @application = Arkaan::OAuth::Application.where(key: params['app_key']).first
13
-
14
- if gateway.nil?
15
- custom_error(404, 'common.token.unknown')
16
- elsif @application.nil?
17
- custom_error(404, 'common.app_key.unknown')
18
- end
8
+ before_checks
19
9
  end
20
10
  end
21
11
  end
@@ -54,6 +54,20 @@ module Arkaan
54
54
  config_file File.join(File.dirname(file), '..', 'config', 'errors.yml')
55
55
  end
56
56
 
57
+ def before_checks
58
+ add_body_to_params
59
+ check_presence('token', 'app_key', route: 'common')
60
+
61
+ gateway = Arkaan::Monitoring::Gateway.where(token: params['token']).first
62
+ @application = Arkaan::OAuth::Application.where(key: params['app_key']).first
63
+
64
+ if gateway.nil?
65
+ custom_error(404, 'common.token.unknown')
66
+ elsif @application.nil?
67
+ custom_error(404, 'common.app_key.unknown')
68
+ end
69
+ end
70
+
57
71
  # Checks the presence of several fields given as parameters and halts the execution if it's not present.
58
72
  # @param fields [Array<String>] an array of fields names to search in the parameters
59
73
  def check_presence(*fields, route:)
@@ -143,7 +157,7 @@ module Arkaan
143
157
  handle_arkaan_exception(exception)
144
158
  end
145
159
 
146
- error StandardError do
160
+ error StandardError do |exception|
147
161
  custom_error(500, 'system_error.unknown_field.unknown_error')
148
162
  end
149
163
  end
@@ -134,7 +134,7 @@ module Arkaan
134
134
  end
135
135
 
136
136
  def load_mongoid_configuration
137
- Mongoid.load!(File.join(location, 'config', 'mongoid.yml'))
137
+ Mongoid.load!(File.join(location, 'config', 'mongoid.yml'), ENV['RACK_ENV'] || :development)
138
138
  end
139
139
 
140
140
  def load_standard_files
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.10.25
4
+ version: 0.10.26
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-09-13 00:00:00.000000000 Z
11
+ date: 2018-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec