rubypitaya 3.6.0 → 3.8.1

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: a36b3ecb6147501bf5c3da00bfefa546c597e96e4520695d785d9dd7719d951e
4
- data.tar.gz: 7517fb91a57fb3c9d4d53811c2a8c564e09bac59daee1a4cb231d17b31f45df6
3
+ metadata.gz: a199a978d1b3f7f0782c57ee6f90a7508fa8cd70426121636d019651694d28ed
4
+ data.tar.gz: f08e585f4414ecc32d997f0b7ef641689ec85ca25c871a60f540ccb2695d5b5e
5
5
  SHA512:
6
- metadata.gz: a4867c9c3420c29630326c79fe12eaa77865e12277af909a7b3be2ef3ed3e0d813f2f735ddc4fdadc113e337d18bb7ef2d1a516ca171db2db1d6e5cafe0ecf8a
7
- data.tar.gz: 819bba7c9f059c09470b92082501cfe4355c3bba85f9ce62f348a39d1057272a22ad6f08867ecf3df0163430e8996994c1fbf40776f15713318612f305d7e775
6
+ metadata.gz: c5e577790193e84cf1a8ca5b94b86bdda16e76bc55a1823e1110780741cea2325127b2deba0905ffdaf1a411e3021b21890ba424e0fe4b69fc455e78459a6fcc
7
+ data.tar.gz: 6713f87272a91b3ead13a0ce84829d3f7c027aa0168c18f0327994808abdf129000787742a745237f4f5acb99660a0d57360587563b08a94c9c4786b6d60fb8c
@@ -1,6 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem 'rubypitaya', '3.6.0'
3
+ gem 'rubypitaya', '3.8.1'
4
4
 
5
5
  group :development do
6
6
  gem 'pry', '0.14.1'
@@ -99,7 +99,7 @@ GEM
99
99
  rspec-support (~> 3.11.0)
100
100
  rspec-support (3.11.0)
101
101
  ruby2_keywords (0.0.5)
102
- rubypitaya (3.6.0)
102
+ rubypitaya (3.8.1)
103
103
  activerecord (= 7.0.2)
104
104
  etcdv3 (= 0.11.5)
105
105
  google-protobuf (= 3.19.4)
@@ -138,7 +138,7 @@ DEPENDENCIES
138
138
  listen (= 3.7.1)
139
139
  pry (= 0.14.1)
140
140
  rspec (= 3.11.0)
141
- rubypitaya (= 3.6.0)
141
+ rubypitaya (= 3.8.1)
142
142
  sinatra-contrib (= 2.1.0)
143
143
 
144
144
  BUNDLED WITH
@@ -10,12 +10,17 @@ KUBECONTEXT ?= ''
10
10
  run:
11
11
  @docker-compose run --service-ports --rm rubypitaya bundle exec rubypitaya run
12
12
 
13
- ## Build project
13
+ ## Build project docker containers
14
14
  build:
15
15
  @docker-compose build
16
+ @docker-compose pull
16
17
  @echo "Copying vendor folder ..."
17
18
  @sh -c "FOLDER=$(notdir $(shell pwd)); CONTAINER="\$${FOLDER}_rubypitaya"; docker cp \$$(docker create \$${CONTAINER}):/app/rubypitaya/vendor ."
18
19
 
20
+ ## Setup project dependencies
21
+ setup: clear
22
+ @docker-compose run --service-ports --rm rubypitaya ./setup/development/main
23
+
19
24
  ## Run ruby irb console
20
25
  console:
21
26
  @docker-compose run --service-ports --rm rubypitaya-console bundle exec ruby ./bin/console
@@ -34,11 +39,15 @@ test: test-rspec test-cucumber
34
39
 
35
40
  ## Run rspec tests. FILE=spec.rb:10
36
41
  test-rspec:
37
- @docker-compose run --service-ports --rm rubypitaya bundle exec rspec $(FILE)
42
+ @docker-compose run --service-ports --rm -e RUBYPITAYA_SERVER_ENVIRONMENT="test" rubypitaya bundle exec rspec $(FILE)
38
43
 
39
44
  ## Run cucumber tests. FILE=something.feature
40
45
  test-cucumber:
41
- @docker-compose run --service-ports --rm rubypitaya bundle exec cucumber --publish-quiet $(FILE)
46
+ @docker-compose run --service-ports --rm -e RUBYPITAYA_SERVER_ENVIRONMENT="test" rubypitaya bundle exec cucumber --publish-quiet $(FILE)
47
+
48
+ ## Setup project dependencies for tests
49
+ setup-test: clear
50
+ @docker-compose run --service-ports --rm -e RUBYPITAYA_SERVER_ENVIRONMENT="test" rubypitaya ./setup/test/main
42
51
 
43
52
  ## Update gems dependencies on Gemfile.lock
44
53
  update-dependencies:
@@ -83,7 +92,7 @@ db-reset:
83
92
 
84
93
  ## Setup test database
85
94
  db-test-setup:
86
- @docker-compose run --service-ports --rm rubypitaya-commands bundle exec rake db:test:setup
95
+ @docker-compose run --service-ports --rm -e RUBYPITAYA_SERVER_ENVIRONMENT="test" rubypitaya-commands bundle exec rake db:test:setup
87
96
 
88
97
  ## + Deployment commands
89
98
 
@@ -1,6 +1,7 @@
1
1
  class StatusCodes
2
2
 
3
3
  CODE_OK = RubyPitaya::StatusCodes::CODE_OK
