Permalink
Browse files

Merge pull request #36 from yyyc514/noop

replace noop installer with Runner while preserving api
  • Loading branch information...
2 parents 639c3dd + e80f293 commit d02215cc06128f3c56dd6d1c3d7746b166ed2131 @crafterm committed Sep 18, 2011
@@ -1,20 +0,0 @@
-module Sprinkle
- module Installers
- # = Noop Installer
- #
- # This installer does nothing, it's simply useful for running pre / post hooks by themselves.
- #
- class Noop < Installer
- def initialize(parent, name, options = {}, &block) #:nodoc:
- super parent, options, &block
- end
-
- protected
-
- def install_commands #:nodoc:
- 'echo noop'
- end
-
- end
- end
-end
@@ -3,8 +3,8 @@ module Installers
class Runner < Installer
attr_accessor :cmd #:nodoc:
- def initialize(parent, cmd) #:nodoc:
- super parent
+ def initialize(parent, cmd, &block) #:nodoc:
+ super parent, {}, &block
@cmd = cmd
end
View
@@ -192,7 +192,7 @@ def thor(name, options = {}, &block)
end
def noop(&block)
- @installers << Sprinkle::Installers::Noop.new(self, name, options, &block)
+ @installers << Sprinkle::Installers::Runner.new(self, "echo noop", &block)
end
def push_text(text, path, options = {}, &block)
@@ -207,8 +207,8 @@ def transfer(source, destination, options = {}, &block)
@installers << Sprinkle::Installers::Transfer.new(self, source, destination, options, &block)
end
- def runner(cmd)
- @installers << Sprinkle::Installers::Runner.new(self, cmd)
+ def runner(cmd, &block)
+ @installers << Sprinkle::Installers::Runner.new(self, cmd, &block)
end
def verify(description = '', &block)
@@ -1,23 +0,0 @@
-require File.expand_path("../../spec_helper", File.dirname(__FILE__))
-
-describe Sprinkle::Installers::Noop do
-
- before do
- @package = mock(Sprinkle::Package, :name => 'spec')
- end
-
- def create_noop(names, options = {}, &block)
- Sprinkle::Installers::Noop.new(@package, options, &block)
- end
-
- describe 'during installation' do
-
- it 'should always be empty' do
- @installer = create_noop 'spec'
- @install_commands = @installer.send :install_commands
- @install_commands.should == 'echo noop'
- end
-
- end
-
-end
@@ -141,6 +141,18 @@ def create_package_with_blank_verify(n = 1)
pkg.should respond_to(:gem)
pkg.installers.first.class.should == Sprinkle::Installers::Gem
end
+
+ it 'should optionally accept a noop installer' do
+ pkg = package @name do
+ noop do
+ end
+ end
+ pkg.should respond_to(:noop)
+ pkg.installers.first.class.should == Sprinkle::Installers::Runner
+ @installer = pkg.installers.first
+ @install_commands = @installer.send :install_commands
+ @install_commands.should == 'echo noop'
+ end
it 'should optionally accept a source installer' do
pkg = package @name do

0 comments on commit d02215c

Please sign in to comment.