Skip to content
Browse files

rename Package.installers to Package.operations in anticipation of se…

…tup tasks
  • Loading branch information...
1 parent b8702c5 commit fbf76da5df0a6973a807cd4372102a37f6756c87 @tobi committed
Showing with 27 additions and 27 deletions.
  1. +16 −16 lib/sprinkle/package.rb
  2. +11 −11 spec/sprinkle/package_spec.rb
View
32 lib/sprinkle/package.rb
@@ -107,7 +107,7 @@ def package(name, metadata = {}, &block)
class Package #:nodoc:
include ArbitraryOptions
- attr_accessor :name, :provides, :installers, :dependencies, :recommends, :verifications
+ attr_accessor :name, :provides, :operations, :dependencies, :recommends, :verifications
def initialize(name, metadata = {}, &block)
raise 'No package name supplied' unless name
@@ -117,47 +117,47 @@ def initialize(name, metadata = {}, &block)
@dependencies = []
@recommends = []
@verifications = []
- @installers = []
+ @operations = []
self.instance_eval(&block)
end
def apt(*names, &block)
- @installers << Sprinkle::Installers::Apt.new(self, *names, &block)
+ @operations << Sprinkle::Installers::Apt.new(self, *names, &block)
end
def deb(*names, &block)
- @installers << Sprinkle::Installers::Deb.new(self, *names, &block)
+ @operations << Sprinkle::Installers::Deb.new(self, *names, &block)
end
def rpm(*names, &block)
- @installers << Sprinkle::Installers::Rpm.new(self, *names, &block)
+ @operations << Sprinkle::Installers::Rpm.new(self, *names, &block)
end
def yum(*names, &block)
- @installers << Sprinkle::Installers::Yum.new(self, *names, &block)
+ @operations << Sprinkle::Installers::Yum.new(self, *names, &block)
end
def gem(name, options = {}, &block)
@recommends << :rubygems
- @installers << Sprinkle::Installers::Gem.new(self, name, options, &block)
+ @operations << Sprinkle::Installers::Gem.new(self, name, options, &block)
end
def source(source, options = {}, &block)
@recommends << :build_essential # Ubuntu/Debian
- @installers << Sprinkle::Installers::Source.new(self, source, options, &block)
+ @operations << Sprinkle::Installers::Source.new(self, source, options, &block)
end
def rake(name, options = {}, &block)
- @installers << Sprinkle::Installers::Rake.new(self, name, options, &block)
+ @operations << Sprinkle::Installers::Rake.new(self, name, options, &block)
end
def noop(&block)
- @installers << Sprinkle::Installers::Noop.new(self, name, options, &block)
+ @operations << Sprinkle::Installers::Noop.new(self, name, options, &block)
end
-
+
def verify(description = '', &block)
@verifications << Sprinkle::Verify.new(self, description, &block)
- end
+ end
def process(deployment, roles)
return if meta_package?
@@ -175,9 +175,9 @@ def process(deployment, roles)
end
end
- @installers.each do |installer|
- installer.defaults(deployment)
- installer.process(roles)
+ @operations.each do |installer|
+ installer.defaults(deployment) if installer.responds_to?(:defaults)
+ installer.process(roles) if installer.responds_to?(:process)
end
process_verifications(deployment, roles)
@@ -233,7 +233,7 @@ def to_s; @name; end
private
def meta_package?
- @installers.empty?
+ @operations.empty?
end
end
end
View
22 spec/sprinkle/package_spec.rb
@@ -22,7 +22,7 @@ def check_block_forwarding_on(installer)
end
end
- pre_count = pkg.installers.last.instance_variable_get(:@pre)[:install].length
+ pre_count = pkg.operations.last.instance_variable_get(:@pre)[:install].length
}.should change { pre_count }.by(1)
CODE
end
@@ -66,7 +66,7 @@ def create_package_with_blank_verify(n = 1)
pkg = package @name do
gem 'rails'
end
- pkg.installers.last.should_not be_nil
+ pkg.operations.last.should_not be_nil
end
it 'should optionally accept dependencies' do
@@ -116,7 +116,7 @@ def create_package_with_blank_verify(n = 1)
apt %w( deb1 deb2 )
end
pkg.should respond_to(:apt)
- pkg.installers.last.class.should == Sprinkle::Installers::Apt
+ pkg.operations.last.class.should == Sprinkle::Installers::Apt
end
it 'should optionally accept an rpm installer' do
@@ -124,7 +124,7 @@ def create_package_with_blank_verify(n = 1)
rpm %w( rpm1 rpm2 )
end
pkg.should respond_to(:rpm)
- pkg.installers.last.class.should == Sprinkle::Installers::Rpm
+ pkg.operations.last.class.should == Sprinkle::Installers::Rpm
end
it 'should optionally accept a gem installer' do
@@ -132,7 +132,7 @@ def create_package_with_blank_verify(n = 1)
gem 'gem'
end
pkg.should respond_to(:gem)
- pkg.installers.last.class.should == Sprinkle::Installers::Gem
+ pkg.operations.last.class.should == Sprinkle::Installers::Gem
end
it 'should optionally accept a source installer' do
@@ -140,7 +140,7 @@ def create_package_with_blank_verify(n = 1)
source 'archive'
end
pkg.should respond_to(:source)
- pkg.installers.last.class.should == Sprinkle::Installers::Source
+ pkg.operations.last.class.should == Sprinkle::Installers::Source
end
end
@@ -152,7 +152,7 @@ def create_package_with_blank_verify(n = 1)
source 'archive' do; end
end
pkg.should respond_to(:source)
- pkg.installers.last.class.should == Sprinkle::Installers::Source
+ pkg.operations.last.class.should == Sprinkle::Installers::Source
end
it 'should forward block to installer superclass' do
@@ -200,14 +200,14 @@ def create_package_with_blank_verify(n = 1)
before do
@deployment = mock(Sprinkle::Deployment)
@roles = [ :app, :db ]
- @installer = mock(Sprinkle::Installers::Installer, :defaults => true, :process => true)
+ @installer = mock(Sprinkle::Installers::Installer, :defaults => true, :process => true, :responds_to? => true)
@package = package @name do; end
end
describe 'with an installer' do
before do
- @package.installers = [@installer]
+ @package.operations = [@installer]
end
it 'should configure itself against the deployment context' do
@@ -235,7 +235,7 @@ def create_package_with_blank_verify(n = 1)
describe 'with verifications' do
before do
@pkg = create_package_with_blank_verify(3)
- @pkg.installers = [@installer]
+ @pkg.operations = [@installer]
@installer.stub!(:defaults)
@installer.stub!(:process)
end
@@ -296,7 +296,7 @@ def create_package_with_blank_verify(n = 1)
@roles = [ :app, :db ]
@installer = mock(Sprinkle::Installers::Installer, :defaults => true, :process => true)
@pkg = create_package_with_blank_verify(3)
- @pkg.installers << @installer
+ @pkg.operations << @installer
@installer.stub!(:defaults)
@installer.stub!(:process)
@logger = mock(ActiveSupport::BufferedLogger, :debug => true, :debug? => true)

0 comments on commit fbf76da

Please sign in to comment.
Something went wrong with that request. Please try again.