4
+ CODE_AUTHENTICATION_ERROR = RubyPitaya::StatusCodes::CODE_AUTHENTICATION_ERROR
4
5
 
5
6
  ################
6
7
  ## Existent Codes
@@ -9,7 +9,7 @@ class ErrorHandler < RubyPitaya::HandlerBase
9
9
  raise RubyPitaya::RouteError.new(error_code, error_message)
10
10
 
11
11
  response = {
12
- code: 'RP-200',
12
+ code: StatusCodes::CODE_OK,
13
13
  data: {
14
14
  message: 'Ok!'
15
15
  }
@@ -1,13 +1,24 @@
1
1
  class HelloWorldHandler < RubyPitaya::HandlerBase
2
2
 
3
- non_authenticated_actions :sayHello
3
+ non_authenticated_actions :sayHello, :showMessage
4
4
 
5
5
  def sayHello
6
6
  response = {
7
- code: 'RP-200',
7
+ code: StatusCodes::CODE_OK,
8
8
  data: {
9
9
  message: 'Hello!'
10
10
  }
11
11
  }
12
12
  end
13
+
14
+ def showMessage
15
+ message = @params[:message]
16
+
17
+ response = {
18
+ code: StatusCodes::CODE_OK,
19
+ data: {
20
+ message: message
21
+ }
22
+ }
23
+ end
13
24
  end
@@ -59,10 +59,7 @@ class PlayerHandler < RubyPitaya::HandlerBase
59
59
  bind_session_response = @postman.bind_session(@session)
60
60
 
61
61
  unless bind_session_response.dig(:error, :code).nil?
62
- return response = {
63
- code: RubyPitaya::StatusCodes::CODE_AUTHENTICATION_ERROR,
64
- msg: 'Error to authenticate',
65
- }
62
+ raise RubyPitaya::RouteError.new(StatusCodes::CODE_AUTHENTICATION_ERROR, 'Error to authenticate')
66
63
  end
67
64
 
68
65
  response = {
@@ -6,3 +6,27 @@ Feature: Hello World
6
6
  Given client call route 'rubypitaya.helloWorldHandler.sayHello'
7
7
  Then server should response 'code' as 'RP-200'
8
8
  And server should response 'data.message' as 'Hello!'
9
+
10
+ Scenario: Custom message
11
+ When client call route 'rubypitaya.helloWorldHandler.showMessage' with params:
12
+ | message |
13
+ | Hello World! |
14
+ Then server should response 'code' as 'RP-200'
15
+ And server should response 'data.message' as 'Hello World!'
16
+
17
+ Scenario: Custom message with json
18
+ When client call route 'rubypitaya.helloWorldHandler.showMessage' with json params:
19
+ """
20
+ {
21
+ "message": "Hello World!"
22
+ }
23
+ """
24
+ Then server should response the following json:
25
+ """
26
+ {
27
+ "code": "RP-200",
28
+ "data": {
29
+ "message": "Hello World!"
30
+ }
31
+ }
32
+ """
@@ -2,6 +2,16 @@ Given(/^[Cc]lient call route ["'](.+)["']$/) do |route|
2
2
  @handler_helper.request(route)
3
3
  end
4
4
 
5
+ Given(/^[Cc]lient call route ["'](.+)["'] with param[s]*[:]*$/) do |route, table|
6
+ params = table.hashes.first.symbolize_keys
7
+ @handler_helper.request(route, params)
8
+ end
9
+
10
+ Given(/^[Cc]lient call route ["'](.+)["'] with json param[s]*[:]*$/) do |route, json|
11
+ params = JSON.parse(json, symbolize_names: true)
12
+ @handler_helper.request(route, params)
13
+ end
14
+
5
15
  Given(/^[Ss]erver should response ["'](.+)["'] as ["'](.+)["']$/) do |response_key, expected_value|
6
16
  response_value = @handler_helper.response.dig(*response_key.split('.').map(&:to_sym))
7
17
 
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ bundle exec rake db:reset
@@ -0,0 +1,4 @@
1
+ #!/bin/bash
2
+
3
+ echo "Setup database"
4
+ ./setup/development/database
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ bundle exec rake db:test:setup
@@ -0,0 +1,4 @@
1
+ #!/bin/bash
2
+
3
+ echo "Setup database"
4
+ ./setup/test/database
@@ -1,3 +1,3 @@
1
1
  module RubyPitaya
2
- VERSION = '3.6.0'
2
+ VERSION = '3.8.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubypitaya
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.0
4
+ version: 3.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luciano Prestes Cavalcanti
@@ -330,6 +330,10 @@ files:
330
330
  - "./lib/rubypitaya/app-template/kubernetes/statefulset-postgres.yaml"
331
331
  - "./lib/rubypitaya/app-template/kubernetes/statefulset-redis.yaml"
332
332
  - "./lib/rubypitaya/app-template/plugins.yaml"
333
+ - "./lib/rubypitaya/app-template/setup/development/database"
334
+ - "./lib/rubypitaya/app-template/setup/development/main"
335
+ - "./lib/rubypitaya/app-template/setup/test/database"
336
+ - "./lib/rubypitaya/app-template/setup/test/main"
333
337
  - "./lib/rubypitaya/app-template/spec/hello_world_handler_spec.rb"
334
338
  - "./lib/rubypitaya/app-template/spec/player_handler_spec.rb"
335
339
  - "./lib/rubypitaya/app-template/spec/redis_service_spec.rb"