Skip to content

Instantly share code, notes, and snippets.

@benpickles
Created November 8, 2009 17:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save benpickles/229403 to your computer and use it in GitHub Desktop.
Save benpickles/229403 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'httparty'
class GoogleClosure
include HTTParty
base_uri 'closure-compiler.appspot.com'
def self.compile(path)
contents = File.read(path)
params = {
:js_code => contents,
:compilation_level => 'SIMPLE_OPTIMIZATIONS',
:output_format => 'text',
:output_info => 'compiled_code',
}
post('/compile',
:body => params,
:headers => {
'Content-type' => 'application/x-www-form-urlencoded'
}
)
end
end
File.open('public/javascripts/bookmarklet.min.js', 'w') do |f|
f.write GoogleClosure.compile('public/javascripts/bookmarklet.js')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment