rubypitaya 2.0.0 → 2.3.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/Rakefile +2 -1
- 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/migration/{002_create_player_migration.rb → 0000000002_create_player_migration.rb} +0 -0
- data/lib/rubypitaya/core/app/models/user.rb +4 -0
- data/lib/rubypitaya/core/application_files_importer.rb +10 -8
- data/lib/rubypitaya/core/config.rb +9 -74
- data/lib/rubypitaya/core/config_core.rb +84 -0
- data/lib/rubypitaya/{app-template/db/migration/001_create_user_migration.rb → core/db/migration/0000000001_create_user_migration.rb} +0 -0
- data/lib/rubypitaya/core/initializer_content.rb +3 -2
- data/lib/rubypitaya/core/main.rb +4 -2
- data/lib/rubypitaya/core/path.rb +4 -0
- data/lib/rubypitaya/version.rb +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56eed6ff93a6e6e8bc76351c3c4d06584fcc247888ef05783040cc96dc2966e6
|
4
|
+
data.tar.gz: 408c3f0226b7c42604fe416362e4bac3d333f72e313f59a2da646c527eec568c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6c3ad1a9c338076f5dcee3000016b41f157f843b921015aa30eb6fcad6da0e6a49265ee39f9dc382dd8840e9e74ba71934a6aea70e8f00490aaef7e15c8a0fe
|
7
|
+
data.tar.gz: 71060870925f98450a9e17326ece14500bd0ff095399b50e33df9dec360fb105321e9fa33bb2b64f17d989d8588584ed983d0d660349cf1ad473cd5221df0b42
|
@@ -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 (2.
|
65
|
+
rubypitaya (2.3.0)
|
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 (= 2.
|
88
|
+
rubypitaya (= 2.2.2)
|
89
89
|
|
90
90
|
BUNDLED WITH
|
91
91
|
1.17.2
|
@@ -24,8 +24,9 @@ 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
|
-
migrations_paths = [RubyPitaya::Path::MIGRATIONS_FOLDER_PATH]
|
27
|
+
migrations_paths = [RubyPitaya::Path::Core::MIGRATIONS_FOLDER_PATH]
|
28
28
|
migrations_paths += RubyPitaya::Path::Plugins::MIGRATIONS_FOLDER_PATHS
|
29
|
+
migrations_paths += [RubyPitaya::Path::MIGRATIONS_FOLDER_PATH]
|
29
30
|
|
30
31
|
ActiveRecord::Base.establish_connection(connection_data)
|
31
32
|
ActiveRecord::Migrator.migrations_paths = migrations_paths
|
@@ -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,7 +5,7 @@ module RubyPitaya
|
|
5
5
|
class ApplicationFilesImporter
|
6
6
|
|
7
7
|
def import
|
8
|
-
@app_folder_paths = [Path::APP_FOLDER_PATH] + Path::Plugins::APP_FOLDER_PATHS
|
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
11
|
app_files_path = "#{app_folder_path}/**/*.rb"
|
@@ -17,14 +17,16 @@ module RubyPitaya
|
|
17
17
|
def auto_reload
|
18
18
|
require 'listen'
|
19
19
|
|
20
|
-
@
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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|
|
25
|
+
import_added_files(added)
|
26
|
+
reload_modified_files(modified)
|
27
27
|
end
|
28
|
+
|
29
|
+
@app_files_listener.start
|
28
30
|
end
|
29
31
|
|
30
32
|
private
|
@@ -1,87 +1,22 @@
|
|
1
|
+
require 'rubypitaya/core/config_core'
|
2
|
+
|
1
3
|
module RubyPitaya
|
2
4
|
|
3
5
|
class Config
|
4
6
|
|
5
|
-
def initialize
|
6
|
-
@
|
7
|
-
@
|
8
|
-
|
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
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def get
|
20
|
-
@config
|
7
|
+
def initialize
|
8
|
+
@config_core = ConfigCore.new
|
9
|
+
@config_core_override = nil
|
21
10
|
end
|
22
11
|
|
23
12
|
def [](key)
|
24
|
-
@
|
13
|
+
result = @config_core_override[key] unless @config_core_override.nil?
|
14
|
+
result = @config_core[key] if result.nil?
|
25
15
|
end
|
26
16
|
|
27
17
|
def auto_reload
|
28
|
-
|
29
|
-
|
30
|
-
@configs_folder_paths.each do |configs_folder_path|
|
31
|
-
config_files_listener = Listen.to(configs_folder_path, only: /\.json$/) do |modified, added, removed|
|
32
|
-
import_added_files(configs_folder_path, added)
|
33
|
-
reload_modified_files(configs_folder_path, modified)
|
34
|
-
end
|
35
|
-
|
36
|
-
config_files_listener.start
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
private
|
41
|
-
|
42
|
-
def load_config_file(configs_folder_path, file_path)
|
43
|
-
config_text = File.open(file_path, &:read)
|
44
|
-
config_hash = JSON.parse(config_text)
|
45
|
-
|
46
|
-
path_array = file_path.sub(/^#{configs_folder_path}/, '')[0..-6]
|
47
|
-
.split('/')
|
48
|
-
|
49
|
-
set_config_value(path_array, config_hash)
|
50
|
-
|
51
|
-
rescue Exception => error
|
52
|
-
puts "ERROR: #{error}"
|
53
|
-
puts error.backtrace
|
54
|
-
end
|
55
|
-
|
56
|
-
def import_added_files(configs_folder_path, files_path)
|
57
|
-
files_path.each do |path|
|
58
|
-
load_config_file(configs_folder_path, path)
|
59
|
-
|
60
|
-
puts "ADDED config: #{path}"
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def reload_modified_files(configs_folder_path, files_path)
|
65
|
-
files_path.each do |path|
|
66
|
-
load_config_file(configs_folder_path, path)
|
67
|
-
|
68
|
-
puts "MODIFIED @config: #{path}"
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def set_config_value(keys, value)
|
73
|
-
config = @config
|
74
|
-
|
75
|
-
keys.each_with_index do |key, index|
|
76
|
-
is_last_index = index == keys.size - 1
|
77
|
-
|
78
|
-
if is_last_index
|
79
|
-
config[key] = value
|
80
|
-
else
|
81
|
-
config[key] = {} unless config.key?(key)
|
82
|
-
config = config[key]
|
83
|
-
end
|
84
|
-
end
|
18
|
+
@config_core.auto_reload
|
19
|
+
@config_core_override.auto_reload unless @config_core_override.nil?
|
85
20
|
end
|
86
21
|
end
|
87
22
|
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
module RubyPitaya
|
2
|
+
|
3
|
+
class ConfigCore
|
4
|
+
|
5
|
+
def initialize()
|
6
|
+
@config = {}
|
7
|
+
@configs_folder_paths = [Path::APP_CONFIG_FOLDER_PATH] + Path::Plugins::APP_CONFIG_FOLDER_PATHS
|
8
|
+
|
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
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def [](key)
|
20
|
+
split_key = key.split('/')
|
21
|
+
@config.dig(*split_key)
|
22
|
+
end
|
23
|
+
|
24
|
+
def auto_reload
|
25
|
+
require 'listen'
|
26
|
+
|
27
|
+
@configs_folder_paths.each do |configs_folder_path|
|
28
|
+
config_files_listener = Listen.to(configs_folder_path, only: /\.json$/) do |modified, added, removed|
|
29
|
+
import_added_files(configs_folder_path, added)
|
30
|
+
reload_modified_files(configs_folder_path, modified)
|
31
|
+
end
|
32
|
+
|
33
|
+
config_files_listener.start
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def load_config_file(configs_folder_path, file_path)
|
40
|
+
config_text = File.open(file_path, &:read)
|
41
|
+
config_hash = JSON.parse(config_text)
|
42
|
+
|
43
|
+
path_array = file_path.sub(/^#{configs_folder_path}/, '')[0..-6]
|
44
|
+
.split('/')
|
45
|
+
|
46
|
+
set_config_value(path_array, config_hash)
|
47
|
+
|
48
|
+
rescue Exception => error
|
49
|
+
puts "ERROR: #{error}"
|
50
|
+
puts error.backtrace
|
51
|
+
end
|
52
|
+
|
53
|
+
def import_added_files(configs_folder_path, files_path)
|
54
|
+
files_path.each do |path|
|
55
|
+
load_config_file(configs_folder_path, path)
|
56
|
+
|
57
|
+
puts "ADDED config: #{path}"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def reload_modified_files(configs_folder_path, files_path)
|
62
|
+
files_path.each do |path|
|
63
|
+
load_config_file(configs_folder_path, path)
|
64
|
+
|
65
|
+
puts "MODIFIED @config: #{path}"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def set_config_value(keys, value)
|
70
|
+
config = @config
|
71
|
+
|
72
|
+
keys.each_with_index do |key, index|
|
73
|
+
is_last_index = index == keys.size - 1
|
74
|
+
|
75
|
+
if is_last_index
|
76
|
+
config[key] = value
|
77
|
+
else
|
78
|
+
config[key] = {} unless config.key?(key)
|
79
|
+
config = config[key]
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
File without changes
|
data/lib/rubypitaya/core/main.rb
CHANGED
@@ -62,12 +62,14 @@ 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
|
|
data/lib/rubypitaya/core/path.rb
CHANGED
@@ -12,6 +12,10 @@ module RubyPitaya
|
|
12
12
|
|
13
13
|
ROUTES_FILE_PATH = File.join(Dir.pwd, 'config/routes.rb')
|
14
14
|
|
15
|
+
class Core
|
16
|
+
APP_FOLDER_PATH = File.join(__dir__, 'app/')
|
17
|
+
MIGRATIONS_FOLDER_PATH = File.join(__dir__, 'db/migration/')
|
18
|
+
end
|
15
19
|
|
16
20
|
class Plugins
|
17
21
|
APP_FOLDER_PATHS = Dir.glob(File.join(Dir.pwd, 'plugins/*/app/'))
|
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: 2.
|
4
|
+
version: 2.3.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: 2020-
|
11
|
+
date: 2020-11-02 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/migration/
|
208
|
-
- "./lib/rubypitaya/app-template/db/migration/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,13 @@ 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
|
+
- "./lib/rubypitaya/core/config_core.rb"
|
230
231
|
- "./lib/rubypitaya/core/database_config.rb"
|
231
232
|
- "./lib/rubypitaya/core/database_connector.rb"
|
233
|
+
- "./lib/rubypitaya/core/db/migration/0000000001_create_user_migration.rb"
|
232
234
|
- "./lib/rubypitaya/core/etcd_connector.rb"
|
233
235
|
- "./lib/rubypitaya/core/handler_base.rb"
|
234
236
|
- "./lib/rubypitaya/core/handler_router.rb"
|