Class: Glossarist::Validation::Rules::DomainRefRule
- Defined in:
- lib/glossarist/validation/rules/domain_ref_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 |
# File 'lib/glossarist/validation/rules/domain_ref_rule.rb', line 12 def applicable?(context) context.concept.data&.domains&.any? end |
#category ⇒ Object
8 |
# File 'lib/glossarist/validation/rules/domain_ref_rule.rb', line 8 def category = :quality |
#check(context) ⇒ Object
16 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 42 43 44 45 46 47 48 |
# File 'lib/glossarist/validation/rules/domain_ref_rule.rb', line 16 def check(context) concept = context.concept fname = context.file_name issues = [] (concept.data.domains || []).each_with_index do |domain, idx| has_ref = domain.concept_id || domain.urn unless has_ref issues << issue( "domain #{idx + 1} has neither concept_id nor urn", location: fname, suggestion: "Provide at least concept_id or urn for the domain reference", ) end next unless domain.ref_type == "section" && domain.concept_id register = context.collection_context.dataset_register next unless register unless register.section_exists?(domain.concept_id) issues << issue( "domain #{idx + 1} references section '#{domain.concept_id}' " \ "that does not exist in register.yaml", location: fname, suggestion: "Add section '#{domain.concept_id}' to " \ "register.yaml or fix the reference", ) end end issues end |
#code ⇒ Object
7 |
# File 'lib/glossarist/validation/rules/domain_ref_rule.rb', line 7 def code = "GLS-309" |
#scope ⇒ Object
10 |
# File 'lib/glossarist/validation/rules/domain_ref_rule.rb', line 10 def scope = :concept |
#severity ⇒ Object
9 |
# File 'lib/glossarist/validation/rules/domain_ref_rule.rb', line 9 def severity = "warning" |