rubypitaya 3.3.2 → 3.3.6

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: b218ecc854aaf6e7cb2cf7bbf1ad80d910967c73b3ccf0ba06f81b039b5838b5
4
- data.tar.gz: 30acb028ff6a65f8b7697be1ca1d533efb5383b3e68d180cdc92bdcf37d762f1
3
+ metadata.gz: 534b8bf854794eab64b53a7f550a18a8bc60b0f13b41ba8f75dba4e58506d319
4
+ data.tar.gz: b76c9e552bdc04d4bdcfabafa94eeeeda84fca483dec6df5c00cbd74c43e0816
5
5
  SHA512:
6
- metadata.gz: 610d327bbf85407e5880b4593bd804c55ffff8022783582340e48f962da345f91d569b24f8b7e477027c8edbd61f8d8e9bb7827acb14e8070c63687e64799049
7
- data.tar.gz: 1c5c9d3256b9d81d539f6b47c0181d15656e4a75185c3634d951984bc532762c5b6f3a390a94e8ae7c4486da20c0cde79885e69391875590f27c843963fdae33
6
+ metadata.gz: 0420eda040f59d7d06913e3352faea670f19536d3435c9e3c2094986ec4bd8b81f2272cd1845e05791695ac610713e652a3985b2e62147b1b66d57e19bed220f
7
+ data.tar.gz: f0f2da6df0dbd54511b0eab8eacbcd98bd07a03a2e285bbd1cd1fb1d8692f71866252f8000a04af5937dfeee25aeacb6e4c834eac14a99115e6a9c64799ccd12
@@ -1,6 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem 'rubypitaya', '3.3.2'
3
+ gem 'rubypitaya', '3.3.6'
4
4
 
5
5
  group :development do
6
6
  gem 'pry', '0.14.1'
@@ -103,7 +103,7 @@ GEM
103
103
  rspec-support (~> 3.10.0)
104
104
  rspec-support (3.10.3)
105
105
  ruby2_keywords (0.0.5)
106
- rubypitaya (3.3.2)
106
+ rubypitaya (3.3.6)
107
107
  activerecord (= 6.1.4.1)
108
108
  etcdv3 (= 0.11.4)
109
109
  google-protobuf (= 3.18.1)
@@ -143,7 +143,7 @@ DEPENDENCIES
143
143
  listen (= 3.7.0)
144
144
  pry (= 0.14.1)
145
145
  rspec (= 3.10.0)
146
- rubypitaya (= 3.3.2)
146
+ rubypitaya (= 3.3.6)
147
147
  sinatra-contrib (= 2.1.0)
148
148
 
149
149
  BUNDLED WITH
@@ -4,12 +4,15 @@ module RubyPitaya
4
4
 
5
5
  class ApplicationFilesImporter
6
6
 
7
- def import
7
+ def import(is_cheats_enabled)
8
8
  app_folder_paths = Path::Plugins::APP_FOLDER_PATHS + [Path::Core::APP_FOLDER_PATH, Path::APP_FOLDER_PATH]
9
9
 
10
10
  app_folder_paths.each do |app_folder_path|
11
11
  app_files_path = "#{app_folder_path}/**/*.rb"
12
12
 
13
+ gem_files = Gem.find_files(app_files_path)
14
+ gem_files = gem_files.select { |a| !a[/.+_cheats.rb/] && !a[/.+_cheat.rb/] } unless is_cheats_enabled
15
+
13
16
  Gem.find_files(app_files_path).each do |path|
14
17
  require path unless path.include?('app/migrations')
15
18
  end
@@ -45,7 +45,10 @@ module RubyPitaya
45
45
 
46
46
  def import_handler_classes
47
47
  handler_classes = ObjectSpace.each_object(HandlerBase.singleton_class).select do |klass|
48
- klass != HandlerBase
48
+ class_name = klass.to_s.downcase
49
+ is_cheat_class = class_name.end_with?('cheat') || class_name.end_with?('cheats')
50
+
51
+ klass != HandlerBase && (@is_cheats_enabled || !is_cheat_class)
49
52
  end
