aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorMax Howell2009-06-08 11:42:28 +0100
committerMax Howell2009-06-08 11:42:28 +0100
commit03f225acef70152bdf2de7a5f1c1ea31eef15246 (patch)
tree9540417716357cc6b9bbef2c5c437c40f3b63983 /bin
parent1ee9ac42ddb6d3551c24d7ffaacba71f531e3f88 (diff)
downloadhomebrew-03f225acef70152bdf2de7a5f1c1ea31eef15246.tar.bz2
Better version extraction and more flexible funcs
Diffstat (limited to 'bin')
-rwxr-xr-xbin/brew21
1 files changed, 12 insertions, 9 deletions
diff --git a/bin/brew b/bin/brew
index 23c38a599..73d8faf2f 100755
--- a/bin/brew
+++ b/bin/brew
@@ -235,19 +235,20 @@ begin
shift_formulae_from_ARGV.each {|name| rm name}
when 'mk'
require 'brewkit'
- class Template <Formula
- @url=ARGV.shift
- end
+ url=ARGV.shift
+ version=extract_version File.basename(url, Pathname.new(url).extname)
+
+ /(.*?)[-_.]?#{version}/.match File.basename(url)
+ raise "Couldn't parse name from #{url}" if $1.nil?
- t=Template.new
- /(.*)[-_.]#{t.version}/.match File.basename(t.url)
- t.name = $1
+ path=$formula+($1+'.rb')
+ raise "#{path} already exists!" if File.exist? path
- f=File.new $formula+(t.name+'.rb'), 'w'
+ f=File.new path, 'w'
f.puts "require 'brewkit'"
f.puts
- f.puts "class #{__class t.name} <Formula"
- f.puts " @url=#{t.url}"
+ f.puts "class #{__class $1} <Formula"
+ f.puts " @url='#{url}'"
f.puts " @md5=''"
f.puts " @homepage=''"
f.puts
@@ -257,6 +258,8 @@ begin
f.puts " end"
f.puts "end"
f.close
+
+ puts path
when 'info'
o=__obj shift_formulae_from_ARGV[0]
puts "#{o.name} #{o.version}"