diff --git a/.suprails.example b/.suprails.example index 0fdb57e..f690b06 100644 --- a/.suprails.example +++ b/.suprails.example @@ -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 \ No newline at end of file +# haml diff --git a/README b/README index 498e8b7..ac867f4 100644 --- a/README +++ b/README @@ -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. diff --git a/lib/runner.rb b/lib/runner.rb index abaf983..b5a2d8f 100644 --- a/lib/runner.rb +++ b/lib/runner.rb @@ -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 @@ -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 @@ -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 diff --git a/lib/suprails.rb b/lib/suprails.rb index 238391e..26ff433 100644 --- a/lib/suprails.rb +++ b/lib/suprails.rb @@ -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 diff --git a/suprails.gemspec b/suprails.gemspec index e952112..1704795 100644 --- a/suprails.gemspec +++ b/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' diff --git a/test/test_runner.rb b/test/test_runner.rb new file mode 100644 index 0000000..a85436a --- /dev/null +++ b/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 \ No newline at end of file