forked from sprinkle-tool/sprinkle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request sprinkle-tool#34 from selectport/master
Added support for thor tasks installer (just like rake) ...
- Loading branch information
Showing
3 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module Sprinkle | ||
module Installers | ||
# = Thor Installer | ||
# | ||
# This installer runs a thor command. | ||
# | ||
# == Example Usage | ||
# | ||
# The following example runs the command "thor spec" on | ||
# the remote server. | ||
# | ||
# package :spec do | ||
# thor 'spec' | ||
# end | ||
# | ||
# Specify a Thorfile with the :thorfile option. | ||
# | ||
# package :spec, :thorfile => "/var/setup/Thorfile" do | ||
# thor 'spec' | ||
# end | ||
|
||
class Thor < Installer | ||
def initialize(parent, commands, options = {}, &block) #:nodoc: | ||
super parent, options, &block | ||
@commands = commands | ||
end | ||
|
||
protected | ||
|
||
def install_commands #:nodoc: | ||
file = @options[:thorfile] ? "-f #{@options[:thorfile]} " : "" | ||
"thor #{file}#{@commands}" | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require File.expand_path("../../spec_helper", File.dirname(__FILE__)) | ||
|
||
describe Sprinkle::Installers::Thor do | ||
|
||
before do | ||
@package = mock(Sprinkle::Package, :name => 'spec') | ||
end | ||
|
||
def create_thor(names, options = {}, &block) | ||
Sprinkle::Installers::Thor.new(@package, names, options, &block) | ||
end | ||
|
||
describe 'during installation' do | ||
|
||
it 'should invoke the thor executer for all specified tasks' do | ||
@installer = create_thor 'spec' | ||
@install_commands = @installer.send :install_commands | ||
@install_commands.should =~ /thor spec/ | ||
end | ||
|
||
it 'should invoke the thor executer for all specified tasks' do | ||
@installer = create_thor 'spec', :thorfile => '/some/Thorfile' | ||
@install_commands = @installer.send :install_commands | ||
@install_commands.should == "thor -f /some/Thorfile spec" | ||
end | ||
|
||
end | ||
|
||
end |