Class: Glossarist::Validation::Rules::DuplicateTermRule

Inherits:
Base
  • Object
show all
Defined in:
lib/glossarist/validation/rules/duplicate_term_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/duplicate_term_rule.rb', line 12

def applicable?(context)
  context.concepts.any?
end

#categoryObject



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

def check(context)
  term_index = build_term_index(context.concepts)
  issues = []

  term_index.each do |(lang, term), ids|
    next if ids.size <= 1

    issues << issue(
      "Duplicate preferred term '#{term}' in #{lang}: " \
      "concepts #{ids.join(', ')}",
      code: code, severity: severity,
      location: lang,
      suggestion: "Differentiate the terms or consolidate the concepts",
    )
  end

  issues
end

#codeObject



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

def code = "GLS-302"

#scopeObject



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

def scope = :collection

#severityObject



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

def severity = "warning"