class SC::Builder::StringWrapper

If a target is a prefetched module, this builder will take the contents of its packed file and wrap it in strings.

Public Instance Methods

build(dst_path) click to toggle source
# 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