virtuaservices 0.2.0 → 0.3.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
  SHA256:
3
- metadata.gz: ffd83b8df86f7ab7232870ca7fe41f470cc5abd22a0e1897f676789e14e0fb65
4
- data.tar.gz: 4e82e446842bec3b9a1910c0be183863d824dbb251ba2861097a401203d92edd
3
+ metadata.gz: 16488d6c6dd2d6b562f3bd1f1242248a504259acfe3f72d7a07860fae29ca936
4
+ data.tar.gz: 2903a8b31b10b89e6f09c7dbf834b88210b2dd220e9a1b9771662ee72a224c25
5
5
  SHA512:
6
- metadata.gz: af088a54dff32f4aad0de454c0f30c2c40bddfc6238dd1c594285ce639e56a1ddbbb9b7ac3b8413611065a49576c44aabe86829396f14977d6a25f6502b8031f
7
- data.tar.gz: b82e088353bf2b763056d67edd8fc0d6ea254c05b1e6283e08f84434692bfaefaafe7089ba7611349754ac740d4d62230d09c0a8671c9b52a781f2b099d99785
6
+ metadata.gz: 993c1bbc126920db2f8111fb1a36f2774598061bbbf84d8e6a7a3737ce189d2f8e8b095b964759b5712f082c58d579e337ef69f6dbd3c90b87518fe44b7b3d07
7
+ data.tar.gz: ddeac73d2ce9691a08b4b3caad9ba391fe669de661ed88162db2ab2f354c9e9062e80a8326ae9a0fea956c2d4f887ac3ddebead8a942c89965f07124eed7d73d
@@ -1,8 +1,8 @@
1
- module Arkaan
1
+ module Virtuaservices
2
2
  module Utils
3
3
  module Controllers
4
- autoload :Base , 'arkaan/utils/controllers/base'
5
- autoload :Checked, 'arkaan/utils/controllers/checked'
4
+ autoload :Base , 'virtuaservices/utils/controllers/base'
5
+ autoload :Checked, 'virtuaservices/utils/controllers/checked'
6
6
  end
7
7
  end
8
8
  end
@@ -1,4 +1,4 @@
1
- module Arkaan
1
+ module Virtuaservices
2
2
  module Utils
3
3
  module Controllers
4
4
  # Base controller to handle the standard error when accessing the API.
@@ -31,15 +31,15 @@ module Arkaan
31
31
  # @param path [String] the path, beginning with a /, of the route to create.
32
32
  # @param premium [Boolean] TRUE to make the route premium, FALSE otherwise.
33
33
  def self.declare_route_with(verb, path, premium, options, &block)
34
- service = Arkaan::Utils::MicroService.instance.service
35
- complete_path = "#{Arkaan::Utils::MicroService.instance.path}#{path == '/' ? '' : path}"
34
+ service = Virtuaservices::Utils::MicroService.instance.service
35
+ complete_path = "#{Virtuaservices::Utils::MicroService.instance.path}#{path == '/' ? '' : path}"
36
36
 
37
37
  unless service.nil? || !service.routes.where(path: path, verb: verb).first.nil?
38
- route = Arkaan::Monitoring::Route.create(path: path, verb: verb, premium: premium, service: service)
38
+ route = Virtuaservices::Monitoring::Route.create(path: path, verb: verb, premium: premium, service: service)
39
39
  if !options.nil? && !options[:authenticated].nil?
40
40
  route.update_attribute(:authenticated, false)
41
41
  end
42
- Arkaan::Permissions::Group.where(is_superuser: true).each do |group|
42
+ Virtuaservices::Permissions::Group.where(is_superuser: true).each do |group|
43
43
  group.routes << route
44
44
  group.save!
45
45
  end
@@ -69,8 +69,8 @@ module Arkaan
69
69
 
70
70
  check_presence('token', 'app_key', route: 'common')
71
71
 
