rubypitaya 2.20.0 → 2.21.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: a6dfc8681449f1ffcae12145b9fb3533f04d82aa42ed663ddac513d16eb57c79
4
- data.tar.gz: 3176f5f30664abbd2f9464eedec8c7f004412d6d4c5391528f17ae35932cecb7
3
+ metadata.gz: 9505e2c4dbb300db345cff9e51d406c5f6b3c6f101c46105b8fa2e949b8c71bc
4
+ data.tar.gz: 9c1fb523cf378d6fa8bd7aa927611bfcd974b0583f22d8fdcbf3a3c71a438bec
5
5
  SHA512:
6
- metadata.gz: c2c31cbe23ea840ba2fb5c0dd59c29a3bdf204bd017d06aa772a3213bf0ce7b99536bafaa60494edb2e462176f3b001125a2c707ee7e387ad5d3cd0fc6aa64bc
7
- data.tar.gz: 59cf7321c84bd05e5727a38236cbec7e6ee4d32f9b02c3ef7349a65e09a327885294de37eeb04e6f2740dbbf5d4c14d9cc93aeb593c2c4ae5cbbe53f0c4bde9a
6
+ metadata.gz: 07c2486f386fef386ec1e002e57a2f723c6ff9f12e693d3c41abb322cf226cea49a9d5eab743f94ffb6d3b72627f48ef40716a03172d9ab58d53d0d53ca6f465
7
+ data.tar.gz: 6c2d3d381cb44074f9b4df501671c4a330e5c370b1b392e041a831d342615394dca786ed72d36de1673dbef45005c18aca0cb279d18f7f0011d0c833a2a8ca1a
@@ -1,6 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem 'rubypitaya', '2.20.0'
3
+ gem 'rubypitaya', '2.21.0'
4
4
 
5
5
  group :development do
6
6
  gem 'pry', '0.14.0'
@@ -108,7 +108,7 @@ GEM
108
108
  rspec-support (~> 3.10.0)
109
109
  rspec-support (3.10.2)
110
110
  ruby2_keywords (0.0.4)
111
- rubypitaya (2.20.0)
111
+ rubypitaya (2.21.0)
112
112
  activerecord (= 6.1.3)
113
113
  etcdv3 (= 0.10.2)
114
114
  nats (= 0.11.0)
@@ -148,7 +148,7 @@ DEPENDENCIES
148
148
  listen (= 3.4.1)
149
149
  pry (= 0.14.0)
150
150
  rspec (= 3.10.0)
151
- rubypitaya (= 2.19.1)
151
+ rubypitaya (= 2.21.0)
152
152
 
153
153
  BUNDLED WITH
154
154
  2.1.4
@@ -8,8 +8,7 @@ namespace :db do
8
8
 
9
9
  desc 'Create the database'
10
10
  task :create do
11
- environment_name = ENV.fetch("RUBYPITAYA_ENV") { 'development' }
12
- database_config = RubyPitaya::DatabaseConfig.new(environment_name, RubyPitaya::Path::DATABASE_CONFIG_PATH)
11
+ database_config = RubyPitaya::DatabaseConfig.new
13
12
  connection_data = database_config.connection_data_without_database
14
13
 
15
14
  ActiveRecord::Base.establish_connection(connection_data)
@@ -21,8 +20,7 @@ namespace :db do
21
20
 
22
21
  desc 'Migrate the database'
23
22
  task :migrate do
24
- environment_name = ENV.fetch("RUBYPITAYA_ENV") { 'development' }
25
- database_config = RubyPitaya::DatabaseConfig.new(environment_name, RubyPitaya::Path::DATABASE_CONFIG_PATH)
23
+ database_config = RubyPitaya::DatabaseConfig.new
26
24
  connection_data = database_config.connection_data
27
25
  migrations_paths = [RubyPitaya::Path::Core::MIGRATIONS_FOLDER_PATH]
28
26
  migrations_paths += RubyPitaya::Path::Plugins::MIGRATIONS_FOLDER_PATHS
@@ -38,8 +36,7 @@ namespace :db do
38
36
 
39
37
  desc 'Rollback migrations'
40
38
  task :rollback do
