Class: ThemeCheck::Check
- Inherits:
-
Object
- Object
- ThemeCheck::Check
- Includes:
- JsonHelpers
- Defined in:
- lib/theme_check/check.rb
Direct Known Subclasses
Constant Summary collapse
- SEVERITIES =
[ :error, :suggestion, :style, ]
- CATEGORIES =
[ :liquid, :translation, :json, ]
Instance Attribute Summary collapse
-
#offenses ⇒ Object
Returns the value of attribute offenses.
-
#options ⇒ Object
Returns the value of attribute options.
-
#theme ⇒ Object
Returns the value of attribute theme.
Class Method Summary collapse
- .all ⇒ Object
- .can_disable(disableable = nil) ⇒ Object
- .category(category = nil) ⇒ Object
- .doc(doc = nil) ⇒ Object
- .severity(severity = nil) ⇒ Object
Instance Method Summary collapse
- #can_disable? ⇒ Boolean
- #category ⇒ Object
- #code_name ⇒ Object
- #doc ⇒ Object
- #ignore! ⇒ Object
- #ignored? ⇒ Boolean
- #severity ⇒ Object
- #to_s ⇒ Object
- #unignore! ⇒ Object
Methods included from JsonHelpers
Instance Attribute Details
#offenses ⇒ Object
Returns the value of attribute offenses.
9 10 11 |
# File 'lib/theme_check/check.rb', line 9 def offenses @offenses end |
#options ⇒ Object
Returns the value of attribute options.
10 11 12 |
# File 'lib/theme_check/check.rb', line 10 def end |
#theme ⇒ Object
Returns the value of attribute theme.
8 9 10 |
# File 'lib/theme_check/check.rb', line 8 def theme @theme end |
Class Method Details
.all ⇒ Object
25 26 27 |
# File 'lib/theme_check/check.rb', line 25 def all @all ||= [] end |
.can_disable(disableable = nil) ⇒ Object
54 55 56 57 58 59 |
# File 'lib/theme_check/check.rb', line 54 def can_disable(disableable = nil) unless disableable.nil? @can_disable = disableable end defined?(@can_disable) ? @can_disable : true end |
.category(category = nil) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/theme_check/check.rb', line 39 def category(category = nil) if category unless CATEGORIES.include?(category) raise ArgumentError, "unknown category. Use: #{CATEGORIES.join(', ')}" end @category = category end @category if defined?(@category) end |
.doc(doc = nil) ⇒ Object
49 50 51 52 |
# File 'lib/theme_check/check.rb', line 49 def doc(doc = nil) @doc = doc if doc @doc if defined?(@doc) end |
.severity(severity = nil) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/theme_check/check.rb', line 29 def severity(severity = nil) if severity unless SEVERITIES.include?(severity) raise ArgumentError, "unknown severity. Use: #{SEVERITIES.join(', ')}" end @severity = severity end @severity if defined?(@severity) end |
Instance Method Details
#can_disable? ⇒ Boolean
90 91 92 |
# File 'lib/theme_check/check.rb', line 90 def can_disable? self.class.can_disable end |
#category ⇒ Object
66 67 68 |
# File 'lib/theme_check/check.rb', line 66 def category self.class.category end |
#code_name ⇒ Object
74 75 76 |
# File 'lib/theme_check/check.rb', line 74 def code_name self.class.name.demodulize end |
#doc ⇒ Object
70 71 72 |
# File 'lib/theme_check/check.rb', line 70 def doc self.class.doc end |
#ignore! ⇒ Object
78 79 80 |
# File 'lib/theme_check/check.rb', line 78 def ignore! @ignored = true end |
#ignored? ⇒ Boolean
86 87 88 |
# File 'lib/theme_check/check.rb', line 86 def ignored? defined?(@ignored) && @ignored end |
#severity ⇒ Object
62 63 64 |
# File 'lib/theme_check/check.rb', line 62 def severity self.class.severity end |
#to_s ⇒ Object
94 95 96 97 98 99 100 101 |
# File 'lib/theme_check/check.rb', line 94 def to_s s = +"#{code_name}:\n" properties = { severity: severity, category: category, doc: doc }.merge() properties.each_pair do |name, value| s << " #{name}: #{value}\n" if value end s end |
#unignore! ⇒ Object
82 83 84 |
# File 'lib/theme_check/check.rb', line 82 def unignore! @ignored = false end |