72
- gateway = Arkaan::Monitoring::Gateway.where(token: params['token']).first
73
- @application = Arkaan::OAuth::Application.where(key: params['app_key']).first
72
+ gateway = Virtuaservices::Monitoring::Gateway.where(token: params['token']).first
73
+ @application = Virtuaservices::OAuth::Application.where(key: params['app_key']).first
74
74
 
75
75
  if gateway.nil?
76
76
  custom_error(404, 'common.token.unknown')
@@ -101,10 +101,10 @@ module Arkaan
101
101
 
102
102
  # Checks if the session ID is given in the parameters and if the session exists.
103
103
  # @param action [String] the action used to get the errors from the errors file.
104
- # @return [Arkaan::Authentication::Session] the session when it exists.
104
+ # @return [Virtuaservices::Authentication::Session] the session when it exists.
105
105
  def check_session(action)
106
106
  check_presence('session_id', route: action)
107
- session = Arkaan::Authentication::Session.where(token: params['session_id']).first
107
+ session = Virtuaservices::Authentication::Session.where(token: params['session_id']).first
108
108
  if session.nil?
109
109
  custom_error(404, "#{action}.session_id.unknown")
110
110
  end
@@ -113,7 +113,7 @@ module Arkaan
113
113
 
114
114
  def check_application(action)
115
115
  check_presence('app_key', route: action)
116
- application = Arkaan::OAuth::Application.where(key: params['app_key']).first
116
+ application = Virtuaservices::OAuth::Application.where(key: params['app_key']).first
117
117
  custom_error(404, "#{action}.app_key.unknown") if application.nil?
118
118
  return application
119
119
  end
@@ -131,10 +131,10 @@ module Arkaan
131
131
  end
132
132
 
133
133
  # Gets the current route in the database from the sinatra route.
134
- # @return [Arkaan::Monitoring::Route] the route declared in the services registry.
134
+ # @return [Virtuaservices::Monitoring::Route] the route declared in the services registry.
135
135
  def parse_current_route
136
136
  splitted = request.env['sinatra.route'].split(' ')
137
- return Arkaan::Monitoring::Route.where(verb: splitted.first.downcase, path: splitted.last).first
137
+ return Virtuaservices::Monitoring::Route.where(verb: splitted.first.downcase, path: splitted.last).first
138
138
  end
139
139
 
140
140
  # Halts the application and creates the returned body from the parameters and the errors config file.
@@ -162,25 +162,25 @@ module Arkaan
162
162
  return params.select { |key, value| fields.include?(key) }
163
163
  end
164
164
 
165
- # Creates a custom error from an existing Arkaan exception class.
165
+ # Creates a custom error from an existing Virtuaservices exception class.
166
166
  # @param exception {StandardError} the exception to transform in a usable error.
167
167
  def handle_arkaan_exception(exception)
168
168
  custom_error(exception.status, "#{exception.action}.#{exception.field}.#{exception.error}")
169
169
  end
170
170
 
171
- error Arkaan::Utils::Errors::BadRequest do |exception|
171
+ error Virtuaservices::Utils::Errors::BadRequest do |exception|
172
172
  handle_arkaan_exception(exception)
173
173
  end
174
174
 
175
- error Arkaan::Utils::Errors::Forbidden do |exception|
175
+ error Virtuaservices::Utils::Errors::Forbidden do |exception|
176
176
  handle_arkaan_exception(exception)
177
177
  end
178
178
 
179
- error Arkaan::Utils::Errors::NotFound do |exception|
179
+ error Virtuaservices::Utils::Errors::NotFound do |exception|
180
180
  handle_arkaan_exception(exception)
181
181
  end
182
182
 
183
- error Arkaan::Factories::Errors::GatewayNotFound do |exception|
183
+ error Virtuaservices::Factories::Errors::GatewayNotFound do |exception|
184
184
  handle_arkaan_exception(exception)
185
185
  end
186
186
 
