Class: Coyote::Bundles::JavaScript

Inherits:
Base
  • Object
show all
Defined in:
lib/coyote/bundles/javascript.rb

Instance Attribute Summary

Attributes inherited from Base

#assets, #contents, #target

Instance Method Summary collapse

Methods inherited from Base

#add, #add_dependencies, #add_directory, #add_file, #empty!, #files, filetypes, #initialize, #manifest, #path_is_directory_or_kosher_file?, #rebuild!, #reset!, #save!, #update!

Constructor Details

This class inherits a constructor from Coyote::Bundles::Base

Instance Method Details

#compress!Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/coyote/bundles/javascript.rb', line 7

def compress!
  notify "Compressing bundle...", :warning, :timestamp
  compiler = Coyote::ClosureCompiler.new.compile(self.contents)
  if compiler.success?
    self.contents = compiler.compiled_code
  elsif compiler.file_too_big?
    notify "Input code too big for API, creating uncompressed file\n", :failure
  elsif compiler.errors
    notify "Google closure API failed to compile, creating uncompressed file\n", :failure
    notify "Errors:", :failure
    notify "#{compiler.errors.to_s}", :failure
  end      
end