Class: Compass::Stats::SassFile
- Inherits:
-
Object
- Object
- Compass::Stats::SassFile
- Defined in:
- lib/compass/stats.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
-
#visitor ⇒ Object
readonly
Returns the value of attribute visitor.
Instance Method Summary collapse
- #analyze! ⇒ Object
- #contents ⇒ Object
-
#initialize(path) ⇒ SassFile
constructor
A new instance of SassFile.
- #lines ⇒ Object
- #mixin_count ⇒ Object
- #mixin_def_count ⇒ Object
- #prop_count ⇒ Object
- #rule_count ⇒ Object
- #tree ⇒ Object
- #visit_tree! ⇒ Object
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
#path ⇒ Object
Returns the value of attribute path.
56 57 58 |
# File 'lib/compass/stats.rb', line 56 def path @path end |
#visitor ⇒ Object (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 |
#contents ⇒ Object
61 62 63 |
# File 'lib/compass/stats.rb', line 61 def contents @contents ||= File.read(path) end |
#lines ⇒ Object
75 76 77 |
# File 'lib/compass/stats.rb', line 75 def lines contents.inject(0){|m,c| m + 1 } end |
#mixin_count ⇒ Object
87 88 89 |
# File 'lib/compass/stats.rb', line 87 def mixin_count visitor.mixin_count end |
#mixin_def_count ⇒ Object
84 85 86 |
# File 'lib/compass/stats.rb', line 84 def mixin_def_count visitor.mixin_def_count end |
#prop_count ⇒ Object
81 82 83 |
# File 'lib/compass/stats.rb', line 81 def prop_count visitor.prop_count end |
#rule_count ⇒ Object
78 79 80 |
# File 'lib/compass/stats.rb', line 78 def rule_count visitor.rule_count end |
#tree ⇒ Object
64 65 66 |
# File 'lib/compass/stats.rb', line 64 def tree @tree = Sass::Engine.new(contents, Compass.configuration.).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 |