rubypitaya 2.7.4 → 2.9.2
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 +4 -4
- data/bin/rubypitaya +48 -3
- data/lib/rubypitaya.rb +35 -0
- data/lib/rubypitaya/app-template/Gemfile +1 -1
- data/lib/rubypitaya/app-template/Gemfile.lock +7 -5
- data/lib/rubypitaya/app-template/Makefile +14 -0
- data/lib/rubypitaya/app-template/Rakefile +19 -0
- data/lib/rubypitaya/app-template/app/app_initializer.rb +10 -0
- data/lib/rubypitaya/app-template/app/models/user.rb +2 -0
- data/lib/rubypitaya/app-template/bin/console +14 -4
- data/lib/rubypitaya/app-template/docker-compose.yml +1 -0
- data/lib/rubypitaya/app-template/docker/dev/Dockerfile +1 -1
- data/lib/rubypitaya/app-template/kubernetes/deployment-rubypitaya.yaml +2 -2
- data/lib/rubypitaya/app-template/kubernetes/role-rubypitaya.yaml +1 -1
- data/lib/rubypitaya/core/handler_base.rb +2 -1
- data/lib/rubypitaya/core/handler_router.rb +2 -1
- data/lib/rubypitaya/core/initializer_base.rb +4 -0
- data/lib/rubypitaya/core/initializer_broadcast.rb +18 -0
- data/lib/rubypitaya/core/initializer_content.rb +3 -2
- data/lib/rubypitaya/core/main.rb +17 -8
- data/lib/rubypitaya/core/path.rb +3 -0
- data/lib/rubypitaya/core/templates/template_migration.rb.erb +13 -0
- data/lib/rubypitaya/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3541acfd67db95762b008eac9b1211229335e6ce7b158c0c8902a50dd80dd705
|
4
|
+
data.tar.gz: 6f3e2e1c18a52d20a2df5735a28c0566e1c222a1b7de52d9ba2208d03abcd9ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 782f21b14a1cd4e1b09accd665fc04efadace45f9ff50c2ab9773e1724f237a5b440024c21d8952a3db0e613a77cbb33ab8a6d156d28cdc4f38074fa7db40b51
|
7
|
+
data.tar.gz: 61c056e184caad45a6018c5426da5d9008e61539cd707f7c8b7b44f1f6b1e5970b08fa45bba7b481e19966fe04821110d191240157606f06564113142a3b0932
|
data/bin/rubypitaya
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'rubypitaya'
|
4
4
|
|
5
|
-
COMMANDS = ['run', 'create']
|
5
|
+
COMMANDS = ['run', 'create', 'create-migration', 'add-plugin']
|
6
6
|
|
7
7
|
def main
|
8
8
|
if ARGV.size == 0 || !COMMANDS.include?(ARGV[0])
|
@@ -19,6 +19,14 @@ def main
|
|
19
19
|
if command == 'create'
|
20
20
|
command_create(ARGV)
|
21
21
|
end
|
22
|
+
|
23
|
+
if command == 'create-migration'
|
24
|
+
command_create_migration(ARGV)
|
25
|
+
end
|
26
|
+
|
27
|
+
if command == 'add-plugin'
|
28
|
+
command_add_plugin(ARGV)
|
29
|
+
end
|
22
30
|
end
|
23
31
|
|
24
32
|
def command_run(argv)
|
@@ -40,11 +48,38 @@ def command_create(argv)
|
|
40
48
|
puts "Project #{project_name} created!"
|
41
49
|
end
|
42
50
|
|
51
|
+
def command_create_migration(argv)
|
52
|
+
if argv.size <= 1
|
53
|
+
show_help_create_migration()
|
54
|
+
exit(-1)
|
55
|
+
end
|
56
|
+
|
57
|
+
migration_name = argv[1]
|
58
|
+
|
59
|
+
migration_file_name = RubyPitaya::RubyPitaya.create_migration(migration_name)
|
60
|
+
|
61
|
+
puts "Migration #{migration_file_name} created!"
|
62
|
+
end
|
63
|
+
|
64
|
+
def command_add_plugin(argv)
|
65
|
+
if argv.size <= 1
|
66
|
+
show_help_add_plugin()
|
67
|
+
exit(-1)
|
68
|
+
end
|
69
|
+
|
70
|
+
plugin_git_link = argv[1]
|
71
|
+
|
72
|
+
plugin_name = RubyPitaya::RubyPitaya.add_plugin(plugin_git_link)
|
73
|
+
|
74
|
+
puts "Plugin #{plugin_name} added!"
|
75
|
+
end
|
76
|
+
|
43
77
|
def show_help
|
44
78
|
puts 'Usage: $ rubypitaya [COMMAND]'
|
45
79
|
puts 'COMMAND:'
|
46
|
-
puts ' run:
|
47
|
-
puts ' create:
|
80
|
+
puts ' run: - Run server'
|
81
|
+
puts ' create: - Create project'
|
82
|
+
puts ' create-migration: - Create migration'
|
48
83
|
puts ''
|
49
84
|
end
|
50
85
|
|
@@ -53,4 +88,14 @@ def show_help_create
|
|
53
88
|
puts ''
|
54
89
|
end
|
55
90
|
|
91
|
+
def show_help_create_migration
|
92
|
+
puts 'Usage: $ rubypitaya create-migration [migration_name]'
|
93
|
+
puts ''
|
94
|
+
end
|
95
|
+
|
96
|
+
def show_help_add_plugin
|
97
|
+
puts 'Usage: $ rubypitaya create-migration [migration_name]'
|
98
|
+
puts ''
|
99
|
+
end
|
100
|
+
|
56
101
|
main
|
data/lib/rubypitaya.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require 'ostruct'
|
1
3
|
require 'fileutils'
|
2
4
|
|
3
5
|
require 'rubypitaya/core/main'
|
@@ -16,5 +18,38 @@ module RubyPitaya
|
|
16
18
|
|
17
19
|
FileUtils.cp_r app_template_path, project_path
|
18
20
|
end
|
21
|
+
|
22
|
+
def self.create_migration(migration_name)
|
23
|
+
migration_name = "#{migration_name}_migration" unless migration_name.underscore.end_with?('migration')
|
24
|
+
migration_timestamp = Time.now.utc.to_i
|
25
|
+
migration_file_name = "#{migration_timestamp}_#{migration_name.underscore}.rb"
|
26
|
+
migration_class_name = migration_name.camelcase
|
27
|
+
|
28
|
+
template_struct = OpenStruct.new(
|
29
|
+
class_name: migration_class_name,
|
30
|
+
)
|
31
|
+
|
32
|
+
template = File.open(Path::MIGRATION_TEMPLATE_PATH, &:read)
|
33
|
+
template_result = ERB.new(template).result(template_struct.instance_eval { binding })
|
34
|
+
|
35
|
+
migration_file_path = File.join(Path::MIGRATIONS_FOLDER_PATH, migration_file_name)
|
36
|
+
File.open(migration_file_path, 'w') { |f| f.write(template_result) }
|
37
|
+
|
38
|
+
migration_file_name
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.add_plugin(plugin_git_link)
|
42
|
+
Dir.mkdir(Path::PLUGINS_FOLDER_PATH) unless File.exists?(Path::PLUGINS_FOLDER_PATH)
|
43
|
+
|
44
|
+
plugin_name = plugin_git_link.scan(/.+\/(.+)\.git/).flatten.first
|
45
|
+
plugin_folder_path = File.join(Path::PLUGINS_FOLDER_PATH, plugin_name)
|
46
|
+
plugin_git_path = File.join(plugin_folder_path, '.git/')
|
47
|
+
|
48
|
+
FileUtils.rm_rf(plugin_folder_path) if File.exists?(plugin_folder_path)
|
49
|
+
`git -C #{Path::PLUGINS_FOLDER_PATH} clone #{plugin_git_link}`
|
50
|
+
FileUtils.rm_rf(plugin_git_path)
|
51
|
+
|
52
|
+
plugin_name
|
53
|
+
end
|
19
54
|
end
|
20
55
|
end
|
@@ -18,11 +18,11 @@ GEM
|
|
18
18
|
etcdv3 (0.10.2)
|
19
19
|
grpc (~> 1.17)
|
20
20
|
eventmachine (1.2.7)
|
21
|
-
ffi (1.
|
21
|
+
ffi (1.14.2)
|
22
22
|
google-protobuf (3.14.0)
|
23
23
|
googleapis-common-protos-types (1.0.5)
|
24
24
|
google-protobuf (~> 3.11)
|
25
|
-
grpc (1.
|
25
|
+
grpc (1.34.0)
|
26
26
|
google-protobuf (~> 3.13)
|
27
27
|
googleapis-common-protos-types (~> 1.0)
|
28
28
|
i18n (1.8.5)
|
@@ -38,6 +38,7 @@ GEM
|
|
38
38
|
ruby2_keywords (~> 0.0.1)
|
39
39
|
nats (0.11.0)
|
40
40
|
eventmachine (~> 1.2, >= 1.2)
|
41
|
+
ostruct (0.1.0)
|
41
42
|
pg (0.21.0)
|
42
43
|
protobuf (3.10.0)
|
43
44
|
activesupport (>= 3.2)
|
@@ -69,11 +70,12 @@ GEM
|
|
69
70
|
rspec-support (~> 3.8.0)
|
70
71
|
rspec-support (3.8.3)
|
71
72
|
ruby2_keywords (0.0.2)
|
72
|
-
rubypitaya (2.
|
73
|
+
rubypitaya (2.9.2)
|
73
74
|
activerecord (= 6.0.2)
|
74
75
|
etcdv3 (= 0.10.2)
|
75
76
|
eventmachine (= 1.2.7)
|
76
77
|
nats (= 0.11.0)
|
78
|
+
ostruct (= 0.1.0)
|
77
79
|
pg (= 0.21.0)
|
78
80
|
protobuf (= 3.10.0)
|
79
81
|
rake (= 10.0)
|
@@ -94,7 +96,7 @@ GEM
|
|
94
96
|
thor (1.0.1)
|
95
97
|
thread_safe (0.3.6)
|
96
98
|
tilt (2.0.10)
|
97
|
-
tzinfo (1.2.
|
99
|
+
tzinfo (1.2.9)
|
98
100
|
thread_safe (~> 0.1)
|
99
101
|
zeitwerk (2.4.2)
|
100
102
|
|
@@ -106,7 +108,7 @@ DEPENDENCIES
|
|
106
108
|
listen (= 3.2.1)
|
107
109
|
pry (= 0.12.2)
|
108
110
|
rspec (= 3.8.0)
|
109
|
-
rubypitaya (= 2.
|
111
|
+
rubypitaya (= 2.9.2)
|
110
112
|
|
111
113
|
BUNDLED WITH
|
112
114
|
1.17.2
|
@@ -2,6 +2,7 @@ IMAGE_TAG ?= latest
|
|
2
2
|
IMAGE_REGISTRY ?= [put-your-registry-here]
|
3
3
|
KUBE_NAMESPACE ?= [put-your-namespace-here]
|
4
4
|
KUBE_DEPLOYMENT_SERVER ?= rubypitaya
|
5
|
+
KUBECONTEXT ?= ''
|
5
6
|
|
6
7
|
## Run ruby pitaya metagame project
|
7
8
|
run:
|
@@ -27,6 +28,14 @@ console:
|
|
27
28
|
bash:
|
28
29
|
@docker-compose run --service-ports --rm rubypitaya bash
|
29
30
|
|
31
|
+
## Create new migrgation. NAME=[migration-name]
|
32
|
+
create-migration:
|
33
|
+
@docker-compose run --service-ports --rm rubypitaya-console bundle exec rubypitaya create-migration $(NAME)
|
34
|
+
|
35
|
+
## Add or update a plugim. GIT=[plugin-git-link]
|
36
|
+
add-plugin:
|
37
|
+
@docker-compose run --service-ports --rm rubypitaya-console bundle exec rubypitaya add-plugin $(GIT)
|
38
|
+
|
30
39
|
## Create database
|
31
40
|
db-create:
|
32
41
|
@docker-compose run --service-ports --rm rubypitaya bundle exec rake db:create
|
@@ -35,6 +44,10 @@ db-create:
|
|
35
44
|
db-migrate:
|
36
45
|
@docker-compose run --service-ports --rm rubypitaya bundle exec rake db:migrate
|
37
46
|
|
47
|
+
## Show migrations status on database
|
48
|
+
db-migrate-status:
|
49
|
+
@docker-compose run --service-ports --rm rubypitaya bundle exec rake db:status
|
50
|
+
|
38
51
|
## Rollback migrations STEP=1
|
39
52
|
db-rollback:
|
40
53
|
@docker-compose run --service-ports --rm -e STEP="$(STEP)" rubypitaya bundle exec rake db:rollback
|
@@ -49,6 +62,7 @@ db-reset:
|
|
49
62
|
|
50
63
|
## Generate Gemfile.lock
|
51
64
|
generate-gemfilelock:
|
65
|
+
@rm -f Gemfile.lock
|
52
66
|
@docker run --rm -v "$(PWD)":/usr/src/app -w /usr/src/app ruby:2.6.6 bundle install
|
53
67
|
|
54
68
|
## Build image to production environment
|
@@ -75,6 +75,25 @@ namespace :db do
|
|
75
75
|
puts 'Database deleted.'
|
76
76
|
end
|
77
77
|
|
78
|
+
desc 'migration status'
|
79
|
+
task :status do
|
80
|
+
environment_name = ENV.fetch("RUBYPITAYA_ENV") { 'development' }
|
81
|
+
database_config = RubyPitaya::DatabaseConfig.new(environment_name, RubyPitaya::Path::DATABASE_CONFIG_PATH)
|
82
|
+
connection_data = database_config.connection_data
|
83
|
+
migrations_paths = [RubyPitaya::Path::Core::MIGRATIONS_FOLDER_PATH]
|
84
|
+
migrations_paths += RubyPitaya::Path::Plugins::MIGRATIONS_FOLDER_PATHS
|
85
|
+
migrations_paths += [RubyPitaya::Path::MIGRATIONS_FOLDER_PATH]
|
86
|
+
|
87
|
+
ActiveRecord::Base.establish_connection(connection_data)
|
88
|
+
ActiveRecord::Migrator.migrations_paths = migrations_paths
|
89
|
+
ActiveRecord::Base.connection.migration_context.migrations_status.each do |status, version, name|
|
90
|
+
puts "#{status.center(8)} #{version.ljust(14)} #{name}"
|
91
|
+
end
|
92
|
+
ActiveRecord::Base.connection.close
|
93
|
+
|
94
|
+
puts 'Rollback done.'
|
95
|
+
end
|
96
|
+
|
78
97
|
desc 'Reset the database'
|
79
98
|
task :reset do
|
80
99
|
Rake::Task['db:drop'].invoke
|
@@ -27,6 +27,12 @@ module MyApp
|
|
27
27
|
# - methods:
|
28
28
|
# - [](key)
|
29
29
|
# - get config file by config path
|
30
|
+
# - log
|
31
|
+
# - class: Logger
|
32
|
+
# - link: https://ruby-doc.org/stdlib-2.6.4/libdoc/logger/rdoc/Logger.html
|
33
|
+
# - methods:
|
34
|
+
# - info
|
35
|
+
# - log information
|
30
36
|
|
31
37
|
def run(initializer_content)
|
32
38
|
bll = initializer_content.bll
|
@@ -35,5 +41,9 @@ module MyApp
|
|
35
41
|
|
36
42
|
bll.add_instance(:player, playerBll)
|
37
43
|
end
|
44
|
+
|
45
|
+
def self.path
|
46
|
+
__FILE__
|
47
|
+
end
|
38
48
|
end
|
39
49
|
end
|
@@ -6,25 +6,35 @@ require 'active_record'
|
|
6
6
|
require 'rubypitaya'
|
7
7
|
require 'rubypitaya/core/database_config'
|
8
8
|
|
9
|
+
# Database connection
|
9
10
|
environment_name = ENV.fetch("RUBYPITAYA_ENV") { 'development' }
|
10
11
|
database_config = RubyPitaya::DatabaseConfig.new(environment_name, RubyPitaya::Path::DATABASE_CONFIG_PATH)
|
11
12
|
ActiveRecord::Base.establish_connection(database_config.connection_data)
|
12
13
|
ActiveRecord::Base.logger = ActiveSupport::Logger.new(STDOUT)
|
13
14
|
ActiveSupport::LogSubscriber.colorize_logging = true
|
14
15
|
|
16
|
+
# Loading core files
|
15
17
|
Gem.find_files('rubypitaya/**/*.rb').each do |path|
|
16
18
|
require path unless path.end_with?('spec.rb') ||
|
17
19
|
path.include?('db/migration') ||
|
20
|
+
path.include?('core/templates') ||
|
18
21
|
path.include?('app-template')
|
19
22
|
end
|
20
23
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
24
|
+
# Loading application files
|
25
|
+
app_folder_paths = RubyPitaya::Path::Plugins::APP_FOLDER_PATHS + [RubyPitaya::Path::APP_FOLDER_PATH]
|
26
|
+
app_folder_paths.each do |app_folder_path|
|
27
|
+
app_files_path = File.join(app_folder_path, '**/*.rb')
|
28
|
+
|
29
|
+
Dir[app_files_path].each do |path|
|
30
|
+
require path unless path.end_with?('spec.rb') ||
|
31
|
+
path.include?('db/migration')
|
32
|
+
end
|
25
33
|
end
|
26
34
|
|
35
|
+
# Starting irb
|
27
36
|
require 'irb'
|
28
37
|
IRB.start(__FILE__)
|
29
38
|
|
39
|
+
# Closing database connection
|
30
40
|
ActiveRecord::Base.connection.close
|
@@ -16,7 +16,7 @@ spec:
|
|
16
16
|
spec:
|
17
17
|
containers:
|
18
18
|
- name: rubypitaya
|
19
|
-
image:
|
19
|
+
image: registry.gitlab.com/lucianopc/ruby-pitaya:latest
|
20
20
|
command: ["bundle", "exec", "rubypitaya", "run"]
|
21
21
|
ports:
|
22
22
|
- containerPort: 4567
|
@@ -45,4 +45,4 @@ spec:
|
|
45
45
|
- name: DATABASE_NAME
|
46
46
|
value: "ruby_pitaya"
|
47
47
|
imagePullSecrets:
|
48
|
-
- name: gitlab-registry
|
48
|
+
- name: gitlab-registry
|
@@ -4,10 +4,11 @@ module RubyPitaya
|
|
4
4
|
|
5
5
|
class_attribute :non_authenticated_routes, default: []
|
6
6
|
|
7
|
-
attr_accessor :bll, :redis, :setup, :config, :params, :session, :postman
|
7
|
+
attr_accessor :bll, :log, :redis, :setup, :config, :params, :session, :postman
|
8
8
|
|
9
9
|
def initialize
|
10
10
|
@bll = nil
|
11
|
+
@log = nil
|
11
12
|
@redis = nil
|
12
13
|
@setup = nil
|
13
14
|
@config = nil
|
@@ -53,7 +53,7 @@ module RubyPitaya
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def call(handler_name, action_name, session, postman, redis, setup, config,
|
56
|
-
bll, params)
|
56
|
+
bll, log, params)
|
57
57
|
unless @handler_name_map.include?(handler_name)
|
58
58
|
return {
|
59
59
|
code: StatusCodes::CODE_HANDLER_NOT_FOUND,
|
@@ -71,6 +71,7 @@ module RubyPitaya
|
|
71
71
|
handler = @handler_name_map[handler_name]
|
72
72
|
|
73
73
|
handler.bll = bll
|
74
|
+
handler.log = log
|
74
75
|
handler.redis = redis
|
75
76
|
handler.setup = setup
|
76
77
|
handler.config = config
|
@@ -6,7 +6,25 @@ module RubyPitaya
|
|
6
6
|
class InitializerBroadcast
|
7
7
|
|
8
8
|
def run(initializer_content)
|
9
|
+
app_classes = []
|
10
|
+
plugin_classes = []
|
11
|
+
|
9
12
|
ObjectSpace.each_object(InitializerBase.singleton_class) do |klass|
|
13
|
+
is_plugin_class = klass.path.include?('plugins')
|
14
|
+
|
15
|
+
if is_plugin_class
|
16
|
+
plugin_classes << klass
|
17
|
+
else
|
18
|
+
app_classes << klass
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
plugin_classes.each do |klass|
|
23
|
+
instance = klass.new
|
24
|
+
instance.run(initializer_content)
|
25
|
+
end
|
26
|
+
|
27
|
+
app_classes.each do |klass|
|
10
28
|
instance = klass.new
|
11
29
|
instance.run(initializer_content)
|
12
30
|
end
|
@@ -2,10 +2,11 @@ module RubyPitaya
|
|
2
2
|
|
3
3
|
class InitializerContent
|
4
4
|
|
5
|
-
attr_reader :bll, :redis, :setup, :config
|
5
|
+
attr_reader :bll, :log, :redis, :setup, :config
|
6
6
|
|
7
|
-
def initialize(bll, redis, setup, config)
|
7
|
+
def initialize(bll, log, redis, setup, config)
|
8
8
|
@bll = bll
|
9
|
+
@log = log
|
9
10
|
@redis = redis
|
10
11
|
@setup = setup
|
11
12
|
@config = config
|
data/lib/rubypitaya/core/main.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'socket'
|
2
|
+
require 'logger'
|
2
3
|
require 'securerandom'
|
3
4
|
require 'active_model'
|
4
5
|
|
@@ -32,6 +33,12 @@ module RubyPitaya
|
|
32
33
|
@environment_name = ENV.fetch("RUBYPITAYA_ENV") { 'development' }
|
33
34
|
@is_development_environment = @environment_name == 'development'
|
34
35
|
|
36
|
+
@log = Logger.new('/proc/self/fd/1')
|
37
|
+
@log.level = Logger::INFO
|
38
|
+
@log.formatter = proc do |severity, datetime, progname, msg|
|
39
|
+
"#{msg}\n"
|
40
|
+
end
|
41
|
+
|
35
42
|
@application_files_importer = ApplicationFilesImporter.new
|
36
43
|
@application_files_importer.import
|
37
44
|
@application_files_importer.auto_reload if @is_development_environment
|
@@ -72,6 +79,7 @@ module RubyPitaya
|
|
72
79
|
@bll = InstanceHolder.new
|
73
80
|
|
74
81
|
@initializer_content = InitializerContent.new(@bll,
|
82
|
+
@log,
|
75
83
|
@redis_connector.redis,
|
76
84
|
@setup,
|
77
85
|
@config)
|
@@ -88,6 +96,7 @@ module RubyPitaya
|
|
88
96
|
|
89
97
|
def run_http
|
90
98
|
HttpRoutes.set :bll, @bll
|
99
|
+
HttpRoutes.set :log, @log
|
91
100
|
HttpRoutes.set :setup, @setup
|
92
101
|
HttpRoutes.set :config, @config
|
93
102
|
HttpRoutes.set :views, [Path::HTTP_VIEWS_PATH] + Path::Plugins::HTTP_VIEWS_PATHS
|
@@ -107,7 +116,7 @@ module RubyPitaya
|
|
107
116
|
Signal.trap("SIGQUIT") { throw :sig_shutdown }
|
108
117
|
Signal.trap("SIGTERM") { throw :sig_shutdown }
|
109
118
|
|
110
|
-
|
119
|
+
@log.info "Server started!"
|
111
120
|
run_nats_connection
|
112
121
|
end
|
113
122
|
|
@@ -122,7 +131,7 @@ module RubyPitaya
|
|
122
131
|
return if @is_shutting_down
|
123
132
|
@is_shutting_down = true
|
124
133
|
|
125
|
-
|
134
|
+
@log.info "Server shutting down..."
|
126
135
|
|
127
136
|
@etcd_connector.disconnect
|
128
137
|
@database_connector.disconnect
|
@@ -153,22 +162,22 @@ module RubyPitaya
|
|
153
162
|
|
154
163
|
handler_name, action_name = message_route.split('.')[1..-1]
|
155
164
|
|
156
|
-
|
157
|
-
|
165
|
+
@log.info "request -> route: #{message_route}"
|
166
|
+
@log.info " -> data: #{message_data}"
|
158
167
|
|
159
168
|
response = @handler_router.call(handler_name, action_name, @session,
|
160
169
|
@postman, @redis_connector.redis,
|
161
|
-
@setup, @config, @bll, params)
|
170
|
+
@setup, @config, @bll, @log, params)
|
162
171
|
|
163
172
|
delta_time_seconds = Time.now.to_i - start_time_seconds
|
164
173
|
|
165
|
-
|
174
|
+
@log.info "response [#{delta_time_seconds}s] -> #{response.to_json}"
|
166
175
|
|
167
176
|
response
|
168
177
|
end
|
169
178
|
rescue Exception => error
|
170
|
-
|
171
|
-
|
179
|
+
@log.info "ERROR: #{error}"
|
180
|
+
@log.info error.backtrace
|
172
181
|
run_nats_connection
|
173
182
|
end
|
174
183
|
end
|
data/lib/rubypitaya/core/path.rb
CHANGED
@@ -2,6 +2,7 @@ module RubyPitaya
|
|
2
2
|
|
3
3
|
class Path
|
4
4
|
APP_TEMPLATE_FOLDER_PATH = File.join(__dir__, '../app-template/')
|
5
|
+
MIGRATION_TEMPLATE_PATH = File.join(__dir__, 'templates/template_migration.rb.erb')
|
5
6
|
|
6
7
|
DATABASE_CONFIG_PATH = File.join(Dir.pwd, 'config/database.yml')
|
7
8
|
|
@@ -10,11 +11,13 @@ module RubyPitaya
|
|
10
11
|
APP_CONFIG_FOLDER_PATH = File.join(Dir.pwd, 'app/config/')
|
11
12
|
APP_SETUP_FOLDER_PATH = File.join(Dir.pwd, 'app/setup/')
|
12
13
|
MIGRATIONS_FOLDER_PATH = File.join(Dir.pwd, 'db/migration/')
|
14
|
+
PLUGINS_FOLDER_PATH = File.join(Dir.pwd, 'plugins/')
|
13
15
|
|
14
16
|
ROUTES_FILE_PATH = File.join(Dir.pwd, 'config/routes.rb')
|
15
17
|
|
16
18
|
HTTP_VIEWS_PATH = File.join(Dir.pwd, 'app/http/views')
|
17
19
|
|
20
|
+
|
18
21
|
class Core
|
19
22
|
APP_FOLDER_PATH = File.join(__dir__, 'app/')
|
20
23
|
MIGRATIONS_FOLDER_PATH = File.join(__dir__, 'db/migration/')
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
|
3
|
+
class <%= class_name %> < ActiveRecord::Migration[5.1]
|
4
|
+
|
5
|
+
enable_extension 'pgcrypto'
|
6
|
+
|
7
|
+
def change
|
8
|
+
create_table :[table-name-here-in-plural], id: :uuid do |t|
|
9
|
+
# t.belongs_to :user, type: :uuid
|
10
|
+
t.timestamps null: false
|
11
|
+
end
|
12
|
+
end
|
13
|
+
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: 2.
|
4
|
+
version: 2.9.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-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - '='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 2.1.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: ostruct
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.1.0
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.1.0
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: sinatra-contrib
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -285,6 +299,7 @@ files:
|
|
285
299
|
- "./lib/rubypitaya/core/session.rb"
|
286
300
|
- "./lib/rubypitaya/core/setup.rb"
|
287
301
|
- "./lib/rubypitaya/core/status_codes.rb"
|
302
|
+
- "./lib/rubypitaya/core/templates/template_migration.rb.erb"
|
288
303
|
- "./lib/rubypitaya/version.rb"
|
289
304
|
- bin/rubypitaya
|
290
305
|
homepage: https://gitlab.com/LucianoPC/ruby-pitaya
|