Class: Glossarist::Validation::Rules::ConceptMentionRule

Inherits:
Base
  • Object
show all
Defined in:
lib/glossarist/validation/rules/concept_mention_rule.rb

Instance Method Summary collapse

Methods inherited from Base

inherited

Instance Method Details

#applicable?(context) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/glossarist/validation/rules/concept_mention_rule.rb', line 12

def applicable?(context)
  context.concept.localizations&.any?
end

#categoryObject



8
# File 'lib/glossarist/validation/rules/concept_mention_rule.rb', line 8

def category = :references

#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
# File 'lib/glossarist/validation/rules/concept_mention_rule.rb', line 16

def check(context)
  concept = context.concept
  fname = context.file_name
  extractor = ReferenceExtractor.new
  issues = []

  refs = extractor.extract_from_managed_concept(concept)
    .select { |r| r.is_a?(ConceptReference) && r.local? }

  refs.each do |ref|
    next if ref.ref_type == "designation"
    next if context.concept_ids.include?(ref.concept_id)

    issues << issue(
      "unresolved intra-set reference: #{ref.term} -> #{ref.concept_id}",
      code: "GLS-100", severity: severity,
      location: fname,
      suggestion: "add concept '#{ref.concept_id}' to the dataset " \
                  "or verify the reference",
    )
  end

  issues
end

#codeObject



7
# File 'lib/glossarist/validation/rules/concept_mention_rule.rb', line 7

def code = "GLS-100"

#scopeObject



10
# File 'lib/glossarist/validation/rules/concept_mention_rule.rb', line 10

def scope = :concept

#severityObject



9
# File 'lib/glossarist/validation/rules/concept_mention_rule.rb', line 9

def severity = "warning"