41
- environment_name = ENV.fetch("RUBYPITAYA_ENV") { 'development' }
42
- database_config = RubyPitaya::DatabaseConfig.new(environment_name, RubyPitaya::Path::DATABASE_CONFIG_PATH)
39
+ database_config = RubyPitaya::DatabaseConfig.new
43
40
  connection_data = database_config.connection_data
44
41
  migrations_paths = [RubyPitaya::Path::Core::MIGRATIONS_FOLDER_PATH]
45
42
  migrations_paths += RubyPitaya::Path::Plugins::MIGRATIONS_FOLDER_PATHS
@@ -64,8 +61,7 @@ namespace :db do
64
61
 
65
62
  desc 'Drop the database'
66
63
  task :drop do
67
- environment_name = ENV.fetch("RUBYPITAYA_ENV") { 'development' }
68
- database_config = RubyPitaya::DatabaseConfig.new(environment_name, RubyPitaya::Path::DATABASE_CONFIG_PATH)
64
+ database_config = RubyPitaya::DatabaseConfig.new
69
65
  connection_data = database_config.connection_data_without_database
70
66
 
71
67
  ActiveRecord::Base.establish_connection(connection_data)
@@ -78,8 +74,7 @@ namespace :db do
78
74
 
79
75
  desc 'migration status'
80
76
  task :status do
81
- environment_name = ENV.fetch("RUBYPITAYA_ENV") { 'development' }
82
- database_config = RubyPitaya::DatabaseConfig.new(environment_name, RubyPitaya::Path::DATABASE_CONFIG_PATH)
77
+ database_config = RubyPitaya::DatabaseConfig.new
83
78
  connection_data = database_config.connection_data
84
79
  migrations_paths = [RubyPitaya::Path::Core::MIGRATIONS_FOLDER_PATH]
85
80
  migrations_paths += RubyPitaya::Path::Plugins::MIGRATIONS_FOLDER_PATHS
@@ -2,7 +2,7 @@ class PlayerBLL
2
2
 
3
3
  def create_new_player(setup, config)
4
4
  name = config['initial_player'][:name]
5
- gold = setup['initial_player.wallet.gold']
5
+ gold = config['initial_player'][:wallet][:gold]
6
6
 
7
7
  player = Player.new(name: name, gold: gold, user: User.new)
8
8
  player.save!
@@ -1,3 +1,6 @@
1
1
  {
2
- "name": "Guest"
2
+ "name": "Guest",
3
+ "wallet": {
4
+ "gold": 10
5
+ }
3
6
  }
@@ -0,0 +1,27 @@
1
+ server:
2
+ name: 'rubypitaya'
3
+ environment: development
4
+
5
+ nats:
6
+ url: 'nats://nats:4222'
7
+
8
+ etcd:
9
+ url: 'http://etcd:2379'
10
+ prefix: 'rubypitaya/'
11
+ leaseSeconds: '60'
12
+
13
+ redis:
14
+ url: 'redis://redis:6379'
15
+
16
+ database:
17
+ host: 'db'
18
+ port: 5432
19
+ user: 'postgres'
20
+ password: 'postgres'
21
+ name: 'ruby_pitaya'
22
+
23
+ http:
24
+ auth:
25
+ user: 'user'
26
+ pass: 'pass'
27
+ enabled: 'false'
@@ -7,8 +7,7 @@ require 'rubypitaya'
7
7
  require 'rubypitaya/core/database_config'
8
8
 
9
9
  # Database connection
10
- environment_name = ENV.fetch("RUBYPITAYA_ENV") { 'development' }
11
- database_config = RubyPitaya::DatabaseConfig.new(environment_name, RubyPitaya::Path::DATABASE_CONFIG_PATH)
10
+ database_config = RubyPitaya::DatabaseConfig.new
12
11
  ActiveRecord::Base.establish_connection(database_config.connection_data)
13
12
  ActiveRecord::Base.logger = ActiveSupport::Logger.new(STDOUT)
14
13
  ActiveSupport::LogSubscriber.colorize_logging = true
@@ -60,22 +60,7 @@ services:
60
60
  ports:
61
61
  - '80:4567'
62
62
  environment:
63
- SERVER_NAME: 'rubypitaya'
64
- RUBYPITAYA_ENV: 'development'
65
63
  HISTFILE: '/app/rubypitaya/.bash-history'
