Sha256: 197250f9cd0640bd39b0496c65d692e76e82fcfa1eb8cd45739f1ca842e4c394

Contents?: true

Size: 668 Bytes

Versions: 1

Compression:

Stored size: 668 Bytes

Contents

require 'open3'

module HtmlUglifier

	class Compressor
		
		COMPRESSOR = File.join(File.dirname(__FILE__), '..', 'vendor', 'htmlcompressor*.jar')

		def initialize(options = '')
			@options = options
		end

		def compress(html)
			Open3.popen2("java -jar #{path COMPRESSOR} --type html #{@options}") do |stdin, stdout|
				stdin.write(html)
				stdin.close_write
				stdout.read
			end
		end

		def compress_file(input_file, output_file)
			minified_html = `java -jar #{path COMPRESSOR} --type html #{@options} #{path input_file}`
			File.open(output_file, 'w') { |f| f.write(minified_html) }
		end

		private

		def path(path)
			path.gsub(' ', '\ ')
		end
	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
html_uglifier-0.1.3 lib/html_uglifier.rb