krakenlab 2018.01.07

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b3ab05e5732c687e312e0f4c91c347583f3334fd
4
+ data.tar.gz: 7679574d57d64ab362f6c67b14ba5a4a9cfdc0be
5
+ SHA512:
6
+ metadata.gz: 69220696053c6d378c78eff7134c6a46375d590f8fc17b4bd564ef7b15908c133e7f5a95a19e960703147ee1f0100f195e41156f93318b7c8409b288dfc82a28
7
+ data.tar.gz: 4be8944ca7f59fb56badb2baf27d16b660c1c402b4a87d090c1da8c76ddbb30d555775c2efedc79da2684bbd0695f36b1d1ef1fed98138f3410c57307c98a0bd
@@ -0,0 +1,3 @@
1
+ *.lock
2
+ *.gem
3
+ .rake_tasks~
@@ -0,0 +1,11 @@
1
+ all:
2
+ exclude:
3
+ - 'spec/**/*'
4
+
5
+ github:
6
+ slug: krakenlab/kraken
7
+ api_endpoint: https://api.github.com/
8
+ web_endpoint: https://github.com/
9
+
10
+ max_warnings: 150
11
+ verbose: true
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format documentation
3
+ --require spec_helper
@@ -0,0 +1,51 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2017-09-15 11:07:31 -0300 using RuboCop version 0.49.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 21
10
+ Metrics/AbcSize:
11
+ Max: 24
12
+
13
+ # Offense count: 7
14
+ # Configuration parameters: CountComments, ExcludedMethods.
15
+ Metrics/BlockLength:
16
+ Max: 39
17
+
18
+ # Offense count: 2
19
+ # Configuration parameters: CountComments.
20
+ Metrics/ClassLength:
21
+ Max: 112
22
+
23
+ # Offense count: 15
24
+ # Configuration parameters: CountComments.
25
+ Metrics/MethodLength:
26
+ Max: 14
27
+
28
+ # Offense count: 1
29
+ # Configuration parameters: CountComments.
30
+ Metrics/ModuleLength:
31
+ Max: 106
32
+
33
+ Metrics/LineLength:
34
+ Max: 130
35
+
36
+ Style/FormatStringToken:
37
+ Enabled: false
38
+
39
+ Metrics/BlockLength:
40
+ Max: 50
41
+ Exclude:
42
+ - 'Rakefile'
43
+ - '**/*.rake'
44
+ - '**/*_spec.rb'
45
+ - '*.gemspec'
46
+
47
+ Style/ClassVars:
48
+ Enabled: false
49
+
50
+ Performance/HashEachMethods:
51
+ Enabled: false
@@ -0,0 +1,19 @@
1
+ language: ruby
2
+
3
+ sudo: true
4
+
5
+ services:
6
+ - redis-server
7
+ - postgresql
8
+
9
+ before_install:
10
+ - sudo apt-get update -qq
11
+ - sudo apt-get install -y postgresql-server-dev-all
12
+
13
+ rvm:
14
+ - 2.4.1
15
+
16
+ script:
17
+ - 'export PRONTO_PULL_REQUEST_ID=${TRAVIS_PULL_REQUEST} && bundle exec pronto run -f github_pr -c origin/${TRAVIS_BRANCH}'
18
+ - bundle exec rspec
19
+ - bundle exec danger
@@ -0,0 +1,57 @@
1
+ # MESSAGE CHECKLIST
2
+
3
+ message = <<-MESSAGE
4
+ ## Hello, hitchhiker. Not that anyone cares about what I say, but please, ensure you did check these things:
5
+
6
+ - [ ] Run all tests locally
7
+ - [ ] If you introduced front-end changes, are there desktop and mobile screenshots attached?
8
+ - [ ] Review the added i18n texts and ensure you added i18n keys for all needed cases
9
+ - [ ] Do manual tests in the pages affected by the changes you're introducing in this PR
10
+ - [ ] Fix all FIXME and remove all TODO comments
11
+
12
+ MESSAGE
13
+
14
+ markdown(message)
15
+
16
+ # GIT & GITHUB
17
+
18
+ ## Make it more obvious that a pr is a work in progress and shouldn't be merged yet
19
+ warn('PR is classed as Work in Progress') if github.pr_title.include?('WIP')
20
+
21
+ ## Warn when there is a big pr
22
+ warn('Big PR') if git.lines_of_code > 500
23
+
24
+ ## If these are all empty something has gone wrong, better to raise it in a comment
25
+ if git.modified_files.empty? && git.added_files.empty? && git.deleted_files.empty?
26
+ raise('This PR has no changes at all, this is likely an issue during development.')
27
+ end
28
+
29
+ # DATABASE
30
+
31
+ added_migration = git.added_files.include?('db/migrate/*.rb')
32
+ has_schema_changes = git.modified_files.include?('db/schema.rb')
33
+
34
+ ## Added migrations and didn't update schema.rb
35
+ if added_migration && !has_schema_changes
36
+ warn('Run `db:migrate` and commit changes of `schema.rb` file!')
37
+ end
38
+
39
+ # TODOS
40
+
41
+ todoist.warn_for_todos
42
+ todoist.print_todos_table
43
+
44
+ # TESTS
45
+
46
+ has_app_changes = !git.modified_files.grep(/(lib|app)/).empty?
47
+ has_test_changes = !git.modified_files.grep(/(spec|test)/).empty?
48
+
49
+ ## Changed the code, but didn't added or updated a test case?
50
+ if has_app_changes && !has_test_changes
51
+ message = <<-MESSAGE
52
+ I think you ought to know I'm feeling very depressed with the fact that you didn't add any test case.
53
+ That's OK as long as you're refactoring existing code.
54
+ MESSAGE
55
+
56
+ warn(message.strip)
57
+ end
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in kraken.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Marlon Henry Schweigert & KrakenLab
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,156 @@
1
+ [![Build Status](https://travis-ci.org/KrakenLab/kraken.svg?branch=master)](https://travis-ci.org/KrakenLab/kraken)
2
+ [![Codacy Badge](https://api.codacy.com/project/badge/Grade/518f7a2f6a2f43bf9002b75ceff439a6)](https://www.codacy.com/app/Schweigert/kraken?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=KrakenLab/kraken&amp;utm_campaign=Badge_Grade)
3
+ [![Gem Version](https://badge.fury.io/rb/krakenlab.svg)](https://badge.fury.io/rb/krakenlab)
4
+ [![Code Triagers Badge](https://www.codetriage.com/krakenlab/kraken/badges/users.svg)](https://www.codetriage.com/krakenlab/kraken)
5
+ [![Dependency Status](https://beta.gemnasium.com/badges/github.com/KrakenLab/kraken.svg)](https://beta.gemnasium.com/projects/github.com/KrakenLab/kraken)
6
+
7
+ # Welcome to Kraken!
8
+
9
+ Kraken is a mmo server framework that includes everything needed to create database-backed according to the Model-View-Controller (MVC) pattern over a distribuited redis network.
10
+
11
+ It's works with:
12
+ - Redis, to distribute game data over all nodes in network.
13
+ - Postgre, To save all permanent data.
14
+
15
+ Applications developed with kraken have 4 pillars:
16
+ - Db instances, saved on Postgre. Database instances are organized by ActiveRecord.
17
+ - Model instances, saved over a Redis Cloud. Model instances are organized by Ohm, a Mapper to redis.
18
+ - Triggers and Callbacks, to made the Remote Call Procedure to server, organized by Kraken.
19
+
20
+ ## Model
21
+
22
+ `Model` are the first pillar from MVC pattern. But, in Kraken, Models are divided into memory and database instances.
23
+
24
+ The `Kraken::Db` is a shortcut to Active Record. You can write Db models to Sqlite, PostgreSQL, MySQL and others Db's.
25
+
26
+ On the other hand, `Kraken::Model` is a shortcut to Ohm mapper. It's write all data in redis-server.
27
+ Be careful! Redis has no garbage collection. Always write the `on_delete` method to garbage data on user disconnection. You can also use this method to write permanent game state updates to the database.
28
+
29
+ ## View
30
+
31
+ `View` are the second pillar from MVC pattern. In kraken, view are the callback of a trigger. It's are a simple data, a array or a hash! You do not need to worry about it! Just write the return! Kraken translates all this to you!
32
+
33
+ ```ruby
34
+ class Example < Kraken::Trigger
35
+ def run
36
+ puts params
37
+ @callback = [1,2,3,4,5]
38
+ end
39
+ end
40
+
41
+ Kraken::Config.instance.setup do |config|
42
+ config.add_trigger klass: Example
43
+ end
44
+ ```
45
+
46
+ ```ruby
47
+ require 'kraken/client'
48
+
49
+ a = Kraken::Client.new('user', 'pass')
50
+ a.connect('localhost', 3030)
51
+ a.call('example', {a: 'hehe'})
52
+ # => [1,2,3,4,5]
53
+ ```
54
+
55
+ ## Controller
56
+
57
+ The `controller` is the logical pillar from MVC! This is a Trigger! Triggers are events that can be triggered by a client, using some argument.
58
+
59
+ You must use the Models in the triggers to update the game states in Database, and use the callback to return and update the game on the client side.
60
+
61
+ # Installation
62
+
63
+ #### Postgre
64
+
65
+ ```bash
66
+ sudo apt-get install postgresql postgresql-contrib libpq-dev
67
+ ```
68
+
69
+ #### Redis
70
+
71
+ ```bash
72
+ cd /tmp
73
+ curl -O http://download.redis.io/redis-stable.tar.gz
74
+ tar xzvf redis-stable.tar.gz
75
+ cd redis-stable
76
+ make
77
+ sudo make install
78
+
79
+ sudo service redis start
80
+ ```
81
+
82
+ #### Kraken Framework
83
+
84
+ Install the kraken:
85
+ `$ gem install kraken`
86
+
87
+ Create a new KrakenApp:
88
+ `$ kraken -n app_name`
89
+
90
+ Use the `migrate.rb` to setup a fixed start database.
91
+
92
+ Add a config file in config path:
93
+
94
+ ```ruby
95
+ # config/config.rb
96
+ Kraken::Config.instance.setup do |config|
97
+ config.server name: 'new_app', handler: :default
98
+
99
+ config.add_trigger klass: Characters::Index
100
+ config.add_trigger klass: Characters::New
101
+ end
102
+ ```
103
+
104
+ and setup a new method authentication method:
105
+ ```ruby
106
+ #config/connection.rb
107
+ class Kraken::Connection < Kraken::Model
108
+ set :characters, :Character
109
+
110
+ attr_accessor :account
111
+ attr_accessor :cache
112
+
113
+ def on_delete
114
+ characters.each { |character| character.delete }
115
+ @cache.each_key { |key| @cach[key].delete }
116
+ end
117
+
118
+ # The standard is to allow everyone!
119
+ # Implement it!
120
+ def authenticate
121
+ @account = Db::Account.where(user: user).first
122
+ return false if account.nil?
123
+ return false unless account.user == user && account.pass == pass
124
+
125
+ @cache = {}
126
+
127
+ true
128
+ end
129
+ end
130
+
131
+ ```
132
+
133
+ and run this!: `kraken -s`
134
+
135
+ # Development
136
+
137
+ After checking out the repo, run `bundle install` to install dependencies. You can also run `rake console` for an interactive prompt that will allow you to experiment.
138
+
139
+ ## Version
140
+
141
+ As we release many stable versions for testing, and we price by incremental implementation, the only rule for the versions is: `Year.Month.Day`
142
+
143
+ # Contributing
144
+
145
+ Bug reports and pull requests are welcome on GitHub at https://github.com/KrakenLab/kraken.
146
+
147
+ Perform automated and manual testing using the console. Do not forget to check the style using `rubocop`.
148
+ We will help with possible problems in your PR '\\o/'!
149
+
150
+ ### contributors
151
+
152
+ - [Marlon Henry Schweigert](http://github.com/Schweigert)
153
+
154
+ # License
155
+
156
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,18 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'redis'
3
+
4
+ task default: :spec
5
+
6
+ task :console do
7
+ sh './bin/console'
8
+ end
9
+
10
+ task test: :dbreset do
11
+ sh 'pronto run'
12
+ sh 'bundle exec rspec'
13
+ end
14
+
15
+ task :dbreset do
16
+ db = Redis.new
17
+ db.keys.each { |key| db.del key }
18
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'kraken'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require 'pry'
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start(__FILE__)
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'require_all'
5
+ require 'kraken'
6
+
7
+ Kraken::App.create_app(ARGV.last) if ARGV.include? '-n'
8
+ Kraken::App.print_version if ARGV.include? '-v'
9
+ Kraken::App.print_help if ARGV.include?('-h') || ARGV.size.zero?
10
+
11
+ Kraken::App.load_app
12
+
13
+ Kraken::App.start_console if ARGV.include? '-d'
14
+ Kraken::App.start_server if ARGV.include? '-s'
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,46 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'kraken/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'krakenlab'
7
+ spec.version = Kraken::VERSION
8
+ spec.authors = ['Marlon Henry Schweigert']
9
+ spec.email = ['fleyhe0@gmail.com']
10
+
11
+ spec.summary = 'Kraken Distribuited MMO Framework.'
12
+ spec.description = 'A Easy way to project your MMO Server.'
13
+ spec.homepage = 'http://www.github.com/KrakenLab/kraken'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+
20
+ spec.bindir = 'bin'
21
+ spec.executables = ['kraken']
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.add_runtime_dependency 'active_record_migrations', '5.0.2.1'
25
+ spec.add_runtime_dependency 'activerecord', '~> 5.0', '>= 5.0.0.1'
26
+ spec.add_runtime_dependency 'logger'
27
+ spec.add_runtime_dependency 'ohm'
28
+ spec.add_runtime_dependency 'pg'
29
+ spec.add_runtime_dependency 'project_creator', '2018.1.1'
30
+ spec.add_runtime_dependency 'require_all', '1.5.0'
31
+
32
+ spec.add_development_dependency 'bundler', '~> 1.16'
33
+ spec.add_development_dependency 'danger'
34
+ spec.add_development_dependency 'danger-github_ext'
35
+ spec.add_development_dependency 'danger-simplecov_json'
36
+ spec.add_development_dependency 'danger-todoist'
37
+ spec.add_development_dependency 'faker'
38
+ spec.add_development_dependency 'pronto'
39
+ spec.add_development_dependency 'pronto-flay'
40
+ spec.add_development_dependency 'pronto-rubocop'
41
+ spec.add_development_dependency 'pry', '0.11.3'
42
+ spec.add_development_dependency 'rake', '12.3.0'
43
+ spec.add_development_dependency 'redis'
44
+ spec.add_development_dependency 'rspec', '3.7'
45
+ spec.add_development_dependency 'rubocop', '0.52.0'
46
+ end