Last active
August 29, 2015 14:27
-
-
Save guilleiguaran/0b99d991b01bf4f78856 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Uglifyrb | |
# A wrapper around the UglifyJS interface | |
class Compressor | |
def initialize(options = {}) | |
end | |
def compress(source) | |
f = Tempfile.new("jstemp") | |
f.write(source) | |
f.close | |
compress_node_with_node(f.path) | |
end | |
private | |
def compress_with_node(path) | |
output = `uglifyjs '#{source}'` | |
raise output unless output.empty? | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment