Dict.org client formula

Added Formula::etc()

Added Pathname::write() convenience function which can write a string out to
the file it points too, raising if it would have to overwrite.
This commit is contained in:
Ben Alpert 2009-08-31 22:34:42 -06:00 committed by Max Howell
parent 8b64f33eb2
commit b71b8e3972
2 changed files with 8 additions and 0 deletions

View File

@ -80,6 +80,7 @@ class Formula
def bin; prefix+'bin' end def bin; prefix+'bin' end
def sbin; prefix+'sbin' end def sbin; prefix+'sbin' end
def doc; prefix+'share'+'doc'+name end def doc; prefix+'share'+'doc'+name end
def etc; prefix+'etc' end
def lib; prefix+'lib' end def lib; prefix+'lib' end
def libexec; prefix+'libexec' end def libexec; prefix+'libexec' end
def man; prefix+'share'+'man' end def man; prefix+'share'+'man' end

View File

@ -54,6 +54,13 @@ class Pathname
end end
end end
# we assume this pathname object is a file obviously
def write content
raise "Will not overwrite #{f}" if exist? and not ARGV.force?
dirname.mkpath
File.open(self, 'w') {|f| f.write content }
end
def cp dst def cp dst
if file? if file?
FileUtils.cp to_s, dst FileUtils.cp to_s, dst