shex 0.6.2 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -102,7 +102,9 @@ module ShEx::Algebra
102
102
  def match?(value, depth: 0)
103
103
  initial_match = case operands.first
104
104
  when :wildcard then true
105
- when RDF::Literal then value.language.to_s.start_with?(operands.first)
105
+ when RDF::Literal
106
+ value.language? &&
107
+ (operands.first.to_s.empty? || value.language.to_s.match?(%r(^#{operands.first}((-.*)?)$)))
106
108
  else false
107
109
  end
108
110
 
@@ -97,7 +97,7 @@ module ShEx::Algebra
97
97
  ref.is_a?(ShapeExpression) ||
98
98
  structure_error("#{json_type} must reference a ShapeExpression: #{ref}")
99
99
  else
100
- structure_error("#{json_type} must reference a ShapeExpression: #{ref}")
100
+ structure_error("#{json_type} must be a ShapeExpression or reference: #{expresson.to_sxp}")
101
101
  end
102
102
  super
103
103
  end
@@ -16,6 +16,24 @@ module ShEx::Algebra
16
16
  raise NotImplementedError, "#matches Not implemented in #{self.class}"
17
17
  end
18
18
 
19
+ ##
20
+ # expressions must be TripleExpressions or references to TripleExpressions
21
+ #
22
+ # @raise [ShEx::StructureError] if the value is invalid
23
+ def validate_expressions!
24
+ expressions.each do |op|
25
+ case op
26
+ when TripleExpression
27
+ when RDF::Resource
28
+ ref = schema.find(op)
29
+ ref.is_a?(TripleExpression) ||
30
+ structure_error("#{json_type} must reference a TripleExpression: #{ref}")
31
+ else
32
+ structure_error("#{json_type} must be a TripleExpression or reference: #{op.to_sxp}")
33
+ end
34
+ end
35
+ end
36
+
19
37
  ##
20
38
  # Included TripleConstraints
21
39
  # @return [Array<TripleConstraints>]
data/lib/shex/algebra.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  $:.unshift(File.expand_path("../..", __FILE__))
2
2
  require 'sparql/algebra'
3
- require 'sxp'
4
3
 
5
4
  module ShEx
6
5
  # Based on the SPARQL Algebra, operators for executing a patch