krakenlab 2018.01.10dev1 → 2018.01.14dev

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
  SHA1:
3
- metadata.gz: 1110dd471c7f67e66bcf1ba1b3d1240bbdbe0e26
4
- data.tar.gz: c648d264140c8fedcc2dac8992f6ca4b9eabd0d1
3
+ metadata.gz: 8d21d0ba7e343c212f5a87e9d6eb416c3f0b1325
4
+ data.tar.gz: 6779c00d9f77ef162ba9e189c6ef9e13d1c75d04
5
5
  SHA512:
6
- metadata.gz: 1f0d61d8fb936165bbae25af717c7bf8b05812ca4e42a6006ffd08931a3e2043f3c709838734c741e945dab1d1eb388064b2460734cf65514148d042de7fef63
7
- data.tar.gz: 93fc1bc7bd5a7060404fbb82f9cf41ff98274dbc5e8d8fb7fe441a3f997d114bd49215333c5144b01012f60762e30773f797cb6aa290cca7148d471b476fef7e
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 = :ruby
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 = "server:
23
+ DB_FILE = "development:
23
24
  adapter: postgresql
24
- database: kraken
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
@@ -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
- # You can configure the server, postgre and redis.
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: 'hehe'
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
@@ -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
- Ohm.redis = Redic.new
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
- if File.exist? 'db/config.yml'
15
- Kraken::StaticModel.establish_connection(YAML.safe_load(File.read('config/db.yml'))['development'])
16
- else
17
- Kraken::StaticModel.establish_connection(adapter: 'postgresql',
18
- database: 'kraken',
19
- host: 'localhost',
20
- port: '5432',
21
- username: 'postgres',
22
- password: 'postgres')
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
@@ -20,6 +20,6 @@ module Kraken
20
20
  super()
21
21
  end
22
22
 
23
- def on_delete(); end
23
+ def on_delete; end
24
24
  end
25
25
  end
@@ -1,3 +1,3 @@
1
1
  module Kraken
2
- VERSION = '2018.01.10dev1'.freeze
2
+ VERSION = '2018.01.14dev'.freeze
3
3
  end
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.10dev1
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-09 00:00:00.000000000 Z
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.14
370
+ rubygems_version: 2.6.13
371
371
  signing_key:
372
372
  specification_version: 4
373
373
  summary: Kraken Distribuited MMO Framework.