Sha256: 57b3cd8ccb9967f808d941961accc028c1fcfb76b80b9efe49adb6cd17c1ee25

Contents?: true

Size: 506 Bytes

Versions: 28

Compression:

Stored size: 506 Bytes

Contents

module Sinatra::AssetPack
  class ClosureEngine < Engine
    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
  end

  Compressor.register :js, :closure, ClosureEngine
end

Version data entries

28 entries across 28 versions & 3 rubygems

Version Path
sinatra-assetpack-0.3.5 lib/sinatra/assetpack/engines/closure.rb
sinatra-assetpack-0.3.3 lib/sinatra/assetpack/engines/closure.rb
sinatra-assetpack-0.3.2 lib/sinatra/assetpack/engines/closure.rb
sinatra-assetpack-0.3.1 lib/sinatra/assetpack/engines/closure.rb
sinatra-assetpack-0.3.0 lib/sinatra/assetpack/engines/closure.rb
sinatra-assetpack-0.2.8 lib/sinatra/assetpack/engines/closure.rb
sinatra-assetpack-0.2.7 lib/sinatra/assetpack/engines/closure.rb
sinatra-assetpack-0.2.6 lib/sinatra/assetpack/engines/closure.rb
sinatra-assetpack-0.2.5 lib/sinatra/assetpack/engines/closure.rb
sinatra-assetpack-0.2.4 lib/sinatra/assetpack/engines/closure.rb
sinatra-assetpack-0.2.3 lib/sinatra/assetpack/engines/closure.rb
sinatra-assetpack-0.2.2 lib/sinatra/assetpack/engines/closure.rb
sinatra-assetpack-0.2.1 lib/sinatra/assetpack/engines/closure.rb
sinatra-assetpack-0.2.0 lib/sinatra/assetpack/engines/closure.rb
sinatra-assetpack-0.1.7 lib/sinatra/assetpack/engines/closure.rb
sundawg-sinatra-assetpack-fork-0.1.6 lib/sinatra/assetpack/engines/closure.rb
sinatra-assetpack-0.1.6 lib/sinatra/assetpack/engines/closure.rb
sinatra-assetpack-0.1.5 lib/sinatra/assetpack/engines/closure.rb
sinatra-assetpack-0.1.4 lib/sinatra/assetpack/engines/closure.rb
sinatra-assetpack-0.1.3 lib/sinatra/assetpack/engines/closure.rb