# 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
# 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(%r,/).size props = declarations.split(%r;/).size self.selector_count += sels self.prop_count += props end end
# File lib/compass/stats.rb, line 41 def contents @contents ||= File.read(path) end
# File lib/compass/stats.rb, line 44 def lines contents.inject(0){|m,c| m + 1 } end