arkaan 1.3.0 → 1.3.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: 4f2e4fd6566216dd4bc532d36c16c0bfc2af3879
4
- data.tar.gz: fe0cc0a6b1a32e76eb8f77af001c80e21402aec7
3
+ metadata.gz: '057528c0fc0b7cf0a8fe4277d95ec306335275be'
4
+ data.tar.gz: 6dbb9551a932b8cbab69fc8247fb25c03c54c6a4
5
5
  SHA512:
6
- metadata.gz: 2495d4bd6c2b7187afeb06020ed31c397ad072523ff61d693952cd4c17ad9586cca12372b3f46b555e6d5168b7baa989280e542cc67257987742fe1e6f341909
7
- data.tar.gz: fbf03545f56d27cc2812424cbac42cb2581faced47284561683e5826aff215cab84a499d33e2d8823f6ecff489ed0c1409e2708fd6ab13ecf45598c226ecb436
6
+ metadata.gz: 2a5d9b711367175109942b3dca458a1acfedf443caa04d7672363c66f32fbf1528381dff35fdedd048e04667844137a2ed668eccb39504944f5b16d886ac6f0e
7
+ data.tar.gz: 8088aa88b8c56adba51d9f849cad10ab614afd6749e3436e878a83890613ec1c5df963b470e58d5b09d9799882ba0eb7af080e9133fae19c299f6465416e58ae
@@ -31,6 +31,8 @@ module Arkaan
31
31
  # @param premium [Boolean] TRUE to make the route premium, FALSE otherwise.
32
32
  def self.declare_route_with(verb, path, premium, options, &block)
33
33
  service = Arkaan::Utils::MicroService.instance.service
34
+ complete_path = "#{Arkaan::Utils::MicroService.instance.path}#{path == '/' ? '' : path}"
35
+
34
36
  unless service.nil? || !service.routes.where(path: path, verb: verb).first.nil?
35
37
  route = Arkaan::Monitoring::Route.create(path: path, verb: verb, premium: premium, service: service)
36
38
  if !options.nil? && !options[:authenticated].nil?
@@ -42,7 +44,7 @@ module Arkaan
42
44
  end
43
45
  end
44
46
  if premium
45
- self.public_send(verb, path) do
47
+ self.public_send(verb, complete_path) do
46
48
  @sinatra_route = parse_current_route
47
49
  if !@application.premium?
48
50
  custom_error(403, 'common.app_key.forbidden')
@@ -50,7 +52,7 @@ module Arkaan
50
52
  instance_eval(&block)
51
53
  end
52
54
  else
53
- self.public_send(verb, path, &block)
55
+ self.public_send(verb, complete_path, &block)
54
56
  end
55
57
  end
56
58
 
@@ -133,6 +135,7 @@ module Arkaan
133
135
  # @param status [Integer] the HTTP status to halt the application with.
134
136
  # @param path [String] the path in the configuration file to access the URL.
135
137
  def custom_error(status, path)
138
+
136
139
  route, field, error = path.split('.')
137
140
  docs = settings.errors[route][field][error] rescue ''
138
141
  halt status, {status: status, field: field, error: error, docs: docs}.to_json
@@ -20,6 +20,9 @@ module Arkaan
20
20
  # @!attribute [r] type
21
21
  # @return [Symbol] the type of instance the application is declaring
22
22
  attr_reader :type
23
+ # @!attribute [rw] controller_classes
24
+ # @return [Array<Class>] an array of controller classes to run
25
+ attr_accessor :controller_classes
23
26
 
24
27
  def initialize
25
28
  @location = false
@@ -27,6 +30,13 @@ module Arkaan
27
30
  @instance = false
28
31
  @name = false
29
32
  @type = ENV['INSTANCE_TYPE'] || :heroku
33
+ @controller_classes = []
34
+ end
35
+
36
+ # Add a controller class to the controllers to use.
37
+ # @param classname [Class] the class to add to the controller to load at startup.
38
+ def add_controller_class(classname)
39
+ @controller_classes << classname
30
40
  end
31
41
 
32
42
  # Determines if the application can be loaded (all the parameters have been correctly set)
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: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincent Courtois