class Compass::Stats::CssFile

Attributes

css[RW]
file_size[RW]
path[RW]
prop_count[RW]
selector_count[RW]

Public Class Methods

new(path) click to toggle source
# File lib/compass/stats.rb, line 33
def initialize(path)
  require 'css_parser'
  self.path = path
  self.css = CssParser::Parser.new
  self.css.add_block!(contents)
  self.selector_count = 0
  self.prop_count = 0
end

Public Instance Methods

analyze!() click to toggle source
# File lib/compass/stats.rb, line 47
def analyze!
  self.file_size = File.size(path)
  css.each_selector do |selector, declarations, specificity|
    sels = selector.split(/,/).size
    props = declarations.split(/;/).size
    self.selector_count += sels
    self.prop_count += props
  end
end
contents() click to toggle source
# File lib/compass/stats.rb, line 41
def contents
  @contents ||= File.read(path)
end
lines() click to toggle source
# File lib/compass/stats.rb, line 44
def lines
  contents.inject(0){|m,c| m + 1 }
end