Class: Fusion::Optimized

Inherits:
Basic
  • Object
show all
Defined in:
lib/fusion.rb

Direct Known Subclasses

DebugOptimized

Instance Method Summary collapse

Methods inherited from Basic

#gather_files, #get_output_file, #get_remote_file, #initialize, #run

Constructor Details

This class inherits a constructor from Fusion::Basic

Instance Method Details

#bundle(config) ⇒ Object

Raises:

  • (Exception)


154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/fusion.rb', line 154

def bundle(config)
  options = []

  options << ["js_output_file", get_output_file(config)]
  options << ["compilation_level", "SIMPLE_OPTIMIZATIONS"]
  options << ["language_in","ECMASCRIPT5"] # This will be compatible w all newer browsers, and helps us avoid old IE quirks

  gather_files(config).each do |input_file|
    options << ["js", input_file]
  end

  options.collect! do |option|
    "--#{option[0]} #{option[1]}"
  end

  jar_file = File.join(__FILE__.split("/")[0..-3].join("/"), "/compiler/compiler.jar")
  cmd = "java -jar #{jar_file} #{options.join(" ")}"
  io = IO.popen(cmd, "w")
  io.close

  raise Exception.new("Error creating bundle: #{get_output_file(config)}") unless $?.exitstatus == 0
end