66
- NATS_URL: 'nats://nats:4222'
67
- ETCD_URL: 'http://etcd:2379'
68
- ETCD_PREFIX: 'rubypitaya/'
69
- ETCD_LEASE_SECONDS: '60'
70
- REDIS_URL: 'redis://redis:6379'
71
- DATABASE_HOST: 'db'
72
- DATABASE_PORT: 5432
73
- DATABASE_USER: 'postgres'
74
- DATABASE_PASSWORD: 'postgres'
75
- DATABASE_NAME: 'ruby_pitaya'
76
- HTTP_AUTH_ENABLED: 'false'
77
- HTTP_AUTH_USER: 'user'
78
- HTTP_AUTH_PASS: 'pass'
79
64
 
80
65
  rubypitaya-console:
81
66
  <<: *rubypitaya
@@ -4,7 +4,10 @@ cmd="$@"
4
4
 
5
5
  echo "=> Waiting for postgres"
6
6
 
7
- ./docker/wait_for.sh $DATABASE_HOST:$DATABASE_PORT
7
+ RUBYPITAYA_DATABASE_HOST=${RUBYPITAYA_DATABASE_HOST:-'db'}
8
+ RUBYPITAYA_DATABASE_PORT=${RUBYPITAYA_DATABASE_PORT:-5432}
9
+
10
+ ./docker/wait_for.sh $RUBYPITAYA_DATABASE_HOST:$RUBYPITAYA_DATABASE_PORT
8
11
 
9
12
  echo "=> Postgres is ready"
10
13
 
@@ -3,7 +3,7 @@ Feature: Player
3
3
  As a game player I want to have a player on database
4
4
 
5
5
  Scenario: Create new player
6
- Given setup key 'initial_player.wallet.gold' is '10'
6
+ Given config key 'initial_player.wallet.gold' is '10'
7
7
  And config key 'initial_player.name' is 'Guest'
8
8
  When client call route 'rubypitaya.playerHandler.authenticate'
9
9
  Then server should response 'code' as 'RP-200'
@@ -25,34 +25,30 @@ spec:
25
25
  - containerPort: 4567
26
26
  name: rubypitaya
27
27
  env:
28
- - name: SERVER_NAME
29
- value: "rubypitaya"
30
- - name: RUBYPITAYA_ENV
31
- value: "production"
32
- - name: NATS_URL
28
+ - name: RUBYPITAYA_SERVER_ENVIRONMENT
29
+ value: {{ .Values.rubypitaya.server.environment | quote }}
30
+ - name: RUBYPITAYA_NATS_URL
33
31
  value: "nats://nats.{{ .Values.namespace }}.svc.cluster.local:4222"
34
- - name: ETCD_URL
32
+ - name: RUBYPITAYA_ETCD_URL
35
33
  value: "http://etcd.{{ .Values.namespace }}.svc.cluster.local:2379"
36
- - name: ETCD_PREFIX
37
- value: "rubypitaya/"
38
- - name: ETCD_LEASE_SECONDS
39
- value: "60"
40
- - name: REDIS_URL
34
+ - name: RUBYPITAYA_REDIS_URL
41
35
  value: "redis://redis.{{ .Values.namespace }}.svc.cluster.local:6379"
42
- - name: DATABASE_NAME
36
+ - name: RUBYPITAYA_DATABASE_NAME
43
37
  value: {{ .Values.database.name | quote }}
44
- - name: DATABASE_HOST
38
+ - name: RUBYPITAYA_DATABASE_HOST
45
39
  value: {{ .Values.database.host | quote }}
46
- - name: DATABASE_USER
40
+ - name: RUBYPITAYA_DATABASE_USER
47
41
  value: {{ .Values.database.user | quote }}
48
- - name: DATABASE_PASSWORD
42
+ - name: RUBYPITAYA_DATABASE_PORT
43
+ value: {{ .Values.database.port | quote }}
44
+ - name: RUBYPITAYA_DATABASE_PASSWORD
49
45
  value: {{ .Values.database.password | quote }}
50
- - name: HTTP_AUTH_ENABLED
51
- value: {{ .Values.http.enabled | quote }}
52
- - name: HTTP_AUTH_USER
53
- value: {{ .Values.http.user | quote }}
54
- - name: HTTP_AUTH_PASS
55
- value: {{ .Values.http.password | quote }}
46
+ - name: RUBYPITAYA_HTTP_AUTH_ENABLED
47
+ value: {{ .Values.http.auth.enabled | quote }}
48
+ - name: RUBYPITAYA_HTTP_AUTH_USER
49
+ value: {{ .Values.http.auth.user | quote }}
50
+ - name: RUBYPITAYA_HTTP_AUTH_PASS
51
+ value: {{ .Values.http.auth.password | quote }}
56
52
  - name: MATCHMAKING_CURRENTROOMBLL
57
53
  value: kubernetes
58
54
  - name: MATCHMAKING_ROOMBLL_KUBERNETES_NAMESPACE
@@ -7,6 +7,8 @@ connector:
7
7
  tag: 0.2.0
8
8
 
9
9
  rubypitaya:
10
+ server:
11
+ environment: production
10
12
  image:
11
13
  repository: [metagame-repository-link]
12
14
  tag: latest
@@ -15,12 +17,14 @@ database:
15
17
  name: [database-name]
16
18
  host: [database-host]
17
19
  user: [database-user]
20
+ port: [database-port]
18
21
  password: [database-password]
19
22
 
20
23
  http:
21
- enabled: false
22
- user: user
23
- password: pass
24
+ auth:
25
+ user: 'user'
26
+ pass: 'pass'
27
+ enabled: 'false'
24
28
 
25
29
  gameserver:
26
30
  image:
@@ -22,27 +22,23 @@ spec:
22
22
  - containerPort: 4567
23
23
  name: rubypitaya
24
24
  env:
25
- - name: SERVER_NAME
26
- value: "rubypitaya"
27
- - name: RUBYPITAYA_ENV
25
+ - name: RUBYPITAYA_SERVER_ENVIRONMENT
28
26
  value: "production"
29
- - name: NATS_URL
27
+ - name: RUBYPITAYA_NATS_URL
30
28
  value: "nats://nats.default.svc.cluster.local:4222"
31
- - name: ETCD_URL
29
+ - name: RUBYPITAYA_ETCD_URL
32
30
  value: "http://etcd.default.svc.cluster.local:2379"
33
- - name: ETCD_PREFIX
34
- value: "rubypitaya/"
35
- - name: ETCD_LEASE_SECONDS
36
- value: "60"
37
- - name: REDIS_URL
31
+ - name: RUBYPITAYA_REDIS_URL
38
32
  value: "redis://redis.default.svc.cluster.local:6379"
39
- - name: DATABASE_HOST
33
+ - name: RUBYPITAYA_DATABASE_HOST
40
34
  value: "postgres.default.svc.cluster.local"
41
- - name: DATABASE_USER
35
+ - name: RUBYPITAYA_DATABASE_USER
42
36
  value: "postgres"
43
- - name: DATABASE_PASSWORD
37
+ - name: RUBYPITAYA_DATABASE_PORT
38
+ value: "5432"
39
+ - name: RUBYPITAYA_DATABASE_PASSWORD
44
40
  value: "postgres"
45
- - name: DATABASE_NAME
41
+ - name: RUBYPITAYA_DATABASE_NAME
46
42
  value: "ruby_pitaya"
47
43
  imagePullSecrets:
48
44
  - name: gitlab-registry
@@ -3,10 +3,11 @@ require 'spec_helper'
3
3
  RSpec.describe 'PlayerHandler', type: :request do
4
4
  context 'authenticate' do
5
5
  it 'create_new_user' do
6
- setup = {'initial_player' => {'wallet' => {'gold' => 10}}}
7
- config = {'initial_player' => {'name' => 'Guest'}}
6
+ config = {'initial_player' => {
7
+ 'name' => 'Guest',
8
+ 'wallet' => {'gold' => 10},
9
+ }}
8
10
 
9
- set_setup(setup)
10
11
  set_config(config)
11
12
 
12
13
  params = {}
@@ -9,6 +9,7 @@ module RubyPitaya
9
9
  @config_core_override = nil
10
10
  @has_config_core_override = false
11
11
 
12
+ @empty_hash = {}
12
13
  @result_cache = {}
13
14
  end
14
15
 
@@ -28,6 +29,13 @@ module RubyPitaya
28
29
  result
29
30
  end
