Class: FrontCompiler::CssSource
- Inherits:
-
SourceCode
- Object
- String
- SourceCode
- FrontCompiler::CssSource
- Includes:
- NestedStyles
- Defined in:
- lib/front_compiler/css_source.rb,
lib/front_compiler/css_source/nested_styles.rb
Defined Under Namespace
Modules: NestedStyles
Constant Summary
Constants included from NestedStyles
NestedStyles::CSS_CONSTRUCTION_RE
Instance Method Summary collapse
-
#remove_comments! ⇒ Object
removes all the comments out of the given source.
-
#remove_empty_lines! ⇒ Object
removes all the empty lines out of the source code.
-
#remove_trailing_spaces! ⇒ Object
removes tailing whitespaces out of the source code.
-
#to_javascript ⇒ Object
converts the source in such a way that it could be delivered with javascript in the same file.
Methods included from NestedStyles
#convert_nested_styles!, #initialize
Methods inherited from SourceCode
#compact, #compact!, #initialize
Instance Method Details
#remove_comments! ⇒ Object
removes all the comments out of the given source
12 13 14 15 16 |
# File 'lib/front_compiler/css_source.rb', line 12 def remove_comments! string_safely do gsub!(/\/\*.*?\*\//im, '') end end |
#remove_empty_lines! ⇒ Object
removes all the empty lines out of the source code
19 20 21 22 23 |
# File 'lib/front_compiler/css_source.rb', line 19 def remove_empty_lines! string_safely do gsub!(/\n\s*\n/m, "\n") end end |
#remove_trailing_spaces! ⇒ Object
removes tailing whitespaces out of the source code
26 27 28 29 30 31 32 33 34 |
# File 'lib/front_compiler/css_source.rb', line 26 def remove_trailing_spaces! string_safely do gsub!(/\s+/im, ' ') gsub!(/\s*(\+|>|\||~|\{|\}|,|\)|\(|;|:|\*)\s*/im, '\1') gsub!(/;\}/, '}') gsub!(/\)([^;}\s])/, ') \1') strip! end end |
#to_javascript ⇒ Object
converts the source in such a way that it could be delivered with javascript in the same file
38 39 40 41 42 |
# File 'lib/front_compiler/css_source.rb', line 38 def to_javascript "document.write(\"<style type=\\\"text/css\\\">#{ compact.gsub('"', '\"') }</style>\");" end |