rubypitaya 2.4.0 → 2.5.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: '093a7c67062ae87c5335220458fd7c8c1a1b97591a8f6ef87121c07aa544eb4d'
4
- data.tar.gz: c0ab2dcd4a08ecda141a8d6ddfa646bb2e01dfb8648ddf78ac64a167a3f4593b
3
+ metadata.gz: d954de0e8be9b30865fd328f1126a35c520fa6bd3f553040bfead26594cb19eb
4
+ data.tar.gz: 0a0663e7dea4b076b57d93d08376d428ac12b87f4ce4068e3033c6298780faf0
5
5
  SHA512:
6
- metadata.gz: af597a9e1481be99c5a93c42ffc3e12629d486acbd931b46e1c2c037f7f8806e1191e28e7669835622bb98d2940e5a00a889a51391bbc3502fff7ed7dacace9f
7
- data.tar.gz: e3be1ef084dce3f1bd9cc77a4c4cab1b51f3d682329e7edbda3736487d3ebbf20d253336767eb97f62a11a191d3add2ba30d85a11669b5c28b9ef25cf2cbf91e
6
+ metadata.gz: 6ec34b4eba49194b30fc00871c034e721b13b3fdc7fb58b6942f9bb5e0a6ea693b7c23678453fed7ff72a18c743f2d78f9dfed0128e48770ab2e73e3c650ad41
7
+ data.tar.gz: 8a6cdc19ecebf38d7c47dc946166c63c408a3192e40b7a1432478e1bb7a947aed545cac1c46f6be2a9ece618a0f4007c555448ba67259390cafdf9b7d5bf6c1d
@@ -1,3 +1,10 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem 'rubypitaya', '2.4.0'
3
+ gem 'rubypitaya', '2.5.0'
4
+
5
+ group :development do
6
+ gem 'pry', '0.12.2'
7
+ gem 'bundler', '1.17.2'
8
+ gem 'rspec', '3.8.0'
9
+ gem 'listen', '3.2.1'
10
+ end
@@ -13,26 +13,26 @@ GEM
13
13
  tzinfo (~> 1.1)
14
14
  zeitwerk (~> 2.2)
15
15
  coderay (1.1.2)
16
- concurrent-ruby (1.1.6)
16
+ concurrent-ruby (1.1.7)
17
17
  diff-lcs (1.3)
18
18
  etcdv3 (0.10.2)
19
19
  grpc (~> 1.17)
20
20
  eventmachine (1.2.7)
21
21
  ffi (1.12.2)
22
- google-protobuf (3.11.4-x86_64-linux)
22
+ google-protobuf (3.13.0)
23
23
  googleapis-common-protos-types (1.0.5)
24
24
  google-protobuf (~> 3.11)
25
- grpc (1.28.0-x86_64-linux)
26
- google-protobuf (~> 3.11)
25
+ grpc (1.32.0)
26
+ google-protobuf (~> 3.13)
27
27
  googleapis-common-protos-types (~> 1.0)
28
- i18n (1.8.2)
28
+ i18n (1.8.5)
29
29
  concurrent-ruby (~> 1.0)
30
30
  listen (3.2.1)
31
31
  rb-fsevent (~> 0.10, >= 0.10.3)
32
32
  rb-inotify (~> 0.9, >= 0.9.10)
33
33
  method_source (0.9.2)
34
34
  middleware (0.1.0)
35
- minitest (5.14.0)
35
+ minitest (5.14.2)
36
36
  nats (0.11.0)
37
37
  eventmachine (~> 1.2, >= 1.2)
38
38
  pg (0.21.0)
@@ -62,19 +62,20 @@ 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.4.0)
65
+ rubypitaya (2.5.0)
66
66
  activerecord (= 6.0.2)
67
67
  etcdv3 (= 0.10.2)
68
68
  eventmachine (= 1.2.7)
69
69
  nats (= 0.11.0)
70
70
  pg (= 0.21.0)
71
71
  protobuf (= 3.10.0)
72
+ rake (= 10.0)
72
73
  redis (= 4.1.3)
73
74
  thor (1.0.1)
74
75
  thread_safe (0.3.6)
75
- tzinfo (1.2.7)
76
+ tzinfo (1.2.8)
76
77
  thread_safe (~> 0.1)
77
- zeitwerk (2.3.0)
78
+ zeitwerk (2.4.1)
78
79
 
79
80
  PLATFORMS
80
81
  ruby
@@ -83,9 +84,8 @@ DEPENDENCIES
83
84
  bundler (= 1.17.2)
84
85
  listen (= 3.2.1)
85
86
  pry (= 0.12.2)
86
- rake (= 10.0)
87
87
  rspec (= 3.8.0)