30
31
 
32
+ def fetch(*args)
33
+ result = self[args[0]]
34
+ return result unless result.nil?
35
+
36
+ @empty_hash.fetch(*args)
37
+ end
38
+
31
39
  def auto_reload
32
40
  @config_core.auto_reload
33
41
  @config_core_override.auto_reload unless @config_core_override.nil?
@@ -1,21 +1,30 @@
1
1
  require 'erb'
2
2
  require 'yaml'
3
3
 
4
- require 'rubypitaya/core/path'
4
+ require 'rubypitaya/core/setup'
5
5
 
6
6
  module RubyPitaya
7
7
 
8
8
  class DatabaseConfig
9
9
 
10
- def initialize(environment_name, database_config_path)
11
- @environment_name = environment_name
10
+ def initialize()
11
+ @setup = Setup.new
12
+
13
+ @config = {
14
+ 'adapter' => 'postgresql',
15
+ 'encoding' => 'unicode',
16
+ 'pool' => @setup.fetch('rubypitaya.database.pool', 5),
17
+ 'host' => @setup['rubypitaya.database.host'],
18
+ 'user' => @setup['rubypitaya.database.user'],
19
+ 'password' => @setup['rubypitaya.database.password'],
20
+ 'database' => @setup['rubypitaya.database.name'],
21
+ }
12
22
 
13
- yaml_contents = File.open(database_config_path).read
14
- @config = YAML.load( ERB.new(yaml_contents).result )
23
+ @config['database'] = "#{@config['database']}_test" if @environment_name == 'test'
15
24
  end
16
25
 
17
26
  def config
18
- @config[@environment_name]
27
+ @config
19
28
  end
20
29
 
21
30
  def connection_data
@@ -44,9 +53,5 @@ module RubyPitaya
44
53
  def database_name
45
54
  config['database']
46
55
  end
47
-
48
- def migrations_path
49
- @migrations_path
50
- end
51
56
  end
52
57
  end
@@ -3,8 +3,7 @@ require 'active_record'
3
3
  require 'rubypitaya/core/database_config'
4
4
 
5
5
  # Database connection
6
- environment_name = ENV.fetch("RUBYPITAYA_ENV") { 'development' }
7
- database_config = RubyPitaya::DatabaseConfig.new(environment_name, RubyPitaya::Path::DATABASE_CONFIG_PATH)
6
+ database_config = RubyPitaya::DatabaseConfig.new
8
7
  ActiveRecord::Base.establish_connection(database_config.connection_data)
9
8
  # ActiveRecord::Base.logger = ActiveSupport::Logger.new(STDOUT)
10
9
  # ActiveSupport::LogSubscriber.colorize_logging = true
@@ -1,13 +1,13 @@
1
1
  require 'sinatra/base'
2
- require 'sinatra/reloader' if ENV['RUBYPITAYA_ENV'] == 'development'
3
2
  require 'rubypitaya/core/parameters'
4
3
 
5
4
  module RubyPitaya
6
5
 
7
6
  class HttpRoutes < Sinatra::Base
8
7
 
9
- if ENV['RUBYPITAYA_ENV'] == 'development'
10
- register Sinatra::Reloader
8
+ def self.auto_reload
9
+ require 'sinatra/reloader'
10
+ register ::Sinatra::Reloader
11
11
  end
12
12
 
13
13
  helpers do
@@ -19,12 +19,12 @@ module RubyPitaya
19
19
  before do
20
20
  content_type :json
21
21
 
22
- return error_unauthorized unless authorized?(request)
23
-
24
22
  @bll = settings.bll
25
23
  @setup = settings.setup
26
24
  @config = settings.config
27
25
 
26
+ return error_unauthorized unless authorized?(request)
27
+
28
28
  @config.clear_cache
29
29
 
30
30
  if request.content_type == 'application/json'
@@ -49,12 +49,12 @@ module RubyPitaya
49
49
  end
50
50
 
51
51
  def http_auth_enabled?
52
- return ENV.fetch("HTTP_AUTH_ENABLED") { 'false' } == 'true'
52
+ return @setup.fetch('rubypitaya.http.auth.enabled') { 'false' } == 'true'
53
53
  end
54
54
 
55
55
  def get_http_auth
