Class: Glossarist::Validation::Rules::ExtensionalDefinitionRule

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

Overview

Validates that extensional definitions do not contain open-ended wording, per ISO 704:2022 §6.4.5.1. An extensional definition must be an EXHAUSTIVE enumeration — open-ended wordings like ..., etc., and so on, and similar, and others, including violate this principle because they imply the enumeration is incomplete.

Mirrors concept-model's check-definition-rules §6.4.5.1 open-ended-wording check, exposed as a consumer-side Validation::Rule.

Scope: concept (rule runs once per concept). Inspects every DetailedDefinition with type: extensional across all of the concept's localized definitions.

Constant Summary collapse

OPEN_ENDED_PATTERNS =

ISO 704:2022 §6.4.5.1 — patterns that signal incomplete enumeration in an extensional definition. The list is intentionally conservative: only wordings that clearly indicate "more exist beyond what's listed."

[
  /\.\.\./,                         # ellipsis
  /\betc\b\.?/i,                    # etc / etc.
  /\band\s+similar\b/i,             # and similar
  /\band\s+so\s+on\b/i,             # and so on
  /\band\s+the\s+like\b/i,          # and the like
  /\band\s+others?\b/i,             # and other / and others
  /\bsuch\s+as\b/i,                 # such as (often partial)
  /\bincluding\b/i,                 # including (often partial)
  /\be\.?g\.?\b/i,                  # e.g. / eg
].freeze

Instance Method Summary collapse

Methods inherited from Base

inherited

Instance Method Details

#applicable?(context) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
45
46
# File 'lib/glossarist/validation/rules/extensional_definition_rule.rb', line 42

def applicable?(context)
  return false unless context.concept.is_a?(V3::ManagedConcept)

  concept_has_extensional_definition?(context.concept)
end

#categoryObject



38
# File 'lib/glossarist/validation/rules/extensional_definition_rule.rb', line 38

def category = :schema

#check(context) ⇒ Object



48
49
50
51
52
53
54
55
56
# File 'lib/glossarist/validation/rules/extensional_definition_rule.rb', line 48

def check(context)
  issues = []

  each_extensional_definition(context.concept) do |l10n_lang, defn, path|
    check_definition(defn, l10n_lang, path, context.file_name, issues)
  end

  issues
end

#codeObject



37
# File 'lib/glossarist/validation/rules/extensional_definition_rule.rb', line 37

def code = "GLS-223"

#scopeObject



40
# File 'lib/glossarist/validation/rules/extensional_definition_rule.rb', line 40

def scope = :concept

#severityObject



39
# File 'lib/glossarist/validation/rules/extensional_definition_rule.rb', line 39

def severity = "warning"