88
- rubypitaya (= 2.4.0)
88
+ rubypitaya (= 2.5.0)
89
89
 
90
90
  BUNDLED WITH
91
91
  1.17.2
@@ -16,7 +16,7 @@ test:
16
16
 
17
17
  ## Run ruby irb console
18
18
  console:
19
- @docker-compose run --service-ports --rm rubypitaya bundle exec ruby ./bin/console
19
+ @docker-compose run --service-ports --rm rubypitaya-console bundle exec ruby ./bin/console
20
20
 
21
21
  ## Run bash on container
22
22
  bash:
@@ -40,6 +40,9 @@ namespace :db do
40
40
  environment_name = ENV.fetch("RUBYPITAYA_ENV") { 'development' }
41
41
  database_config = RubyPitaya::DatabaseConfig.new(environment_name, RubyPitaya::Path::DATABASE_CONFIG_PATH)
42
42
  connection_data = database_config.connection_data
43
+ migrations_paths = [RubyPitaya::Path::Core::MIGRATIONS_FOLDER_PATH]
44
+ migrations_paths += RubyPitaya::Path::Plugins::MIGRATIONS_FOLDER_PATHS
45
+ migrations_paths += [RubyPitaya::Path::MIGRATIONS_FOLDER_PATH]
43
46
 
44
47
  step = ENV["STEP"] ? ENV["STEP"].to_i : 1
45
48
 
@@ -51,6 +54,7 @@ namespace :db do
51
54
  end
52
55
 
53
56
  ActiveRecord::Base.establish_connection(connection_data)
57
+ ActiveRecord::Migrator.migrations_paths = migrations_paths
54
58
  ActiveRecord::Base.connection.migration_context.rollback(step)
55
59
  ActiveRecord::Base.connection.close
56
60
 
@@ -0,0 +1,27 @@
1
+ require 'rubypitaya/core/http_routes'
2
+
3
+ RubyPitaya::HttpRoutes.class_eval do
4
+
5
+ get '/hello-world/html' do
6
+ content_type 'text/html'
7
+
8
+ @message = "Hello World"
9
+
10
+ erb :hello_world
11
+ end
12
+
13
+ get '/hello-world/json' do
14
+ response = {
15
+ message: 'Hello World!'
16
+ }.to_json
17
+ end
18
+
19
+ private
20
+
21
+ def response_error(message)
22
+ response = {
23
+ code: StatusCodes::CODE_ERROR,
24
+ message: message,
25
+ }.to_json
26
+ end
27
+ end
@@ -0,0 +1 @@
1
+ <h3><%= @message %></h3>
@@ -44,6 +44,35 @@ services:
44
44
  SERVER_ROUTES: 'rubypitaya'
45
45
 
46
46
  rubypitaya:
47
+ depends_on:
48
+ - 'db'
49
+ - 'nats'
50
+ - 'etcd'
51
+ - 'redis'
52
+ - 'connector'
53
+ build:
54
+ context: '.'
55
+ dockerfile: 'docker/dev/Dockerfile'
56
+ working_dir: '/app/rubypitaya'
57
+ volumes:
58
+ - '.:/app/rubypitaya'
59
+ ports:
60
+ - '80:4567'
61
+ environment:
62
+ SERVER_NAME: 'rubypitaya'
63
+ RUBYPITAYA_ENV: 'development'
64
+ HISTFILE: '/app/rubypitaya/.bash-history'
65
+ NATS_URL: 'nats://nats:4222'
66
+ ETCD_URL: 'http://etcd:2379'
67
+ ETCD_PREFIX: 'rubypitaya/'
68
+ ETCD_LEASE_SECONDS: '60'
69
+ REDIS_URL: 'redis://redis:6379'
70
+ DATABASE_HOST: 'db'
71
+ DATABASE_USER: 'postgres'
72
+ DATABASE_PASSWORD: 'postgres'
73
+ DATABASE_NAME: 'ruby_pitaya'
74
+
75
+ rubypitaya-console:
47
76
  depends_on:
48
77
  - 'db'
49
78
  - 'nats'
@@ -0,0 +1,25 @@
1
+ require 'sinatra/base'
2
+ require 'sinatra/reloader' if ENV['RUBYPITAYA_ENV'] == 'development'
3
+ require 'rubypitaya/core/parameters'
4
+
5
+ module RubyPitaya
6
+
7
+ class HttpRoutes < Sinatra::Base
8
+
9
+ if ENV['RUBYPITAYA_ENV'] == 'development'
10
+ register Sinatra::Reloader
11
+ end
12
+
13
+ before do
14
+ content_type :json
15
+
16
+ @bll = settings.bll
17
+ @config = settings.config
18
+
19
+ request_body = request.body.read
20
+ @params.merge!(JSON.parse(request_body)) if !request_body.blank?
21
+
22
+ @params = Parameters.new(@params)
23
+ end
24
+ end
25
+ end
@@ -75,11 +75,24 @@ module RubyPitaya
75
75
 