50
53
 
51
54
  @handlers = handler_classes.map { |handler_class| handler_class.new }
@@ -10,6 +10,7 @@ require 'rubypitaya/core/session'
10
10
  require 'rubypitaya/core/postman'
11
11
  require 'rubypitaya/core/parameters'
12
12
  require 'rubypitaya/core/http_routes'
13
+ require 'rubypitaya/core/route_error'
13
14
  require 'rubypitaya/core/routes_base'
14
15
  require 'rubypitaya/core/status_codes'
15
16
  require 'rubypitaya/core/handler_router'
@@ -31,6 +32,7 @@ module RubyPitaya
31
32
  def initialize
32
33
  @setup = Setup.new
33
34
  @environment_name = @setup.fetch('rubypitaya.server.environment', 'development')
35
+ @is_cheats_enabled = @setup.fetch('rubypitaya.server.cheats', false)
34
36
  @is_development_environment = @environment_name == 'development'
35
37
  @setup.auto_reload if @is_development_environment
36
38
 
@@ -41,7 +43,7 @@ module RubyPitaya
41
43
  end
42
44
 
43
45
  @application_files_importer = ApplicationFilesImporter.new
44
- @application_files_importer.import
46
+ @application_files_importer.import(@is_cheats_enabled)
45
47
  @application_files_importer.auto_reload if @is_development_environment
46
48
 
47
49
  @server_name = @setup['rubypitaya.server.name']
@@ -93,7 +95,6 @@ module RubyPitaya
93
95
  @initializer_broadcast = InitializerBroadcast.new
94
96
  @initializer_broadcast.run(@initializer_content)
95
97
 
96
- @is_cheats_enabled = @setup.fetch('rubypitaya.server.cheats', false)
97
98
  @handler_router = HandlerRouter.new(@is_cheats_enabled)
98
99
 
99
100
  run_http
@@ -179,10 +180,20 @@ module RubyPitaya
179
180
 
180
181
  @config.clear_cache
181
182
 
182
- response = @handler_router.call(handler_name, action_name, @session,
183
- @postman, @redis_connector.redis,
184
- @mongo_connector.mongo, @setup, @config,
185
- @log, params)
183
+ response = {}
184
+
185
+ begin
186
+ response = @handler_router.call(handler_name, action_name, @session,
187
+ @postman, @redis_connector.redis,
188
+ @mongo_connector.mongo, @setup, @config,
189
+ @log, params)
190
+ rescue RouteError => error
191
+ @log.error "ROUTE ERROR: #{error.class} | #{error.message}} \n #{error.backtrace.join("\n")}"
192
+ response = {
193
+ code: error.code,
194
+ message: error.message
195
+ }
196
+ end
186
197
 
187
198
  delta_time_seconds = ((Time.now.to_f - start_time_seconds) * 1000).round(2)
188
199
 
@@ -190,12 +201,6 @@ module RubyPitaya
190
201
 
191
202
  response
192
203
  end
193
- rescue RouteError => error
194
- @log.error "ROUTE ERROR: #{error.class} | #{error.message}} \n #{error.backtrace.join("\n")}"
195
- response = {
196
- code: error.code,
197
- message: error.message
198
- }
199
204
  rescue Exception => error
200
205
  @log.error "INTERNAL ERROR: #{error.class} | #{error.message}} \n #{error.backtrace.join("\n")}"
201
206
  run_nats_connection
@@ -1,6 +1,8 @@
1
1
  module RubyPitaya
2
2
  class RouteError < StandardError
3
3
 
4
+ attr_reader :code, :message
5
+
4
6
  def initialize(code, message)
5
7
  @code = code
6
8
  @message = message
@@ -1,3 +1,3 @@
1
1
  module RubyPitaya
2
- VERSION = '3.3.2'
2
+ VERSION = '3.3.6'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubypitaya
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.2
4
+ version: 3.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luciano Prestes Cavalcanti