Allow partial installation of resources

This commit is contained in:
Jack Nagel 2013-09-17 21:25:43 -05:00
parent 28cb9978ee
commit 50d2f632d9
2 changed files with 9 additions and 0 deletions

View File

@ -1,5 +1,6 @@
require 'pathname' require 'pathname'
require 'mach' require 'mach'
require 'resource'
# we enhance pathname to make our code more readable # we enhance pathname to make our code more readable
class Pathname class Pathname
@ -12,6 +13,8 @@ class Pathname
case src case src
when Resource when Resource
src.stage(self) src.stage(self)
when Resource::Partial
src.resource.stage { install(*src.files) }
when Array when Array
if src.empty? if src.empty?
opoo "tried to install empty array to #{self}" opoo "tried to install empty array to #{self}"

View File

@ -62,6 +62,12 @@ class Resource
end end
end end
Partial = Struct.new(:resource, :files)
def files(*files)
Partial.new(self, files)
end
# For brew-fetch and others. # For brew-fetch and others.
def fetch def fetch
# Ensure the cache exists # Ensure the cache exists