rubypitaya 3.0.3 → 3.3.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: 5a9246223a2328fd375d34a04259e1ac01f3eb3b021a39cfad33d8541870dbcc
4
- data.tar.gz: 5e0182a29f83521950107d6863889055452ed73ec465cb613ddd959a1b511710
3
+ metadata.gz: f57bbdb5e9f7f12097c4013871c3947a1655e3c79fe31b9e259d911c0563ef0d
4
+ data.tar.gz: bd54ecb7812fd7d16573f986f274abf0949cd0a7d460ec30ece58bef51201ec2
5
5
  SHA512:
6
- metadata.gz: bb5a55039932f42a8595b3f3e2641c8b865a5d3e0dd4fb3d69781d48ce0fcffc8b1aaec445943c6f7e366cf0dc2b722294f2540a0400a415913e7d7166f7e9f6
7
- data.tar.gz: 5a08fbfd5dc3225bcd6d0383b930876db9d907fcf89a97c3d6b4844eb118fde5806490981aaa8fefee9bb62a325a17fda060764dc4465c56a4a7f2eaa960ff0c
6
+ metadata.gz: 2440c10e3c923ccfbe29e6730bbfae01385caf00a8d9c2aff001740c5f3e91670d8cfc020bfd4655fd143062a1a1921a21dcc6846424cef48403344b9841497b
7
+ data.tar.gz: 2beb8d98dade8520167c774714bb71673ee6f8329494a8b0a80674ac44f63384b50dd2af32dd20e01975dcb622a0624c74457fd730ea6a77b44ea821dfb41ed6
@@ -1,6 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem 'rubypitaya', '3.0.3'
3
+ gem 'rubypitaya', '3.3.0'
4
4
 
5
5
  group :development do
6
6
  gem 'pry', '0.14.1'
@@ -103,7 +103,7 @@ GEM
103
103
  rspec-support (~> 3.10.0)
104
104
  rspec-support (3.10.3)
105
105
  ruby2_keywords (0.0.5)
106
- rubypitaya (3.0.3)
106
+ rubypitaya (3.3.0)
107
107
  activerecord (= 6.1.4.1)
108
108
  etcdv3 (= 0.11.4)
109
109
  google-protobuf (= 3.18.1)
@@ -143,7 +143,7 @@ DEPENDENCIES
143
143
  listen (= 3.7.0)
144
144
  pry (= 0.14.1)
145
145
  rspec (= 3.10.0)
146
- rubypitaya (= 3.0.3)
146
+ rubypitaya (= 3.3.0)
147
147
  sinatra-contrib (= 2.1.0)
148
148
 
149
149
  BUNDLED WITH
@@ -11,6 +11,7 @@ class StatusCodes
11
11
  #
12
12
  #
13
13
  ## Error codes
14
+ # RubyPitaya::StatusCodes::CODE_ERROR = 'RP-201'
14
15
  # RubyPitaya::StatusCodes::CODE_UNKNOWN = 'RP-000'
15
16
  # RubyPitaya::StatusCodes::CODE_HANDLER_NOT_FOUND = 'RP-001'
16
17
  # RubyPitaya::StatusCodes::CODE_ACTION_NOT_FOUND = 'RP-002'
@@ -0,0 +1,2 @@
1
+ ---
2
+ plugins: {}
@@ -0,0 +1,9 @@
1
+ class RubyPitayaError < StandardError
2
+
3
+ def initialize(code, message)
4
+ @code = code
5
+ @message = message
6
+
7
+ super(message)
8
+ end
9
+ end
@@ -109,7 +109,7 @@ module RubyPitaya
109
109
  HttpRoutes.set :setup, @setup
110
110
  HttpRoutes.set :config, @config
111
111
  HttpRoutes.set :objects, @objects
112
- HttpRoutes.set :views, [Path::HTTP_VIEWS_PATH] + Path::Plugins::HTTP_VIEWS_PATHS
112
+ HttpRoutes.set :views, [Path::HTTP_VIEWS_FOLDER_PATH] + Path::Plugins::HTTP_VIEWS_FOLDER_PATHS
113
113
 
114
114
  HttpRoutes.auto_reload if @is_development_environment
115
115
 
@@ -190,9 +190,14 @@ module RubyPitaya
190
190
 
191
191
  response
192
192
  end
193
+ rescue RubyPitaya::Error => error
194
+ @log.error "ROUTE ERROR: #{error.class} | #{error.message}} \n #{error.backtrace.join("\n")}"
195
+ response = {
196
+ code: error.code,
197
+ message: error.message
198
+ }
193
199
  rescue Exception => error
194
- @log.info "ERROR: #{error}"
195
- @log.info error.backtrace.join("\n")
200
+ @log.error "INTERNAL ERROR: #{error.class} | #{error.message}} \n #{error.backtrace.join("\n")}"
196
201
  run_nats_connection
197
202
  end
198
203
  end
@@ -10,10 +10,10 @@ module RubyPitaya
10
10
  APP_SETUP_FOLDER_PATH = File.join(Dir.pwd, 'app/setup/')
11
11
  MIGRATIONS_FOLDER_PATH = File.join(Dir.pwd, 'app/migrations/')
12
12
  PLUGINS_FOLDER_PATH = File.join(Dir.pwd, 'plugins/')
13
+ HTTP_VIEWS_FOLDER_PATH = File.join(Dir.pwd, 'app/http/views/')
13
14
 
