whiskey 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +24 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +8 -0
- data/CHANGELOG.md +9 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +74 -0
- data/ROADMAP.md +13 -0
- data/Rakefile +24 -0
- data/bin/whiskey +17 -0
- data/lib/whiskey.rb +16 -0
- data/lib/whiskey/command.rb +30 -0
- data/lib/whiskey/command/build.rb +89 -0
- data/lib/whiskey/command/start_server.rb +15 -0
- data/lib/whiskey/command/templates/Gemfile +10 -0
- data/lib/whiskey/command/templates/LICENSE.txt +22 -0
- data/lib/whiskey/command/templates/Procfile +1 -0
- data/lib/whiskey/command/templates/Thorfile +4 -0
- data/lib/whiskey/command/templates/db/seed.rb +15 -0
- data/lib/whiskey/command/templates/gitignore +17 -0
- data/lib/whiskey/command/templates/lib/action.rb +3 -0
- data/lib/whiskey/command/templates/lib/controls.rb +7 -0
- data/lib/whiskey/command/templates/lib/controls/router_control.rb +19 -0
- data/lib/whiskey/command/templates/lib/controls/world_control.rb +6 -0
- data/lib/whiskey/command/templates/lib/example.rb +7 -0
- data/lib/whiskey/command/templates/lib/models.rb +3 -0
- data/lib/whiskey/command/templates/lib/models/account.rb +6 -0
- data/lib/whiskey/command/templates/lib/models/actor.rb +6 -0
- data/lib/whiskey/command/templates/lib/models/place.rb +6 -0
- data/lib/whiskey/command/templates/ruby-gemset +1 -0
- data/lib/whiskey/command/templates/ruby-version +1 -0
- data/lib/whiskey/command/templates/server.rb +20 -0
- data/lib/whiskey/server.rb +81 -0
- data/lib/whiskey/server/action.rb +22 -0
- data/lib/whiskey/server/configuration.rb +9 -0
- data/lib/whiskey/server/connection.rb +51 -0
- data/lib/whiskey/server/control.rb +33 -0
- data/lib/whiskey/server/cycle.rb +35 -0
- data/lib/whiskey/server/deserializer.rb +21 -0
- data/lib/whiskey/server/error.rb +79 -0
- data/lib/whiskey/server/handler.rb +17 -0
- data/lib/whiskey/server/interpretor.rb +32 -0
- data/lib/whiskey/server/receiver.rb +19 -0
- data/lib/whiskey/server/responder.rb +19 -0
- data/lib/whiskey/server/router.rb +45 -0
- data/lib/whiskey/server/serializer.rb +22 -0
- data/lib/whiskey/version.rb +3 -0
- data/spec/lib/command/build_spec.rb +5 -0
- data/spec/lib/command/start_server_spec.rb +5 -0
- data/spec/lib/command_spec.rb +5 -0
- data/spec/lib/server/configuration_spec.rb +5 -0
- data/spec/lib/server/connection_spec.rb +43 -0
- data/spec/lib/server/cycle_spec.rb +23 -0
- data/spec/lib/server/deserializer_spec.rb +11 -0
- data/spec/lib/server/error_spec.rb +5 -0
- data/spec/lib/server/handler_spec.rb +5 -0
- data/spec/lib/server/interpretor_spec.rb +5 -0
- data/spec/lib/server/receiver_spec.rb +5 -0
- data/spec/lib/server/responder_spec.rb +15 -0
- data/spec/lib/server/serializer_spec.rb +11 -0
- data/spec/lib/server_spec.rb +31 -0
- data/spec/spec_helper.rb +9 -0
- data/test/lib/whiskey/server/connection_test.rb +42 -0
- data/test/lib/whiskey/server/cycle_test.rb +16 -0
- data/test/lib/whiskey/server/handler_test.rb +18 -0
- data/whiskey.gemspec +39 -0
- metadata +383 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a2088c079d3067b82297aeed166800c22a74331a
|
4
|
+
data.tar.gz: 08a400becd9045f5e182236cf91ca564037fd38b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a9a54201dc14352ede9bd6a2404470eb6480ef8e5e92f077970b3055817391bb8941238b41c89b1c399668711352e57ad81f01fa5bc2a9d68efe0450773da43a
|
7
|
+
data.tar.gz: 5b283dedc0322323f9d541170df10f5971e8d51e4e5e4079184d996f8d51b5f5cca1e9425dba7118fef3898c93ad7563ce476de3ad9a9bf09ea38f8cd04e98d0
|
data/.gitignore
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
2
|
+
#
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
5
|
+
# git config --global core.excludesfile ~/.gitignore
|
6
|
+
|
7
|
+
# Ignore all of the generated gem stuff
|
8
|
+
/pkg
|
9
|
+
/*.gem
|
10
|
+
|
11
|
+
# Ignore bundler config
|
12
|
+
/.bundle
|
13
|
+
/Gemfile.lock
|
14
|
+
|
15
|
+
# Ignore all bundler caching
|
16
|
+
/vendor/cache
|
17
|
+
/vendor/ruby
|
18
|
+
|
19
|
+
# Ignore all tempfiles
|
20
|
+
/tmp
|
21
|
+
|
22
|
+
# Ignores that should be in the global gitignore
|
23
|
+
/coverage
|
24
|
+
/doc
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
whiskey
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.0.0-p247
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Kurtis Rainbolt-Greene
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
Whiskey
|
2
|
+
-------
|
3
|
+
|
4
|
+
- [![Gem Version](https://badge.fury.io/rb/whiskey.png)](https://rubygems.org/gems/whiskey)
|
5
|
+
- [![Code Quality](https://codeclimate.com/github/krainboltgreene/whiskey.png)](https://codeclimate.com/github/krainboltgreene/whiskey)
|
6
|
+
- [![Build Status](https://travis-ci.org/krainboltgreene/whiskey.png)](https://travis-ci.org/krainboltgreene/whiskey)
|
7
|
+
- [![Dependency Status](https://gemnasium.com/krainboltgreene/whiskey.png)](https://gemnasium.com/krainboltgreene/whiskey)
|
8
|
+
- [![Coverage Status](https://coveralls.io/repos/krainboltgreene/whiskey/badge.png?branch=master)](https://coveralls.io/r/krainboltgreene/whiskey)
|
9
|
+
|
10
|
+
Whiskey is a [MUTE][MUTE] Engine.
|
11
|
+
|
12
|
+
|
13
|
+
Using Whiskey
|
14
|
+
=============
|
15
|
+
|
16
|
+
Once you've installed Whiskey you can start your new server with:
|
17
|
+
|
18
|
+
``` bash
|
19
|
+
$ whiskey server start
|
20
|
+
```
|
21
|
+
|
22
|
+
If you want to start whiskey on a specific port you'll need to specify like this:
|
23
|
+
|
24
|
+
``` bash
|
25
|
+
$ whiskey server start [-p|--port] 4001
|
26
|
+
```
|
27
|
+
|
28
|
+
The server defaults to running in development mode, but you can can also specify:
|
29
|
+
|
30
|
+
``` bash
|
31
|
+
$ whiskey server start [-e|--environment] production
|
32
|
+
```
|
33
|
+
|
34
|
+
If you want Whiskey to run in the background specify with:
|
35
|
+
|
36
|
+
``` bash
|
37
|
+
$ whiskey server start [-b|--background]
|
38
|
+
```
|
39
|
+
|
40
|
+
Any changes you make to the code will require reloading the server so to kill
|
41
|
+
the running server:
|
42
|
+
|
43
|
+
``` bash
|
44
|
+
$ whiskey kill all
|
45
|
+
```
|
46
|
+
|
47
|
+
|
48
|
+
Installing Whiskey
|
49
|
+
==================
|
50
|
+
|
51
|
+
**Requirements**:
|
52
|
+
|
53
|
+
1. JVM 1.7+ (See [guide][JVMINSTALL])
|
54
|
+
2. JRuby 1.7+ (See [guide][JRUBYINSTALL])
|
55
|
+
3. Some Database (See [guide][DBINSTALL])
|
56
|
+
|
57
|
+
Install it using RubyGems:
|
58
|
+
|
59
|
+
$ gem install whiskey
|
60
|
+
|
61
|
+
Now you can create your first project with:
|
62
|
+
|
63
|
+
``` bash
|
64
|
+
$ whiskey build whiskey_project
|
65
|
+
```
|
66
|
+
|
67
|
+
Contributing
|
68
|
+
============
|
69
|
+
|
70
|
+
1. Fork it
|
71
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
72
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
73
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
74
|
+
5. Create new Pull Request
|
data/ROADMAP.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
1.0.0
|
2
|
+
-----
|
3
|
+
|
4
|
+
- Client DSL stuff here
|
5
|
+
- Controls & actions should be namespaced to the app
|
6
|
+
- We should let controls report to us, instead of finding them in object space
|
7
|
+
- Tests, yo
|
8
|
+
- Documentation, yo
|
9
|
+
- Logging system
|
10
|
+
- STDOUT logging
|
11
|
+
- File logging
|
12
|
+
- Testing framework
|
13
|
+
-
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
require "rspec/core/rake_task"
|
4
|
+
require "yard"
|
5
|
+
require "pry"
|
6
|
+
|
7
|
+
begin
|
8
|
+
Bundler.setup :default, :development
|
9
|
+
Bundler::GemHelper.install_tasks
|
10
|
+
rescue Bundler::BundlerError => error
|
11
|
+
$stderr.puts error.message
|
12
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
13
|
+
exit error.status_code
|
14
|
+
end
|
15
|
+
|
16
|
+
RSpec::Core::RakeTask.new(:spec)
|
17
|
+
|
18
|
+
desc "Generate all of the docs"
|
19
|
+
YARD::Rake::YardocTask.new do |config|
|
20
|
+
config.files = Dir["lib/**/*.rb"]
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "Default: run tests and generate docs"
|
24
|
+
task :default => [ :spec, :yard ]
|
data/bin/whiskey
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "thor"
|
4
|
+
require "whiskey/command"
|
5
|
+
|
6
|
+
@traces = Hash.new([])
|
7
|
+
|
8
|
+
# catcher = TracePoint.new(:call) do |point|
|
9
|
+
# if point.defined_class.to_s.include?("Whiskey")
|
10
|
+
# trace = { path: point.path, line: point.lineno, method: point.method_id, type: point.event, class: point.defined_class }
|
11
|
+
# puts "#{trace[:class]}##{trace[:method]} #{trace[:path].gsub(/^.+whiskey/, "whiskey")}:#{trace[:line]}"
|
12
|
+
# @traces[point.defined_class] = @traces[point.defined_class] << trace
|
13
|
+
# end
|
14
|
+
# end
|
15
|
+
|
16
|
+
# catcher.enable
|
17
|
+
Whiskey::Command.start
|
data/lib/whiskey.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require "active_record"
|
2
|
+
require "forwardable"
|
3
|
+
require "multi_json"
|
4
|
+
require "astruct"
|
5
|
+
require "logger"
|
6
|
+
|
7
|
+
require_relative "whiskey/version"
|
8
|
+
|
9
|
+
module Whiskey
|
10
|
+
def self.logger
|
11
|
+
@logger ||= Logger.new(STDOUT).tap do |log|
|
12
|
+
log.level = ENV["WHISKEY_ENVIRONMENT"] == "development" ? Logger::DEBUG : Logger::INFO
|
13
|
+
log.formatter = nil
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "thor"
|
2
|
+
require "whiskey"
|
3
|
+
require "active_support/core_ext"
|
4
|
+
require_relative "command/build"
|
5
|
+
require_relative "command/start_server"
|
6
|
+
|
7
|
+
module Whiskey
|
8
|
+
class Command < Thor
|
9
|
+
include Thor::Actions
|
10
|
+
|
11
|
+
attr_accessor :values
|
12
|
+
|
13
|
+
def self.source_root
|
14
|
+
File.join(File.dirname(__FILE__), "command", "templates")
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "build NAME", "Builds a new whiskey project from the scaffold"
|
18
|
+
def build(name)
|
19
|
+
@values = AltStruct.new
|
20
|
+
Build.new(self, name).call
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "server [start|stop]", "Starts the whiskey server up"
|
24
|
+
def server(switch)
|
25
|
+
case switch
|
26
|
+
when "start" then StartServer.new.call
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
module Whiskey
|
2
|
+
class Command < Thor
|
3
|
+
class Build
|
4
|
+
extend Forwardable
|
5
|
+
|
6
|
+
RUBIES = ["rbx", "jruby", "ruby-2.0.0"]
|
7
|
+
RUBIES_ASK = "Which Ruby do you want to use?\n\n\t- ruby-2.0.0\n\t- rubinius\n\t- jruby\n"
|
8
|
+
|
9
|
+
attr_reader :command, :name
|
10
|
+
|
11
|
+
def_delegator :@command, :empty_directory
|
12
|
+
def_delegator :@command, :directory
|
13
|
+
def_delegator :@command, :template
|
14
|
+
def_delegator :@command, :inside
|
15
|
+
def_delegator :@command, :run
|
16
|
+
def_delegator :@command, :ask
|
17
|
+
def_delegator :@command, :say
|
18
|
+
|
19
|
+
def initialize(command, name)
|
20
|
+
@command = command
|
21
|
+
@name = @command.values.name = name
|
22
|
+
end
|
23
|
+
|
24
|
+
def call
|
25
|
+
create_root
|
26
|
+
setup_root
|
27
|
+
setup_server
|
28
|
+
setup_db
|
29
|
+
setup_ruby
|
30
|
+
run("git init")
|
31
|
+
say("You should now run: bundle install")
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def create_root
|
37
|
+
empty_directory(name)
|
38
|
+
command.destination_root = name
|
39
|
+
end
|
40
|
+
|
41
|
+
def setup_ruby
|
42
|
+
@command.values.ruby = ask(RUBIES_ASK, limit_to: RUBIES)
|
43
|
+
template("ruby-version", ".ruby-version")
|
44
|
+
template("ruby-gemset", ".ruby-gemset")
|
45
|
+
end
|
46
|
+
|
47
|
+
def setup_root
|
48
|
+
template("Gemfile")
|
49
|
+
template("gitignore", ".gitignore")
|
50
|
+
template("LICENSE.txt")
|
51
|
+
template("Thorfile")
|
52
|
+
template("Procfile")
|
53
|
+
template("server.rb")
|
54
|
+
empty_directories("script", "log", "tmp", "doc")
|
55
|
+
end
|
56
|
+
|
57
|
+
def empty_directories(*directories)
|
58
|
+
directories.each { |directory| empty_directory directory }
|
59
|
+
end
|
60
|
+
|
61
|
+
def setup_server
|
62
|
+
inside("lib") do
|
63
|
+
template("example.rb", "#{name}.rb")
|
64
|
+
template("models.rb")
|
65
|
+
template("action.rb")
|
66
|
+
template("controls.rb")
|
67
|
+
setup_models
|
68
|
+
setup_controls
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def setup_models
|
73
|
+
directory("models")
|
74
|
+
end
|
75
|
+
|
76
|
+
def setup_controls
|
77
|
+
directory("controls")
|
78
|
+
end
|
79
|
+
|
80
|
+
def setup_db
|
81
|
+
inside("db") do
|
82
|
+
# if persistence == activerecord
|
83
|
+
empty_directory("migrations")
|
84
|
+
template("seed.rb")
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Whiskey
|
2
|
+
class Command < Thor
|
3
|
+
class StartServer
|
4
|
+
def initialize(host = nil, port = nil, environment = "development")
|
5
|
+
ENV["WHISKEY_HOST"] = host
|
6
|
+
ENV["WHISKEY_PORT"] = port
|
7
|
+
ENV["WHISKEY_ENVIRONMENT"] = environment
|
8
|
+
end
|
9
|
+
|
10
|
+
def call
|
11
|
+
load File.join(Dir.pwd, "server.rb")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
source "https://rubygems.org"
|
3
|
+
|
4
|
+
gem "whiskey", "<%= Whiskey::VERSION %>", github: "krainboltgreene/whiskey"
|
5
|
+
|
6
|
+
gem "sqlite3", "~> 1.3"
|
7
|
+
# gem "pg", "~> 0.14"
|
8
|
+
# gem "mysql2", "~> 0.3"
|
9
|
+
# gem "redis", "~> 3.0"
|
10
|
+
# gem "dalli", "~> 2.6"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 YOUR NAME HERE
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1 @@
|
|
1
|
+
mute: bundle exec whiskey server
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# This is where you'll place any logic that boots up your instance from scratch
|
2
|
+
|
3
|
+
introduction = Document.create do |doc|
|
4
|
+
doc.title = "Introduction"
|
5
|
+
doc.body = """
|
6
|
+
Welcome to <%= values.name.camelize %> a new MUTE!
|
7
|
+
|
8
|
+
To make an account here simply type:
|
9
|
+
|
10
|
+
account create a_suitable_username a_suitable_password
|
11
|
+
|
12
|
+
To login to your account type:
|
13
|
+
|
14
|
+
account access a_suitable_username a_suitable_password
|
15
|
+
"""
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
2
|
+
#
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
5
|
+
# git config --global core.excludesfile ~/.gitignore
|
6
|
+
|
7
|
+
# Ignore all bundler caching
|
8
|
+
/vendor/cache
|
9
|
+
/vendor/ruby
|
10
|
+
|
11
|
+
# Ignore all tempfiles
|
12
|
+
/tmp
|
13
|
+
|
14
|
+
# Ignores that should be in the global gitignore
|
15
|
+
/coverage/
|
16
|
+
/doc/
|
17
|
+
/log/
|