rubypitaya 2.26.0 → 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: 8c289b7e66999cba7c278e77dd8658527cd101218009709e533fe853b5f43250
4
- data.tar.gz: 4dd6b6fe78b6c22b30b1a7564a9972da484753c8d8716e4fd5dabd0e0f5ae001
3
+ metadata.gz: e382eff25c29ad543511d22efa945c52d1b770c7e9237ab46338db08d087842f
4
+ data.tar.gz: '08e25deffa96ab5acc7b3e239f8b9515355f7e9308228b4d7cfb8e25528403d6'
5
5
  SHA512:
6
- metadata.gz: 3faa2a8b0cda879621cb823ae920271477596c556c9938881fcd829e185a7563d6da3492bb7a387c5a58766ce5d8f990dbc1c73bf997a19c3e0eaf5db6153ccc
7
- data.tar.gz: ee519fc3028078226cc0e5e01e0b706bd96962481b10ca263e60c28f371b354bd0480b0fa3452e4fc9007ea4f786bbf0ba2ca75c330a6ad72b901cbf9defae9c
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.0'
3
+ gem 'rubypitaya', '2.27.0'
4
4
 
5
5
  group :development do
6
6
  gem 'pry', '0.14.0'
@@ -1,12 +1,12 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- activemodel (6.1.3)
5
- activesupport (= 6.1.3)
6
- activerecord (6.1.3)
7
- activemodel (= 6.1.3)
8
- activesupport (= 6.1.3)
9
- activesupport (6.1.3)
4
+ activemodel (6.1.4.1)
5
+ activesupport (= 6.1.4.1)
6
+ activerecord (6.1.4.1)
7
+ activemodel (= 6.1.4.1)
8
+ activesupport (= 6.1.4.1)
9
+ activesupport (6.1.4.1)
10
10
  concurrent-ruby (~> 1.0, >= 1.0.2)
11
11
  i18n (>= 1.6, < 2)
12
12
  minitest (>= 5.1)
@@ -48,10 +48,10 @@ GEM
48
48
  cucumber-cucumber-expressions (~> 10.3, >= 10.3.0)
49
49
  cucumber-messages (~> 13.0, >= 13.0.1)
50
50
  diff-lcs (1.4.4)
51
- etcdv3 (0.10.2)
51
+ etcdv3 (0.11.3)
52
52
  grpc (~> 1.17)
53
53
  eventmachine (1.2.7)
54
- ffi (1.15.3)
54
+ ffi (1.15.4)
55
55
  google-protobuf (3.17.3)
56
56
  googleapis-common-protos-types (1.1.0)
57
57
  google-protobuf (~> 3.14)
@@ -74,9 +74,9 @@ GEM
74
74
  ruby2_keywords (~> 0.0.1)
75
75
  nats (0.11.0)
76
76
  eventmachine (~> 1.2, >= 1.2)
77
- ostruct (0.3.3)
77
+ ostruct (0.4.0)
78
78
  pg (1.2.3)
79
- protobuf (3.10.0)
79
+ protobuf (3.10.4)
80
80
  activesupport (>= 3.2)
81
81
  middleware
82
82
  thor
@@ -92,11 +92,11 @@ GEM
92
92
  rack (2.2.3)
93
93
  rack-protection (2.1.0)
94
94
  rack
95
- rake (13.0.3)
95
+ rake (13.0.6)
96
96
  rb-fsevent (0.11.0)
97
97
  rb-inotify (0.10.1)
98
98
  ffi (~> 1.0)
99
- redis (4.2.5)
99
+ redis (4.4.0)
100
100
  rspec (3.10.0)
101
101
  rspec-core (~> 3.10.0)
102
102
  rspec-expectations (~> 3.10.0)
@@ -111,16 +111,16 @@ 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.0)
115
- activerecord (= 6.1.3)
116
- etcdv3 (= 0.10.2)
114
+ rubypitaya (2.27.0)
115
+ activerecord (= 6.1.4.1)
116
+ etcdv3 (= 0.11.3)
117
117
  mongo (= 2.15.0)
118
118
  nats (= 0.11.0)
119
- ostruct (= 0.3.3)
119
+ ostruct (= 0.4.0)
120
120
  pg (= 1.2.3)
121
- protobuf (= 3.10.0)
122
- rake (= 13.0.3)
123
- redis (= 4.2.5)
121
+ protobuf (= 3.10.4)
122
+ rake (= 13.0.6)
123
+ redis (= 4.4.0)
124
124
  sinatra (= 2.1.0)
125
125
  sinatra-contrib (= 2.1.0)
126
126
  sinatra (2.1.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.0)
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 {
@@ -1,11 +1,9 @@
1
1
  require 'sinatra/base'
2
- require 'sinatra/activerecord'
3
2
  require 'rubypitaya/core/parameters'
4
3
 
5
4
  module RubyPitaya
6
5
 
7
6
  class HttpRoutes < Sinatra::Base
8
- register Sinatra::ActiveRecordExtension
9
7
 
10
8
  def self.auto_reload
11
9
  require 'sinatra/reloader'
@@ -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.0'
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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubypitaya
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.26.0
4
+ version: 2.27.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luciano Prestes Cavalcanti
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-01 00:00:00.000000000 Z
11
+ date: 2021-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -164,20 +164,6 @@ dependencies:
164
164
  - - '='
165
165
  - !ruby/object:Gem::Version
166
166
  version: 2.1.0
167
- - !ruby/object:Gem::Dependency
168
- name: sinatra-activerecord
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - '='
172
- - !ruby/object:Gem::Version
173
- version: 2.0.23
174
- type: :runtime
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - '='
179
- - !ruby/object:Gem::Version
180
- version: 2.0.23
181
167
  - !ruby/object:Gem::Dependency
182
168
  name: pry
183
169
  requirement: !ruby/object:Gem::Requirement