2010-11-29 10:11:09 +00:00
|
|
|
require 'formula'
|
|
|
|
|
2011-03-10 05:11:03 +00:00
|
|
|
class Htmlcompressor < Formula
|
2010-11-29 10:11:09 +00:00
|
|
|
homepage 'http://code.google.com/p/htmlcompressor/'
|
2014-03-05 07:22:08 +00:00
|
|
|
url 'https://htmlcompressor.googlecode.com/files/htmlcompressor-1.5.3.jar'
|
2012-07-25 05:08:23 +00:00
|
|
|
sha1 '57db73b92499e018b2f2978f1c7aa7b1238c7a39'
|
2010-11-29 10:11:09 +00:00
|
|
|
|
2012-09-04 03:12:48 +00:00
|
|
|
option 'yuicompressor', "Use YUICompressor for JS/CSS compression"
|
2012-12-27 20:33:41 +00:00
|
|
|
option 'closure-compiler', "Use Closure Compiler for JS optimization"
|
2012-07-22 12:39:35 +00:00
|
|
|
|
2013-02-02 03:57:02 +00:00
|
|
|
depends_on "yuicompressor" if build.include? 'yuicompressor'
|
|
|
|
depends_on "closure-compiler" if build.include? 'closure-compiler'
|
2012-07-22 12:39:35 +00:00
|
|
|
|
2010-11-29 10:11:09 +00:00
|
|
|
def install
|
2013-08-12 23:47:41 +00:00
|
|
|
libexec.install "htmlcompressor-#{version}.jar"
|
|
|
|
bin.write_jar_script libexec/"htmlcompressor-#{version}.jar", "htmlcompressor"
|
2012-09-04 03:12:48 +00:00
|
|
|
|
|
|
|
if build.include? 'yuicompressor'
|
2014-02-25 14:38:06 +00:00
|
|
|
yui = Formula["yuicompressor"]
|
2014-03-26 03:43:35 +00:00
|
|
|
libexec.install_symlink yui.opt_libexec/"yuicompressor-#{yui.version}.jar"
|
2012-07-22 12:39:35 +00:00
|
|
|
end
|
2012-12-27 20:33:41 +00:00
|
|
|
|
|
|
|
if build.include? 'closure-compiler'
|
2014-03-26 03:43:35 +00:00
|
|
|
libexec.install_symlink Formula["closure-compiler"].opt_libexec/"build/compiler.jar"
|
2012-12-27 20:33:41 +00:00
|
|
|
end
|
2010-11-29 10:11:09 +00:00
|
|
|
end
|
2014-02-05 02:46:16 +00:00
|
|
|
|
|
|
|
test do
|
|
|
|
path = testpath/"index.xml"
|
|
|
|
path.write <<-EOS
|
|
|
|
<foo>
|
|
|
|
<bar /> <!-- -->
|
|
|
|
</foo>
|
|
|
|
EOS
|
|
|
|
|
|
|
|
output = `#{bin}/htmlcompressor #{path}`.strip
|
|
|
|
assert_equal "<foo><bar/></foo>", output
|
|
|
|
assert_equal 0, $?.exitstatus
|
|
|
|
end
|
2010-11-29 10:11:09 +00:00
|
|
|
end
|