Class: ThemeCheck::DisabledChecks
- Inherits:
-
Object
- Object
- ThemeCheck::DisabledChecks
- Defined in:
- lib/theme_check/disabled_checks.rb
Constant Summary collapse
- DISABLE_START =
'theme-check-disable'
- DISABLE_END =
'theme-check-enable'
- DISABLE_PREFIX_PATTERN =
/#{DISABLE_START}|#{DISABLE_END}/
- ACTION_DISABLE_CHECKS =
:disable
- ACTION_ENABLE_CHECKS =
:enable
- ACTION_UNRELATED_COMMENT =
:unrelated
Instance Method Summary collapse
-
#all ⇒ Object
Get a list of all the individual disabled checks.
-
#all_disabled? ⇒ Boolean
Whether all checks should be disabled.
-
#any? ⇒ Boolean
Whether any checks are currently disabled.
-
#full_document_disabled? ⇒ Boolean
If the first line of the document is a theme-check-disable comment.
-
#initialize ⇒ DisabledChecks
constructor
A new instance of DisabledChecks.
- #update(node) ⇒ Object
Constructor Details
#initialize ⇒ DisabledChecks
Returns a new instance of DisabledChecks.
13 14 15 16 17 |
# File 'lib/theme_check/disabled_checks.rb', line 13 def initialize @disabled = [] @all_disabled = false @full_document_disabled = false end |
Instance Method Details
#all ⇒ Object
Get a list of all the individual disabled checks
48 49 50 |
# File 'lib/theme_check/disabled_checks.rb', line 48 def all @disabled end |
#all_disabled? ⇒ Boolean
Whether all checks should be disabled
43 44 45 |
# File 'lib/theme_check/disabled_checks.rb', line 43 def all_disabled? @all_disabled end |
#any? ⇒ Boolean
Whether any checks are currently disabled
38 39 40 |
# File 'lib/theme_check/disabled_checks.rb', line 38 def any? !@disabled.empty? || @all_disabled end |
#full_document_disabled? ⇒ Boolean
If the first line of the document is a theme-check-disable comment
53 54 55 |
# File 'lib/theme_check/disabled_checks.rb', line 53 def full_document_disabled? @full_document_disabled end |
#update(node) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/theme_check/disabled_checks.rb', line 19 def update(node) text = comment_text(node) if start_disabling?(text) @disabled = checks_from_text(text) @all_disabled = @disabled.empty? if node&.line_number == 1 @full_document_disabled = true end elsif stop_disabling?(text) checks = checks_from_text(text) @disabled = checks.empty? ? [] : @disabled - checks @all_disabled = false end end |