benpickles (owner)

Revisions

gist: 229403 Download_button fork
public
Public Clone URL: git://gist.github.com/229403.git
Embed All Files: show embed
Ruby #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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