Class: Glossarist::Validation::Rules::SchemaVersionRule

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

def applicable?(context)
  context.concept.is_a?(ManagedConcept)
end

#categoryObject



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

def category = :schema

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

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

  version = concept.schema_version
  if version.nil? || version.to_s.strip.empty?
    issues << issue(
      "concept has no schema_version",
      location: fname,
      suggestion: "Add schema_version: \"3\" to the concept",
    )
  elsif version.to_s != "3"
    issues << issue(
      "concept has schema_version '#{version}', expected '3'",
      location: fname,
      suggestion: "Run schema migration to upgrade to version 3",
    )
  end

  issues
end

#codeObject



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

def code = "GLS-010"

#scopeObject



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

def scope = :concept

#severityObject



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

def severity = "warning"