class Compass::Stats::CssFile

Attributes

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

Public Class Methods

new(path) click to toggle source
# File lib/compass/stats.rb, line 32
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 46
def analyze!
  css.each_selector do |selector, declarations, specificity|
    sels = selector.split(%r,/).size
    props = declarations.split(%r;/).size
    self.selector_count += sels
    self.prop_count += props
  end
end
contents() click to toggle source
# File lib/compass/stats.rb, line 40
def contents
  @contents ||= File.read(path)
end
lines() click to toggle source
# File lib/compass/stats.rb, line 43
def lines
  contents.inject(0){|m,c| m + 1 }
end