Class: SHACL::Format
- Inherits:
-
RDF::Format
- Object
- RDF::Format
- SHACL::Format
- Defined in:
- vendor/bundler/ruby/3.3.0/bundler/gems/shacl-e638b9acc6d8/lib/shacl/format.rb
Overview
SHACL format specification. Note that this format does not define any readers or writers.
Class Method Summary collapse
-
.cli_commands ⇒ Hash{Symbol => Lambda(Array, Hash)}
Hash of CLI commands appropriate for this format.
Methods inherited from RDF::Format
accept_type, accept_types, content_encoding, content_type, content_types, detect, each, file_extension, file_extensions, for, name, reader, reader_symbols, reader_types, require, symbols, to_sym, uri, uris, writer, writer_symbols, writer_types
Class Method Details
.cli_commands ⇒ Hash{Symbol => Lambda(Array, Hash)}
Hash of CLI commands appropriate for this format
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/shacl-e638b9acc6d8/lib/shacl/format.rb', line 13 def self.cli_commands { shacl: { description: "Validate repository given shape", help: %(shacl [--shape URI] [--focus Resource] [--replace] Evaluates the repository according the the specified shapes. If no shape file is specified, it will look for one or more shapes graphs using the sh:shapesGraph property found within the repository. ).gsub(/^\s+/, ''), parse: true, lambda: -> (argv, **) do shacl = case [:shape] when IO, StringIO SHACL.get_shapes(RDF::Reader.new([:shape]), **) when nil SHACL.from_queryable(RDF::CLI.repository, **) else SHACL.open([:shape], **) end if [:to_sxp] [:messages][:shacl] = {} [:messages][:shacl].merge!({"S-Expression": [SXP::Generator.string(shacl.to_sxp_bin)]}) else start = Time.now report = shacl.execute(RDF::CLI.repository, **) secs = Time.new - start [:logger].info "SHACL resulted in #{report.conform? ? 'success' : 'failure'} including #{report.count} results." [:logger].info "Validated in #{secs} seconds." [:messages][:shacl] = {result: report.conform? ? "Satisfied shape" : "Did not satisfy shape"} if report.conform? [:messages][:shacl] = {result: ["Satisfied shape"]} else RDF::CLI.repository << report [:messages][:shacl] = {result: ["Did not satisfy shape: #{report.count} results"]} [:messages].merge!(report.) end end RDF::CLI.repository end, options: [ RDF::CLI::Option.new( symbol: :focus, datatype: String, control: :text, on: ["--focus Resource"], description: "Focus node within repository" ) {|v| RDF::URI(v)}, RDF::CLI::Option.new( symbol: :replace, datatype: TrueClass, control: :checkbox, on: ["--replace"], description: "Replaces the data graph with the validation report" ) {|v| RDF::URI(v)}, RDF::CLI::Option.new( symbol: :shape, datatype: String, control: :url2, on: ["--shape URI"], description: "SHACL shapes graph location" ) {|v| RDF::URI(v)}, RDF::CLI::Option.new( symbol: :to_sxp, datatype: String, control: :checkbox, on: ["--to-sxp"], description: "Display parsed shapes as an S-Expression" ), ] } } end |