Module: ShEx
- Defined in:
- lib/shex.rb,
lib/shex/format.rb,
lib/shex/parser.rb,
lib/shex/algebra.rb,
lib/shex/version.rb,
lib/shex/terminals.rb
Overview
A ShEx runtime for RDF.rb.
Defined Under Namespace
Modules: Algebra, Meta, Terminals, VERSION Classes: Error, Extension, Format, NotMatched, NotSatisfied, ParseError, Parser, StructureError, Test
Constant Summary collapse
- CONTEXT =
Location of the ShEx JSON-LD context
"http://www.w3.org/ns/shex.jsonld"
- EXTENSIONS =
Extensions defined in this gem
%w{test}
Class Method Summary collapse
-
.execute(expression, queryable, map, format: 'shexc', **options) ⇒ Hash{RDF::Term => Array<ShapeResult>}
Parse and validate the given ShEx ‘expression` string against `queriable`.
-
.Extension(uri) ⇒ Class
Alias for ‘ShEx::Extension.create`.
-
.open(filename, format: 'shexc', **options, &block) ⇒ ShEx::Algebra::Schema
Parses input from the given file name or URL.
-
.parse(expression, format: 'shexc', **options) ⇒ ShEx::Algebra::Schema
Parse the given ShEx ‘query` string.
-
.satisfies?(expression, queryable, map, format: 'shexc', **options) ⇒ Boolean
Parse and validate the given ShEx ‘expression` string against `queriable`.
Class Method Details
.execute(expression, queryable, map, format: 'shexc', **options) ⇒ Hash{RDF::Term => Array<ShapeResult>}
Parse and validate the given ShEx ‘expression` string against `queriable`.
75 76 77 78 79 80 |
# File 'lib/shex.rb', line 75 def self.execute(expression, queryable, map, format: 'shexc', **) shex = self.parse(expression, .merge(format: format)) queryable = queryable || RDF::Graph.new shex.execute(queryable, map, ) end |
.Extension(uri) ⇒ Class
Alias for ‘ShEx::Extension.create`.
105 106 107 |
# File 'lib/shex.rb', line 105 def self.Extension(uri) Extension.send(:create, uri) end |
.open(filename, format: 'shexc', **options, &block) ⇒ ShEx::Algebra::Schema
Parses input from the given file name or URL.
58 59 60 61 62 |
# File 'lib/shex.rb', line 58 def self.open(filename, format: 'shexc', **, &block) RDF::Util::File.open_file(filename, ) do |file| self.parse(file, .merge(format: format)) end end |
.parse(expression, format: 'shexc', **options) ⇒ ShEx::Algebra::Schema
Parse the given ShEx ‘query` string.
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/shex.rb', line 34 def self.parse(expression, format: 'shexc', **) case format.to_s when 'shexc' then Parser.new(expression, ).parse when 'shexj' expression = expression.read if expression.respond_to?(:read) Algebra.from_shexj(JSON.parse(expression), ) when 'sxp' expression = expression.read if expression.respond_to?(:read) Algebra.from_sxp(expression, ) else raise "Unknown expression format: #{format.inspect}" end end |
.satisfies?(expression, queryable, map, format: 'shexc', **options) ⇒ Boolean
Parse and validate the given ShEx ‘expression` string against `queriable`.
93 94 95 96 97 98 |
# File 'lib/shex.rb', line 93 def self.satisfies?(expression, queryable, map, format: 'shexc', **) shex = self.parse(expression, .merge(format: format)) queryable = queryable || RDF::Graph.new shex.satisfies?(queryable, map, ) end |