aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Contributions
diff options
context:
space:
mode:
authorJack Nagel2014-03-03 18:14:02 -0600
committerJack Nagel2014-03-03 18:14:02 -0600
commit459554280258ea284ed2bf270ca7fffa033e5c26 (patch)
tree28bdb86515da84e17c644933786195413646758a /Library/Contributions
parent68dfcda524374a425657f30629f91693eed63531 (diff)
downloadhomebrew-459554280258ea284ed2bf270ca7fffa033e5c26.tar.bz2
Replace subformula example with a resource example
Diffstat (limited to 'Library/Contributions')
-rw-r--r--Library/Contributions/example-formula.rb27
1 files changed, 14 insertions, 13 deletions
diff --git a/Library/Contributions/example-formula.rb b/Library/Contributions/example-formula.rb
index 98e775b6f..5d5336c1b 100644
--- a/Library/Contributions/example-formula.rb
+++ b/Library/Contributions/example-formula.rb
@@ -202,6 +202,16 @@ class ExampleFormula < Formula
cause 'multiple configure and compile errors'
end
+ ## Resources
+
+ # Additional downloads can be defined as resources and accessed in the
+ # install method. Resources can also be defined inside a stable, devel, or
+ # head block. This mechanism replaces ad-hoc "subformula" classes.
+ resource "additional_files" do
+ url 'https://example.com/additional-stuff.tar.gz'
+ sha1 'deadbeef7890123456789012345678901234567890'
+ end
+
## Patches
@@ -348,12 +358,10 @@ class ExampleFormula < Formula
# Copy `./example_code/simple/ones` to share/demos/examples
(share/'demos').install "example_code/simple/ones" => 'examples'
- # Additional stuff can be defined in a sub-formula (see below) and
- # with a block like this, it will be extracted into its own temporary
- # dir. We can install into the Cellar of the main formula easily,
- # because `prefix`, `bin` and all the other pre-defined variables are
- # from the main formula.
- AdditionalStuff.new.brew { bin.install 'my/extra/tool' }
+ # Additional downloads can be defined as resources (see above).
+ # The stage method will create a temporary directory and yield
+ # to a block.
+ resource("additional_files").stage { bin.install 'my/extra/tool' }
# `name` and `version` are accessible too, if you need them.
end
@@ -412,13 +420,6 @@ class ExampleFormula < Formula
def plist; nil; end
end
-class AdditionalStuff < Formula
- # Often, a second formula is used to download some resource
- # NOTE: This is going to change when https://github.com/Homebrew/homebrew/pull/21714 happens.
- url 'https://example.com/additional-stuff.tar.gz'
- sha1 'deadbeef7890123456789012345678901234567890'
-end
-
__END__
# Room for a patch after the `__END__`
# Read in the wiki about how to get a patch in here: