rubypitaya 2.22.0 → 2.23.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: 7529399c736434f01aee685406c3d2763e6ecd167fcf0b783aac93a2aef7c0e4
4
- data.tar.gz: 6eceae718f3027593dfd6d82a384b1c139a241e36decc0bc6d51553f59717567
3
+ metadata.gz: 3622a8779af46681d3a25d677021ef477a968e2a538d3dc7712c54a3bb5cd01d
4
+ data.tar.gz: d3357dc303db00fc1d29c208557547d60def38e432558a8286313dce4a9776df
5
5
  SHA512:
6
- metadata.gz: 4f41f11c539540593b5da84a986c7baa2209a6108f2fb3ddeca6b6577509d96732704609dd13000b8c9e2573ac9acd3d2f58b55c1ffe8c45ccdbc1e507d9ff50
7
- data.tar.gz: 3f1d834d5442848c9637491709ae0c7bff746e345e316afd13cec022d65a652591ea0a4ac01e42986132defd7feac209ebf934b782e4bf58274ffa21f670abb1
6
+ metadata.gz: 7f253dd21e9999acbe8ca3e6f64795f5c434a392cc7ad58749d5d0ac964fd1261e1440ef28a676489ce545bc406f39d5e1547242cee04575b666acfbe9dac4cb
7
+ data.tar.gz: 8ea11f029554fbb21abecb2f12dd69f6a40f6bff2dcb326e1bb28812be9261318bb650f8ff783b010fd68f5ac430de311263338d725b44e9715da914cc4ed2d6
data/lib/rubypitaya.rb CHANGED
@@ -49,7 +49,14 @@ module RubyPitaya
49
49
  `git -C #{Path::PLUGINS_FOLDER_PATH} clone #{plugin_git_link}`
50
50
  FileUtils.rm_rf(plugin_git_path)
51
51
 
52
- plugin_migrations_path = File.join(plugin_folder_path, 'db/migration/')
52
+ Dir.entries(plugin_folder_path).each do |entry|
53
+ entry_path = File.join(plugin_folder_path, entry)
54
+ FileUtils.rm_rf(entry_path) unless entry == 'app' ||
55
+ entry == '.' ||
56
+ entry == '..'
57
+ end
58
+
59
+ plugin_migrations_path = File.join(plugin_folder_path, 'app/migrations/')
53
60
  plugin_migrations_files = Dir[File.join(plugin_migrations_path, '*')]
54
61
  base_migration_timestamp = Time.now.utc.to_i
55
62
 
@@ -1,6 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem 'rubypitaya', '2.22.0'
3
+ gem 'rubypitaya', '2.23.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.22.0)
114
+ rubypitaya (2.23.0)
115
115
  activerecord (= 6.1.3)
116
116
  etcdv3 (= 0.10.2)
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.22.0)
155
+ rubypitaya (= 2.23.0)
156
156
 
157
157
  BUNDLED WITH
158
158
  2.1.4
@@ -49,7 +49,7 @@ update-dependencies:
49
49
  create-migration:
50
50
  @docker-compose run --service-ports --rm rubypitaya-commands bundle exec rubypitaya create-migration $(NAME)
51
51
 
52
- ## Add or update a plugim. GIT=[plugin-git-link]
52
+ ## Add or update a plugin. GIT=[plugin-http-git-link]
53
53
  add-plugin:
54
54
  @docker-compose run --service-ports --rm rubypitaya-commands bundle exec rubypitaya add-plugin $(GIT)
55
55
 
@@ -13,6 +13,9 @@ class AppInitializer < RubyPitaya::InitializerBase
13
13
  # - get instance by key
14
14
  # - redis
15
15
  # - link: https://github.com/redis/redis-rb/
16
+ # - mongo
17
+ # - class: Mongo::Client
18
+ # - link: https://docs.mongodb.com/ruby-driver/current/tutorials/quick-start/
16
19
  # - config
17
20
  # - class: RubyPitaya::Config
18
21
  # - link: https://gitlab.com/LucianoPC/ruby-pitaya/-/blob/master/lib/rubypitaya/core/config.rb
@@ -11,6 +11,10 @@ class PlayerHandler < RubyPitaya::HandlerBase
11
11
  # - @redis
12
12
  # - link: https://github.com/redis/redis-rb/
13
13
  #
14
+ # - @mongo
15
+ # - class: Mongo::Client
16
+ # - link: https://docs.mongodb.com/ruby-driver/current/tutorials/quick-start/
17
+ #
14
18
  # - @config
