Class: SC::Builder::Combine
- Defined in:
- lib/sproutcore/builders/combine.rb
Overview
This builder combines several javascript files into a single file. It is used to prepare a single javascript file for production use. This build tool expects the javascript files to have already been processed for any build directives such sc_static().
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
build, #initialize, #joinlines, #read, #readlines, #replace_static_url, #sc_static_match, #static_url, #writeline, #writelinebinary, #writelines
Constructor Details
This class inherits a constructor from SC::Builder::Base
Instance Method Details
#build(dst_path) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/sproutcore/builders/combine.rb', line 22 def build(dst_path) lines = "" entries = entry[:ordered_entries] || entry[:source_entries] target_name = entry.target[:target_name].to_s.sub(/^\//,'') if entry[:top_level_lazy_instantiation] && entry[:combined] lines << "; if ((typeof SC !== 'undefined') && SC && !SC.LAZY_INSTANTIATION) { SC.LAZY_INSTANTIATION = {}; } if(!SC.LAZY_INSTANTIATION['#{target_name}']) { SC.LAZY_INSTANTIATION['#{target_name}'] = []; } SC.LAZY_INSTANTIATION['#{target_name}'].push( ( function() { " end entries.each do |entry| src_path = entry.stage![:staging_path] next unless File.exist?(src_path) lines << "/* >>>>>>>>>> BEGIN #{entry[:filename]} */\n" + File.read(src_path) + "\n" end if entry[:top_level_lazy_instantiation] && entry[:combined] lines << " } ) ); " end writelines dst_path, lines end |