arkaan 0.7.0 → 0.7.1

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: 07b4489f79230ccb811f9d1ce8450b9d3b3f4f09
4
- data.tar.gz: e9b8a2f2b4fc2077fbefb9c03f27deab149ac00b
3
+ metadata.gz: c9d0b93bf17b741d717240767aa10b61724cce7d
4
+ data.tar.gz: ad0862a9a838a87f589076e9e591ba7d836c8141
5
5
  SHA512:
6
- metadata.gz: 27c4afac918bef59a56c8f6cba6b0b44d9c7e5433d1edf7fd25b6a7e0f87358ad8ff6028cc991f0f550af0cfb0050c886b10d1b8d27cbdd58c71b6bef2d74b1d
7
- data.tar.gz: a60ed29bf413cd20889560f183058f36ad57094f2cbe809337d120d41f7ae38c95eea61b8b1795ef5ec93d9afd45490f3bc2f3b54748350002682c0f7826e1e6
6
+ metadata.gz: 1b266cfc05f76a91b9527f7fb0df999cffd521affbbe27bd42d8565e8ec5171cb81cf420692b48d13898bf963a23532f8f553cd178390a0af85c16f08f2dab7a
7
+ data.tar.gz: 95d74ccd55f89352c4a6fb1bc313d8b228db5b71cc58561a776810b244ff486410b551c8c6b9c2e26eb178eca5f1a9f218f05175cf53076f9bc536bdfa0a3658
@@ -18,13 +18,13 @@ module Arkaan
18
18
 
19
19
  # @!attribute [rw] service
20
20
  # @return [Arkaan::Monitoring::Service] the service in which this route is declared.
21
- embedded_in :service, class_name: 'Arkaan::Monitoring::Service', inverse_of: :routes
21
+ belongs_to :service, class_name: 'Arkaan::Monitoring::Service', inverse_of: :routes
22
22
 
23
23
  validates :path,
24
- format: {with: /\A(\/[A-Za-z0-9\/])+\z/, message: 'route.path.format', if: :path?}
24
+ format: {with: /\A(\/|((\/[a-zA-Z0-9]+)+))\z/, message: 'route.path.format', if: :path?}
25
25
 
26
26
  validates :verb,
27
27
  inclusion: {message: 'route.verb.unknown', in: ['get', 'post', 'put', 'delete', 'patch', 'option']}
28
28
  end
29
29
  end
30
- end
30
+ end
@@ -28,7 +28,7 @@ module Arkaan
28
28
  embeds_many :instances, class_name: 'Arkaan::Monitoring::Instance', inverse_of: :service
29
29
  # @!attribute [rw] routes
30
30
  # @return [Array<Arkaan::Monitoring::Route>] the routes associated to this service, accessible from the gateway.
31
- embeds_many :routes, class_name: 'Arkaan::Monitoring::Route', inverse_of: :service
31
+ has_many :routes, class_name: 'Arkaan::Monitoring::Route', inverse_of: :service
32
32
 
33
33
  validates :key, uniqueness: {message: 'service.key.uniq'}
34
34
 
@@ -20,6 +20,26 @@ module Arkaan
20
20
  end
21
21
  end
22
22
 
23
+ def self.declare_service(key)
24
+ @@micro_service = Arkaan::Monitoring::Service.find_by(key: key)
25
+ end
26
+
27
+ def self.declare_route(verb, path, &block)
28
+ self.declare_route_with(verb, path, false, &block)
29
+ end
30
+
31
+ def self.declare_premium_route(verb, path, &block)
32
+ self.declare_route_with(verb, path, true, &block)
33
+ end
34
+
35
+ def self.declare_route_with(verb, path, premium, &block)
36
+ unless @@micro_service.nil?
37
+ @@micro_service.routes << Arkaan::Monitoring::Route.new(path: path, verb: verb, premium: premium)
38
+ @@micro_service.save!
39
+ end
40
+ self.public_send(verb, path, &block)
41
+ end
42
+
23
43
  # Checks the presence of several fields given as parameters and halts the execution if it's not present.
24
44
  # @param fields [Array<String>] an array of fields names to search in the parameters
25
45
  def check_presence(*fields)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arkaan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincent Courtois