Skip to content

Commit

Permalink
Finalizing movement
Browse files Browse the repository at this point in the history
  • Loading branch information
Kurtis Rainbolt-Greene committed Nov 24, 2013
1 parent 9e1f05f commit 45bc2d4
Show file tree
Hide file tree
Showing 65 changed files with 1,163 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .ruby-gemset
Original file line number Diff line number Diff line change
@@ -1 +1 @@
blankgem
whiskey
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
language: ruby
rvm:
- 1.8.7
- 1.9.3
- 2.0.0
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env ruby
source "https://rubygems.org/"

# Specify your gem's dependencies in blankgem.gemspec
# Specify your gem's dependencies in whiskey.gemspec
gemspec
49 changes: 39 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,66 @@
blankgem
whiskey
--------

- [![Version](https://badge.fury.io/rb/blankgem.png)](https://rubygems.org/gems/blankgem)
- [![Climate](https://codeclimate.com/github/krainboltgreene/blankgem.png)](https://codeclimate.com/github/krainboltgreene/blankgem)
- [![Build](http://img.shields.io/travis-ci/krainboltgreene/blankgem.png)](https://travis-ci.org/krainboltgreene/blankgem)
- [![Dependencies](https://gemnasium.com/krainboltgreene/blankgem.png)](https://gemnasium.com/krainboltgreene/blankgem)
- [![Coverage](http://img.shields.io/coveralls/krainboltgreene/blankgem.png)](https://coveralls.io/r/krainboltgreene/blankgem)
- [![Version](https://badge.fury.io/rb/whiskey.png)](https://rubygems.org/gems/whiskey)
- [![Climate](https://codeclimate.com/github/krainboltgreene/whiskey.png)](https://codeclimate.com/github/krainboltgreene/whiskey)
- [![Build](http://img.shields.io/travis-ci/krainboltgreene/whiskey.png)](https://travis-ci.org/krainboltgreene/whiskey)
- [![Dependencies](https://gemnasium.com/krainboltgreene/whiskey.png)](https://gemnasium.com/krainboltgreene/whiskey)
- [![Coverage](http://img.shields.io/coveralls/krainboltgreene/whiskey.png)](https://coveralls.io/r/krainboltgreene/whiskey)
- [![Gittip](http://img.shields.io/gittip/krainboltgreene.png)](https://www.gittip.com/krainboltgreene/)
- [![License](http://img.shields.io/license/MIT.png?color=green)](http://opensource.org/licenses/MIT)

TODO: Write a gem description
Whiskey is a [MUTE](MUTE) Engine.


Using
=====

TODO: Write usage instructions here
Once you've installed Whiskey you can start your new server with:

``` bash
$ whiskey server start
```

If you want to start whiskey on a specific port you'll need to specify like this:

``` bash
$ whiskey server start [-p|--port] 4001
```

The server defaults to running in development mode, but you can can also specify:

``` bash
$ whiskey server start [-e|--environment] production
```

If you want Whiskey to run in the background specify with:

``` bash
$ whiskey server start [-b|--background]
```

Any changes you make to the code will require reloading the server so to kill
the running server:

``` bash
$ whiskey kill all
```


Installing
==========

Add this line to your application's Gemfile:

gem "blankgem"
gem "whiskey"

And then execute:

$ bundle

Or install it yourself as:

$ gem install blankgem
$ gem install whiskey


Contributing
Expand Down
3 changes: 0 additions & 3 deletions bin/example

This file was deleted.

5 changes: 5 additions & 0 deletions bin/whiskey
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env ruby

require "whiskey/command"

Whiskey::Command.start
5 changes: 0 additions & 5 deletions lib/blankgem.rb

This file was deleted.

14 changes: 14 additions & 0 deletions lib/whiskey.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require "logger"
require "astruct"
require "active_support/core_ext"

module Whiskey
def self.logger
@logger ||= Logger.new(STDOUT).tap do |log|
log.level = ENV["WHISKEY_ENVIRONMENT"] == "development" ? Logger::DEBUG : Logger::INFO
log.formatter = nil
end
end
end

require_relative "whiskey/version"
30 changes: 30 additions & 0 deletions lib/whiskey/command.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
require "thor"
require "whiskey"

module Whiskey
class Command < Thor
include Thor::Actions

attr_accessor :values

def self.source_root
File.join(File.dirname(__FILE__), "command", "templates")
end

desc "build NAME", "Builds a new whiskey project from the scaffold"
def build(name)
@values = AltStruct.new
Build.new(self, name).call
end

desc "server [start|stop]", "Starts the whiskey server up"
def server(switch)
case switch
when "start" then StartServer.new.call
end
end
end
end

require_relative "command/build"
require_relative "command/start_server"
54 changes: 54 additions & 0 deletions lib/whiskey/command/build.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
module Whiskey
class Command < Thor
class Build
extend Forwardable

RUBIES = ["rbx", "jruby", "ruby-2.0.0"]
RUBIES_ASK = "Which Ruby do you want to use?\n\n\t- ruby-2.0.0\n\t- rubinius\n\t- jruby\n"

attr_reader :command, :name

def_delegator :@command, :empty_directory
def_delegator :@command, :directory
def_delegator :@command, :template
def_delegator :@command, :inside
def_delegator :@command, :run
def_delegator :@command, :ask
def_delegator :@command, :say

def initialize(command, name)
@command = command
@name = @command.values.name = name
end

def call
empty_directory(name)
command.destination_root = name
template("Gemfile")
template("gitignore", ".gitignore")
template("LICENSE.txt")
template("Thorfile")
template("Procfile")
template("server.rb")
inside("lib") do
template("example.rb", "#{name}.rb")
directory("example", "#{name}")
end
directory("db")

@command.values.ruby = ask(RUBIES_ASK, limit_to: RUBIES)
template("ruby-version", ".ruby-version")
template("ruby-gemset", ".ruby-gemset")
empty_directories("script", "log", "tmp", "doc")
run("git init")
say("You should now run: bundle install")
end

private

def empty_directories(*directories)
directories.each { |directory| empty_directory directory }
end
end
end
end
15 changes: 15 additions & 0 deletions lib/whiskey/command/start_server.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module Whiskey
class Command < Thor
class StartServer
def initialize(host = nil, port = nil, environment = "development")
ENV["WHISKEY_HOST"] = host
ENV["WHISKEY_PORT"] = port
ENV["WHISKEY_ENVIRONMENT"] = environment
end

def call
load File.join(Dir.pwd, "server.rb")
end
end
end
end
10 changes: 10 additions & 0 deletions lib/whiskey/command/templates/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env ruby
source "https://rubygems.org"

gem "whiskey", "<%= Whiskey::VERSION %>"

gem "sqlite3", "~> 1.3"
# gem "pg", "~> 0.14"
# gem "mysql2", "~> 0.3"
# gem "redis", "~> 3.0"
# gem "dalli", "~> 2.6"
22 changes: 22 additions & 0 deletions lib/whiskey/command/templates/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Copyright (c) 2013 YOUR NAME HERE

MIT License

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 change: 1 addition & 0 deletions lib/whiskey/command/templates/Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mute: bundle exec whiskey server
4 changes: 4 additions & 0 deletions lib/whiskey/command/templates/Thorfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env ruby
$:.unshift File.expand_path("../server", __FILE__)

require "bundler"
15 changes: 15 additions & 0 deletions lib/whiskey/command/templates/db/seed.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This is where you'll place any logic that boots up your instance from scratch

introduction = Document.create do |doc|
doc.title = "Introduction"
doc.body = """
Welcome to <%= values.name.camelize %> a new MUTE!
To make an account here simply type:
account create a_suitable_username a_suitable_password
To login to your account type:
account access a_suitable_username a_suitable_password
"""
17 changes: 17 additions & 0 deletions lib/whiskey/command/templates/gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile ~/.gitignore

# Ignore all bundler caching
/vendor/cache
/vendor/ruby

# Ignore all tempfiles
/tmp

# Ignores that should be in the global gitignore
/coverage/
/doc/
/log/
5 changes: 5 additions & 0 deletions lib/whiskey/command/templates/lib/example.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module <%= values.name.camelize %>
require_relative "<%= values.name %>/model"
require_relative "<%= values.name %>/action"
require_relative "<%= values.name %>/control"
end
5 changes: 5 additions & 0 deletions lib/whiskey/command/templates/lib/example/action.rb.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module <%= values.name.camelize %>
class Action < Whiskey::Server::Action

end
end
6 changes: 6 additions & 0 deletions lib/whiskey/command/templates/lib/example/control.rb.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module <%= values.name.camelize %>
module Control
include Whiskey::Server::Control
require_relative "control/routes"
end
end
63 changes: 63 additions & 0 deletions lib/whiskey/command/templates/lib/example/control/accounts.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
module <%= values.name.camelize %>
module Control
module Accounts
include Whiskey::Server::Control

class Create < Action
include Accounts

def initialize(parameters)

end

def to_hash
{

}
end
end

class Update < Action
include Accounts

def initialize(parameters)

end

def to_hash
{

}
end
end

class Show < Action
include Accounts

def initialize(parameters)

end

def to_hash
{

}
end
end

class List < Action
include Accounts

def initialize(parameters)

end

def to_hash
{

}
end
end
end
end
end

0 comments on commit 45bc2d4

Please sign in to comment.