rubypitaya 1.8.2 → 2.2.2
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/Rakefile +4 -2
- data/lib/rubypitaya/app-template/app/app_initializer.rb +8 -1
- data/lib/rubypitaya/app-template/app/models/user.rb +3 -4
- data/lib/rubypitaya/app-template/bin/console +2 -2
- data/lib/rubypitaya/app-template/db/{migrate/002_create_player_migration.rb → migration/0000000002_create_player_migration.rb} +0 -0
- data/lib/rubypitaya/app-template/docker-compose.yml +1 -1
- data/lib/rubypitaya/core/app/models/user.rb +4 -0
- data/lib/rubypitaya/core/application_files_importer.rb +11 -3
- data/lib/rubypitaya/core/config.rb +24 -20
- data/lib/rubypitaya/{app-template/db/migrate/001_create_user_migration.rb → core/db/migration/0000000001_create_user_migration.rb} +0 -0
- data/lib/rubypitaya/core/handler_router.rb +8 -2
- data/lib/rubypitaya/core/initializer_content.rb +3 -2
- data/lib/rubypitaya/core/main.rb +5 -4
- data/lib/rubypitaya/core/path.rb +13 -1
- data/lib/rubypitaya/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e34b4f837db342c17e307255d3f45ead903794ab727e7de806674906019329c6
|
4
|
+
data.tar.gz: 335696b1f6de405da7f7f7bf5426c8a86485c7b46e3675729847f6203224ee95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a7c707616860f57845ccb552b593c1ef11b884918fc71eda11b1615e8e8aef335c4a91f44003cc4c74ee0d7446c1dc1db734f51878cd51203f1a285d06ede92
|
7
|
+
data.tar.gz: 34bf38eea9e9d1986a8a3aad6f0bf4231149a1ced7f21c48f9ae6b4106f2d496e375adf829087f15c1ac7d4f8691cb24a7395c302dcb2f68b62f68e425c7d286
|
@@ -62,7 +62,7 @@ GEM
|
|
62
62
|
diff-lcs (>= 1.2.0, < 2.0)
|
63
63
|
rspec-support (~> 3.8.0)
|
64
64
|
rspec-support (3.8.3)
|
65
|
-
rubypitaya (
|
65
|
+
rubypitaya (2.2.2)
|
66
66
|
activerecord (= 6.0.2)
|
67
67
|
etcdv3 (= 0.10.2)
|
68
68
|
eventmachine (= 1.2.7)
|
@@ -85,7 +85,7 @@ DEPENDENCIES
|
|
85
85
|
pry (= 0.12.2)
|
86
86
|
rake (= 10.0)
|
87
87
|
rspec (= 3.8.0)
|
88
|
-
rubypitaya (=
|
88
|
+
rubypitaya (= 2.2.2)
|
89
89
|
|
90
90
|
BUNDLED WITH
|
91
91
|
1.17.2
|
@@ -24,10 +24,12 @@ namespace :db do
|
|
24
24
|
environment_name = ENV.fetch("RUBYPITAYA_ENV") { 'development' }
|
25
25
|
database_config = RubyPitaya::DatabaseConfig.new(environment_name, RubyPitaya::Path::DATABASE_CONFIG_PATH)
|
26
26
|
connection_data = database_config.connection_data
|
27
|
-
|
27
|
+
migrations_paths = [RubyPitaya::Path::Core::MIGRATIONS_FOLDER_PATH]
|
28
|
+
migrations_paths += RubyPitaya::Path::Plugins::MIGRATIONS_FOLDER_PATHS
|
29
|
+
migrations_paths += [RubyPitaya::Path::MIGRATIONS_FOLDER_PATH]
|
28
30
|
|
29
31
|
ActiveRecord::Base.establish_connection(connection_data)
|
30
|
-
ActiveRecord::Migrator.migrations_paths =
|
32
|
+
ActiveRecord::Migrator.migrations_paths = migrations_paths
|
31
33
|
ActiveRecord::Tasks::DatabaseTasks.migrate
|
32
34
|
ActiveRecord::Base.connection.close
|
33
35
|
puts 'Database migrated.'
|
@@ -4,7 +4,8 @@ class AppInitializer < RubyPitaya::InitializerBase
|
|
4
4
|
# parameter: initializer_content
|
5
5
|
# attributes:
|
6
6
|
# - bll
|
7
|
-
# - class: InstanceHolder
|
7
|
+
# - class: RubyPitaya::InstanceHolder
|
8
|
+
# - link: https://gitlab.com/LucianoPC/ruby-pitaya/-/blob/master/lib/rubypitaya/core/instance_holder.rb
|
8
9
|
# - methods:
|
9
10
|
# - add_instance(key, instance)
|
10
11
|
# - add any instance to any key
|
@@ -12,6 +13,12 @@ class AppInitializer < RubyPitaya::InitializerBase
|
|
12
13
|
# - get instance by key
|
13
14
|
# - redis
|
14
15
|
# - link: https://github.com/redis/redis-rb/
|
16
|
+
# - config
|
17
|
+
# - class: RubyPitaya::Config
|
18
|
+
# - link: https://gitlab.com/LucianoPC/ruby-pitaya/-/blob/master/lib/rubypitaya/core/config.rb
|
19
|
+
# - methods:
|
20
|
+
# - [](key)
|
21
|
+
# - get config file by config path
|
15
22
|
|
16
23
|
def run(initializer_content)
|
17
24
|
bll = initializer_content.bll
|
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
end
|
1
|
+
User.class_eval do
|
2
|
+
# has_one :player
|
3
|
+
end
|
@@ -14,14 +14,14 @@ ActiveSupport::LogSubscriber.colorize_logging = true
|
|
14
14
|
|
15
15
|
Gem.find_files('rubypitaya/**/*.rb').each do |path|
|
16
16
|
require path unless path.end_with?('spec.rb') ||
|
17
|
-
path.include?('db/
|
17
|
+
path.include?('db/migration') ||
|
18
18
|
path.include?('app-template')
|
19
19
|
end
|
20
20
|
|
21
21
|
app_files_path = File.join(RubyPitaya::Path::APP_FOLDER_PATH, '**/*.rb')
|
22
22
|
Dir[app_files_path].each do |path|
|
23
23
|
require path unless path.end_with?('spec.rb') ||
|
24
|
-
path.include?('db/
|
24
|
+
path.include?('db/migration')
|
25
25
|
end
|
26
26
|
|
27
27
|
require 'irb'
|
File without changes
|
@@ -5,15 +5,23 @@ module RubyPitaya
|
|
5
5
|
class ApplicationFilesImporter
|
6
6
|
|
7
7
|
def import
|
8
|
-
|
8
|
+
@app_folder_paths = [Path::Core::APP_FOLDER_PATH, Path::APP_FOLDER_PATH] + Path::Plugins::APP_FOLDER_PATHS
|
9
9
|
|
10
|
-
|
10
|
+
@app_folder_paths.each do |app_folder_path|
|
11
|
+
app_files_path = "#{app_folder_path}/**/*.rb"
|
12
|
+
|
13
|
+
Gem.find_files(app_files_path).each { |path| require path }
|
14
|
+
end
|
11
15
|
end
|
12
16
|
|
13
17
|
def auto_reload
|
14
18
|
require 'listen'
|
15
19
|
|
16
|
-
@app_files_listener = Listen.to(
|
20
|
+
@app_files_listener = Listen.to(*@app_folder_paths,
|
21
|
+
only: /\.rb$/,
|
22
|
+
force_polling: true,
|
23
|
+
latency: 0.25,
|
24
|
+
wait_for_delay: 0.1) do |modified, added, removed|
|
17
25
|
import_added_files(added)
|
18
26
|
reload_modified_files(modified)
|
19
27
|
end
|
@@ -2,16 +2,17 @@ module RubyPitaya
|
|
2
2
|
|
3
3
|
class Config
|
4
4
|
|
5
|
-
def initialize(
|
6
|
-
@configs_folder_path = configs_folder_path
|
7
|
-
|
8
|
-
path_to_all_files = File.join(@configs_folder_path, '**/*.json')
|
9
|
-
config_files = Dir.glob(path_to_all_files)
|
10
|
-
|
5
|
+
def initialize()
|
11
6
|
@config = {}
|
7
|
+
@configs_folder_paths = [Path::APP_CONFIG_FOLDER_PATH] + Path::Plugins::APP_CONFIG_FOLDER_PATHS
|
12
8
|
|
13
|
-
|
14
|
-
|
9
|
+
@configs_folder_paths.each do |configs_folder_path|
|
10
|
+
path_to_all_files = File.join(configs_folder_path, '**/*.json')
|
11
|
+
config_files = Dir.glob(path_to_all_files)
|
12
|
+
|
13
|
+
config_files.each do |config_file|
|
14
|
+
load_config_file(configs_folder_path, config_file)
|
15
|
+
end
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
@@ -20,27 +21,30 @@ module RubyPitaya
|
|
20
21
|
end
|
21
22
|
|
22
23
|
def [](key)
|
23
|
-
|
24
|
+
split_key = key.split('/')
|
25
|
+
@config.dig(*split_key)
|
24
26
|
end
|
25
27
|
|
26
28
|
def auto_reload
|
27
29
|
require 'listen'
|
28
30
|
|
29
|
-
@
|
30
|
-
|
31
|
-
|
32
|
-
|
31
|
+
@configs_folder_paths.each do |configs_folder_path|
|
32
|
+
config_files_listener = Listen.to(configs_folder_path, only: /\.json$/) do |modified, added, removed|
|
33
|
+
import_added_files(configs_folder_path, added)
|
34
|
+
reload_modified_files(configs_folder_path, modified)
|
35
|
+
end
|
33
36
|
|
34
|
-
|
37
|
+
config_files_listener.start
|
38
|
+
end
|
35
39
|
end
|
36
40
|
|
37
41
|
private
|
38
42
|
|
39
|
-
def load_config_file(file_path)
|
43
|
+
def load_config_file(configs_folder_path, file_path)
|
40
44
|
config_text = File.open(file_path, &:read)
|
41
45
|
config_hash = JSON.parse(config_text)
|
42
46
|
|
43
|
-
path_array = file_path.sub(/^#{
|
47
|
+
path_array = file_path.sub(/^#{configs_folder_path}/, '')[0..-6]
|
44
48
|
.split('/')
|
45
49
|
|
46
50
|
set_config_value(path_array, config_hash)
|
@@ -50,17 +54,17 @@ module RubyPitaya
|
|
50
54
|
puts error.backtrace
|
51
55
|
end
|
52
56
|
|
53
|
-
def import_added_files(files_path)
|
57
|
+
def import_added_files(configs_folder_path, files_path)
|
54
58
|
files_path.each do |path|
|
55
|
-
load_config_file(path)
|
59
|
+
load_config_file(configs_folder_path, path)
|
56
60
|
|
57
61
|
puts "ADDED config: #{path}"
|
58
62
|
end
|
59
63
|
end
|
60
64
|
|
61
|
-
def reload_modified_files(files_path)
|
65
|
+
def reload_modified_files(configs_folder_path, files_path)
|
62
66
|
files_path.each do |path|
|
63
|
-
load_config_file(path)
|
67
|
+
load_config_file(configs_folder_path, path)
|
64
68
|
|
65
69
|
puts "MODIFIED @config: #{path}"
|
66
70
|
end
|
File without changes
|
@@ -4,9 +4,15 @@ module RubyPitaya
|
|
4
4
|
|
5
5
|
class HandlerRouter
|
6
6
|
|
7
|
-
def initialize(
|
7
|
+
def initialize()
|
8
|
+
routes_path = Path::ROUTES_FILE_PATH
|
9
|
+
handler_folder_paths = [Path::HANDLERS_FOLDER_PATH] + Path::Plugins::HANDLERS_FOLDER_PATHS
|
10
|
+
|
8
11
|
import_routes_file(routes_path)
|
9
|
-
|
12
|
+
|
13
|
+
handler_folder_paths.each do |handler_folder_path|
|
14
|
+
import_handler_files(handler_folder_path)
|
15
|
+
end
|
10
16
|
|
11
17
|
import_routes_class
|
12
18
|
import_handler_classes
|
data/lib/rubypitaya/core/main.rb
CHANGED
@@ -62,17 +62,18 @@ module RubyPitaya
|
|
62
62
|
|
63
63
|
@session = Session.new
|
64
64
|
@postman = Postman.new(@nats_connector)
|
65
|
-
@config = Config.new(
|
65
|
+
@config = Config.new()
|
66
66
|
@config.auto_reload if @is_development_environment
|
67
67
|
|
68
68
|
@bll = InstanceHolder.new
|
69
69
|
|
70
|
-
@initializer_content = InitializerContent.new(@bll,
|
70
|
+
@initializer_content = InitializerContent.new(@bll,
|
71
|
+
@redis_connector.redis,
|
72
|
+
@config)
|
71
73
|
@initializer_broadcast = InitializerBroadcast.new
|
72
74
|
@initializer_broadcast.run(@initializer_content)
|
73
75
|
|
74
|
-
@handler_router = HandlerRouter.new(
|
75
|
-
Path::ROUTES_FILE_PATH)
|
76
|
+
@handler_router = HandlerRouter.new()
|
76
77
|
|
77
78
|
run_server
|
78
79
|
end
|
data/lib/rubypitaya/core/path.rb
CHANGED
@@ -8,8 +8,20 @@ module RubyPitaya
|
|
8
8
|
APP_FOLDER_PATH = File.join(Dir.pwd, 'app/')
|
9
9
|
HANDLERS_FOLDER_PATH = File.join(Dir.pwd, 'app/handlers/')
|
10
10
|
APP_CONFIG_FOLDER_PATH = File.join(Dir.pwd, 'app/config/')
|
11
|
-
MIGRATIONS_FOLDER_PATH = File.join(Dir.pwd, 'db/
|
11
|
+
MIGRATIONS_FOLDER_PATH = File.join(Dir.pwd, 'db/migration/')
|
12
12
|
|
13
13
|
ROUTES_FILE_PATH = File.join(Dir.pwd, 'config/routes.rb')
|
14
|
+
|
15
|
+
class Core
|
16
|
+
APP_FOLDER_PATH = File.join(__dir__, 'app/')
|
17
|
+
MIGRATIONS_FOLDER_PATH = File.join(__dir__, 'db/migration/')
|
18
|
+
end
|
19
|
+
|
20
|
+
class Plugins
|
21
|
+
APP_FOLDER_PATHS = Dir.glob(File.join(Dir.pwd, 'plugins/*/app/'))
|
22
|
+
HANDLERS_FOLDER_PATHS = Dir.glob(File.join(Dir.pwd, 'plugins/*/app/handlers'))
|
23
|
+
APP_CONFIG_FOLDER_PATHS = Dir.glob(File.join(Dir.pwd, 'plugins/*/app/config/'))
|
24
|
+
MIGRATIONS_FOLDER_PATHS = Dir.glob(File.join(Dir.pwd, 'plugins/*/db/migration'))
|
25
|
+
end
|
14
26
|
end
|
15
27
|
end
|
data/lib/rubypitaya/version.rb
CHANGED
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:
|
4
|
+
version: 2.2.2
|
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: 2020-
|
11
|
+
date: 2020-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|
@@ -204,8 +204,7 @@ files:
|
|
204
204
|
- "./lib/rubypitaya/app-template/bin/console"
|
205
205
|
- "./lib/rubypitaya/app-template/config/database.yml"
|
206
206
|
- "./lib/rubypitaya/app-template/config/routes.rb"
|
207
|
-
- "./lib/rubypitaya/app-template/db/
|
208
|
-
- "./lib/rubypitaya/app-template/db/migrate/002_create_player_migration.rb"
|
207
|
+
- "./lib/rubypitaya/app-template/db/migration/0000000002_create_player_migration.rb"
|
209
208
|
- "./lib/rubypitaya/app-template/docker-compose.yml"
|
210
209
|
- "./lib/rubypitaya/app-template/docker/dev/Dockerfile"
|
211
210
|
- "./lib/rubypitaya/app-template/docker/entrypoint.sh"
|
@@ -225,10 +224,12 @@ files:
|
|
225
224
|
- "./lib/rubypitaya/app-template/kubernetes/statefulset-nats.yaml"
|
226
225
|
- "./lib/rubypitaya/app-template/kubernetes/statefulset-postgres.yaml"
|
227
226
|
- "./lib/rubypitaya/app-template/kubernetes/statefulset-redis.yaml"
|
227
|
+
- "./lib/rubypitaya/core/app/models/user.rb"
|
228
228
|
- "./lib/rubypitaya/core/application_files_importer.rb"
|
229
229
|
- "./lib/rubypitaya/core/config.rb"
|
230
230
|
- "./lib/rubypitaya/core/database_config.rb"
|
231
231
|
- "./lib/rubypitaya/core/database_connector.rb"
|
232
|
+
- "./lib/rubypitaya/core/db/migration/0000000001_create_user_migration.rb"
|
232
233
|
- "./lib/rubypitaya/core/etcd_connector.rb"
|
233
234
|
- "./lib/rubypitaya/core/handler_base.rb"
|
234
235
|
- "./lib/rubypitaya/core/handler_router.rb"
|