Class: SC::Builder::StringWrapper
- Defined in:
- lib/sproutcore/builders/string_wrapper.rb
Overview
If a target is a prefetched module, this builder will take the contents of its packed file and wrap it in strings.
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
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/sproutcore/builders/string_wrapper.rb', line 17 def build(dst_path) src_path = entry.source_entry[:build_path] entry.source_entry.build! return if not File.exist? src_path # Normalize the target name by removing any initial forward slash target = entry.target target_name = target[:target_name].to_s.sub(/^\//,'') # Set the source property of the module's SC.MODULE_INFO hash to the # JSON-escaped contents of the file. output = "SC.MODULE_INFO['#{target_name}'].source = " content = readlines(src_path) output += content.join.to_json output += ";" writeline dst_path, output end |