rubypitaya 2.2.2 → 2.4.1
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 -9
- data/lib/rubypitaya/app-template/Gemfile.lock +2 -2
- data/lib/rubypitaya/core/application_files_importer.rb +6 -4
- data/lib/rubypitaya/core/config.rb +11 -74
- data/lib/rubypitaya/core/config_core.rb +88 -0
- data/lib/rubypitaya/core/handler_router.rb +1 -1
- data/lib/rubypitaya/core/main.rb +1 -1
- data/lib/rubypitaya/version.rb +1 -1
- metadata +16 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15a4c18905f4a79f7187e77415448088f7f1b85f67af17e0435d0bb1d7446fb6
|
4
|
+
data.tar.gz: 0af1363c965f78d0468444f068ccd5d9ae85888c5487bf7eaf0711e4f97ec8ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e08b6488c57f20bf8ef2999e5788c71a6499ac8a6693470ccbf2dda3b8a949a7326756001d74e18c195d3c473b7dea0133c4213ca859298436a18e8465466c57
|
7
|
+
data.tar.gz: a0a60168b6dd1de0fef61a67ac7bfa04b9f3a665d56620a7fe4b8718592846929cb9e31a2cb74246c271d9714a0a281d9b9bdbe93512882b47247fe9ef4478b2
|
@@ -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.4.1)
|
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.4.1)
|
89
89
|
|
90
90
|
BUNDLED WITH
|
91
91
|
1.17.2
|
@@ -5,9 +5,9 @@ module RubyPitaya
|
|
5
5
|
class ApplicationFilesImporter
|
6
6
|
|
7
7
|
def import
|
8
|
-
|
8
|
+
app_folder_paths = Path::Plugins::APP_FOLDER_PATHS + [Path::Core::APP_FOLDER_PATH, Path::APP_FOLDER_PATH]
|
9
9
|
|
10
|
-
|
10
|
+
app_folder_paths.each do |app_folder_path|
|
11
11
|
app_files_path = "#{app_folder_path}/**/*.rb"
|
12
12
|
|
13
13
|
Gem.find_files(app_files_path).each { |path| require path }
|
@@ -17,7 +17,9 @@ module RubyPitaya
|
|
17
17
|
def auto_reload
|
18
18
|
require 'listen'
|
19
19
|
|
20
|
-
|
20
|
+
app_folder_paths = [Path::Core::APP_FOLDER_PATH, Path::APP_FOLDER_PATH]
|
21
|
+
|
22
|
+
app_files_listener = Listen.to(*app_folder_paths,
|
21
23
|
only: /\.rb$/,
|
22
24
|
force_polling: true,
|
23
25
|
latency: 0.25,
|
@@ -26,7 +28,7 @@ module RubyPitaya
|
|
26
28
|
reload_modified_files(modified)
|
27
29
|
end
|
28
30
|
|
29
|
-
|
31
|
+
app_files_listener.start
|
30
32
|
end
|
31
33
|
|
32
34
|
private
|
@@ -1,88 +1,25 @@
|
|
1
|
+
require 'rubypitaya/core/config_core'
|
2
|
+
|
1
3
|
module RubyPitaya
|
2
4
|
|
3
5
|
class Config
|
4
6
|
|
5
|
-
|
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
|
7
|
+
attr_writer :config_core_override
|
18
8
|
|
19
|
-
def
|
20
|
-
@
|
9
|
+
def initialize
|
10
|
+
@config_core = ConfigCore.new
|
11
|
+
@config_core_override = nil
|
21
12
|
end
|
22
13
|
|
23
14
|
def [](key)
|
24
|
-
|
25
|
-
@
|
15
|
+
result = @config_core_override[key] unless @config_core_override.nil?
|
16
|
+
result = @config_core[key] if result.nil?
|
17
|
+
result
|
26
18
|
end
|
27
19
|
|
28
20
|
def auto_reload
|
29
|
-
|
30
|
-
|
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
|
36
|
-
|
37
|
-
config_files_listener.start
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
private
|
42
|
-
|
43
|
-
def load_config_file(configs_folder_path, file_path)
|
44
|
-
config_text = File.open(file_path, &:read)
|
45
|
-
config_hash = JSON.parse(config_text)
|
46
|
-
|
47
|
-
path_array = file_path.sub(/^#{configs_folder_path}/, '')[0..-6]
|
48
|
-
.split('/')
|
49
|
-
|
50
|
-
set_config_value(path_array, config_hash)
|
51
|
-
|
52
|
-
rescue Exception => error
|
53
|
-
puts "ERROR: #{error}"
|
54
|
-
puts error.backtrace
|
55
|
-
end
|
56
|
-
|
57
|
-
def import_added_files(configs_folder_path, files_path)
|
58
|
-
files_path.each do |path|
|
59
|
-
load_config_file(configs_folder_path, path)
|
60
|
-
|
61
|
-
puts "ADDED config: #{path}"
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def reload_modified_files(configs_folder_path, files_path)
|
66
|
-
files_path.each do |path|
|
67
|
-
load_config_file(configs_folder_path, path)
|
68
|
-
|
69
|
-
puts "MODIFIED @config: #{path}"
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def set_config_value(keys, value)
|
74
|
-
config = @config
|
75
|
-
|
76
|
-
keys.each_with_index do |key, index|
|
77
|
-
is_last_index = index == keys.size - 1
|
78
|
-
|
79
|
-
if is_last_index
|
80
|
-
config[key] = value
|
81
|
-
else
|
82
|
-
config[key] = {} unless config.key?(key)
|
83
|
-
config = config[key]
|
84
|
-
end
|
85
|
-
end
|
21
|
+
@config_core.auto_reload
|
22
|
+
@config_core_override.auto_reload unless @config_core_override.nil?
|
86
23
|
end
|
87
24
|
end
|
88
25
|
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
module RubyPitaya
|
2
|
+
|
3
|
+
class ConfigCore
|
4
|
+
|
5
|
+
def initialize()
|
6
|
+
@config = {}
|
7
|
+
configs_folder_paths = Path::Plugins::APP_CONFIG_FOLDER_PATHS + [Path::APP_CONFIG_FOLDER_PATH]
|
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_path = Path::APP_CONFIG_FOLDER_PATH
|
28
|
+
|
29
|
+
config_files_listener = Listen.to(configs_folder_path,
|
30
|
+
only: /\.json$/,
|
31
|
+
force_polling: true,
|
32
|
+
latency: 0.25,
|
33
|
+
wait_for_delay: 0.1) do |modified, added, removed|
|
34
|
+
import_added_files(configs_folder_path, added)
|
35
|
+
reload_modified_files(configs_folder_path, modified)
|
36
|
+
end
|
37
|
+
|
38
|
+
config_files_listener.start
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def load_config_file(configs_folder_path, file_path)
|
44
|
+
config_text = File.open(file_path, &:read)
|
45
|
+
config_hash = JSON.parse(config_text)
|
46
|
+
|
47
|
+
path_array = file_path.sub(/^#{configs_folder_path}/, '')[0..-6]
|
48
|
+
.split('/')
|
49
|
+
|
50
|
+
set_config_value(path_array, config_hash)
|
51
|
+
|
52
|
+
rescue Exception => error
|
53
|
+
puts "ERROR: #{error}"
|
54
|
+
puts error.backtrace
|
55
|
+
end
|
56
|
+
|
57
|
+
def import_added_files(configs_folder_path, files_path)
|
58
|
+
files_path.each do |path|
|
59
|
+
load_config_file(configs_folder_path, path)
|
60
|
+
|
61
|
+
puts "ADDED config: #{path}"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def reload_modified_files(configs_folder_path, files_path)
|
66
|
+
files_path.each do |path|
|
67
|
+
load_config_file(configs_folder_path, path)
|
68
|
+
|
69
|
+
puts "MODIFIED @config: #{path}"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def set_config_value(keys, value)
|
74
|
+
config = @config
|
75
|
+
|
76
|
+
keys.each_with_index do |key, index|
|
77
|
+
is_last_index = index == keys.size - 1
|
78
|
+
|
79
|
+
if is_last_index
|
80
|
+
config[key] = value
|
81
|
+
else
|
82
|
+
config[key] = {} unless config.key?(key)
|
83
|
+
config = config[key]
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -6,7 +6,7 @@ module RubyPitaya
|
|
6
6
|
|
7
7
|
def initialize()
|
8
8
|
routes_path = Path::ROUTES_FILE_PATH
|
9
|
-
handler_folder_paths =
|
9
|
+
handler_folder_paths = Path::Plugins::HANDLERS_FOLDER_PATHS + [Path::HANDLERS_FOLDER_PATH]
|
10
10
|
|
11
11
|
import_routes_file(routes_path)
|
12
12
|
|
data/lib/rubypitaya/core/main.rb
CHANGED
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.4.1
|
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-10
|
11
|
+
date: 2020-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|
@@ -25,19 +25,19 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.21.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: '10.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: '10.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: nats
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,47 +109,47 @@ dependencies:
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 6.0.2
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: eventmachine
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - '='
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
118
|
-
type: :
|
117
|
+
version: 1.2.7
|
118
|
+
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - '='
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
124
|
+
version: 1.2.7
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
126
|
+
name: pry
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - '='
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
131
|
+
version: 0.12.2
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - '='
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
138
|
+
version: 0.12.2
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
140
|
+
name: bundler
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
143
|
- - '='
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version:
|
145
|
+
version: 1.17.2
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - '='
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version:
|
152
|
+
version: 1.17.2
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: rspec
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -227,6 +227,7 @@ files:
|
|
227
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"
|
232
233
|
- "./lib/rubypitaya/core/db/migration/0000000001_create_user_migration.rb"
|