Skip to content

Commit

Permalink
merged in p8 work
Browse files Browse the repository at this point in the history
  • Loading branch information
listrophy committed Nov 3, 2008
2 parents 889c007 + 420e364 commit fa20ebc
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 26 deletions.
7 changes: 6 additions & 1 deletion .suprails.example
Expand Up @@ -101,10 +101,15 @@ git
# Example:
# svn

# Need a command not supplied (yet!) by suprails?
# You can extend it by using runcommand
# Example:
# runcommand "capify ."

# Oh yeah, you can use plugins, too. Except, to prevent confusion with real
# rails plugins, we call them facets for suprails. They should be installed at:
# ~/.suprails/facets
# Haml is one such facet. It requires special attention because installing it
# as a plugin does not complete its installation into the rails app
# Example:
# haml
# haml
4 changes: 3 additions & 1 deletion README
Expand Up @@ -67,9 +67,11 @@ Now, run suprails instead of rails:

$ suprails AppName

Bugs
History/Bugs
====

0.1.1 - Added the runcommand verb

0.1 - The DB commands do not yet work. You have to just use the file command
instead.

Expand Down
33 changes: 16 additions & 17 deletions lib/runner.rb
Expand Up @@ -75,17 +75,11 @@ def debug p = ''
end

def plugin plugin_location
`cd #{Runner.app_name}; script/plugin install #{plugin_location}`
runcommand("script/plugin install #{plugin_location}")
end

def generate generator, *opts
if opts.length
args = ''
opts.each {|x| args += " #{x}"}
`cd #{Runner.app_name}; script/generate #{generator} #{args}`
else
`cd #{Runner.app_name}; script/generate #{generator}`
end
runcommand("script/generate #{generator} #{opts.join(' ')}")
end

def folder folder_name
Expand Down Expand Up @@ -129,13 +123,7 @@ def gpl
end

def rake *opts
if opts.length
args = ''
opts.each {|x| args += " #{x}"}
`cd #{Runner.app_name}; rake #{args}`
else
`cd #{Runner.app_name}; rake`
end
runcommand("rake #{opts.join(' ')}")
end

def git
Expand All @@ -148,11 +136,22 @@ def git
if gem
g = Git.init(@base)
else
`cd #{Runner.app_name}; git init`
runcommand 'git init'
end
end

def svn
`cd #{Runner.app_name}; svnadmin create`
runcommand 'svnadmin create'
end

def runcommand *opts
shell "cd #{Runner.app_name}; #{opts.join(' ')}"
end

private

def shell cmd
`#{cmd}`
end

end
8 changes: 1 addition & 7 deletions lib/suprails.rb
Expand Up @@ -23,19 +23,13 @@

class Suprails

attr_accessor :app_name

def initialize(app_name = "")
@app_name = app_name
@run_file = ""
end

def app_name=(val)
@app_name = val
end
def app_name
@app_name
end

def create_project
Runner.new(@app_name).run
end
Expand Down
4 changes: 4 additions & 0 deletions suprails.gemspec
@@ -1,7 +1,11 @@
Gem::Specification.new do |s|
s.name = "suprails"
s.version = "0.1.1"
<<<<<<< .merge_file_c6ZLOU
s.date = "2008-10-31"
=======
s.date = "2008-10-18"
>>>>>>> .merge_file_eYSMe9
s.authors = ["Bradley Grzesiak"]
s.email = "listrophy@gmail.com"
s.summary = 'Suprails provides a wrapper to the rails command'
Expand Down
62 changes: 62 additions & 0 deletions test/test_runner.rb
@@ -0,0 +1,62 @@
require File.dirname(__FILE__) + '/../lib/runner.rb'
require 'test/unit' unless defined? $ZENTEST and $ZENTEST
require 'rubygems'
require 'mocha'

class TestRunner < Test::Unit::TestCase

def setup
@runner = Runner.new('test_app')
end

def test_generate
@runner.expects(:runcommand).with('script/generate model ')
@runner.generate('model')
end

def test_generate_with_options
@runner.expects(:runcommand).with('script/generate model user ')
@runner.generate('model user')
end

def test_generate_with_options_as_symbols
@runner.expects(:runcommand).with('script/generate model user')
@runner.generate(:model, :user)
end

def test_svn
@runner.expects(:runcommand).with('svnadmin create')
@runner.svn
end

def test_git
@runner.expects(:runcommand).with('git init')
@runner.git
end

def test_plugin
@runner.expects(:runcommand).with('script/plugin install a')
@runner.plugin('a')
end

def test_rake
@runner.expects(:runcommand).with('rake ')
@runner.rake()
end

def test_rake_with_options
@runner.expects(:runcommand).with('rake test')
@runner.rake('test')
end

def test_runcommand
@runner.expects(:shell).with( "cd test_app; cmd")
@runner.runcommand('cmd')
end

def test_runcommand_with_options
@runner.expects(:shell).with( "cd test_app; cmd a b")
@runner.runcommand('cmd a b')
end

end

0 comments on commit fa20ebc

Please sign in to comment.