Skip to content

Commit

Permalink
more documentation, clean up unused variables and such
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Klauer (a03182) committed May 29, 2011
1 parent 5b0c74a commit c861d43
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -3,5 +3,5 @@
Gemfile.lock
pkg/*
*.swp
doc
html
.yardoc/
1 change: 0 additions & 1 deletion Gemfile
@@ -1,5 +1,4 @@
source "http://rubygems.org"
source "http://rubygems.torquebox.org"

# Specify your gem's dependencies in tbox-template.gemspec
gemspec
14 changes: 9 additions & 5 deletions README.md
Expand Up @@ -62,21 +62,25 @@ Why
Torquebox is a really awesome project and I was interested in doing something
with it. Since there didn't appear to be any project-generator-type
thing in place, I decided to make one. This is as much an experiment with
[Thor][2] as it is an interest in making Torquebox have a command-line application
that you can spin up TB apps quickly.
[Thor][2] as it is an interest in providing Torquebox a command-line application
to spin up TB apps quickly.

Obviously, if you find bugs, report them, throw a pull request my way, and
feel free to critique the hell out of this. This is my first project in the
Ruby space, and I'm more interested in making this a good app, even if it's not
entirely useful to anybody.

### Note:
I have no tests at all for this. I'm interested in trying to test it, but I'm
not entirely sure how I would test a command-line app when much of it's
functionality is wrapped in Thor (which I trust to do its job) tasks and such.

To Do
=====
I didn't anticipate needing much more than what this offers, but I have a small
list of things I'd like to include to fill it out a bit:
I don't have an interest in adding too many more features, but I have a small list of things
I'd like to include to fill it out a bit:

* wrap rake tasks in the command-line app
* wrap [rake tasks][3]
* include the [rails template generator][4] provided by the Torquebox team

[1]: http://www.torquebox.org/
Expand Down
16 changes: 8 additions & 8 deletions Rakefile
@@ -1,18 +1,18 @@
#require 'rake/clean'
require 'rdoc'
gem 'rdoc'
require 'rdoc/task'
require 'rake/clean'
require 'bundler'

Bundler::GemHelper.install_tasks

# How the hell is this broken?
#
#CLOBBER.include( 'pkg/', 'doc/' )
CLEAN.include('*.tmp')
CLOBBER.include('*.tmp', 'pkg/', 'html/')

task :default => ["spec", "build"]
# Default is to build and generate docs. No tests yet, so can't do that
task :default => ["build", "rdoc"]

# And this, too...
# Document gem and place in html/
Rake::RDocTask.new do |rd|
rd.main = "README.md"
rd.rdoc_files.include("lib/**/*.rb", "README.md")
rd.options << "--o doc"
end
4 changes: 4 additions & 0 deletions lib/tb-cli.rb
Expand Up @@ -4,6 +4,8 @@
require 'thor/group'

module Tbox
# Base Command Line interface. Registers the two major Thor tasks (Rack and
# Add).
class Cli < Thor
require 'tb-cli/camel_case'
require 'tb-cli/descriptions'
Expand All @@ -14,6 +16,7 @@ class Cli < Thor
register Tbox::Add, "add", "add [component]", ADD
register Tbox::Rack, "rack", "rack [project_name]", RACK

# Default help message when nothing is passed in
def help(meth=nil)
puts BANNER
super
Expand All @@ -25,6 +28,7 @@ def self.start(*)
super
end

# Default Help Message banner.
BANNER = <<-BAN
Torquebox CLI
Expand Down
13 changes: 13 additions & 0 deletions lib/tb-cli/config_file.rb
@@ -1,9 +1,19 @@
module Tbox
# ConfigFile class provides some simple YAML configuration file helpers.
# While normal YAML methods within Ruby are fine (and used heavily), these
# helpers assist in adding, removing, and replacing configurations for the
# Torquebox.yml default specification file. These methods make adding
# a config to the torquebox.yml much easier, as it abstracts out the details
# of having to know the underlying data structure (Hashes, Arrays, boolean,
# string) and just pass in to this ConfigFile the pieces you want to add
class ConfigFile
require 'yaml'

