krakenlab 2018.01.10dev1 → 2018.01.14dev
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kraken/constants/project.rb +11 -3
- data/lib/kraken/core/config.rb +18 -3
- data/lib/kraken/models/db.rb +19 -12
- data/lib/kraken/models/model.rb +1 -1
- data/lib/kraken/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d21d0ba7e343c212f5a87e9d6eb416c3f0b1325
|
4
|
+
data.tar.gz: 6779c00d9f77ef162ba9e189c6ef9e13d1c75d04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4afe50eefebd76ecd253f2bf7b78679fef498b8271b6b10cbdc4e7ddb2aeb6e8953a781c23c3a6bfcd5196906344477880f92b33648ea1da93f5c558488afd7
|
7
|
+
data.tar.gz: db1817286a8f184253fbcd472efec950f887612d8a4c8558430905b92886acadae121cd8ae6bf80eb452dee9597628bc950a04388eaa4b56bc5f2f7da690fc6a
|
@@ -1,11 +1,12 @@
|
|
1
1
|
module Kraken
|
2
2
|
APP_FILE = "require 'yaml'\n
|
3
3
|
Kraken::Config.instance.setup do |config|
|
4
|
+
config.database static_env: 'development', redis_url: nil
|
4
5
|
config.server name: 'app name', version: '1.0', handler: :godot_30
|
5
6
|
config.add_trigger klass: Kraken::Trigger
|
6
7
|
end\n
|
7
8
|
Kraken::Migrations.configure do |c|
|
8
|
-
c.schema_format = :
|
9
|
+
c.schema_format = :sql
|
9
10
|
c.db_dir = 'db'
|
10
11
|
c.yaml_config = 'config/db.yml'
|
11
12
|
c.migrations_paths = ['db/migrate']
|
@@ -19,9 +20,16 @@ end
|
|
19
20
|
end
|
20
21
|
end".freeze
|
21
22
|
|
22
|
-
DB_FILE = "
|
23
|
+
DB_FILE = "development:
|
23
24
|
adapter: postgresql
|
24
|
-
database:
|
25
|
+
database: kraken_dev
|
26
|
+
encoding: utf8
|
27
|
+
host: localhost
|
28
|
+
username: postgres
|
29
|
+
password: postgres
|
30
|
+
test:
|
31
|
+
adapter: postgresql
|
32
|
+
database: kraken_test
|
25
33
|
encoding: utf8
|
26
34
|
host: localhost
|
27
35
|
username: postgres
|
data/lib/kraken/core/config.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
require 'singleton'
|
2
|
+
require 'kraken/models/db'
|
2
3
|
|
3
4
|
module Kraken
|
4
5
|
# Configure the kraken framework.
|
5
|
-
#
|
6
|
-
# You can configure the events in server.
|
6
|
+
# Configure triggers, database and server settings
|
7
7
|
# Yes! You can configure other plugins here!
|
8
8
|
#
|
9
9
|
# Kraken::Config.instance.setup do |config|
|
10
|
-
# config.server name: '
|
10
|
+
# config.server name: 'kraken app', version: 'valid version', handler: :default
|
11
|
+
# config.database static_env: 'test', redis_url: nil
|
11
12
|
# end
|
12
13
|
class Config
|
13
14
|
include Singleton
|
@@ -28,6 +29,12 @@ module Kraken
|
|
28
29
|
@server_handler = handler
|
29
30
|
end
|
30
31
|
|
32
|
+
def database(static_env: nil, static_hash: nil, redis_url: nil)
|
33
|
+
Kraken::Db.load_active_record_config_from_env(static_env) unless static_env.nil?
|
34
|
+
Kraken::Db.load_active_record_config_from_hash(static_hash) unless static_hash.nil?
|
35
|
+
Kraken::Db.load_redis_config(redis_url)
|
36
|
+
end
|
37
|
+
|
31
38
|
def add_trigger(klass: Kraken::Trigger)
|
32
39
|
raise 'Klass needs to inherit Kraken::Trigger' unless klass <= Kraken::Trigger
|
33
40
|
|
@@ -35,5 +42,13 @@ module Kraken
|
|
35
42
|
@triggers[klass.to_s.downcase] = klass
|
36
43
|
Kraken::Log.info "trigger [#{klass.to_s.downcase}] loaded"
|
37
44
|
end
|
45
|
+
|
46
|
+
def add_namespace(namespace: nil)
|
47
|
+
return if namespace.nil?
|
48
|
+
namespace.constants.select do |free_consts|
|
49
|
+
const = namespace.const_get(free_consts)
|
50
|
+
add_trigger(klass: const) if const <= Kraken::Trigger && const.is_a?(Class)
|
51
|
+
end
|
52
|
+
end
|
38
53
|
end
|
39
54
|
end
|
data/lib/kraken/models/db.rb
CHANGED
@@ -1,24 +1,31 @@
|
|
1
|
+
require 'pg'
|
1
2
|
require 'ohm'
|
2
3
|
require 'yaml'
|
3
4
|
require 'active_record'
|
4
5
|
require 'active_record_migrations'
|
5
6
|
|
6
|
-
# In db.rb file has some definitions to warp modules from other gens to Kraken framework.
|
7
7
|
module Kraken
|
8
8
|
StaticModel = ActiveRecord::Base
|
9
|
-
Migration = ActiveRecord::Migration
|
10
9
|
Migrations = ActiveRecordMigrations
|
11
10
|
|
12
|
-
|
11
|
+
# This class made some configurations in database
|
12
|
+
class Db
|
13
|
+
class << self
|
14
|
+
# Use a ActiveRecord yml file
|
15
|
+
def load_active_record_config_from_env(category)
|
16
|
+
Kraken::StaticModel.establish_connection(YAML.safe_load(File.read('config/db.yml'))[category])
|
17
|
+
end
|
13
18
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
# Use a hash to configure ActiveRecord
|
20
|
+
def load_active_record_config_from_hash(hash)
|
21
|
+
Kraken::StaticModel.establish_connection(hash)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Configure the redis configuration!
|
25
|
+
def load_redis_config(url)
|
26
|
+
Ohm.redis = Redic.new if url.nil?
|
27
|
+
Ohm.redis = Redic.new unless url.nil?
|
28
|
+
end
|
29
|
+
end
|
23
30
|
end
|
24
31
|
end
|
data/lib/kraken/models/model.rb
CHANGED
data/lib/kraken/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: krakenlab
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2018.01.
|
4
|
+
version: 2018.01.14dev
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marlon Henry Schweigert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_record_migrations
|
@@ -367,7 +367,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
367
367
|
version: 1.3.1
|
368
368
|
requirements: []
|
369
369
|
rubyforge_project:
|
370
|
-
rubygems_version: 2.6.
|
370
|
+
rubygems_version: 2.6.13
|
371
371
|
signing_key:
|
372
372
|
specification_version: 4
|
373
373
|
summary: Kraken Distribuited MMO Framework.
|