15
19
  # - info: Hash with config json files inside of 'app/config'
16
20
  # - example:
@@ -20,6 +20,12 @@ database:
20
20
  password: 'postgres'
21
21
  name: 'ruby_pitaya'
22
22
 
23
+ mongo:
24
+ url: mongo:27017
25
+ user: 'user'
26
+ pass: 'password'
27
+ database: admin
28
+
23
29
  http:
24
30
  auth:
25
31
  user: 'user'
@@ -15,7 +15,7 @@ ActiveSupport::LogSubscriber.colorize_logging = true
15
15
  # Loading core files
16
16
  Gem.find_files('rubypitaya/**/*.rb').each do |path|
17
17
  require path unless path.end_with?('spec.rb') ||
18
- path.include?('db/migration') ||
18
+ path.include?('app/migrations') ||
19
19
  path.include?('core/templates') ||
20
20
  path.include?('core/spec-helpers') ||
21
21
  path.include?('app-template')
@@ -28,7 +28,7 @@ app_folder_paths.each do |app_folder_path|
28
28
 
29
29
  Dir[app_files_path].each do |path|
30
30
  require path unless path.end_with?('spec.rb') ||
31
- path.include?('db/migration') ||
31
+ path.include?('app/migrations') ||
32
32
  path.include?('spec_helper.rb')
33
33
  end
34
34
  end
@@ -26,6 +26,28 @@ services:
26
26
  ports:
27
27
  - '9100:5432'
28
28
 
29
+ mongo:
30
+ image: mongo:5.0.0
31
+ restart: always
32
+ ports:
33
+ - 27017:27017
34
+ environment:
35
+ MONGO_INITDB_ROOT_USERNAME: user
36
+ MONGO_INITDB_ROOT_PASSWORD: password
37
+
38
+ mongo-express:
39
+ depends_on:
40
+ - 'mongo'
41
+ image: mongo-express:0.54.0
42
+ restart: always
43
+ ports:
44
+ - 8081:8081
45
+ environment:
46
+ ME_CONFIG_MONGODB_ADMINUSERNAME: user
47
+ ME_CONFIG_MONGODB_ADMINPASSWORD: password
48
+ ME_CONFIG_MONGODB_SERVER: 'mongo'
49
+ ME_CONFIG_MONGODB_PORT: '27017'
50
+
29
51
  connector:
30
52
  image: 'registry.gitlab.com/lucianopc/pitaya-connector:0.1.0'
31
53
  depends_on:
@@ -49,6 +71,8 @@ services:
49
71
  - 'nats'
50
72
  - 'etcd'
51
73
  - 'redis'
74
+ - 'mongo'
75
+ - 'mongo-express'
52
76
  - 'connector'
53
77
  build:
54
78
  context: '.'
@@ -10,7 +10,9 @@ module RubyPitaya
10
10
  app_folder_paths.each do |app_folder_path|
11
11
  app_files_path = "#{app_folder_path}/**/*.rb"
12
12
 
13
- Gem.find_files(app_files_path).each { |path| require path }
13
+ Gem.find_files(app_files_path).each do |path|
14
+ require path unless path.include?('app/migrations')
15
+ end
14
16
  end
15
17
  end
16
18
 
@@ -17,10 +17,11 @@ module RubyPitaya
17
17
  @postman = nil
18
18
  end
19
19
 
20
- def set_attributes(bll, log, redis, setup, config, params, session, postman)
20
+ def set_attributes(bll, log, redis, mongo, setup, config, params, session, postman)
21
21
  @bll = bll
22
22
  @log = log
23
23
  @redis = redis
24
+ @mongo = mongo
24
25
  @setup = setup
25
26
  @config = config
26
27
  @params = params
@@ -54,8 +54,8 @@ module RubyPitaya
54
54
  @handler_name_map = @handler_name_map.to_h
55
55
  end
56
56
 
57
- def call(handler_name, action_name, session, postman, redis, setup, config,
58
- bll, log, params)
57
+ def call(handler_name, action_name, session, postman, redis, mongo, setup,
58
+ config, bll, log, params)
59
59
  unless @handler_name_map.include?(handler_name)
