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

Commit 1e93f76

Browse files
committed
Merge pull request #75 from mikemcquaid/boxen-commands
Move boxen-* commands into the tap's cmd directory.
2 parents 4edaf0d + e95e6b3 commit 1e93f76

File tree

9 files changed

+30
-53
lines changed

9 files changed

+30
-53
lines changed

files/boxen-install.rb

Lines changed: 0 additions & 10 deletions
This file was deleted.

files/boxen-upgrade.rb

Lines changed: 0 additions & 10 deletions
This file was deleted.

files/brew-boxen-install.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
require File.expand_path("#{File.dirname(__FILE__)}/boxen-bottle-hooks")
2+
require "cmd/install"
3+
4+
# A custom Homebrew command that loads our bottle hooks.
5+
Homebrew.install
Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
require "boxen-bottle-hooks"
1+
require File.expand_path("#{File.dirname(__FILE__)}/boxen-bottle-hooks")
22

33
# A custom Homebrew command that gives us the latest available version
44
# for a given formula. This allows us to avoid the terrifying prospect
55
# of loading Homebrew Ruby code in the Puppet process.
66
#
77
# $ brew boxen-latest <formula-name>
8-
9-
module Homebrew
10-
def self.boxen_latest
11-
raise FormulaUnspecifiedError if ARGV.named.empty?
12-
puts ARGV.formulae.first.version
13-
end
14-
end
8+
raise FormulaUnspecifiedError if ARGV.named.empty?
9+
puts ARGV.formulae.first.version

files/brew-boxen-upgrade.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
require File.expand_path("#{File.dirname(__FILE__)}/boxen-bottle-hooks")
2+
require "cmd/upgrade"
3+
4+
# A custom Homebrew command that loads our bottle hooks.
5+
Homebrew.upgrade

manifests/config.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
$cmddir = "${installdir}/Library/Homebrew/cmd"
1515
$tapsdir = "${installdir}/Library/Taps"
1616

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

1919
$min_revision = '2d96b48970feff15774e04ae01cec11716f8b7f4'
2020
}

manifests/formula.pp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,15 @@
1010
default => $source
1111
}
1212

13-
$boxen_tapdir = "${homebrew::tapsdir}/boxen"
14-
15-
ensure_resource('file', $boxen_tapdir, {
16-
'ensure' => 'directory',
17-
'owner' => $::boxen_user,
18-
'group' => 'staff',
19-
})
20-
21-
ensure_resource('file', "${boxen_tapdir}/homebrew-brews", {
13+
ensure_resource('file', $homebrew::brewsdir, {
2214
'ensure' => 'directory',
2315
'owner' => $::boxen_user,
2416
'group' => 'staff',
25-
'require' => File[$boxen_tapdir],
17+
'require' => File[$homebrew::brewsdir],
2618
})
2719

28-
file { "${boxen_tapdir}/homebrew-brews/${name}.rb":
20+
file { "${homebrew::brewsdir}/${name}.rb":
2921
source => $formula_source,
30-
require => File["${boxen_tapdir}/homebrew-brews"]
22+
require => File[$homebrew::brewsdir],
3123
}
3224
}

manifests/init.pp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,18 @@
7575
}
7676

7777
file {
78-
[$cachedir, $tapsdir, $cmddir]:
78+
[$cachedir, $tapsdir, $cmddir, "${brewsdir}/cmd"]:
7979
ensure => 'directory' ;
8080

8181
# shim for bottle hooks
82-
"${installdir}/Library/Homebrew/boxen-bottle-hooks.rb":
82+
"${brewsdir}/cmd/boxen-bottle-hooks.rb":
8383
source => 'puppet:///modules/homebrew/boxen-bottle-hooks.rb' ;
84-
"${cmddir}/boxen-latest.rb":
85-
source => 'puppet:///modules/homebrew/boxen-latest.rb' ;
86-
"${cmddir}/boxen-install.rb":
87-
source => 'puppet:///modules/homebrew/boxen-install.rb' ;
88-
"${installdir}/Library/Homebrew/cmd/boxen-upgrade.rb":
89-
source => 'puppet:///modules/homebrew/boxen-upgrade.rb' ;
84+
"${brewsdir}/cmd/brew-boxen-latest.rb":
85+
source => 'puppet:///modules/homebrew/brew-boxen-latest.rb' ;
86+
"${brewsdir}/cmd/brew-boxen-install.rb":
87+
source => 'puppet:///modules/homebrew/brew-boxen-install.rb' ;
88+
"${brewsdir}/cmd/brew-boxen-upgrade.rb":
89+
source => 'puppet:///modules/homebrew/brew-boxen-upgrade.rb' ;
9090
}
9191

9292
->

spec/classes/homebrew_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
let(:facts) { default_test_facts }
55

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

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

2121
should contain_boxen__env_script("homebrew")
2222

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

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

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

0 commit comments

Comments
 (0)