Skip to content
This repository has been archived by the owner on Dec 2, 2020. It is now read-only.

Commit

Permalink
Merge pull request #75 from mikemcquaid/boxen-commands
Browse files Browse the repository at this point in the history
Move boxen-* commands into the tap's cmd directory.
  • Loading branch information
MikeMcQuaid committed Feb 18, 2015
2 parents 4edaf0d + e95e6b3 commit 1e93f76
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 53 deletions.
10 changes: 0 additions & 10 deletions files/boxen-install.rb

This file was deleted.

10 changes: 0 additions & 10 deletions files/boxen-upgrade.rb

This file was deleted.

5 changes: 5 additions & 0 deletions files/brew-boxen-install.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require File.expand_path("#{File.dirname(__FILE__)}/boxen-bottle-hooks")
require "cmd/install"

# A custom Homebrew command that loads our bottle hooks.
Homebrew.install
11 changes: 3 additions & 8 deletions files/boxen-latest.rb → files/brew-boxen-latest.rb
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
require "boxen-bottle-hooks"
require File.expand_path("#{File.dirname(__FILE__)}/boxen-bottle-hooks")

# A custom Homebrew command that gives us the latest available version
# for a given formula. This allows us to avoid the terrifying prospect
# of loading Homebrew Ruby code in the Puppet process.
#
# $ brew boxen-latest <formula-name>

module Homebrew
def self.boxen_latest
raise FormulaUnspecifiedError if ARGV.named.empty?
puts ARGV.formulae.first.version
end
end
raise FormulaUnspecifiedError if ARGV.named.empty?
puts ARGV.formulae.first.version
5 changes: 5 additions & 0 deletions files/brew-boxen-upgrade.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require File.expand_path("#{File.dirname(__FILE__)}/boxen-bottle-hooks")
require "cmd/upgrade"

# A custom Homebrew command that loads our bottle hooks.
Homebrew.upgrade
2 changes: 1 addition & 1 deletion manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
$cmddir = "${installdir}/Library/Homebrew/cmd"
$tapsdir = "${installdir}/Library/Taps"

$brewsdir = "${tapsdir}/boxen-brews"
$brewsdir = "${tapsdir}/boxen/homebrew-brews"

$min_revision = '2d96b48970feff15774e04ae01cec11716f8b7f4'
}
16 changes: 4 additions & 12 deletions manifests/formula.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,15 @@
default => $source
}

$boxen_tapdir = "${homebrew::tapsdir}/boxen"

ensure_resource('file', $boxen_tapdir, {
'ensure' => 'directory',
'owner' => $::boxen_user,
'group' => 'staff',
})

ensure_resource('file', "${boxen_tapdir}/homebrew-brews", {
ensure_resource('file', $homebrew::brewsdir, {
'ensure' => 'directory',
'owner' => $::boxen_user,
'group' => 'staff',
'require' => File[$boxen_tapdir],
'require' => File[$homebrew::brewsdir],
})

file { "${boxen_tapdir}/homebrew-brews/${name}.rb":
file { "${homebrew::brewsdir}/${name}.rb":
source => $formula_source,
require => File["${boxen_tapdir}/homebrew-brews"]
require => File[$homebrew::brewsdir],
}
}
16 changes: 8 additions & 8 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,18 @@
}

file {
[$cachedir, $tapsdir, $cmddir]:
[$cachedir, $tapsdir, $cmddir, "${brewsdir}/cmd"]:
ensure => 'directory' ;

# shim for bottle hooks
"${installdir}/Library/Homebrew/boxen-bottle-hooks.rb":
"${brewsdir}/cmd/boxen-bottle-hooks.rb":
source => 'puppet:///modules/homebrew/boxen-bottle-hooks.rb' ;
"${cmddir}/boxen-latest.rb":
source => 'puppet:///modules/homebrew/boxen-latest.rb' ;
"${cmddir}/boxen-install.rb":
source => 'puppet:///modules/homebrew/boxen-install.rb' ;
"${installdir}/Library/Homebrew/cmd/boxen-upgrade.rb":
source => 'puppet:///modules/homebrew/boxen-upgrade.rb' ;
"${brewsdir}/cmd/brew-boxen-latest.rb":
source => 'puppet:///modules/homebrew/brew-boxen-latest.rb' ;
"${brewsdir}/cmd/brew-boxen-install.rb":
source => 'puppet:///modules/homebrew/brew-boxen-install.rb' ;
"${brewsdir}/cmd/brew-boxen-upgrade.rb":
source => 'puppet:///modules/homebrew/brew-boxen-upgrade.rb' ;
}

->
Expand Down
8 changes: 4 additions & 4 deletions spec/classes/homebrew_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
let(:facts) { default_test_facts }

let(:dir) { facts[:homebrew_root] }
let(:cmddir) { "#{dir}/Library/Homebrew/cmd" }
let(:cmddir) { "#{dir}/Library/Taps/boxen/homebrew-brews/cmd" }

it do
should contain_exec("install homebrew to #{dir}").with({
Expand All @@ -20,12 +20,12 @@

should contain_boxen__env_script("homebrew")

should contain_file("#{dir}/Library/Homebrew/boxen-bottle-hooks.rb").
should contain_file("#{cmddir}/boxen-bottle-hooks.rb").
with_source("puppet:///modules/homebrew/boxen-bottle-hooks.rb")

["latest", "install", "upgrade"].each do |cmd|
should contain_file("#{cmddir}/boxen-#{cmd}.rb").
with_source("puppet:///modules/homebrew/boxen-#{cmd}.rb")
should contain_file("#{cmddir}/brew-boxen-#{cmd}.rb").
with_source("puppet:///modules/homebrew/brew-boxen-#{cmd}.rb")
end

should contain_file("#{dir}/lib").with_ensure("directory")
Expand Down

0 comments on commit 1e93f76

Please sign in to comment.