rubypitaya 2.4.4 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb195bab202604c6eccf3bf77c6a61a63accd532c0cb2a5717b65f88d5a2f820
4
- data.tar.gz: 61f32399ad655d8896ce4e88d4143dfe5bcf3b11272fa61729226503bd670881
3
+ metadata.gz: d954de0e8be9b30865fd328f1126a35c520fa6bd3f553040bfead26594cb19eb
4
+ data.tar.gz: 0a0663e7dea4b076b57d93d08376d428ac12b87f4ce4068e3033c6298780faf0
5
5
  SHA512:
6
- metadata.gz: be967053676552234531e322b6bd5e1202e3d2c8425c83f7476bc03371797193f23c644ff8d883eae5c380da208b96003b23d5fdc7bccb4edadd85659917cd3c
7
- data.tar.gz: 308c1ba083efd8c8c576c5f597ccd13cc195cb77960166eeadf3aeff2a3e3ef314b84135483327e4c737a168fe026f0fedd176411b74cb3d9e4c2a2e62b92a36
6
+ metadata.gz: 6ec34b4eba49194b30fc00871c034e721b13b3fdc7fb58b6942f9bb5e0a6ea693b7c23678453fed7ff72a18c743f2d78f9dfed0128e48770ab2e73e3c650ad41
7
+ data.tar.gz: 8a6cdc19ecebf38d7c47dc946166c63c408a3192e40b7a1432478e1bb7a947aed545cac1c46f6be2a9ece618a0f4007c555448ba67259390cafdf9b7d5bf6c1d
@@ -1,6 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem 'rubypitaya', '2.4.4'
3
+ gem 'rubypitaya', '2.5.0'
4
4
 
5
5
  group :development do
6
6
  gem 'pry', '0.12.2'
@@ -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.4.4)
65
+ rubypitaya (2.5.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
  listen (= 3.2.1)
86
86
  pry (= 0.12.2)
87
87
  rspec (= 3.8.0)
88
- rubypitaya (= 2.4.4)
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:
@@ -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.4'
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.4
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-25 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
@@ -199,6 +227,8 @@ files:
199
227
  - "./lib/rubypitaya/app-template/app/constants/status_codes.rb"
200
228
  - "./lib/rubypitaya/app-template/app/handlers/hello_world_handler.rb"
201
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"
202
232
  - "./lib/rubypitaya/app-template/app/models/player.rb"
203
233
  - "./lib/rubypitaya/app-template/app/models/user.rb"
204
234
  - "./lib/rubypitaya/app-template/bin/console"
@@ -234,6 +264,7 @@ files:
234
264
  - "./lib/rubypitaya/core/etcd_connector.rb"
235
265
  - "./lib/rubypitaya/core/handler_base.rb"
236
266
  - "./lib/rubypitaya/core/handler_router.rb"
267
+ - "./lib/rubypitaya/core/http_routes.rb"
237
268
  - "./lib/rubypitaya/core/initializer_base.rb"
238
269
  - "./lib/rubypitaya/core/initializer_broadcast.rb"
239
270
  - "./lib/rubypitaya/core/initializer_content.rb"