rubypitaya 1.1.0 → 1.2.7

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: 573d0dce81f6383ae631e5bcde6676f45d516ce7a38b51eefa4ebd922d229e4e
4
- data.tar.gz: 1b163c885db0a3a532edfd21d07cd9058f7003f2ad44dd40e90429f1311c337e
3
+ metadata.gz: 01e78050058f7e00777d3d9f168855354b46796eec352f1df99bc27e7c16af3d
4
+ data.tar.gz: 7d875078ea6c1935a86ad06ca1e737ebdf2b1b7da14a8cc972d8e4d81c641542
5
5
  SHA512:
6
- metadata.gz: b5a39ccf4533c32c285c1e31f0db14131c3a255639693e4c343b4d2f8cd2fda9f4be5d000c7b68a0a7b78fbb9a80d32e26a23792a3e88dbaab27efefd7ceb55c
7
- data.tar.gz: bc1c57916f513bac17a22e8b3ad720d725d93fd9369111b6bcb0fd18175063c7a69e84e90cf1aaab474ad215c0658102c10c7355ce075783fa85c53302e98035
6
+ metadata.gz: 816cc0dc23754b0624a9cba1dd450986b6d1e5570c44995c03779a91fd3118f17c4cc6104b2fbbc3660bb43bdf1695922acc73625c450335bf9bfc2aa263ca7d
7
+ data.tar.gz: 3c2124c65a0c24e1c1bb3eebd4fd080b62f4938df37d161051df34522905087c42126d4bc764c3a4bb5bc79816035225241c316396cb0e90fdda469a03ff88e6
@@ -0,0 +1,166 @@
1
+ ### GEM ###
2
+ /.bundle/
3
+ /.yardoc
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
13
+
14
+ ### History ###
15
+ .irb-history
16
+ .bash-history
17
+
18
+ ### Rider ###
19
+ # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
20
+ # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
21
+
22
+ # User-specific stuff
23
+ .idea/**/workspace.xml
24
+ .idea/**/tasks.xml
25
+ .idea/**/usage.statistics.xml
26
+ .idea/**/dictionaries
27
+ .idea/**/shelf
28
+
29
+ # Generated files
30
+ .idea/**/contentModel.xml
31
+
32
+ # Sensitive or high-churn files
33
+ .idea/**/dataSources/
34
+ .idea/**/dataSources.ids
35
+ .idea/**/dataSources.local.xml
36
+ .idea/**/sqlDataSources.xml
37
+ .idea/**/dynamic.xml
38
+ .idea/**/uiDesigner.xml
39
+ .idea/**/dbnavigator.xml
40
+
41
+ # Gradle
42
+ .idea/**/gradle.xml
43
+ .idea/**/libraries
44
+
45
+ # Gradle and Maven with auto-import
46
+ # When using Gradle or Maven with auto-import, you should exclude module files,
47
+ # since they will be recreated, and may cause churn. Uncomment if using
48
+ # auto-import.
49
+ # .idea/modules.xml
50
+ # .idea/*.iml
51
+ # .idea/modules
52
+
53
+ # CMake
54
+ cmake-build-*/
55
+
56
+ # Mongo Explorer plugin
57
+ .idea/**/mongoSettings.xml
58
+
59
+ # File-based project format
60
+ *.iws
61
+
62
+ # IntelliJ
63
+ out/
64
+
65
+ # mpeltonen/sbt-idea plugin
66
+ .idea_modules/
67
+
68
+ # JIRA plugin
69
+ atlassian-ide-plugin.xml
70
+
71
+ # Cursive Clojure plugin
72
+ .idea/replstate.xml
73
+
74
+ # Crashlytics plugin (for Android Studio and IntelliJ)
75
+ com_crashlytics_export_strings.xml
76
+ crashlytics.properties
77
+ crashlytics-build.properties
78
+ fabric.properties
79
+
80
+ # Editor-based Rest Client
81
+ .idea/httpRequests
82
+
83
+ # Android studio 3.1+ serialized cache file
84
+ .idea/caches/build_file_checksums.ser
85
+
86
+ ### Ruby ###
87
+ *.gem
88
+ *.rbc
89
+ /.config
90
+ /coverage/
91
+ /InstalledFiles
92
+ /pkg/
93
+ /spec/reports/
94
+ /spec/examples.txt
95
+ /test/tmp/
96
+ /test/version_tmp/
97
+ /tmp/
98
+
99
+ # Used by dotenv library to load environment variables.
100
+ # .env
101
+
102
+ ## Specific to RubyMotion:
103
+ .dat*
104
+ .repl_history
105
+ build/
106
+ *.bridgesupport
107
+ build-iPhoneOS/
108
+ build-iPhoneSimulator/
109
+
110
+ ## Specific to RubyMotion (use of CocoaPods):
111
+ #
112
+ # We recommend against adding the Pods directory to your .gitignore. However
113
+ # you should judge for yourself, the pros and cons are mentioned at:
114
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
115
+ #
116
+ # vendor/Pods/
117
+
118
+ ## Documentation cache and generated files:
119
+ /.yardoc/
120
+ /_yardoc/
121
+ /doc/
122
+ /rdoc/
123
+
124
+ ## Environment normalization:
125
+ /.bundle/
126
+ /vendor/bundle
127
+ /lib/bundler/man/
128
+
129
+ # for a library or gem, you might want to ignore these files since the code is
130
+ # intended to run in multiple environments; otherwise, check them in:
131
+ # Gemfile.lock
132
+ # .ruby-version
133
+ # .ruby-gemset
134
+
135
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
136
+ .rvmrc
137
+
138
+ ### Vim ###
139
+ # Swap
140
+ [._]*.s[a-v][a-z]
141
+ [._]*.sw[a-p]
142
+ [._]s[a-rt-v][a-z]
143
+ [._]ss[a-gi-z]
144
+ [._]sw[a-p]
145
+
146
+ # Session
147
+ Session.vim
148
+
149
+ # Temporary
150
+ .netrwhist
151
+ *~
152
+ # Auto-generated tag files
153
+ tags
154
+ # Persistent undo
155
+ [._]*.un~
156
+
157
+ ### VisualStudioCode ###
158
+ .vscode/*
159
+ !.vscode/settings.json
160
+ !.vscode/tasks.json
161
+ !.vscode/launch.json
162
+ !.vscode/extensions.json
163
+
164
+ ### VisualStudioCode Patch ###
165
+ # Ignore all local history of files
166
+ .history
@@ -0,0 +1,10 @@
1
+ require 'irb/completion'
2
+ require 'irb/ext/save-history'
3
+ IRB.conf[:SAVE_HISTORY] = 2000
4
+ IRB.conf[:HISTORY_FILE] = '/app/rubypitaya/.irb-history'
5
+ IRB.conf[:AUTO_INDENT] = true
6
+ IRB.conf[:USE_READLINE] = true
7
+ IRB.conf[:LOAD_MODULES] = [] unless IRB.conf.key?(:LOAD_MODULES)
8
+ unless IRB.conf[:LOAD_MODULES].include?('irb/completion')
9
+ IRB.conf[:LOAD_MODULES] << 'irb/completion'
10
+ end
@@ -1,10 +1,11 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem 'rubypitaya', '1.1.0'
3
+ gem 'rubypitaya', '1.2.7'
4
4
 
5
5
  group :development do
6
6
  gem 'pry', '0.12.2'
7
7
  gem 'bundler', '1.17.2'
8
8
  gem 'rake', '10.0'
9
9
  gem 'rspec', '3.8.0'
10
+ gem 'listen', '3.2.1'
10
11
  end
@@ -18,14 +18,18 @@ GEM
18
18
  etcdv3 (0.10.2)
19
19
  grpc (~> 1.17)
20
20
  eventmachine (1.2.7)
21
- google-protobuf (3.11.4)
21
+ ffi (1.12.2)
22
+ google-protobuf (3.11.4-x86_64-linux)
22
23
  googleapis-common-protos-types (1.0.5)
23
24
  google-protobuf (~> 3.11)
24
- grpc (1.28.0)
25
+ grpc (1.28.0-x86_64-linux)
25
26
  google-protobuf (~> 3.11)
26
27
  googleapis-common-protos-types (~> 1.0)
27
28
  i18n (1.8.2)
28
29
  concurrent-ruby (~> 1.0)
30
+ listen (3.2.1)
31
+ rb-fsevent (~> 0.10, >= 0.10.3)
32
+ rb-inotify (~> 0.9, >= 0.9.10)
29
33
  method_source (0.9.2)
30
34
  middleware (0.1.0)
31
35
  minitest (5.14.0)
@@ -41,6 +45,9 @@ GEM
41
45
  coderay (~> 1.1.0)
42
46
  method_source (~> 0.9.0)
43
47
  rake (10.0.0)
48
+ rb-fsevent (0.10.3)
49
+ rb-inotify (0.10.1)
50
+ ffi (~> 1.0)
44
51
  redis (4.1.3)
45
52
  rspec (3.8.0)
46
53
  rspec-core (~> 3.8.0)
@@ -55,7 +62,7 @@ GEM
55
62
  diff-lcs (>= 1.2.0, < 2.0)
56
63
  rspec-support (~> 3.8.0)
57
64
  rspec-support (3.8.3)
58
- rubypitaya (1.1.0)
65
+ rubypitaya (1.2.7)
59
66
  activerecord (= 6.0.2)
60
67
  etcdv3 (= 0.10.2)
61
68
  eventmachine (= 1.2.7)
@@ -74,10 +81,11 @@ PLATFORMS
74
81
 
75
82
  DEPENDENCIES
76
83
  bundler (= 1.17.2)
84
+ listen (= 3.2.1)
77
85
  pry (= 0.12.2)
78
86
  rake (= 10.0)
79
87
  rspec (= 3.8.0)
80
- rubypitaya (= 1.0.6)
88
+ rubypitaya (= 1.2.7)
81
89
 
82
90
  BUNDLED WITH
83
91
  1.17.2
@@ -44,7 +44,7 @@ generate-gemfilelock:
44
44
 
45
45
  ## Build image to production environment
46
46
  prod-build-image:
47
- @docker build . -f docker/prod/Dockerfile -t registry.gitlab.com/lucianopc/ruby-pitaya-app:latest
47
+ @docker build . -f docker/prod/Dockerfile -t rubypitaya-prod:latest
48
48
 
49
49
  .DEFAULT_GOAL := show-help
50
50
 
@@ -4,7 +4,7 @@ WORKDIR /app/rubypitaya/
4
4
 
5
5
  COPY Gemfile Gemfile.lock ./
6
6
 
7
- RUN bundle install
7
+ RUN bundle install --without development
8
8
 
9
9
  COPY . .
10
10
 
@@ -9,5 +9,42 @@ module RubyPitaya
9
9
 
10
10
  Gem.find_files(app_files_path).each { |path| require path }
11
11
  end
12
+
13
+ def auto_reload
14
+ require 'listen'
15
+
16
+ @app_files_listener = Listen.to(Path::APP_FOLDER_PATH, only: /\.rb$/) do |modified, added, removed|
17
+ import_added_files(added)
18
+ reload_modified_files(modified)
19
+ end
20
+
21
+ @app_files_listener.start
22
+ end
23
+
24
+ private
25
+
26
+ def import_added_files(files_path)
27
+ Gem.find_files(files_path).each do |path|
28
+ require path
29
+
30
+ puts "ADDED ruby file: #{path}"
31
+ end
32
+
33
+ rescue Exception => error
34
+ puts "ERROR: #{error}"
35
+ puts error.backtrace
36
+ end
37
+
38
+ def reload_modified_files(files_path)
39
+ files_path.each do |path|
40
+ load(path)
41
+
42
+ puts "MODIFIED ruby file: #{path}"
43
+ end
44
+
45
+ rescue Exception => error
46
+ puts "ERROR: #{error}"
47
+ puts error.backtrace
48
+ end
12
49
  end
13
- end
50
+ end
@@ -3,23 +3,16 @@ module RubyPitaya
3
3
  class Config
4
4
 
5
5
  def initialize(configs_folder_path)
6
- path_to_all_files = File.join(configs_folder_path, '**/*.json')
6
+ @configs_folder_path = configs_folder_path
7
+
8
+ path_to_all_files = File.join(@configs_folder_path, '**/*.json')
7
9
  config_files = Dir.glob(path_to_all_files)