60
60
  return {
61
61
  code: StatusCodes::CODE_HANDLER_NOT_FOUND,
@@ -72,11 +72,11 @@ module RubyPitaya
72
72
  handler = @handler_name_map[handler_name]
73
73
 
74
74
  if !handler.class.authenticated_action_name?(action_name)
75
- handler.set_attributes(bll, log, redis, setup, config, params, session, postman)
75
+ handler.set_attributes(bll, log, redis, mongo, setup, config, params, session, postman)
76
76
  handler.send(action_name)
77
77
  else
78
78
  if session.authenticated?
79
- handler.set_attributes(bll, log, redis, setup, config, params, session, postman)
79
+ handler.set_attributes(bll, log, redis, mongo, setup, config, params, session, postman)
80
80
  handler.send(action_name)
81
81
  else
82
82
  return {
@@ -18,7 +18,7 @@ ActiveRecord::Migration.maintain_test_schema!
18
18
  # Loading core files
19
19
  Gem.find_files('rubypitaya/**/*.rb').each do |path|
20
20
  require path unless path.end_with?('spec.rb') ||
21
- path.include?('db/migration') ||
21
+ path.include?('app/migrations') ||
22
22
  path.include?('core/templates') ||
23
23
  path.include?('core/spec-helpers') ||
24
24
  path.include?('app-template')
@@ -31,6 +31,6 @@ app_folder_paths.each do |app_folder_path|
31
31
 
32
32
  Dir[app_files_path].each do |path|
33
33
  require path unless path.end_with?('spec.rb') ||
34
- path.include?('db/migration')
34
+ path.include?('app/migrations')
35
35
  end
36
36
  end
@@ -20,6 +20,7 @@ module RubyPitaya
20
20
  content_type :json
21
21
 
22
22
  @bll = settings.bll
23
+ @mongo = settings.mongo
23
24
  @setup = settings.setup
24
25
  @config = settings.config
25
26
 
@@ -2,11 +2,12 @@ module RubyPitaya
2
2
 
3
3
  class InitializerContent
4
4
 
5
- attr_reader :bll, :log, :redis, :setup, :config
5
+ attr_reader :bll, :log, :redis, :mongo, :setup, :config
6
6
 
7
- def initialize(bll, log, redis, setup, config)
7
+ def initialize(bll, log, redis, mongo, setup, config)
8
8
  @bll = bll
9
9
  @log = log
10
+ @mongo = mongo
10
11
  @redis = redis
11
12
  @setup = setup
12
13
  @config = config
@@ -16,8 +16,9 @@ require 'rubypitaya/core/handler_router'
16
16
  require 'rubypitaya/core/etcd_connector'
17
17
  require 'rubypitaya/core/nats_connector'
18
18
  require 'rubypitaya/core/database_config'
19
- require 'rubypitaya/core/redis_connector'
20
19
  require 'rubypitaya/core/instance_holder'
20
+ require 'rubypitaya/core/mongo_connector'
21
+ require 'rubypitaya/core/redis_connector'
21
22
  require 'rubypitaya/core/database_connector'
22
23
  require 'rubypitaya/core/initializer_content'
23
24
  require 'rubypitaya/core/initializer_broadcast'
@@ -71,6 +72,14 @@ module RubyPitaya
71
72
  @database_connector = DatabaseConnector.new(@database_config)
72
73
  @database_connector.connect
73
74
 
75
+ @mongo_address = @setup['rubypitaya.mongo.url']
76
+ @mongo_user = @setup['rubypitaya.mongo.user']
77
+ @mongo_password = @setup['rubypitaya.mongo.pass']
78
+ @mongo_database_name = @setup['rubypitaya.mongo.database']
79
+ @mongo_connector = MongoConnector.new(@mongo_address, @mongo_user,
80
+ @mongo_password, @mongo_database_name)
81
+ @mongo_connector.connect
82
+
74
83
  @session = Session.new
75
84
  @postman = Postman.new(@nats_connector)
76
85
  @config = Config.new
@@ -81,6 +90,7 @@ module RubyPitaya
81
90
  @initializer_content = InitializerContent.new(@bll,
82
91
  @log,
83
92
  @redis_connector.redis,
93
+ @mongo_connector.mongo,
84
94
  @setup,
85
95
  @config)
86
96
  @initializer_broadcast = InitializerBroadcast.new
@@ -97,6 +107,8 @@ module RubyPitaya
97
107
  def run_http
98
108
  HttpRoutes.set :bll, @bll
99
109
  HttpRoutes.set :log, @log
110
+ HttpRoutes.set :redis, @redis_connector.redis
111
+ HttpRoutes.set :mongo, @mongo_connector.mongo
100
112
  HttpRoutes.set :setup, @setup
101
113
  HttpRoutes.set :config, @config
102
114
  HttpRoutes.set :views, [Path::HTTP_VIEWS_PATH] + Path::Plugins::HTTP_VIEWS_PATHS
@@ -172,7 +184,8 @@ module RubyPitaya
172
184
 
173
185
  response = @handler_router.call(handler_name, action_name, @session,
174
186
  @postman, @redis_connector.redis,
175
- @setup, @config, @bll, @log, params)
187
+ @mongo_connector.mongo, @setup, @config,
188
+ @bll, @log, params)
176
189
 
177
190
  delta_time_seconds = ((Time.now.to_f - start_time_seconds) * 1000).round(2)
178
191
 
@@ -0,0 +1,25 @@
1
+ require 'mongo'
2
+
3
+ module RubyPitaya
4
+
5
+ class MongoConnector
6
+
7
+ def initialize(mongo_address, mongo_user, mongo_password, mongo_database_name)
8
+ @mongo_address = mongo_address
9
+ @mongo_user = mongo_user
10
+ @mongo_password = mongo_password
11
+ @mongo_database_name = mongo_database_name
12
+ end
13
+
14
+ def connect
15
+ @mongo_client = Mongo::Client.new([@mongo_address],
16
+ user: @mongo_user,
17
+ password: @mongo_password,
18
+ database: @mongo_database_name)
19
+ end
20
+
21
+ def mongo
22
+ @mongo_client
23
+ end
24
+ end
25
+ end
@@ -8,7 +8,7 @@ module RubyPitaya
8
8
  HANDLERS_FOLDER_PATH = File.join(Dir.pwd, 'app/handlers/')
9
9
  APP_CONFIG_FOLDER_PATH = File.join(Dir.pwd, 'app/config/')
10
10
  APP_SETUP_FOLDER_PATH = File.join(Dir.pwd, 'app/setup/')
11
- MIGRATIONS_FOLDER_PATH = File.join(Dir.pwd, 'db/migration/')
11
+ MIGRATIONS_FOLDER_PATH = File.join(Dir.pwd, 'app/migrations/')
12
12
  PLUGINS_FOLDER_PATH = File.join(Dir.pwd, 'plugins/')
13
13
 
14
14
  ROUTES_FILE_PATH = File.join(Dir.pwd, 'config/routes.rb')
@@ -18,7 +18,7 @@ module RubyPitaya
18
18
 
19
19
  class Core
20
20
  APP_FOLDER_PATH = File.join(__dir__, 'app/')
21
- MIGRATIONS_FOLDER_PATH = File.join(__dir__, 'db/migration/')
21
+ MIGRATIONS_FOLDER_PATH = File.join(__dir__, 'app/migrations/')
22
22
  end
23
23
 
24
24
  class Plugins
@@ -26,7 +26,7 @@ module RubyPitaya
26
26
  HANDLERS_FOLDER_PATHS = Dir.glob(File.join(Dir.pwd, 'plugins/*/app/handlers'))
27
27
  APP_CONFIG_FOLDER_PATHS = Dir.glob(File.join(Dir.pwd, 'plugins/*/app/config/'))
28
28
  APP_SETUP_FOLDER_PATHS = Dir.glob(File.join(Dir.pwd, 'plugins/*/app/setup/'))
29
- MIGRATIONS_FOLDER_PATHS = Dir.glob(File.join(Dir.pwd, 'plugins/*/db/migration'))
29
+ MIGRATIONS_FOLDER_PATHS = Dir.glob(File.join(Dir.pwd, 'plugins/*/app/migrations/'))
30
30
  HTTP_VIEWS_PATHS = Dir.glob(File.join(Dir.pwd, 'plugins/*/app/http/views'))
31
31
  end
32
32
  end
@@ -22,6 +22,7 @@ module RubyPitaya
22
22
  @@response = {}
23
23
 
24
24
  initialize_redis
25
+ initialize_mongo
25
26
 
26
27
  @@handler_router ||= HandlerRouter.new()
27
28
 
@@ -29,6 +30,7 @@ module RubyPitaya
29
30
  @@initializer_content = InitializerContent.new(@@bll,
30
31
  @@log,
31
32
  @@redis_connector.redis,
33
+ @@mongo_connector.mongo,
32
34
  @@setup,
33
35
  @@config)
34
36
  @@initializer_broadcast = InitializerBroadcast.new
@@ -40,7 +42,8 @@ module RubyPitaya
40
42
 
41
43
  @@response = @@handler_router.call(handler_name, action_name, @@session,
42
44
  @@postman, @@redis_connector.redis,
43
- @@setup, @@config, @@bll, @@log, params)
45
+ @@mongo_connector.mongo, @@setup,
46
+ @@config, @@bll, @@log, params)
44
47
  end
