You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+119-2Lines changed: 119 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,10 +19,12 @@ This is a pure-Ruby library for working with the [Shape Expressions Language][Sh
19
19
20
20
The ShEx gem implements a [ShEx][ShExSpec] Shape Expression engine.
21
21
22
-
*`ShEx::Parser` parses ShExC formatted documents generating executable operators which can be serialized as [S-Expressions](http://en.wikipedia.org/wiki/S-expression).
22
+
*`ShEx::Parser` parses ShExC and ShExJ formatted documents generating executable operators which can be serialized as [S-Expressions](http://en.wikipedia.org/wiki/S-expression).
23
23
*`ShEx::Algebra` executes operators against Any `RDF::Graph`, including compliant [RDF.rb][].
24
+
*[Implementation Report](file.earl.html)
24
25
25
-
## Example
26
+
## Examples
27
+
### Validating a node using ShExC
26
28
27
29
require 'rubygems'
28
30
require 'rdf/turtle'
@@ -46,6 +48,121 @@ The ShEx gem implements a [ShEx][ShExSpec] Shape Expression engine.
ShEx has an extension mechanism using [Semantic Actions](https://shexspec.github.io/spec/#semantic-actions). Extensions may be implemented in Ruby ShEx by sub-classing {ShEx::Extension} and implementing {ShEx::Extension#visit} and possibly {ShEx::Extension#initialize}, {ShEx::Extension#enter}, {ShEx::Extension#exit}, and {ShEx::Extension#close}. The `#visit` method will be called as part of the `#satisfies?` operation.
147
+
148
+
require 'shex'
149
+
class ShEx::Test < ShEx::Extension("http://shex.io/extensions/Test/")
The `#enter` method will be called on any {ShEx::Algebra::TripleExpression} that includes a {ShEx::Algebra::SemAct} referencing the extension, while the `#exit` method will be called on exit, even if not satisfied.
162
+
163
+
The `#initialize` method is called when {ShEx::Algebra::Schema#execute} starts and `#close` called on exit, even if not satisfied.
164
+
165
+
To make sure your extension is found, make sure to require it before the shape is executed.
0 commit comments