Sha256: 853471f2afb04b2411b3e1cb3b98e0a3af99b69e4c9e3c841cae13a39a39da5b

Contents?: true

Size: 1.46 KB

Versions: 13

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

13 entries across 13 versions & 1 rubygems

Version Path
sproutit-sproutcore-1.0.0.20090407205609 lib/sproutcore/builders/stylesheet.rb
sproutit-sproutcore-1.0.0.20090408130025 lib/sproutcore/builders/stylesheet.rb
sproutit-sproutcore-1.0.0.20090416161445 lib/sproutcore/builders/stylesheet.rb
sproutit-sproutcore-1.0.0.20090720093355 lib/sproutcore/builders/stylesheet.rb
sproutit-sproutcore-1.0.0.20090720202429 lib/sproutcore/builders/stylesheet.rb
sproutit-sproutcore-1.0.0.20090721125122 lib/sproutcore/builders/stylesheet.rb
sproutit-sproutcore-1.0.126 lib/sproutcore/builders/stylesheet.rb
sproutit-sproutcore-1.0.20090721145236 lib/sproutcore/builders/stylesheet.rb
sproutit-sproutcore-1.0.20090721145251 lib/sproutcore/builders/stylesheet.rb
sproutit-sproutcore-1.0.20090721145280 lib/sproutcore/builders/stylesheet.rb
sproutit-sproutcore-1.0.20090721145281 lib/sproutcore/builders/stylesheet.rb
sproutit-sproutcore-1.0.20090721145282 lib/sproutcore/builders/stylesheet.rb
sproutit-sproutcore-1.0.203 lib/sproutcore/builders/stylesheet.rb