Class: SC::Builder::Stylesheet
- Defined in:
- lib/sproutcore/builders/stylesheet.rb
Overview
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.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #build(dst_path) ⇒ Object
-
#rewrite_inline_code(line) ⇒ Object
Rewrites any inline content such as static urls.
- #static_url(url = '') ⇒ Object
Methods inherited from Base
build, #initialize, #joinlines, #readlines, #replace_static_url, #writelines
Constructor Details
This class inherits a constructor from SC::Builder::Base
Instance Method Details
#build(dst_path) ⇒ Object
21 22 23 24 |
# File 'lib/sproutcore/builders/stylesheet.rb', line 21 def build(dst_path) lines = readlines(entry.source_path).map { |l| rewrite_inline_code(l) } writelines dst_path, lines end |
#rewrite_inline_code(line) ⇒ Object
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().
30 31 32 33 34 |
# File 'lib/sproutcore/builders/stylesheet.rb', line 30 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 |
#static_url(url = '') ⇒ Object
36 |
# File 'lib/sproutcore/builders/stylesheet.rb', line 36 def static_url(url=''); "url('#{url}')" ; end |