Class: Smurf::Stylesheet

Inherits:
Object
  • Object
show all
Defined in:
lib/smurf/stylesheet.rb

Defined Under Namespace

Modules: Minifier

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content) ⇒ Stylesheet

Returns a new instance of Stylesheet.



5
6
7
# File 'lib/smurf/stylesheet.rb', line 5

def initialize(content)
  @content = content.nil? ? nil : minify(content)
end

Class Method Details

.minifies?(paths) ⇒ Boolean

Returns:

  • (Boolean)


3
# File 'lib/smurf/stylesheet.rb', line 3

def self.minifies?(paths) !paths.grep(%r[\.css(\?\d+)?$]).empty?; end

Instance Method Details

#minifiedObject



9
# File 'lib/smurf/stylesheet.rb', line 9

def minified; @content; end

#minify(content) ⇒ Object

TODO: deal with string values better (urls, content blocks, etc.)



12
13
14
15
16
# File 'lib/smurf/stylesheet.rb', line 12

def minify(content)
  class << content; include Minifier; end
  content.compress_whitespace.remove_comments.remove_spaces_outside_block.
    remove_spaces_inside_block.trim_last_semicolon.strip
end