Class: Fusion::DebugOptimized
- Defined in:
- lib/fusion.rb
Instance Method Summary collapse
Methods inherited from Optimized
Methods inherited from Basic
#get_output_file, #get_remote_file, #initialize, #run
Constructor Details
This class inherits a constructor from Fusion::Basic
Instance Method Details
#gather_files(config) ⇒ Object
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
# File 'lib/fusion.rb', line 180 def gather_files(config) @log.debug "Warning ... using Debug compiler." input_files = [] if(config[:input_files]) config[:input_files].each do |input_file| @log.debug "Remote file? #{!(input_file =~ URI::regexp).nil?}" if (input_file =~ URI::regexp).nil? # Not a URL input_files << File.join(@bundle_options[:project_path], input_file) else # This is a remote file, if we don't have it, get it input_files << get_remote_file(input_file) end end end if (config[:input_directory]) directory = File.join(@bundle_options[:project_path],config[:input_directory]) file_names = Dir.open(directory).entries.sort.find_all {|filename| filename.end_with?(".js") } input_files += file_names.collect do |file_name| File.join(directory, file_name) end end input_files.uniq! # Now wrap each file in a try/catch block and update the input_files list FileUtils::mkpath(File.join(@bundle_options[:project_path],".debug")) input_files.collect do |input_file| contents = File.open(input_file).read new_input_file ="" file_name = input_file.split("/").last if input_file.include?(".remote") new_input_file = input_file.gsub(".remote",".debug") else new_input_file = File.join(@bundle_options[:project_path], ".debug", file_name) end new_contents = "///////////////////\n//mw_bundle: #{input_file}\n///////////////////\n\n try{\n#{contents}\n}catch(e){\nconsole.log('Error (' + e + 'generated in : #{input_file}');\n}" File.open(new_input_file,"w") {|f| f << new_contents} new_input_file end end |