Class: Glossarist::Validation::Rules::SourceEnumRule
- Defined in:
- lib/glossarist/validation/rules/source_type_rule.rb
Constant Summary collapse
- VALID_TYPES =
Glossarist::GlossaryDefinition::CONCEPT_SOURCE_TYPES
- VALID_STATUSES =
Glossarist::GlossaryDefinition::CONCEPT_SOURCE_STATUSES
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
15 16 17 |
# File 'lib/glossarist/validation/rules/source_type_rule.rb', line 15 def applicable?(context) context.concept.localizations&.any? end |
#category ⇒ Object
8 |
# File 'lib/glossarist/validation/rules/source_type_rule.rb', line 8 def category = :schema |
#check(context) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/glossarist/validation/rules/source_type_rule.rb', line 19 def check(context) concept = context.concept fname = context.file_name issues = [] concept.localizations.flat_map(&:all_sources).each_with_index do |source, idx| unless VALID_TYPES.include?(source.type) issues << issue( "source #{idx + 1} has invalid type '#{source.type}'", code: "GLS-202", severity: severity, location: fname, suggestion: "Use one of: #{VALID_TYPES.join(', ')}", ) end next unless source.status && !VALID_STATUSES.include?(source.status) issues << issue( "source #{idx + 1} has invalid status '#{source.status}'", code: "GLS-203", severity: severity, location: fname, suggestion: "Use one of: #{VALID_STATUSES.join(', ')}", ) end issues end |
#code ⇒ Object
7 |
# File 'lib/glossarist/validation/rules/source_type_rule.rb', line 7 def code = "GLS-202" |
#scope ⇒ Object
10 |
# File 'lib/glossarist/validation/rules/source_type_rule.rb', line 10 def scope = :concept |
#severity ⇒ Object
9 |
# File 'lib/glossarist/validation/rules/source_type_rule.rb', line 9 def severity = "error" |