Sha256: d659e48cc11154ba390a4be6763f93981a6fb3687e18c68118d4d53801b5265f

Contents?: true

Size: 1.6 KB

Versions: 41

Compression:

Stored size: 1.6 KB

Contents

# ===========================================================================
# Project:   Abbot - SproutCore Build Tools
# Copyright: ©2009 Apple Inc.
#            portions copyright @2006-2011 Strobe Inc.
#            and contributors
# ===========================================================================

require "sproutcore/builders/base"
require 'fileutils'

require 'chance'

module SC

  # 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().
  #
  class Builder::Combine < Builder::Base

    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

  end

end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
sproutcore-1.11.0 lib/sproutcore/builders/combine.rb
sproutcore-1.11.0.rc3 lib/sproutcore/builders/combine.rb
sproutcore-1.11.0.rc2 lib/sproutcore/builders/combine.rb
sproutcore-1.11.0.rc1 lib/sproutcore/builders/combine.rb
sproutcore-1.10.3.1 lib/sproutcore/builders/combine.rb
sproutcore-1.10.2 lib/sproutcore/builders/combine.rb
sproutcore-1.10.1 lib/sproutcore/builders/combine.rb
sproutcore-1.10.0 lib/sproutcore/builders/combine.rb
sproutcore-1.10.0.rc.3 lib/sproutcore/builders/combine.rb
sproutcore-1.10.0.rc.2 lib/sproutcore/builders/combine.rb
sproutcore-1.10.0.rc.1 lib/sproutcore/builders/combine.rb
sproutcore-1.9.2 lib/sproutcore/builders/combine.rb
sproutcore-1.9.1 lib/sproutcore/builders/combine.rb
sproutcore-1.9.0 lib/sproutcore/builders/combine.rb
sproutcore-1.8.2.1 lib/sproutcore/builders/combine.rb
sproutcore-1.8.1 lib/sproutcore/builders/combine.rb
sproutcore-1.8.0 lib/sproutcore/builders/combine.rb
sproutcore-1.7.1.beta-java lib/sproutcore/builders/combine.rb
sproutcore-1.7.1.beta lib/sproutcore/builders/combine.rb
sproutcore-1.6.0.1-java lib/sproutcore/builders/combine.rb