Added small DSL for formulas

You can now use "url", "version", "homepage", and any checksums as
class methods, like so:

    class Dos2unix <Formula
      url 'http://www.sfr-fresh.com/linux/misc/old/dos2unix-3.1.tar.gz'
      md5 '25ff56bab202de63ea6f6c211c416e96'
      homepage 'http://www.sfr-fresh.com/linux/misc/'
    end

The previous usage ("@url = 'http://example.com/tarball.tgz'") still
works, maintaining compatibility with previous formulas.

"dos2unix.rb" is translated into the new format as an example.
This commit is contained in:
Clinton R. Nixon committed 2009-09-23 14:51:11 -04:00
1 parent b8c17e90f7
commit 9713b07890
3 files changed
+17 -8

No files matched your search

+3 -3
View File
@@ -1,9 +1,9 @@
require 'brewkit'
class Dos2unix <Formula
@url='http://www.sfr-fresh.com/linux/misc/old/dos2unix-3.1.tar.gz'
@md5='25ff56bab202de63ea6f6c211c416e96'
@homepage='http://www.sfr-fresh.com/linux/misc/'
url 'http://www.sfr-fresh.com/linux/misc/old/dos2unix-3.1.tar.gz'
md5 '25ff56bab202de63ea6f6c211c416e96'
homepage 'http://www.sfr-fresh.com/linux/misc/'
def install
File.unlink 'dos2unix'
+12 -3
View File
@@ -330,9 +330,18 @@ private
end
class <<self
attr_reader :url, :version, :homepage, :head, :deps
attr_reader *CHECKSUM_TYPES
def self.attr_rw(*attrs)
attrs.each do |attr|
class_eval %Q{
def #{attr}(val=nil)
val.nil? ? @#{attr} : @#{attr} = val
end
}
end
end
attr_rw :url, :version, :homepage, :head, :deps, *CHECKSUM_TYPES
def depends_on name, *args
@deps ||= []
+2 -2
View File
@@ -75,8 +75,8 @@ class TestBallOverrideBrew <Formula
end
class TestScriptFileFormula <ScriptFileFormula
@url="file:///#{Pathname.new(ABS__FILE__).realpath}"
@version="1"
url "file:///#{Pathname.new(ABS__FILE__).realpath}"
version "1"
def initialize
super