45
48
 
46
49
  def response
@@ -105,5 +108,22 @@ module RubyPitaya
105
108
 
106
109
  @@redis_connector.redis.flushall
107
110
  end
111
+
112
+ def initialize_mongo
113
+ @@mongo_connector ||= nil
114
+
115
+ if @@mongo_connector.nil?
116
+ @@core_setup ||= Setup.new
117
+ mongo_address = @@core_setup['rubypitaya.mongo.url']
118
+ mongo_user = @@core_setup['rubypitaya.mongo.user']
119
+ mongo_password = @@core_setup['rubypitaya.mongo.pass']
120
+ mongo_database_name = @@core_setup['rubypitaya.mongo.database']
121
+ @@mongo_connector = MongoConnector.new(mongo_address, mongo_user,
122
+ mongo_password, mongo_database_name)
123
+ @@mongo_connector.connect
124
+ end
125
+
126
+ @@mongo_connector.mongo.collections.map(&:drop)
127
+ end
108
128
  end
109
129
  end
@@ -1,3 +1,3 @@
1
1
  module RubyPitaya
2
- VERSION = '2.22.0'
2
+ VERSION = '2.23.0'
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: 2.22.0
4
+ version: 2.23.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luciano Prestes Cavalcanti
@@ -258,12 +258,12 @@ files:
258
258
  - "./lib/rubypitaya/app-template/app/handlers/player_handler.rb"
259
259
  - "./lib/rubypitaya/app-template/app/http/hello_world_http.rb"
260
260
  - "./lib/rubypitaya/app-template/app/http/views/hello_world.erb"
261
+ - "./lib/rubypitaya/app-template/app/migrations/1606736477_create_player_migration.rb"
261
262
  - "./lib/rubypitaya/app-template/app/models/player.rb"
262
263
  - "./lib/rubypitaya/app-template/app/models/user.rb"
263
264
  - "./lib/rubypitaya/app-template/app/setup/rubypitaya.yml"
264
265
  - "./lib/rubypitaya/app-template/bin/console"
265
266
  - "./lib/rubypitaya/app-template/config/routes.rb"
266
- - "./lib/rubypitaya/app-template/db/migration/1606736477_create_player_migration.rb"
267
267
  - "./lib/rubypitaya/app-template/docker-compose.yml"
268
268
  - "./lib/rubypitaya/app-template/docker/dev/Dockerfile"
269
269
  - "./lib/rubypitaya/app-template/docker/entrypoint.sh"
@@ -316,13 +316,13 @@ files:
316
316
  - "./lib/rubypitaya/app-template/spec/hello_world_handler_spec.rb"
317
317
  - "./lib/rubypitaya/app-template/spec/player_handler_spec.rb"
318
318
  - "./lib/rubypitaya/app-template/spec/spec_helper.rb"
319
+ - "./lib/rubypitaya/core/app/migrations/0000000001_create_user_migration.rb"
319
320
  - "./lib/rubypitaya/core/app/models/user.rb"
320
321
  - "./lib/rubypitaya/core/application_files_importer.rb"
321
322
  - "./lib/rubypitaya/core/config.rb"
322
323
  - "./lib/rubypitaya/core/config_core.rb"
323
324
  - "./lib/rubypitaya/core/database_config.rb"
324
325
  - "./lib/rubypitaya/core/database_connector.rb"
325
- - "./lib/rubypitaya/core/db/migration/0000000001_create_user_migration.rb"
326
326
  - "./lib/rubypitaya/core/etcd_connector.rb"
327
327
  - "./lib/rubypitaya/core/handler_base.rb"
328
328
  - "./lib/rubypitaya/core/handler_router.rb"
@@ -333,6 +333,7 @@ files:
333
333
  - "./lib/rubypitaya/core/initializer_content.rb"
334
334
  - "./lib/rubypitaya/core/instance_holder.rb"
335
335
  - "./lib/rubypitaya/core/main.rb"
336
+ - "./lib/rubypitaya/core/mongo_connector.rb"
336
337
  - "./lib/rubypitaya/core/nats_connector.rb"
337
338
  - "./lib/rubypitaya/core/parameters.rb"
338
339
  - "./lib/rubypitaya/core/path.rb"