Class: SHACL::Algebra::PatternConstraintComponent
- Inherits:
-
ConstraintComponent
- Object
- SPARQL::Algebra::Operator
- Operator
- ConstraintComponent
- SHACL::Algebra::PatternConstraintComponent
- Defined in:
- lib/shacl/algebra/pattern.rb
Constant Summary collapse
- NAME =
:pattern
Constants inherited from Operator
Operator::BUILTIN_KEYS, Operator::PARAMETERS
Instance Attribute Summary
Attributes inherited from Operator
#graph, #options, #shapes_graph
Instance Method Summary collapse
-
#conforms(node, path: nil, depth: 0, **options) ⇒ Array<SHACL::ValidationResult>
Specifies a regular expression that each value node matches to satisfy the condition.
Methods inherited from ConstraintComponent
Methods inherited from Operator
add_component, apply_op, #comment, component_params, #deactivated?, from_expanded_value, from_json, #id, iri, #iri, #label, #not_satisfied, params, parse_path, #satisfy, to_rdf, #to_sxp_bin, #type
Instance Method Details
#conforms(node, path: nil, depth: 0, **options) ⇒ Array<SHACL::ValidationResult>
Specifies a regular expression that each value node matches to satisfy the condition.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/shacl/algebra/pattern.rb', line 23 def conforms(node, path: nil, depth: 0, **) log_debug(NAME, depth: depth) {SXP::Generator.string({node: node}.to_sxp_bin)} pattern = Array(operands.first).first flags = operands.last.last if operands.last.is_a?(Array) && operands.last.first == :flags flags = flags.to_s regex_opts = 0 regex_opts |= Regexp::MULTILINE if flags.include?(?m) regex_opts |= Regexp::IGNORECASE if flags.include?(?i) regex_opts |= Regexp::EXTENDED if flags.include?(?x) pat = Regexp.new(pattern, regex_opts) compares = !node.node? && pat.match?(node.to_s) satisfy(focus: node, path: path, value: node, message: "is#{' not' unless compares} a match #{pat.inspect}", resultSeverity: (.fetch(:severity) unless compares), component: RDF::Vocab::SHACL.PatternConstraintComponent, **) end |