Class: Glossarist::Validation::Rules::EntryStatusRule

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

Constant Summary collapse

VALID_STATUSES =
%w[valid superseded withdrawn draft].freeze

Instance Method Summary collapse

Methods inherited from Base

#applicable?, inherited

Instance Method Details

#categoryObject



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

def category = :schema

#check(context) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/glossarist/validation/rules/entry_status_rule.rb', line 14

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

  (concept.localizations&.values || []).each do |l10n|
    lang = l10n.language_code || "unknown"
    status = l10n.data&.entry_status
    next unless status
    next if VALID_STATUSES.include?(status)

    issues << issue(
      "#{fname}/#{lang}: invalid entry_status '#{status}' " \
      "(expected one of: #{VALID_STATUSES.join(', ')})",
      code: code, severity: "error",
      location: "#{fname}/#{lang}",
    )
  end

  issues
end

#codeObject



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

def code = "GLS-003"

#scopeObject



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

def scope = :concept

#severityObject



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

def severity = "error"