forked from sprinkle-tool/sprinkle
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'bsears/homebrew'
- Loading branch information
Showing
3 changed files
with
121 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,34 @@ | ||
module Sprinkle | ||
module Installers | ||
# = Homebrew Package Installer | ||
# | ||
# The Homebrew package installer uses the +brew+ command to install | ||
# packages on OSX. | ||
# | ||
# == Example Usage | ||
# | ||
# package :magic_beans do | ||
# description "Beans beans they're good for your heart..." | ||
# brew 'magic_beans_package' | ||
# end | ||
# | ||
class Brew < Installer | ||
attr_accessor :formulas #:nodoc: | ||
|
||
def initialize(parent, *formulas, &block) #:nodoc: | ||
formulas.flatten! | ||
|
||
super parent, &block | ||
|
||
@formulas = formulas | ||
end | ||
|
||
protected | ||
|
||
def install_commands #:nodoc: | ||
"brew install #{@formulas.join(' ')}" | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module Sprinkle | ||
module Verifiers | ||
# = Brew package Verifier | ||
# | ||
# Contains a verifier to check the existance of a Homebrew formula. | ||
# | ||
# == Example Usage | ||
# | ||
# verify { has_brew 'ntp' } | ||
# | ||
module Brew | ||
Sprinkle::Verify.register(Sprinkle::Verifiers::Brew) | ||
|
||
# Checks to make sure the brew <tt>formula</tt> exists on the remote server. | ||
def has_brew(package) | ||
@commands << "brew list | grep #{package}" | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
require File.dirname(__FILE__) + '/../../spec_helper' | ||
|
||
describe Sprinkle::Installers::Brew do | ||
|
||
before do | ||
@formula = mock(Sprinkle::Package, :name => 'formula') | ||
end | ||
|
||
def create_brew(*formulas, &block) | ||
Sprinkle::Installers::Brew.new(@formula, *formulas, &block) | ||
end | ||
|
||
describe 'when created' do | ||
|
||
it 'should accept a single package to install' do | ||
@installer = create_brew 'ruby' | ||
@installer.formulas.should == [ 'ruby' ] | ||
end | ||
|
||
it 'should accept an array of packages to install' do | ||
@installer = create_brew %w( gcc gdb g++ ) | ||
@installer.formulas.should == ['gcc', 'gdb', 'g++'] | ||
end | ||
|
||
it 'should remove options from packages list' do | ||
@installer = create_brew 'ruby' | ||
@installer.formulas.should == [ 'ruby' ] | ||
end | ||
|
||
end | ||
|
||
describe 'during installation' do | ||
|
||
before do | ||
@installer = create_brew 'ruby' do | ||
pre :install, 'op1' | ||
post :install, 'op2' | ||
end | ||
@install_commands = @installer.send :install_commands | ||
end | ||
|
||
it 'should invoke the apt installer for all specified packages' do | ||
@install_commands.should =~ /brew install ruby/ | ||
end | ||
|
||
it 'should automatically insert pre/post commands for the specified package' do | ||
@installer.send(:install_sequence).should == [ 'op1', %(brew install ruby), 'op2' ] | ||
end | ||
|
||
it 'should install a specific version if defined' | ||
|
||
end | ||
|
||
# describe 'during dependencies only installation' do | ||
# | ||
# before do | ||
# @installer = create_apt('ruby') { dependencies_only true } | ||
# @install_commands = @installer.send :install_commands | ||
# end | ||
# | ||
# it 'should invoke the apt installer with build-dep command for all specified packages' do | ||
# @install_commands.should =~ /apt-get --force-yes -qyu build-dep ruby/ | ||
# end | ||
# | ||
# end | ||
end |