rubypitaya 2.26.3 → 2.27.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: 03d922e0e3018a516710860db14edb745a8091de11e357ac28350fd2bc0c4c1b
4
- data.tar.gz: 88ebed05ee6d18892875786f0e652d6fb0236f66458304534f16026c86369fe2
3
+ metadata.gz: e382eff25c29ad543511d22efa945c52d1b770c7e9237ab46338db08d087842f
4
+ data.tar.gz: '08e25deffa96ab5acc7b3e239f8b9515355f7e9308228b4d7cfb8e25528403d6'
5
5
  SHA512:
6
- metadata.gz: f651a4e71c89ced83d2ec5be02415b0b4c3744f77198737ed5a4507302720286e698dcb60928efdfce2b81a109cfcf84fe27ee1dfeb9f3328039a6eb991e834b
7
- data.tar.gz: ad997b323bf2fb3b23cb682e0643dc6516d0b6f9c1ab206195003c4799c9155f25966f7deffe6d4238f809044d51e772b2b75cf140b36755dadc483731093703
6
+ metadata.gz: c57f7eb3b0637bd463efc43185dd1c8a543b275f7db1ed2739e84b4d547f5c21d9519c1d910d9418ce7f19e273d24746b907e8ff32c334727ba0897b06eec66d
7
+ data.tar.gz: 29ea1d9037c932b84e0016316169c5e2821b166728075512cdaf132c110cf679d9544168881b65fb8bd9e701654d786eb05bba366ca2d272dfb0e26e66af348c
@@ -1,6 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem 'rubypitaya', '2.26.3'
3
+ gem 'rubypitaya', '2.27.0'
4
4
 
5
5
  group :development do
6
6
  gem 'pry', '0.14.0'
@@ -111,7 +111,7 @@ GEM
111
111
  rspec-support (~> 3.10.0)
112
112
  rspec-support (3.10.2)
113
113
  ruby2_keywords (0.0.5)
114
- rubypitaya (2.26.3)
114
+ rubypitaya (2.27.0)
115
115
  activerecord (= 6.1.4.1)
116
116
  etcdv3 (= 0.11.3)
117
117
  mongo (= 2.15.0)
@@ -152,7 +152,7 @@ DEPENDENCIES
152
152
  listen (= 3.4.1)
153
153
  pry (= 0.14.0)
154
154
  rspec (= 3.10.0)
155
- rubypitaya (= 2.26.3)
155
+ rubypitaya (= 2.27.0)
156
156
 
157
157
  BUNDLED WITH
158
158
  2.1.4
@@ -3,14 +3,6 @@ class AppInitializer < RubyPitaya::InitializerBase
3
3
  # method: run
4
4
  # parameter: initializer_content
5
5
  # attributes:
6
- # - bll
7
- # - class: RubyPitaya::InstanceHolder
8
- # - link: https://gitlab.com/LucianoPC/ruby-pitaya/-/blob/master/lib/rubypitaya/core/instance_holder.rb
9
- # - methods:
10
- # - add_instance(key, instance)
11
- # - add any instance to any key
12
- # - [](key)
13
- # - get instance by key
14
6
  # - redis
15
7
  # - link: https://github.com/redis/redis-rb/
16
8
  # - mongo
@@ -36,11 +28,9 @@ class AppInitializer < RubyPitaya::InitializerBase
36
28
  # - log information
37
29
 
38
30
  def run(initializer_content)
39
- bll = initializer_content.bll
40
-
41
31
  playerBll = PlayerBLL.new
42
32
 
43
- bll.add_instance(:player, playerBll)
33
+ PlayerHandler.bll.add_instance(:player, playerBll)
44
34
  end
45
35
 
46
36
  def self.path
@@ -42,7 +42,7 @@ RSpec.describe 'PlayerHandler', type: :request do
42
42
  request("rubypitaya.playerHandler.getInfo")
43
43
 
44
44
  expect(response[:code]).to eq(RubyPitaya::StatusCodes::CODE_NOT_AUTHENTICATED)
45
- expect(response[:msg]).to eq('Not authenticated')
45
+ expect(response[:message]).to eq('Not authenticated')
46
46
  end
47
47
  end
48
48
  end
@@ -1,13 +1,15 @@
1
+ require 'rubypitaya/core/instance_holder'
2
+
1
3
  module RubyPitaya
2
4
 
3
5
  class HandlerBase
4
6
 
5
7
  class_attribute :non_authenticated_routes, default: []
8
+ class_attribute :handler_bll, default: nil, instance_reader: false, instance_writer: false, instance_accessor: false, instance_predicate: false
6
9
 
7
- attr_accessor :bll, :log, :redis, :setup, :config, :params, :session, :postman
10
+ attr_reader :bll, :log, :redis, :setup, :config, :params, :session, :postman
8
11
 
9
12
  def initialize
10
- @bll = nil
11
13
  @log = nil
12
14
  @redis = nil
13
15
  @setup = nil
@@ -15,10 +17,11 @@ module RubyPitaya
15
17
  @params = nil
16
18
  @session = nil
17
19
  @postman = nil
20
+
21
+ @bll = self.class.bll
18
22
  end
19
23
 
20
- def set_attributes(bll, log, redis, mongo, setup, config, params, session, postman)
21
- @bll = bll
24
+ def set_attributes(log, redis, mongo, setup, config, params, session, postman)
22
25
  @log = log
23
26
  @redis = redis
24
27
  @mongo = mongo
@@ -29,6 +32,10 @@ module RubyPitaya
29
32
  @postman = postman
30
33
  end
31
34
 
35
+ def self.bll
36
+ self.handler_bll ||= InstanceHolder.new
37
+ end
38
+
32
39
  def self.non_authenticated_actions(*action_names)
33
40
  self.non_authenticated_routes = action_names.map(&:to_s)
34
41
  end
@@ -57,7 +57,7 @@ module RubyPitaya
57
57
  end
58
58
 
59
59
  def call(handler_name, action_name, session, postman, redis, mongo, setup,
60
- config, bll, log, params)
60
+ config, log, params)
61
61
  unless @handler_name_map.include?(handler_name)
62
62
  return {
63
63
  code: StatusCodes::CODE_HANDLER_NOT_FOUND,
@@ -75,11 +75,11 @@ module RubyPitaya
75
75
  handler = @handler_name_map[handler_name]
76
76
 
77
77
  if !handler.class.authenticated_action_name?(action_name)
78
- handler.set_attributes(bll, log, redis, mongo, setup, config, params, session, postman)
78
+ handler.set_attributes(log, redis, mongo, setup, config, params, session, postman)
79
79
  handler.send(action_name)
80
80
  else
81
81
  if session.authenticated?
82
- handler.set_attributes(bll, log, redis, mongo, setup, config, params, session, postman)
82
+ handler.set_attributes(log, redis, mongo, setup, config, params, session, postman)
83
83
  handler.send(action_name)
84
84
  else
85
85
  return {
@@ -2,10 +2,9 @@ module RubyPitaya
2
2
 
3
3
  class InitializerContent
4
4
 
5
- attr_reader :bll, :log, :redis, :mongo, :setup, :config
5
+ attr_reader :log, :redis, :mongo, :setup, :config
6
6
 
7
- def initialize(bll, log, redis, mongo, setup, config)
8
- @bll = bll
7
+ def initialize(log, redis, mongo, setup, config)
9
8
  @log = log
10
9
  @mongo = mongo
11
10
  @redis = redis
@@ -87,8 +87,7 @@ module RubyPitaya
87
87
 
88
88
  @bll = InstanceHolder.new
89
89
 
90
- @initializer_content = InitializerContent.new(@bll,
91
- @log,
90
+ @initializer_content = InitializerContent.new(@log,
92
91
  @redis_connector.redis,
93
92
  @mongo_connector.mongo,
94
93
  @setup,
@@ -159,17 +158,17 @@ module RubyPitaya
159
158
 
160
159
  message_route = request[:msg][:route]
161
160
  message_data = request[:msg][:data] || {}
162
- message_data = JSON.parse(message_data) if message_data.class == String
161
+ message_data = JSON.parse(message_data)
163
162
 
164
163
  params = Parameters.new(message_data)
165
164
 
166
165
  session_id = request[:session][:id]
167
166
  session_uid = request[:session].fetch(:uid, '')
168
167
  session_data = request[:session][:data]
169
- session_data = JSON.parse(session_data, symbolize_names: true) if session_data.class == String
168
+ session_data = JSON.parse(session_data, symbolize_names: true)
170
169
  frontend_id = request[:frontendID]
171
170
  metadata = request[:metadata]
172
- metadata = JSON.parse(metadata, symbolize_names: true) if metadata.class == String
171
+ metadata = JSON.parse(metadata, symbolize_names: true)
173
172
 
174
173
  @session.update(session_id, session_uid, session_data, metadata,
175
174
  frontend_id)
@@ -185,7 +184,7 @@ module RubyPitaya
185
184
  response = @handler_router.call(handler_name, action_name, @session,
186
185
  @postman, @redis_connector.redis,
187
186
  @mongo_connector.mongo, @setup, @config,
188
- @bll, @log, params)
187
+ @log, params)
189
188
 
190
189
  delta_time_seconds = ((Time.now.to_f - start_time_seconds) * 1000).round(2)
191
190
 
@@ -12,7 +12,6 @@ module RubyPitaya
12
12
  def initialize(context)
13
13
  @@context = context
14
14
 
15
- @@bll = InstanceHolder.new
16
15
  @@log = Logger.new('/dev/null')
17
16
  @@setup = SetupSpecHelper.new
18
17
  @@config = ConfigSpecHelper.new
@@ -27,8 +26,7 @@ module RubyPitaya
27
26
  @@handler_router ||= HandlerRouter.new()
28
27
 
29
28
 
30
- @@initializer_content = InitializerContent.new(@@bll,
31
- @@log,
29
+ @@initializer_content = InitializerContent.new(@@log,
32
30
  @@redis_connector.redis,
33
31
  @@mongo_connector.mongo,
34
32
  @@setup,
@@ -43,7 +41,7 @@ module RubyPitaya
43
41
  @@response = @@handler_router.call(handler_name, action_name, @@session,
44
42
  @@postman, @@redis_connector.redis,
45
43
  @@mongo_connector.mongo, @@setup,
46
- @@config, @@bll, @@log, params)
44
+ @@config, @@log, params)
47
45
  end
48
46
 
49
47
  def response
@@ -74,10 +72,6 @@ module RubyPitaya
74
72
  @@setup.add(*keys, value)
75
73
  end
76
74
 
77
- def bll
78
- @@bll
79
- end
80
-
81
75
  def log
82
76
  @@log
83
77
  end
@@ -11,4 +11,8 @@ RSpec.configure do |config|
11
11
  config.before(:each) do
12
12
  ActiveRecord::Base.descendants.each { |c| c.delete_all unless c == ActiveRecord::SchemaMigration }
13
13
  end
14
+
15
+ config.after(:each) do
16
+ ActiveRecord::Base.clear_active_connections!
17
+ end
14
18
  end
@@ -1,3 +1,3 @@
1
1
  module RubyPitaya
2
- VERSION = '2.26.3'
2
+ VERSION = '2.27.0'
3
3
  end
data/lib/rubypitaya.rb CHANGED
@@ -66,7 +66,7 @@ module RubyPitaya
66
66
 
67
67
  plugin_migrations_files.each_with_index do |migration_file, i|
68
68
  migration_timestamp = base_migration_timestamp + i
69
- new_file = migration_file.gsub(/^(.+\/migration\/)\d+(_.+)$/, "\\1#{migration_timestamp}\\2")
69
+ new_file = migration_file.gsub(/^(.+\/migrations\/)\d+(_.+)$/, "\\1#{migration_timestamp}\\2")
70
70
 
71
71
  File.rename(migration_file, new_file)
72
72
  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: 2.26.3
4
+ version: 2.27.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luciano Prestes Cavalcanti