attr_accessor :config, :torquebox_yml

# Create and/or open a YAML configuration file
# [destination_root] Directory that you will find the YAML file
# [file] Filename of the YAML file to load
def initialize(destination_root=nil, file='torquebox.yml')
@filename = file
@torquebox_yml = File.join(destination_root, @filename)
Expand All @@ -14,10 +24,12 @@ def initialize(destination_root=nil, file='torquebox.yml')
end
end

# Is the configuration file there or does a new config there to laod?
def config_present?
File.exist? @torquebox_yml
end

# Convert config to YAML
def yaml
@config.to_yaml
end
Expand Down Expand Up @@ -45,6 +57,7 @@ def add_config(root, config=nil, value=nil)
puts "Current #{@filename} configuration file:\n\n#{yaml}\n"
end

# Not tested or documented
def remove_config(meth, config)
conf = @config[meth.to_s]
unless conf
Expand Down
38 changes: 8 additions & 30 deletions lib/tb-cli/descriptions.rb
@@ -1,4 +1,5 @@
ADD = <<-COMPONENT
# Description for when you pass in the 'add' method execution.
ADD = <<-COMPONENT
Add a new component to the torquebox.yml file. The type of component can be:
- application
Expand All @@ -15,35 +16,12 @@
- pooling
For more help on a particular subcommand, enter
tb add help [component]
COMPONENT

REMOVE = <<-COMPONENT
Remove a component from your torquebox.yml file. Types of things
to remove can be the same as with add:
- application
- web
- ruby
- environment
- queue
- topic
- messaging
- task
- job
- service
- auth
- pooling
For more help on a particular subcommand, enter
tb remove help [component]
tb add help [component]
COMPONENT
COMPONENT

MESSAGING_LONG = <<-MSG
MESSAGING_LONG = <<-MSG
Messaging
=========
For more information, go to (http://torquebox.org/documentation/1.0.0/messaging.html#messaging-consumers) for information (figure 8.15, specifically):
Expand All @@ -60,9 +38,9 @@
MyBarHandler:
durable: true
MSG
MSG

RACK = <<-RCK
RACK = <<-RCK
Create a new Rack Application template. By default, will generate the following:
project_folder
Expand All @@ -74,4 +52,4 @@
Much of this would be much similar to a rails app, but if you
have an interest in doing something more lightweight, you might
find this template more appealing and minimal.
RCK
RCK
1 change: 1 addition & 0 deletions lib/tb-cli/version.rb
@@ -1,5 +1,6 @@
module Tbox
module Cli
# Version of the application
VERSION = "0.1.0"
end
end
Empty file removed spec/cli_specs.rb
Empty file.
12 changes: 7 additions & 5 deletions tb-cli.gemspec
Expand Up @@ -9,17 +9,19 @@ Gem::Specification.new do |s|
s.authors = ["Nick Klauer"]
s.email = ["klauer@gmail.com"]
s.homepage = ""
s.summary = %q{Create simple Torquebox templates for your Rack-based applications.}
s.description = %q{In creating a new Torquebox integration, there are a few common files that you could
use to set up your context to deploy to, what the name of the app is, and other
general-purpose deployment information. Simplify that with this command-line gem.}
s.summary = %q{Create simple Torquebox.yml templates for your Torquebox, Rack-based applications.}
s.description = %q{Torquebox (http://www.torquebox.org) is a JBoss Application Server that will run your
Rack and Rails apps in JRuby. Torquebox provides a number of additional functionality that you might find useful, such
as messaging, background services, and scheduled tasks. Configuring those is incredibly easy, since they all rely on
simple YAML file configs. This CLI application simplifies that further by lettnig you generate your applications and
application templates with simple command line executions.}

s.add_development_dependency "rspec"
s.add_development_dependency "sinatra"
s.add_dependency "thor"

s.executables << "tb"

s.rubyforge_project = "tb-cli"

s.files = `git ls-files`.split("\n")
Expand Down

0 comments on commit c861d43

Please sign in to comment.