Class: Glossarist::Validation::Rules::LanguageListRule
- Defined in:
- lib/glossarist/validation/rules/language_list_rule.rb
Instance Method Summary collapse
- #applicable?(context) ⇒ Boolean
- #category ⇒ Object
- #check(context) ⇒ Object
- #code ⇒ Object
- #scope ⇒ Object
- #severity ⇒ Object
Methods inherited from Base
Instance Method Details
#applicable?(context) ⇒ Boolean
12 13 14 15 |
# File 'lib/glossarist/validation/rules/language_list_rule.rb', line 12 def applicable?(context) declared = context.declared_languages declared.is_a?(Array) && declared.any? end |
#category ⇒ Object
8 |
# File 'lib/glossarist/validation/rules/language_list_rule.rb', line 8 def category = :integrity |
#check(context) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/glossarist/validation/rules/language_list_rule.rb', line 17 def check(context) declared = Set.new(context.declared_languages) actual = Set.new(context.actual_languages) issues = [] missing = declared - actual if missing.any? issues << issue( "declared languages not found in concepts: #{missing.sort.join(', ')}", code: code, severity: severity, suggestion: "Update the languages list or add missing localizations", ) end extra = actual - declared if extra.any? issues << issue( "concepts use languages not declared: #{extra.sort.join(', ')}", code: code, severity: severity, suggestion: "Add these languages to the languages list in metadata", ) end issues end |
#code ⇒ Object
7 |
# File 'lib/glossarist/validation/rules/language_list_rule.rb', line 7 def code = "GLS-012" |
#scope ⇒ Object
10 |
# File 'lib/glossarist/validation/rules/language_list_rule.rb', line 10 def scope = :collection |
#severity ⇒ Object
9 |
# File 'lib/glossarist/validation/rules/language_list_rule.rb', line 9 def severity = "warning" |