rubypitaya 2.2.1 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f281a68ed8014d040980a1e38c395a06e01a2f6e0baa299ae31e721b96e38110
4
- data.tar.gz: 5f4d111862aeb5ca039600fc7e89c371e7bc974fcbe36ce925d67185b4f6a341
3
+ metadata.gz: '093a7c67062ae87c5335220458fd7c8c1a1b97591a8f6ef87121c07aa544eb4d'
4
+ data.tar.gz: c0ab2dcd4a08ecda141a8d6ddfa646bb2e01dfb8648ddf78ac64a167a3f4593b
5
5
  SHA512:
6
- metadata.gz: 9fbedb2b7e8671ebeb45abb4f59cb4555541293bb345d72a224b8f7e0b8dbb80f01ccc99d73be01859ea12c6be0a172ca998275f500fe33d81c1d351b481481e
7
- data.tar.gz: 9abcf3ed56d184a29b673e03606a08b29c05344a07636797492aca84882bb66b690ba1e727f47eb21b703a1e2b1438c2d8f7f4867f456e29eea03167faeba86a
6
+ metadata.gz: af597a9e1481be99c5a93c42ffc3e12629d486acbd931b46e1c2c037f7f8806e1191e28e7669835622bb98d2940e5a00a889a51391bbc3502fff7ed7dacace9f
7
+ data.tar.gz: e3be1ef084dce3f1bd9cc77a4c4cab1b51f3d682329e7edbda3736487d3ebbf20d253336767eb97f62a11a191d3add2ba30d85a11669b5c28b9ef25cf2cbf91e
@@ -1,11 +1,3 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem 'rubypitaya', '2.2.1'
4
-
5
- group :development do
6
- gem 'pry', '0.12.2'
7
- gem 'bundler', '1.17.2'
8
- gem 'rake', '10.0'
9
- gem 'rspec', '3.8.0'
10
- gem 'listen', '3.2.1'
11
- end
3
+ gem 'rubypitaya', '2.4.0'
@@ -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.2.1)
65
+ rubypitaya (2.4.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.2.1)
88
+ rubypitaya (= 2.4.0)
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
- @app_folder_paths = [Path::Core::APP_FOLDER_PATH, Path::APP_FOLDER_PATH] + Path::Plugins::APP_FOLDER_PATHS
8
+ app_folder_paths = Path::Plugins::APP_FOLDER_PATHS + [Path::Core::APP_FOLDER_PATH, Path::APP_FOLDER_PATH]
9
9
 
10
- @app_folder_paths.each do |app_folder_path|
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,14 +17,18 @@ module RubyPitaya
17
17
  def auto_reload
18
18
  require 'listen'
19
19
 
20
- @app_folder_paths.each do |app_folder_path|
21
- @app_files_listener = Listen.to(app_folder_path, only: /\.rb$/) do |modified, added, removed|
22
- import_added_files(added)
23
- reload_modified_files(modified)
24
- end
20
+ app_folder_paths = [Path::Core::APP_FOLDER_PATH, Path::APP_FOLDER_PATH]
25
21
 
26
- @app_files_listener.start
22
+ app_files_listener = Listen.to(*app_folder_paths,
23
+ only: /\.rb$/,
24
+ force_polling: true,
25
+ latency: 0.25,
26
+ wait_for_delay: 0.1) do |modified, added, removed|
27
+ import_added_files(added)
28
+ reload_modified_files(modified)
27
29
  end
30
+
31
+ app_files_listener.start
28
32
  end
29
33
 
30
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
- 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
7
+ attr_writer :config_core_override
18
8
 
19
- def get
20
- @config
9
+ def initialize
10
+ @config_core = ConfigCore.new
11
+ @config_core_override = nil
21
12
  end
22
13
 
23
14
  def [](key)
24
- split_key = key.split('/')
25
- @config.dig(*split_key)
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
- require 'listen'
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 = [Path::HANDLERS_FOLDER_PATH] + Path::Plugins::HANDLERS_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
 
@@ -62,7 +62,7 @@ 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
@@ -1,3 +1,3 @@
1
1
  module RubyPitaya
2
- VERSION = '2.2.1'
2
+ VERSION = '2.4.0'
3
3
  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.2.1
4
+ version: 2.4.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-10-31 00:00:00.000000000 Z
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: eventmachine
28
+ name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 1.2.7
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: 1.2.7
40
+ version: '10.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: nats
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - '='
109
109
  - !ruby/object:Gem::Version
110
110
  version: 6.0.2
111
+ - !ruby/object:Gem::Dependency
112
+ name: eventmachine
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '='
116
+ - !ruby/object:Gem::Version
117
+ version: 1.2.7
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '='
123
+ - !ruby/object:Gem::Version
124
+ version: 1.2.7
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: pry
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -227,6 +241,7 @@ files:
227
241
  - "./lib/rubypitaya/core/app/models/user.rb"
228
242
  - "./lib/rubypitaya/core/application_files_importer.rb"
229
243
  - "./lib/rubypitaya/core/config.rb"
244
+ - "./lib/rubypitaya/core/config_core.rb"
230
245
  - "./lib/rubypitaya/core/database_config.rb"
231
246
  - "./lib/rubypitaya/core/database_connector.rb"
232
247
  - "./lib/rubypitaya/core/db/migration/0000000001_create_user_migration.rb"