76
76
  @handler_router = HandlerRouter.new()
77
77
 
78
+ run_http
78
79
  run_server
79
80
  end
80
81
 
81
82
  private
82
83
 
84
+ def run_http
85
+ HttpRoutes.set :bll, @bll
86
+ HttpRoutes.set :config, @config
87
+ HttpRoutes.set :views, [Path::HTTP_VIEWS_PATH] + Path::Plugins::APP_CONFIG_FOLDER_PATHS;
88
+
89
+ Thread.new do
90
+ HttpRoutes.bind = '0.0.0.0'
91
+ HttpRoutes.port = '4567'
92
+ HttpRoutes.run!
93
+ end
94
+ end
95
+
83
96
  def run_server
84
97
  @is_shutting_down = false
85
98
 
@@ -12,6 +12,8 @@ module RubyPitaya
12
12
 
13
13
  ROUTES_FILE_PATH = File.join(Dir.pwd, 'config/routes.rb')
14
14
 
15
+ HTTP_VIEWS_PATH = File.join(Dir.pwd, 'app/http/views')
16
+
15
17
  class Core
16
18
  APP_FOLDER_PATH = File.join(__dir__, 'app/')
17
19
  MIGRATIONS_FOLDER_PATH = File.join(__dir__, 'db/migration/')
@@ -22,6 +24,7 @@ module RubyPitaya
22
24
  HANDLERS_FOLDER_PATHS = Dir.glob(File.join(Dir.pwd, 'plugins/*/app/handlers'))
23
25
  APP_CONFIG_FOLDER_PATHS = Dir.glob(File.join(Dir.pwd, 'plugins/*/app/config/'))
24
26
  MIGRATIONS_FOLDER_PATHS = Dir.glob(File.join(Dir.pwd, 'plugins/*/db/migration'))
27
+ HTTP_VIEWS_PATHS = Dir.glob(File.join(Dir.pwd, 'plugins/*/app/http/views'))
25
28
  end
26
29
  end
27
30
  end
@@ -1,3 +1,3 @@
1
1
  module RubyPitaya
2
- VERSION = '2.4.0'
2
+ VERSION = '2.5.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.4.0
4
+ version: 2.5.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-11-10 00:00:00.000000000 Z
11
+ date: 2020-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -80,6 +80,34 @@ dependencies:
80
80
  - - '='
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.10.2
83
+ - !ruby/object:Gem::Dependency
84
+ name: sinatra
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 2.1.0
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 2.1.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: sinatra-contrib
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: 2.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: 2.1.0
83
111
  - !ruby/object:Gem::Dependency
84
112
  name: protobuf
85
113
  requirement: !ruby/object:Gem::Requirement
@@ -150,20 +178,6 @@ dependencies:
150
178
  - - '='
151
179
  - !ruby/object:Gem::Version
152
180
  version: 1.17.2
153
- - !ruby/object:Gem::Dependency
154
- name: rake
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - '='
158
- - !ruby/object:Gem::Version
159
- version: '10.0'
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - '='
165
- - !ruby/object:Gem::Version
166
- version: '10.0'
167
181
  - !ruby/object:Gem::Dependency
168
182
  name: rspec
169
183
  requirement: !ruby/object:Gem::Requirement
@@ -213,6 +227,8 @@ files:
213
227
  - "./lib/rubypitaya/app-template/app/constants/status_codes.rb"
214
228
  - "./lib/rubypitaya/app-template/app/handlers/hello_world_handler.rb"
215
229
  - "./lib/rubypitaya/app-template/app/handlers/player_handler.rb"
230
+ - "./lib/rubypitaya/app-template/app/http/hello_world.rb"
231
+ - "./lib/rubypitaya/app-template/app/http/views/hello_world.erb"
216
232
  - "./lib/rubypitaya/app-template/app/models/player.rb"
217
233
  - "./lib/rubypitaya/app-template/app/models/user.rb"
218
234
  - "./lib/rubypitaya/app-template/bin/console"
@@ -248,6 +264,7 @@ files:
248
264
  - "./lib/rubypitaya/core/etcd_connector.rb"
249
265
  - "./lib/rubypitaya/core/handler_base.rb"
250
266
  - "./lib/rubypitaya/core/handler_router.rb"
267
+ - "./lib/rubypitaya/core/http_routes.rb"
251
268
  - "./lib/rubypitaya/core/initializer_base.rb"
252
269
  - "./lib/rubypitaya/core/initializer_broadcast.rb"
253
270
  - "./lib/rubypitaya/core/initializer_content.rb"