@@ -1,9 +1,9 @@
1
- module Arkaan
1
+ module Virtuaservices
2
2
  module Utils
3
3
  module Controllers
4
4
  # Base controller to handle the standard error when accessing the API.
5
5
  # @author Vincent Courtois <courtois.vincenet@outlook.com>
6
- class Checked < Arkaan::Utils::Controllers::Base
6
+ class Checked < Virtuaservices::Utils::Controllers::Base
7
7
 
8
8
  before do
9
9
  before_checks
@@ -1,12 +1,12 @@
1
- module Arkaan
1
+ module Virtuaservices
2
2
  module Utils
3
3
  # Module gathering all the exception classes used throughout the utils module, mainly linked to HTTP errors.
4
4
  # @author Vincent Courtois <courtois.vincent@outlook.com>
5
5
  module Errors
6
- autoload :BadRequest, 'arkaan/utils/errors/bad_request'
7
- autoload :Forbidden , 'arkaan/utils/errors/forbidden'
8
- autoload :NotFound , 'arkaan/utils/errors/not_found'
9
- autoload :HTTPError , 'arkaan/utils/errors/http_error'
6
+ autoload :BadRequest, 'virtuaservices/utils/errors/bad_request'
7
+ autoload :Forbidden , 'virtuaservices/utils/errors/forbidden'
8
+ autoload :NotFound , 'virtuaservices/utils/errors/not_found'
9
+ autoload :HTTPError , 'virtuaservices/utils/errors/http_error'
10
10
  end
11
11
  end
12
12
  end
@@ -1,9 +1,9 @@
1
- module Arkaan
1
+ module Virtuaservices
2
2
  module Utils
3
3
  module Errors
4
4
  # A bad request error is raised when the data given to a model makes this model invalid.
5
5
  # @author Vincent Courtois <courtois.vincent@outlook.com>
6
- class BadRequest < Arkaan::Utils::Errors::HTTPError
6
+ class BadRequest < Virtuaservices::Utils::Errors::HTTPError
7
7
 
8
8
  def initialize(action:, field:, error:)
9
9
  super(action, field, error, 400)
@@ -1,7 +1,7 @@
1
- module Arkaan
1
+ module Virtuaservices
2
2
  module Utils
3
3
  module Loaders
4
- autoload :Heroku, 'arkaaan/utils/loaders/heroku'
4
+ autoload :Heroku, 'virtuaservices/utils/loaders/heroku'
5
5
  end
6
6
  end
7
7
  end
@@ -1,9 +1,9 @@
1
- module Arkaan
1
+ module Virtuaservices
2
2
  module Utils
3
3
  module Plugins
4
4
  class Heroku
5
5
  # Loads the heroku informations inside the data of the instance.
6
- # @param instance [Arkaan::Monitoring::Instance] the instance to put the enrichment inside.
6
+ # @param instance [Virtuaservices::Monitoring::Instance] the instance to put the enrichment inside.
7
7
  def self.load!(instance)
8
8
  if !ENV['OAUTH_TOKEN'].nil? && instance != false && instance.persisted?
9
9
  heroku = PlatformAPI.connect_oauth(ENV['OAUTH_TOKEN'])
@@ -1,4 +1,4 @@
1
- module Arkaan
1
+ module Virtuaservices
2
2
  module Utils
3
3
  # This class is a singleton to load and save parameters for the whole application.
4
4
  # @author Vincent Courtois <courtois.vincent@outlook.com>
@@ -1,4 +1,4 @@
1
- module Arkaan
1
+ module Virtuaservices
2
2
  module Utils
3
3
  # This class loads the necessary data in the database if they don't exist yet.
4
4
  # @author Vincent Courtois <courtois.vincent@outlook.com>
@@ -1,3 +1,3 @@
1
1
  module Virtuaservices
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: virtuaservices
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.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: 2019-07-08 00:00:00.000000000 Z
11
+ date: 2019-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec