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 +4 -4
- data/lib/rubypitaya/app-template/Gemfile +1 -1
- data/lib/rubypitaya/app-template/Gemfile.lock +2 -2
- data/lib/rubypitaya/app-template/app/app_initializer.rb +1 -11
- data/lib/rubypitaya/app-template/spec/player_handler_spec.rb +1 -1
- data/lib/rubypitaya/core/handler_base.rb +11 -4
- data/lib/rubypitaya/core/handler_router.rb +3 -3
- data/lib/rubypitaya/core/initializer_content.rb +2 -3
- data/lib/rubypitaya/core/main.rb +5 -6
- data/lib/rubypitaya/core/spec-helpers/handler_spec_helper.rb +2 -8
- data/lib/rubypitaya/core/spec-helpers/rubypitaya_spec_helper.rb +4 -0
- data/lib/rubypitaya/version.rb +1 -1
- data/lib/rubypitaya.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e382eff25c29ad543511d22efa945c52d1b770c7e9237ab46338db08d087842f
|
4
|
+
data.tar.gz: '08e25deffa96ab5acc7b3e239f8b9515355f7e9308228b4d7cfb8e25528403d6'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c57f7eb3b0637bd463efc43185dd1c8a543b275f7db1ed2739e84b4d547f5c21d9519c1d910d9418ce7f19e273d24746b907e8ff32c334727ba0897b06eec66d
|
7
|
+
data.tar.gz: 29ea1d9037c932b84e0016316169c5e2821b166728075512cdaf132c110cf679d9544168881b65fb8bd9e701654d786eb05bba366ca2d272dfb0e26e66af348c
|
@@ -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.
|
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.
|
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[:
|
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
|
-
|
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(
|
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,
|
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(
|
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(
|
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 :
|
5
|
+
attr_reader :log, :redis, :mongo, :setup, :config
|
6
6
|
|
7
|
-
def initialize(
|
8
|
-
@bll = bll
|
7
|
+
def initialize(log, redis, mongo, setup, config)
|
9
8
|
@log = log
|
10
9
|
@mongo = mongo
|
11
10
|
@redis = redis
|
data/lib/rubypitaya/core/main.rb
CHANGED
@@ -87,8 +87,7 @@ module RubyPitaya
|
|
87
87
|
|
88
88
|
@bll = InstanceHolder.new
|
89
89
|
|
90
|
-
@initializer_content = InitializerContent.new(@
|
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)
|
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)
|
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)
|
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
|
-
@
|
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(@@
|
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, @@
|
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
|
data/lib/rubypitaya/version.rb
CHANGED
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(/^(.+\/
|
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
|