Class: Chemicalml::Convention::Dictionary::Constraints::DictionaryNamespaceShouldEndWithSlashOrHash

Inherits:
Constraint::NodeConstraint
  • Object
show all
Defined in:
lib/chemicalml/convention/dictionary/constraints/dictionary_namespace_should_end_with_slash_or_hash.rb

Overview

The namespace URI SHOULD end with / or # so terms can be referenced by appending them to the URI. Warning level.

Instance Method Summary collapse

Methods inherited from Constraint::NodeConstraint

#check

Instance Method Details

#check_node(node, path) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/chemicalml/convention/dictionary/constraints/dictionary_namespace_should_end_with_slash_or_hash.rb', line 11

def check_node(node, path)

  ns = node.namespace.to_s
  return [] if ns.empty?
  return [] if ns.end_with?('/', '#')

  [violation(path: path.join('/'),
             message: "dictionary namespace #{ns.inspect} should end with / or # " \
                      'so terms can be referenced by appending',
             severity: :warning)]
end