8
10
 
9
- config_hashes = []
11
+ @config = {}
10
12
 
11
13
  config_files.each do |config_file|
12
- config_text = File.open(config_file, &:read)
13
- config_readed = JSON.parse(config_text)
14
-
15
- path_array = config_file.sub(/^#{configs_folder_path}/, '')[0..-6]
16
- .split('/')
17
- config_hash = path_array.reverse.inject(config_readed) {|a, b| {b => a}}
18
-
19
- config_hashes << config_hash
14
+ load_config_file(config_file)
20
15
  end
21
-
22
- @config = config_hashes.inject(&:deep_merge)
23
16
  end
24
17
 
25
18
  def get
@@ -29,5 +22,63 @@ module RubyPitaya
29
22
  def [](key)
30
23
  @config[key]
31
24
  end
25
+
26
+ def auto_reload
27
+ require 'listen'
28
+
29
+ @config_files_listener = Listen.to(@configs_folder_path, only: /\.json$/) do |modified, added, removed|
30
+ import_added_files(added)
31
+ reload_modified_files(modified)
32
+ end
33
+
34
+ @config_files_listener.start
35
+ end
36
+
37
+ private
38
+
39
+ def load_config_file(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(files_path)
54
+ files_path.each do |path|
55
+ load_config_file(path)
56
+
57
+ puts "ADDED config: #{path}"
58
+ end
59
+ end
60
+
61
+ def reload_modified_files(files_path)
62
+ files_path.each do |path|
63
+ load_config_file(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] = {}
79
+ config = config[key]
80
+ end
81
+ end
82
+ end
32
83
  end
33
84
  end
@@ -26,8 +26,12 @@ module RubyPitaya
26
26
 
27
27
  private
28
28
  def initialize
29
+ @environment_name = ENV.fetch("RUBYPITAYA_ENV") { 'development' }
30
+ @is_development_environment = @environment_name == 'development'
31
+
29
32
  @application_files_importer = ApplicationFilesImporter.new
30
33
  @application_files_importer.import
34
+ @application_files_importer.auto_reload if @is_development_environment
31
35
 
32
36
  @server_name = ENV['SERVER_NAME']
33
37
  @service_uuid = SecureRandom.uuid
@@ -49,7 +53,6 @@ module RubyPitaya
49
53
  @redis_connector = RedisConnector.new(@redis_address)
50
54
  @redis_connector.connect
51
55
 
52
- @environment_name = ENV.fetch("RUBYPITAYA_ENV") { 'development' }
53
56
  @database_config = DatabaseConfig.new(@environment_name, Path::DATABASE_CONFIG_PATH)
54
57
  @database_connector = DatabaseConnector.new(@database_config)
55
58
  @database_connector.connect
@@ -57,6 +60,7 @@ module RubyPitaya
57
60
  @session = Session.new
58
61
  @postman = Postman.new(@nats_connector)
59
62
  @config = Config.new(Path::APP_CONFIG_FOLDER_PATH)
63
+ @config.auto_reload if @is_development_environment
60
64
 
61
65
  @bll = InstanceHolder.new
62
66
 
@@ -1,4 +1,4 @@
1
1
  module RubyPitaya
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.7"
3
3
  end
4
4
 
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: 1.1.0
4
+ version: 1.2.7
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-04-26 00:00:00.000000000 Z
11
+ date: 2020-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -164,6 +164,20 @@ dependencies:
164
164
  - - '='
165
165
  - !ruby/object:Gem::Version
166
166
  version: 3.8.0
167
+ - !ruby/object:Gem::Dependency
168
+ name: listen
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - '='
172
+ - !ruby/object:Gem::Version
173
+ version: 3.2.1
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - '='
179
+ - !ruby/object:Gem::Version
180
+ version: 3.2.1
167
181
  description: RubyPitaya is an application to create servers using the pitaya protocol.
168
182
  email:
169
183
  - lucianopcbr@gmail.com
@@ -173,6 +187,8 @@ extensions: []
173
187
  extra_rdoc_files: []
174
188
  files:
175
189
  - "./lib/rubypitaya.rb"
190
+ - "./lib/rubypitaya/app-template/.gitignore"
191
+ - "./lib/rubypitaya/app-template/.irbrc"
176
192
  - "./lib/rubypitaya/app-template/Gemfile"
177
193
  - "./lib/rubypitaya/app-template/Gemfile.lock"
178
194
  - "./lib/rubypitaya/app-template/Makefile"