Class: SeeLessEssEss::Checker
- Inherits:
-
Object
- Object
- SeeLessEssEss::Checker
- Defined in:
- lib/see-less-ess-ess.rb
Instance Method Summary collapse
- #css_classes_whitelist ⇒ Object
- #does_not_use(sequence) ⇒ Object
- #html_tags_whitelist ⇒ Object
-
#initialize(extractor, used_classes) ⇒ Checker
constructor
A new instance of Checker.
- #unused(simple) ⇒ Object
Constructor Details
#initialize(extractor, used_classes) ⇒ Checker
Returns a new instance of Checker.
59 60 61 62 |
# File 'lib/see-less-ess-ess.rb', line 59 def initialize(extractor, used_classes) @extractor = extractor @used_classes = used_classes end |
Instance Method Details
#css_classes_whitelist ⇒ Object
83 84 85 |
# File 'lib/see-less-ess-ess.rb', line 83 def css_classes_whitelist @class_whitelist ||= @extractor.css_classes + @used_classes end |
#does_not_use(sequence) ⇒ Object
64 65 66 67 68 69 70 71 |
# File 'lib/see-less-ess-ess.rb', line 64 def does_not_use(sequence) selectors = sequence.members.reject { |s| s.is_a?(String) } selectors.any? do |selector| selector.members.any? do |simple| unused(simple) end end end |
#html_tags_whitelist ⇒ Object
86 87 88 |
# File 'lib/see-less-ess-ess.rb', line 86 def @tag_whitelist ||= @extractor. end |
#unused(simple) ⇒ Object
73 74 75 76 77 78 79 80 81 |
# File 'lib/see-less-ess-ess.rb', line 73 def unused(simple) if simple.is_a?(Sass::Selector::Class) !css_classes_whitelist.include?(simple.name[0].to_s) elsif simple.is_a?(Sass::Selector::Element) !.include?(simple.name[0].to_s) else false end end |