Class: Compass::Stats::SassFile
- Inherits:
-
Object
- Object
- Compass::Stats::SassFile
- Defined in:
- lib/compass/stats.rb
Instance Attribute Summary collapse
-
#file_size ⇒ Object
Returns the value of attribute file_size.
-
#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.
62 63 64 |
# File 'lib/compass/stats.rb', line 62 def initialize(path) self.path = path end |
Instance Attribute Details
#file_size ⇒ Object
Returns the value of attribute file_size.
60 61 62 |
# File 'lib/compass/stats.rb', line 60 def file_size @file_size end |
#path ⇒ Object
Returns the value of attribute path.
58 59 60 |
# File 'lib/compass/stats.rb', line 58 def path @path end |
#visitor ⇒ Object (readonly)
Returns the value of attribute visitor.
59 60 61 |
# File 'lib/compass/stats.rb', line 59 def visitor @visitor end |
Instance Method Details
#analyze! ⇒ Object
78 79 80 81 |
# File 'lib/compass/stats.rb', line 78 def analyze! self.file_size = File.size(path) visit_tree! end |
#contents ⇒ Object
65 66 67 |
# File 'lib/compass/stats.rb', line 65 def contents @contents ||= File.read(path) end |
#lines ⇒ Object
82 83 84 |
# File 'lib/compass/stats.rb', line 82 def lines contents.inject(0){|m,c| m + 1 } end |
#mixin_count ⇒ Object
94 95 96 |
# File 'lib/compass/stats.rb', line 94 def mixin_count visitor.mixin_count end |
#mixin_def_count ⇒ Object
91 92 93 |
# File 'lib/compass/stats.rb', line 91 def mixin_def_count visitor.mixin_def_count end |
#prop_count ⇒ Object
88 89 90 |
# File 'lib/compass/stats.rb', line 88 def prop_count visitor.prop_count end |
#rule_count ⇒ Object
85 86 87 |
# File 'lib/compass/stats.rb', line 85 def rule_count visitor.rule_count end |
#tree ⇒ Object
68 69 70 71 72 |
# File 'lib/compass/stats.rb', line 68 def tree opts = Compass.configuration. opts[:syntax] = path[-4..-1].to_sym @tree = Sass::Engine.new(contents, opts).to_tree end |
#visit_tree! ⇒ Object
73 74 75 76 77 |
# File 'lib/compass/stats.rb', line 73 def visit_tree! @visitor = StatsVisitor.new tree.visit_depth_first(@visitor) @visitor end |