14
15
  ROUTES_FILE_PATH = File.join(Dir.pwd, 'config/routes.rb')
15
-
16
- HTTP_VIEWS_PATH = File.join(Dir.pwd, 'app/http/views')
16
+ PLUGIN_CONFIG_FILE_PATH = File.join(Dir.pwd, 'plugins.yaml')
17
17
 
18
18
 
19
19
  class Core
@@ -27,7 +27,7 @@ module RubyPitaya
27
27
  APP_CONFIG_FOLDER_PATHS = Dir.glob(File.join(Dir.pwd, 'plugins/*/app/config/'))
28
28
  APP_SETUP_FOLDER_PATHS = Dir.glob(File.join(Dir.pwd, 'plugins/*/app/setup/'))
29
29
  MIGRATIONS_FOLDER_PATHS = Dir.glob(File.join(Dir.pwd, 'plugins/*/app/migrations/'))
30
- HTTP_VIEWS_PATHS = Dir.glob(File.join(Dir.pwd, 'plugins/*/app/http/views'))
30
+ HTTP_VIEWS_FOLDER_PATHS = Dir.glob(File.join(Dir.pwd, 'plugins/*/app/http/views/'))
31
31
  end
32
32
  end
33
33
  end
@@ -77,6 +77,14 @@ module RubyPitaya
77
77
  @@log
78
78
  end
79
79
 
80
+ def setup
81
+ @@setup
82
+ end
83
+
84
+ def config
85
+ @@config
86
+ end
87
+
80
88
  def session
81
89
  @@session
82
90
  end
@@ -5,6 +5,7 @@ module RubyPitaya
5
5
  CODE_OK = 'RP-200'
6
6
 
7
7
  # Error codes
8
+ CODE_ERROR = 'RP-201'
8
9
  CODE_UNKNOWN = 'RP-000'
9
10
  CODE_HANDLER_NOT_FOUND = 'RP-001'
10
11
  CODE_ACTION_NOT_FOUND = 'RP-002'
@@ -1,3 +1,3 @@
1
1
  module RubyPitaya
2
- VERSION = '3.0.3'
2
+ VERSION = '3.3.0'
3
3
  end
data/lib/rubypitaya.rb CHANGED
@@ -45,12 +45,14 @@ module RubyPitaya
45
45
  plugin_folder_path = File.join(Path::PLUGINS_FOLDER_PATH, plugin_name)
46
46
  plugin_git_path = File.join(plugin_folder_path, '.git/')
47
47
 
48
- branch_command = ""
48
+ commit_hash = ''
49
+ branch_command = ''
49
50
  branch_command = "--branch #{branch_name}" unless branch_name.blank?
50
51
 
51
52
  FileUtils.rm_rf(plugin_folder_path) if File.exists?(plugin_folder_path)
52
53
  puts "git -C #{Path::PLUGINS_FOLDER_PATH} clone --depth 1 #{branch_command} #{plugin_git_url}"
53
54
  `git -C #{Path::PLUGINS_FOLDER_PATH} clone --depth 1 #{branch_command} #{plugin_git_url}`
55
+ commit_hash = `git rev-parse --short HEAD`.strip
54
56
  FileUtils.rm_rf(plugin_git_path)
55
57
 
56
58
  Dir.entries(plugin_folder_path).each do |entry|
@@ -71,6 +73,15 @@ module RubyPitaya
71
73
  File.rename(migration_file, new_file)
72
74
  end
73
75
 
76
+ plugins_config = YAML.load(File.open(Path::PLUGIN_CONFIG_FILE_PATH, &:read))
77
+ plugins_config['plugins'][plugin_name] = {
78
+ 'git' => plugin_git_url,
79
+ 'branch' => branch_name || '',
80
+ 'commit' => commit_hash,
81
+ }
82
+
83
+ File.open(Path::PLUGIN_CONFIG_FILE_PATH, 'w') { |f| f.write(plugins_config.to_yaml) }
84
+
74
85
  plugin_name
75
86
  end
76
87
  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: 3.0.3
4
+ version: 3.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: 2021-11-23 00:00:00.000000000 Z
11
+ date: 2021-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -328,6 +328,7 @@ files:
328
328
  - "./lib/rubypitaya/app-template/kubernetes/statefulset-nats.yaml"
329
329
  - "./lib/rubypitaya/app-template/kubernetes/statefulset-postgres.yaml"
330
330
  - "./lib/rubypitaya/app-template/kubernetes/statefulset-redis.yaml"
331
+ - "./lib/rubypitaya/app-template/plugins.yaml"
331
332
  - "./lib/rubypitaya/app-template/spec/hello_world_handler_spec.rb"
332
333
  - "./lib/rubypitaya/app-template/spec/player_handler_spec.rb"
333
334
  - "./lib/rubypitaya/app-template/spec/spec_helper.rb"
@@ -338,6 +339,7 @@ files:
338
339
  - "./lib/rubypitaya/core/config_core.rb"
339
340
  - "./lib/rubypitaya/core/database_config.rb"
340
341
  - "./lib/rubypitaya/core/database_connector.rb"
342
+ - "./lib/rubypitaya/core/error.rb"
341
343
  - "./lib/rubypitaya/core/etcd_connector.rb"
342
344
  - "./lib/rubypitaya/core/handler_base.rb"
343
345
  - "./lib/rubypitaya/core/handler_router.rb"