Class: Compass::Stats::SassFile

Inherits:
Object
  • Object
show all
Defined in:
lib/compass/stats.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ SassFile

Returns a new instance of SassFile.



58
59
60
# File 'lib/compass/stats.rb', line 58

def initialize(path)
  self.path = path
end

Instance Attribute Details

#pathObject

Returns the value of attribute path.



56
57
58
# File 'lib/compass/stats.rb', line 56

def path
  @path
end

#visitorObject (readonly)

Returns the value of attribute visitor.



57
58
59
# File 'lib/compass/stats.rb', line 57

def visitor
  @visitor
end

Instance Method Details

#analyze!Object



72
73
74
# File 'lib/compass/stats.rb', line 72

def analyze!
  visit_tree!
end

#contentsObject



61
62
63
# File 'lib/compass/stats.rb', line 61

def contents
  @contents ||= File.read(path)
end

#linesObject



75
76
77
# File 'lib/compass/stats.rb', line 75

def lines
  contents.inject(0){|m,c| m + 1 }
end

#mixin_countObject



87
88
89
# File 'lib/compass/stats.rb', line 87

def mixin_count
  visitor.mixin_count
end

#mixin_def_countObject



84
85
86
# File 'lib/compass/stats.rb', line 84

def mixin_def_count
  visitor.mixin_def_count
end

#prop_countObject



81
82
83
# File 'lib/compass/stats.rb', line 81

def prop_count
  visitor.prop_count
end

#rule_countObject



78
79
80
# File 'lib/compass/stats.rb', line 78

def rule_count
  visitor.rule_count
end

#treeObject



64
65
66
# File 'lib/compass/stats.rb', line 64

def tree
  @tree = Sass::Engine.new(contents, Compass.configuration.to_sass_engine_options).to_tree
end

#visit_tree!Object



67
68
69
70
71
# File 'lib/compass/stats.rb', line 67

def visit_tree!
  @visitor = StatsVisitor.new
  tree.visit_depth_first(@visitor)
  @visitor
end