Sha256: f3619d789f2b962b8ca72d5dcec117f712f9ed09d2a44ac62e13067e51eec5f4

Contents?: true

Size: 1.46 KB

Versions: 17

Compression:

Stored size: 1.46 KB

Contents

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

require File.expand_path(File.join(File.dirname(__FILE__), 'base'))
require 'fileutils'

module SC

  # This builder is used to process a single CSS stylesheet.  Converts any
  # build tool directives (such as sc_require() and sc_resource()) into 
  # comments.  It will also substitute any calls to sc_static() (or 
  # static_url())  This builder does NOT handle combining multiple stylesheets
  # into one.  See the Builder::CombineStylesheets builder instead.
  #
  class Builder::Stylesheet < Builder::Base
    
    def build(dst_path)
      lines = readlines(entry.source_path).map { |l| rewrite_inline_code(l) }
      writelines dst_path, lines
    end

    # Rewrites any inline content such as static urls.  Subclasseses can
    # override this to rewrite any other inline content.
    #
    # The default will rewrite calls to static_url().
    def rewrite_inline_code(line)
      # look for sc_require, require or sc_resource.  wrap in comment
      line = line.gsub(/((sc_require|require|sc_resource)\(\s*['"].*["']\s*\)\s*\;)/, '/* \1 */')
      line = replace_static_url(line)
    end
    
    def static_url(url=''); "url('#{url}')" ; end
    
  end
  
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
sproutit-sproutcore-1.0.20090721145285 lib/sproutcore/builders/stylesheet.rb
sproutcore-1.0.1046 lib/sproutcore/builders/stylesheet.rb
sproutcore-1.0.1043 lib/sproutcore/builders/stylesheet.rb
sproutcore-1.0.1042 lib/sproutcore/builders/stylesheet.rb
sproutcore-1.0.1037 lib/sproutcore/builders/stylesheet.rb
sproutcore-1.0.1035 lib/sproutcore/builders/stylesheet.rb
sproutcore-1.0.1031 lib/sproutcore/builders/stylesheet.rb
sproutcore-1.0.1030 lib/sproutcore/builders/stylesheet.rb
sproutcore-1.0.1029 lib/sproutcore/builders/stylesheet.rb
sproutcore-1.0.1027 lib/sproutcore/builders/stylesheet.rb
sproutcore-1.0.1028 lib/sproutcore/builders/stylesheet.rb
sproutcore-1.0.1026 lib/sproutcore/builders/stylesheet.rb
sproutcore-1.0.1025 lib/sproutcore/builders/stylesheet.rb
sproutcore-1.0.1024 lib/sproutcore/builders/stylesheet.rb
sproutcore-1.0.1009 lib/sproutcore/builders/stylesheet.rb
sproutcore-1.0.1008 lib/sproutcore/builders/stylesheet.rb
sproutcore-1.0.1003 lib/sproutcore/builders/stylesheet.rb