Class: Sinatra::AssetPack::ClosureEngine

Inherits:
Engine
  • Object
show all
Defined in:
lib/sinatra/assetpack/engines/closure.rb

Instance Method Summary collapse

Methods inherited from Engine

#sys

Instance Method Details

#js(str, options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/sinatra/assetpack/engines/closure.rb', line 3

def js(str, options={})
  require 'net/http'
  require 'uri'

  response = Net::HTTP.post_form(URI.parse('http://closure-compiler.appspot.com/compile'), {
    'js_code' => str,
    'compilation_level' => options[:level] || "ADVANCED_OPTIMIZATIONS",
    'output_format' => 'text',
    'output_info' => 'compiled_code'
  })

  response.body
end