56
- user = ENV.fetch("HTTP_AUTH_USER") { '' }
57
- pass = ENV.fetch("HTTP_AUTH_PASS") { '' }
56
+ user = @setup.fetch('rubypitaya.http.auth.user') { '' }
57
+ pass = @setup.fetch('rubypitaya.http.auth.pass') { '' }
58
58
 
59
59
  auth_token = ::Base64.strict_encode64("#{user}:#{pass}")
60
60
 
@@ -30,8 +30,10 @@ module RubyPitaya
30
30
  attr_reader :redis_connector, :config, :bll
31
31
 
32
32
  def initialize
33
- @environment_name = ENV.fetch("RUBYPITAYA_ENV") { 'development' }
33
+ @setup = Setup.new
34
+ @environment_name = @setup.fetch('rubypitaya.server.environment', 'development')
34
35
  @is_development_environment = @environment_name == 'development'
36
+ @setup.auto_reload if @is_development_environment
35
37
 
36
38
  @log = Logger.new('/proc/self/fd/1')
37
39
  @log.level = Logger::INFO
@@ -43,13 +45,13 @@ module RubyPitaya
43
45
  @application_files_importer.import
44
46
  @application_files_importer.auto_reload if @is_development_environment
45
47
 
46
- @server_name = ENV['SERVER_NAME']
48
+ @server_name = @setup['rubypitaya.server.name']
47
49
  @service_uuid = SecureRandom.uuid
48
50
  @desktop_name = Socket.gethostname
49
51
 
50
- @etcd_prefix = ENV['ETCD_PREFIX']
51
- @etcd_address = ENV['ETCD_URL']
52
- @etcd_lease_seconds = ENV['ETCD_LEASE_SECONDS'].to_i
52
+ @etcd_prefix = @setup['rubypitaya.etcd.prefix']
53
+ @etcd_address = @setup['rubypitaya.etcd.url']
54
+ @etcd_lease_seconds = @setup['rubypitaya.etcd.leaseSeconds'].to_i
53
55
  @allow_reconnect = false
54
56
  @etcd_connector = EtcdConnector.new(@service_uuid, @desktop_name,
55
57
  @server_name, @etcd_prefix,
@@ -57,15 +59,15 @@ module RubyPitaya
57
59
  @etcd_lease_seconds)
58
60
  @etcd_connector.connect
59
61
 
60
- @nats_address = ENV['NATS_URL']
62
+ @nats_address = @setup['rubypitaya.nats.url']
61
63
  @nats_connector = NatsConnector.new(@nats_address, @service_uuid,
62
64
  @server_name)
63
65
 
64
- @redis_address = ENV['REDIS_URL']
66
+ @redis_address = @setup['rubypitaya.redis.url']
65
67
  @redis_connector = RedisConnector.new(@redis_address)
66
68
  @redis_connector.connect
67
69
 
68
- @database_config = DatabaseConfig.new(@environment_name, Path::DATABASE_CONFIG_PATH)
70
+ @database_config = DatabaseConfig.new
69
71
  @database_connector = DatabaseConnector.new(@database_config)
70
72
  @database_connector.connect
71
73
 
@@ -73,8 +75,6 @@ module RubyPitaya
73
75
  @postman = Postman.new(@nats_connector)
74
76
  @config = Config.new
75
77
  @config.auto_reload if @is_development_environment
76
- @setup = Setup.new
77
- @setup.auto_reload if @is_development_environment
78
78
 
79
79
  @bll = InstanceHolder.new
80
80
 
@@ -101,6 +101,8 @@ module RubyPitaya
101
101
  HttpRoutes.set :config, @config
102
102
  HttpRoutes.set :views, [Path::HTTP_VIEWS_PATH] + Path::Plugins::HTTP_VIEWS_PATHS
103
103
 
104
+ HttpRoutes.auto_reload if @is_development_environment
105
+
104
106
  Thread.new do
105
107
  HttpRoutes.bind = '0.0.0.0'
106
108
  HttpRoutes.port = '4567'
@@ -4,8 +4,6 @@ module RubyPitaya
4
4
  APP_TEMPLATE_FOLDER_PATH = File.join(__dir__, '../app-template/')
5
5
  MIGRATION_TEMPLATE_PATH = File.join(__dir__, 'templates/template_migration.rb.erb')
6
6
 
7
- DATABASE_CONFIG_PATH = File.join(Dir.pwd, 'config/database.yml')
8
-
9
7
  APP_FOLDER_PATH = File.join(Dir.pwd, 'app/')
10
8
  HANDLERS_FOLDER_PATH = File.join(Dir.pwd, 'app/handlers/')
11
9
  APP_CONFIG_FOLDER_PATH = File.join(Dir.pwd, 'app/config/')
@@ -1,9 +1,12 @@
1
+ require 'rubypitaya/core/path'
2
+
1
3
  module RubyPitaya
2
4
 
3
5
  class Setup
4
6
 
5
7
  def initialize()
6
8
  @config = {}
9
+ @empty_hash = {}
7
10
  configs_folder_paths = Path::Plugins::APP_SETUP_FOLDER_PATHS + [Path::APP_SETUP_FOLDER_PATH]
8
11
 
9
12
  configs_folder_paths.each do |configs_folder_path|
@@ -24,6 +27,13 @@ module RubyPitaya
24
27
  @config.dig(*split_key)
25
28
  end
26
29
 
30
+ def fetch(*args)
31
+ result = self[args[0]]
32
+ return result unless result.nil?
33
+
34
+ @empty_hash.fetch(*args)
35
+ end
36
+
27
37
  def auto_reload
28
38
  require 'listen'
29
39
 
@@ -1,3 +1,4 @@
1
+ require 'rubypitaya/core/setup'
1
2
  require 'rubypitaya/core/handler_router'
2
3
  require 'rubypitaya/core/redis_connector'
3
4
  require 'rubypitaya/core/spec-helpers/setup_spec_helper'
@@ -96,7 +97,8 @@ module RubyPitaya
96
97
  @@redis_connector ||= nil
97
98
 
98
99
  if @@redis_connector.nil?
99
- redis_address = ENV['REDIS_URL']
100
+ @@core_setup ||= Setup.new
101
+ redis_address = @@core_setup['rubypitaya.redis.url']
100
102
  @@redis_connector = RedisConnector.new(redis_address)
101
103
  @@redis_connector.connect
102
104
  end
@@ -1,3 +1,3 @@
1
1
  module RubyPitaya
2
- VERSION = '2.20.0'
2
+ VERSION = '2.21.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.20.0
4
+ version: 2.21.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-04-21 00:00:00.000000000 Z
11
+ date: 2021-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.11.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: mongo
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 2.15.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 2.15.0
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: redis
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -246,9 +260,8 @@ files:
246
260
  - "./lib/rubypitaya/app-template/app/http/views/hello_world.erb"
247
261
  - "./lib/rubypitaya/app-template/app/models/player.rb"
248
262
  - "./lib/rubypitaya/app-template/app/models/user.rb"
249
- - "./lib/rubypitaya/app-template/app/setup/initial_player.yml"
263
+ - "./lib/rubypitaya/app-template/app/setup/rubypitaya.yml"
250
264
  - "./lib/rubypitaya/app-template/bin/console"
251
- - "./lib/rubypitaya/app-template/config/database.yml"
252
265
  - "./lib/rubypitaya/app-template/config/routes.rb"
253
266
  - "./lib/rubypitaya/app-template/db/migration/1606736477_create_player_migration.rb"
254
267
  - "./lib/rubypitaya/app-template/docker-compose.yml"
@@ -1,2 +0,0 @@
1
- wallet:
2
- gold: 10
@@ -1,20 +0,0 @@
1
- default: &default
2
- adapter: postgresql
3
- encoding: unicode
4
- pool: <%= ENV['RUBYPITAYA_MAX_THREADS'] { 5 } %>
5
- host: <%= ENV['DATABASE_HOST'] %>
6
- user: <%= ENV['DATABASE_USER'] %>
7
- password: <%= ENV['DATABASE_PASSWORD'] %>
8
-
9
- development:
10
- <<: *default
11
- database: <%= "#{ENV['DATABASE_NAME']}" %>
12
-
13
- test:
14
- <<: *default
15
- database: <%= "#{ENV['DATABASE_NAME']}_test" %>
16
-
17
- production:
18
- <<: *default
19
- database: <%= "#{ENV['DATABASE_NAME']}" %>
20
-