Class: SC::Builder::Combine

Inherits:
Base
  • Object
show all
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

#entry

Instance Method Summary collapse

Methods inherited from Base

build, #initialize, #joinlines, #readlines, #replace_static_url, #static_url, #writelines

Constructor Details

This class inherits a constructor from SC::Builder::Base

Instance Method Details

#build(dst_path) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/sproutcore/builders/combine.rb', line 20

def build(dst_path)
  lines = []
  entries = entry.ordered_entries || entry.source_entries
  
  entries.each do |entry|
    src_path = entry.stage!.staging_path
    next unless File.exist?(src_path)
    
    lines << "/* >>>>>>>>>> BEGIN #{entry.filename} */\n"
    lines += readlines(src_path)
    lines << "\n"
  end
  writelines dst_path, lines
end