class HtmlUglifier::Compressor

Constants

COMPRESSOR

Public Class Methods

new(options = '') click to toggle source
# File lib/html_uglifier.rb, line 9
def initialize(options = '')
        @options = options
end

Public Instance Methods

compress(html) click to toggle source
# File lib/html_uglifier.rb, line 13
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
compress_file(input_file, output_file) click to toggle source
# File lib/html_uglifier.rb, line 21
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 Instance Methods

path(path) click to toggle source
# File lib/html_uglifier.rb, line 28
def path(path)
        path.gsub(' ', '\ ')
end