ld-patch 0.3.0 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/README.md +28 -15
- data/VERSION +1 -1
- data/bin/ldpatch +5 -5
- data/lib/ld/patch.rb +5 -5
- data/lib/ld/patch/format.rb +24 -10
- data/lib/ld/patch/meta.rb +25 -1
- data/lib/ld/patch/parser.rb +25 -73
- metadata +29 -37
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: fb352bd5bbc3691896fc9db702efc945b23f1c788839a0b0455ba353f4b37ae8
|
|
4
|
+
data.tar.gz: b07b9e419fd2dc3b290af7d399c4b05b3e2e81c5edd2a8fc22cfb483892240b9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dfa6ad6e3127cc6d0ce8827675e9ee223c7dd68d513c2c86588b0b53ec145e08c514cef5aa20a613ad939c607f4bb80e33a8ecd6a0692980ac742275f4e35198
|
|
7
|
+
data.tar.gz: bf91d175b92ebd050bf9f6f77b5e9482e9fec9421d4f52d241b82fc4bb2d7781db49ee2cf371bbe1d205d34d5a9067b48024b822d3bd853801b6e5d0cdfebfeb
|
data/README.md
CHANGED
|
@@ -24,7 +24,7 @@ This gem implements the [LD Patch][] specification with a couple of changes and/
|
|
|
24
24
|
* 100% free and unencumbered [public domain](http://unlicense.org/) software.
|
|
25
25
|
* Complete [Linked Data Patch Format][LD Patch] parsing and execution
|
|
26
26
|
* Implementation Report: {file:etc/earl.html EARL}
|
|
27
|
-
* Compatible with Ruby >= 2.
|
|
27
|
+
* Compatible with Ruby >= 2.4.
|
|
28
28
|
|
|
29
29
|
## Documentation
|
|
30
30
|
Full documentation available on [Rubydoc.info][LD-Patch doc]
|
|
@@ -50,9 +50,22 @@ Full documentation available on [Rubydoc.info][LD-Patch doc]
|
|
|
50
50
|
Bind ?ruby <> / doap:programming-language .
|
|
51
51
|
Cut ?ruby .
|
|
52
52
|
)
|
|
53
|
-
operator = LD::Patch.parse(patch, base_uri: "
|
|
53
|
+
operator = LD::Patch.parse(patch, base_uri: "https://rubygems.org/gems/ld-patch")
|
|
54
54
|
operator.execute(queryable) # alternatively queryable.query(operator)
|
|
55
55
|
|
|
56
|
+
## Command Line
|
|
57
|
+
When the `linkeddata` gem is installed, RDF.rb includes a `rdf` executable which acts as a wrapper to perform a number of different
|
|
58
|
+
operations on RDF files, including LD::Patch, which is used as a stream command and must be followed by serialize to see the results. The commands specific to LD::Patch is
|
|
59
|
+
|
|
60
|
+
* `ld-patch`: Patch the current graph using a patch file
|
|
61
|
+
|
|
62
|
+
Using this command requires either a `patch-input` where the patch is URI encoded, or `patch-file`, which references a URI or file path to the patch.
|
|
63
|
+
Example usage:
|
|
64
|
+
|
|
65
|
+
rdf patch serialize https://raw.githubusercontent.com/ruby-rdf/ld-patch/develop/etc/doap.ttl \
|
|
66
|
+
--patch-input Add%20%7B%20%3Chttp://example.org/s2%3E%20%3Chttp://example.org/p2%3E%20%3Chttp://example.org/o2%3E%20%7D%20. \
|
|
67
|
+
--output-format ttl
|
|
68
|
+
|
|
56
69
|
## Implementation Notes
|
|
57
70
|
The reader uses the [EBNF][] gem to generate first, follow and branch tables, and uses the `Parser` and `Lexer` modules to implement the LD Patch parser.
|
|
58
71
|
|
|
@@ -60,18 +73,18 @@ The parser takes branch and follow tables generated from the [LD Patch Grammar](
|
|
|
60
73
|
|
|
61
74
|
## Dependencies
|
|
62
75
|
|
|
63
|
-
* [Ruby](http://ruby-lang.org/) (>= 2.
|
|
64
|
-
* [RDF.rb](
|
|
65
|
-
* [EBNF][] (~> 1.
|
|
66
|
-
* [SPARQL][] (~>
|
|
67
|
-
* [SXP][] (~>
|
|
68
|
-
* [RDF::XSD][] (~>
|
|
76
|
+
* [Ruby](http://ruby-lang.org/) (>= 2.4)
|
|
77
|
+
* [RDF.rb](https://rubygems.org/gems/rdf) (~> 3.1)
|
|
78
|
+
* [EBNF][] (~> 1.2)
|
|
79
|
+
* [SPARQL][] (~> 3.1)
|
|
80
|
+
* [SXP][] (~> 1.1)
|
|
81
|
+
* [RDF::XSD][] (~> 3.1)
|
|
69
82
|
|
|
70
83
|
## Mailing List
|
|
71
84
|
* <http://lists.w3.org/Archives/Public/public-rdf-ruby/>
|
|
72
85
|
|
|
73
86
|
## Author
|
|
74
|
-
* [Gregg Kellogg](
|
|
87
|
+
* [Gregg Kellogg](https://github.com/gkellogg) - <http://greggkellogg.net/>
|
|
75
88
|
|
|
76
89
|
## Contributing
|
|
77
90
|
This repository uses [Git Flow](https://github.com/nvie/gitflow) to mange development and release activity. All submissions _must_ be on a feature branch based on the _develop_ branch to ease staging and integration.
|
|
@@ -94,12 +107,12 @@ A copy of the [LD Patch EBNF](file:etc/ld-patch.ebnf) and derived parser files a
|
|
|
94
107
|
[YARD]: http://yardoc.org/
|
|
95
108
|
[YARD-GS]: http://rubydoc.info/docs/yard/file/docs/GettingStarted.md
|
|
96
109
|
[PDD]: http://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html
|
|
97
|
-
[RDF.rb]:
|
|
98
|
-
[RDF::XSD]:
|
|
99
|
-
[EBNF]:
|
|
100
|
-
[SPARQL]:
|
|
101
|
-
[Linked Data]:
|
|
110
|
+
[RDF.rb]: https://rubygems.org/gems/rdf
|
|
111
|
+
[RDF::XSD]: https://rubygems.org/gems/rdf-xsd
|
|
112
|
+
[EBNF]: https://rubygems.org/gems/ebnf
|
|
113
|
+
[SPARQL]: https://rubygems.org/gems/sparql
|
|
114
|
+
[Linked Data]: https://rubygems.org/gems/linkeddata
|
|
102
115
|
[SSE]: http://openjena.org/wiki/SSE
|
|
103
|
-
[SXP]:
|
|
116
|
+
[SXP]: https://rubygems.org/gems/sxp-ruby
|
|
104
117
|
[LD Patch]: http://www.w3.org/TR/ldpatch/
|
|
105
118
|
[LD-Patch doc]: http://rubydoc.info/github/ruby-rdf/ld-patch
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
3.1.1
|
data/bin/ldpatch
CHANGED
|
@@ -22,9 +22,9 @@ def run(graph, options = {})
|
|
|
22
22
|
|
|
23
23
|
patch = LD::Patch.parse(options[:patch], options)
|
|
24
24
|
|
|
25
|
-
puts ("\
|
|
25
|
+
puts ("\nSXP:\n" + patch.to_sse) if options[:debug] || options[:to_sxp]
|
|
26
26
|
|
|
27
|
-
unless options[:
|
|
27
|
+
unless options[:to_sxp]
|
|
28
28
|
res = patch.execute(graph, options)
|
|
29
29
|
puts res.dump(:ttl, base_uri: patch.base_uri, prefixes: patch.prefixes, standard_prefixes: true)
|
|
30
30
|
end
|
|
@@ -35,7 +35,7 @@ opts = GetoptLong.new(
|
|
|
35
35
|
["--execute", "-e", GetoptLong::REQUIRED_ARGUMENT],
|
|
36
36
|
["--patch", GetoptLong::REQUIRED_ARGUMENT],
|
|
37
37
|
["--progress", GetoptLong::NO_ARGUMENT],
|
|
38
|
-
["--to-
|
|
38
|
+
["--to-sxp", GetoptLong::NO_ARGUMENT],
|
|
39
39
|
["--validate", GetoptLong::NO_ARGUMENT],
|
|
40
40
|
["--verbose", GetoptLong::NO_ARGUMENT],
|
|
41
41
|
["--help", "-?", GetoptLong::NO_ARGUMENT]
|
|
@@ -50,7 +50,7 @@ opts.each do |opt, arg|
|
|
|
50
50
|
when '--execute' then options[:patch] = arg
|
|
51
51
|
when '--patch' then options[:patch] = RDF::Util::File.open_file(arg).read
|
|
52
52
|
when '--progress' then options[:debug] ||= 2
|
|
53
|
-
when '--to-
|
|
53
|
+
when '--to-sxp' then options[:to_sxp] = true
|
|
54
54
|
when '--validate' then options[:validate] = true
|
|
55
55
|
when '--verbose' then options[:verbose] = true
|
|
56
56
|
when "--help"
|
|
@@ -61,7 +61,7 @@ opts.each do |opt, arg|
|
|
|
61
61
|
puts " --execute,-e: Use option argument as the patch input"
|
|
62
62
|
puts " --patch: Location of patch document"
|
|
63
63
|
puts " --progress Display parse tree"
|
|
64
|
-
puts " --to-
|
|
64
|
+
puts " --to-sxp: Generate S-Expression for patch instead of running query"
|
|
65
65
|
puts " --validate: Validate patch document"
|
|
66
66
|
puts " --verbose: Display details of processing"
|
|
67
67
|
puts " --help,-?: This message"
|
data/lib/ld/patch.rb
CHANGED
|
@@ -14,7 +14,7 @@ module LD
|
|
|
14
14
|
autoload :Meta, 'ld/patch/meta'
|
|
15
15
|
autoload :Parser, 'ld/patch/parser'
|
|
16
16
|
autoload :Terminals, 'ld/patch/terminals'
|
|
17
|
-
autoload :
|
|
17
|
+
autoload :VERSION, 'ld/patch/version'
|
|
18
18
|
|
|
19
19
|
##
|
|
20
20
|
# Parse the given LD Patch `input` string.
|
|
@@ -28,8 +28,8 @@ module LD
|
|
|
28
28
|
# the base URI to use when resolving relative URIs
|
|
29
29
|
# @option (see LD::Patch::Parser#initialize)
|
|
30
30
|
# @return [SPARQL::Algebra::Operator] The executable parsed Patch
|
|
31
|
-
def self.parse(input, options
|
|
32
|
-
LD::Patch::Parser.new(input, options).parse
|
|
31
|
+
def self.parse(input, **options)
|
|
32
|
+
LD::Patch::Parser.new(input, **options).parse
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
class Error < StandardError
|
|
@@ -42,7 +42,7 @@ module LD
|
|
|
42
42
|
# @param [String, #to_s] message
|
|
43
43
|
# @param [Hash{Symbol => Object}] options
|
|
44
44
|
# @option options [Integer] :code (422)
|
|
45
|
-
def initialize(message, options
|
|
45
|
+
def initialize(message, **options)
|
|
46
46
|
@code = options.fetch(:status_code, 422)
|
|
47
47
|
super(message.to_s)
|
|
48
48
|
end
|
|
@@ -70,7 +70,7 @@ module LD
|
|
|
70
70
|
# @option options [String] :token (nil)
|
|
71
71
|
# @option options [Integer] :lineno (nil)
|
|
72
72
|
# @option options [Integer] :code (400)
|
|
73
|
-
def initialize(message, options
|
|
73
|
+
def initialize(message, **options)
|
|
74
74
|
@token = options[:token]
|
|
75
75
|
@lineno = options[:lineno] || (@token.lineno if @token.respond_to?(:lineno))
|
|
76
76
|
super(message.to_s, code: options.fetch(:code, 400))
|
data/lib/ld/patch/format.rb
CHANGED
|
@@ -20,29 +20,43 @@ module LD::Patch
|
|
|
20
20
|
def self.cli_commands
|
|
21
21
|
{
|
|
22
22
|
patch: {
|
|
23
|
-
description: "Patch the current graph using a
|
|
24
|
-
help: "patch [--patch 'patch'] [--patch-file file]",
|
|
23
|
+
description: "Patch the current graph using a patch file",
|
|
24
|
+
help: "patch [--patch-input 'patch'] [--patch-file file]",
|
|
25
|
+
control: :button,
|
|
25
26
|
parse: true,
|
|
26
27
|
lambda: -> (argv, opts) do
|
|
27
|
-
opts[:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
opts[:patch_input] ||= case opts[:patch_file]
|
|
29
|
+
when IO, StringIO then opts[:patch_file]
|
|
30
|
+
else RDF::Util::File.open_file(opts[:patch_file]) {|f| f.read}
|
|
31
|
+
end
|
|
32
|
+
raise ArgumentError, "Patching requires a patch or reference to patch resource" unless opts[:patch_input]
|
|
33
|
+
opts[:logger].info "Patch"
|
|
34
|
+
patch = LD::Patch.parse(opts[:patch_input], base_uri: opts.fetch(:patch_file, "https://rubygems.org/gems/ld-patch"))
|
|
35
|
+
opts[:messages][:reasoner] = {"S-Expression": [patch.to_sse]} if opts[:to_sxp]
|
|
31
36
|
RDF::CLI.repository.query(patch)
|
|
32
37
|
end,
|
|
33
38
|
options: [
|
|
34
39
|
RDF::CLI::Option.new(
|
|
35
|
-
symbol: :
|
|
40
|
+
symbol: :patch_input,
|
|
36
41
|
datatype: String,
|
|
37
|
-
|
|
42
|
+
control: :none,
|
|
43
|
+
on: ["--patch-input STRING"],
|
|
38
44
|
description: "Patch in URI encoded format"
|
|
39
|
-
) {|v|
|
|
45
|
+
) {|v| CGI.decode(v)},
|
|
40
46
|
RDF::CLI::Option.new(
|
|
41
47
|
symbol: :patch_file,
|
|
42
48
|
datatype: String,
|
|
49
|
+
control: :url2,
|
|
43
50
|
on: ["--patch-file URI"],
|
|
44
|
-
description: "
|
|
51
|
+
description: "Patch file"
|
|
45
52
|
) {|v| RDF::URI(v)},
|
|
53
|
+
RDF::CLI::Option.new(
|
|
54
|
+
symbol: :to_sxp,
|
|
55
|
+
datatype: String,
|
|
56
|
+
control: :checkbox,
|
|
57
|
+
on: ["--to-sxp"],
|
|
58
|
+
description: "Instead of patching repository, display parsed patch as an S-Expression"
|
|
59
|
+
),
|
|
46
60
|
]
|
|
47
61
|
}
|
|
48
62
|
}
|
data/lib/ld/patch/meta.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# This file is automatically generated by /Users/gregg/.rvm/gems/ruby-2.
|
|
1
|
+
# This file is automatically generated by /Users/gregg/.rvm/gems/ruby-2.3.3/bundler/gems/ebnf-7d5f4b7c477c/lib/ebnf/base.rb
|
|
2
2
|
# BRANCH derived from etc/ld-patch.ebnf
|
|
3
3
|
module LD::Patch::Meta
|
|
4
4
|
START = :ldpatch
|
|
@@ -2662,5 +2662,29 @@ module LD::Patch::Meta
|
|
|
2662
2662
|
:STRING_LITERAL_LONG_SINGLE_QUOTE,
|
|
2663
2663
|
:STRING_LITERAL_LONG_QUOTE],
|
|
2664
2664
|
}.freeze
|
|
2665
|
+
CLEANUP = {
|
|
2666
|
+
:_RDFLiteral_1 => :opt,
|
|
2667
|
+
:_bind_2 => :opt,
|
|
2668
|
+
:_collection_1 => :star,
|
|
2669
|
+
:_collection_2 => :merge,
|
|
2670
|
+
:_constraint_2 => :opt,
|
|
2671
|
+
:_graph_1 => :star,
|
|
2672
|
+
:_graph_3 => :merge,
|
|
2673
|
+
:_graph_4 => :opt,
|
|
2674
|
+
:_ldpatch_1 => :star,
|
|
2675
|
+
:_ldpatch_2 => :merge,
|
|
2676
|
+
:_objectList_1 => :star,
|
|
2677
|
+
:_objectList_3 => :merge,
|
|
2678
|
+
:path => :star,
|
|
2679
|
+
:_path_2 => :merge,
|
|
2680
|
+
:_predicateObjectList_1 => :star,
|
|
2681
|
+
:_predicateObjectList_3 => :merge,
|
|
2682
|
+
:_predicateObjectList_4 => :opt,
|
|
2683
|
+
:prologue => :star,
|
|
2684
|
+
:_prologue_1 => :merge,
|
|
2685
|
+
:_slice_1 => :opt,
|
|
2686
|
+
:_slice_2 => :opt,
|
|
2687
|
+
:_triples_3 => :opt,
|
|
2688
|
+
}.freeze
|
|
2665
2689
|
end
|
|
2666
2690
|
|
data/lib/ld/patch/parser.rb
CHANGED
|
@@ -177,11 +177,11 @@ module LD::Patch
|
|
|
177
177
|
end
|
|
178
178
|
|
|
179
179
|
# [13] path ::= ( '/' step | constraint )*
|
|
180
|
-
|
|
181
|
-
|
|
180
|
+
|
|
181
|
+
# [14] step ::= '^' iri | iri | INTEGER
|
|
182
|
+
production(:step) do |input, current, callback|
|
|
182
183
|
step = case
|
|
183
184
|
when current[:literal] then Algebra::Index.new(current[:literal])
|
|
184
|
-
when current[:constraint] then current[:constraint]
|
|
185
185
|
when current[:reverse] then Algebra::Reverse.new(current[:iri])
|
|
186
186
|
else current[:iri]
|
|
187
187
|
end
|
|
@@ -191,7 +191,7 @@ module LD::Patch
|
|
|
191
191
|
# [15] constraint ::= '[' path ( '=' value )? ']' | '!'
|
|
192
192
|
production(:constraint) do |input, current, callback|
|
|
193
193
|
path = Algebra::Path.new(*Array(current[:path]))
|
|
194
|
-
input[:
|
|
194
|
+
(input[:path] ||= []) << if current[:value]
|
|
195
195
|
Algebra::Constraint.new(path, current[:value])
|
|
196
196
|
elsif current[:path]
|
|
197
197
|
Algebra::Constraint.new(path)
|
|
@@ -295,7 +295,7 @@ module LD::Patch
|
|
|
295
295
|
str = lit.delete(:string)
|
|
296
296
|
lit[:datatype] = lit.delete(:iri) if lit[:iri]
|
|
297
297
|
lit[:language] = lit.delete(:language).last.downcase if lit[:language]
|
|
298
|
-
input[:literal] = RDF::Literal.new(str, lit) if str
|
|
298
|
+
input[:literal] = RDF::Literal.new(str, **lit) if str
|
|
299
299
|
end
|
|
300
300
|
end
|
|
301
301
|
|
|
@@ -323,7 +323,7 @@ module LD::Patch
|
|
|
323
323
|
# @yield [parser] `self`
|
|
324
324
|
# @yieldparam [LD::Patch::Parser] parser
|
|
325
325
|
# @return [LD::Patch::Parser] The parser instance, or result returned from block
|
|
326
|
-
def initialize(input = nil, options
|
|
326
|
+
def initialize(input = nil, **options, &block)
|
|
327
327
|
@input = case input
|
|
328
328
|
when IO, StringIO then input.read
|
|
329
329
|
else input.to_s.dup
|
|
@@ -349,26 +349,6 @@ module LD::Patch
|
|
|
349
349
|
end
|
|
350
350
|
end
|
|
351
351
|
|
|
352
|
-
##
|
|
353
|
-
# Returns `true` if the input string is syntactically valid.
|
|
354
|
-
#
|
|
355
|
-
# @return [Boolean]
|
|
356
|
-
def valid?
|
|
357
|
-
parse
|
|
358
|
-
true
|
|
359
|
-
rescue ParseError
|
|
360
|
-
false
|
|
361
|
-
end
|
|
362
|
-
|
|
363
|
-
# @return [String]
|
|
364
|
-
def to_sxp_bin
|
|
365
|
-
@result
|
|
366
|
-
end
|
|
367
|
-
|
|
368
|
-
def to_s
|
|
369
|
-
@result.to_sxp
|
|
370
|
-
end
|
|
371
|
-
|
|
372
352
|
##
|
|
373
353
|
# Accumulated errors found during processing
|
|
374
354
|
# @return [Array<String>]
|
|
@@ -386,10 +366,13 @@ module LD::Patch
|
|
|
386
366
|
# @return [SPARQL::Algebra::Operator, Object]
|
|
387
367
|
# @raise [ParseError] when illegal grammar detected.
|
|
388
368
|
def parse(prod = START)
|
|
389
|
-
ll1_parse(@input,
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
369
|
+
ll1_parse(@input,
|
|
370
|
+
prod.to_sym,
|
|
371
|
+
branch: BRANCH,
|
|
372
|
+
first: FIRST,
|
|
373
|
+
follow: FOLLOW,
|
|
374
|
+
whitespace: WS,
|
|
375
|
+
**@options
|
|
393
376
|
) do |context, *data|
|
|
394
377
|
case context
|
|
395
378
|
when :trace
|
|
@@ -514,57 +497,26 @@ module LD::Patch
|
|
|
514
497
|
# Return variable allocated to an ID.
|
|
515
498
|
# If no ID is provided, a new variable
|
|
516
499
|
# is allocated. Otherwise, any previous assignment will be used.
|
|
517
|
-
#
|
|
518
|
-
# The variable has a #distinguished? method applied depending on if this
|
|
519
|
-
# is a disinguished or non-distinguished variable. Non-distinguished
|
|
520
|
-
# variables are effectively the same as BNodes.
|
|
521
500
|
# @return [RDF::Query::Variable]
|
|
522
501
|
def variable(id, distinguished = true)
|
|
523
|
-
id
|
|
524
|
-
|
|
525
|
-
if id
|
|
526
|
-
@vars[id] ||= begin
|
|
527
|
-
v = RDF::Query::Variable.new(id)
|
|
528
|
-
v.distinguished = distinguished
|
|
529
|
-
v
|
|
530
|
-
end
|
|
531
|
-
else
|
|
532
|
-
unless distinguished
|
|
533
|
-
# Allocate a non-distinguished variable identifier
|
|
534
|
-
id = @nd_var_gen
|
|
535
|
-
@nd_var_gen = id.succ
|
|
536
|
-
end
|
|
502
|
+
@vars[id] ||= begin
|
|
537
503
|
v = RDF::Query::Variable.new(id)
|
|
538
504
|
v.distinguished = distinguished
|
|
539
505
|
v
|
|
540
506
|
end
|
|
541
507
|
end
|
|
542
508
|
|
|
543
|
-
# Used for generating BNode labels
|
|
544
|
-
attr_accessor :nd_var_gen
|
|
545
|
-
|
|
546
|
-
# Reset the bnode cache, always generating new nodes, and start generating BNodes instead of non-distinguished variables
|
|
547
|
-
def clear_bnode_cache
|
|
548
|
-
@nd_var_gen = false
|
|
549
|
-
@bnode_cache = {}
|
|
550
|
-
end
|
|
551
|
-
|
|
552
509
|
# Generate a BNode identifier
|
|
553
510
|
def bnode(id = nil)
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
(@bnode_cache ||= {})[id.to_s] ||= begin
|
|
564
|
-
new_bnode = RDF::Node.new
|
|
565
|
-
new_bnode.lexical = "_:#{id}"
|
|
566
|
-
new_bnode
|
|
567
|
-
end
|
|
511
|
+
unless id
|
|
512
|
+
id = @options[:anon_base]
|
|
513
|
+
@options[:anon_base] = @options[:anon_base].succ
|
|
514
|
+
end
|
|
515
|
+
# Don't use provided ID to avoid aliasing issues when re-serializing the graph, when the bnode identifiers are re-used
|
|
516
|
+
(@bnode_cache ||= {})[id.to_s] ||= begin
|
|
517
|
+
new_bnode = RDF::Node.new
|
|
518
|
+
new_bnode.lexical = "_:#{id}"
|
|
519
|
+
new_bnode
|
|
568
520
|
end
|
|
569
521
|
end
|
|
570
522
|
|
|
@@ -596,7 +548,7 @@ module LD::Patch
|
|
|
596
548
|
end
|
|
597
549
|
|
|
598
550
|
# Create a literal
|
|
599
|
-
def literal(value, options
|
|
551
|
+
def literal(value, **options)
|
|
600
552
|
options = options.dup
|
|
601
553
|
# Internal representation is to not use xsd:string, although it could arguably go the other way.
|
|
602
554
|
options.delete(:datatype) if options[:datatype] == RDF::XSD.string
|
|
@@ -605,7 +557,7 @@ module LD::Patch
|
|
|
605
557
|
"options: #{options.inspect}, " +
|
|
606
558
|
"validate: #{validate?.inspect}, "
|
|
607
559
|
end
|
|
608
|
-
RDF::Literal.new(value,
|
|
560
|
+
RDF::Literal.new(value, validate: validate?, **options)
|
|
609
561
|
end
|
|
610
562
|
end
|
|
611
563
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ld-patch
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 3.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Gregg Kellogg
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2020-07-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rdf
|
|
@@ -16,118 +16,112 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
19
|
+
version: '3.1'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
26
|
+
version: '3.1'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: ebnf
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '
|
|
34
|
-
- - ">="
|
|
35
|
-
- !ruby/object:Gem::Version
|
|
36
|
-
version: 1.0.1
|
|
33
|
+
version: '2.0'
|
|
37
34
|
type: :runtime
|
|
38
35
|
prerelease: false
|
|
39
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
40
37
|
requirements:
|
|
41
38
|
- - "~>"
|
|
42
39
|
- !ruby/object:Gem::Version
|
|
43
|
-
version: '
|
|
44
|
-
- - ">="
|
|
45
|
-
- !ruby/object:Gem::Version
|
|
46
|
-
version: 1.0.1
|
|
40
|
+
version: '2.0'
|
|
47
41
|
- !ruby/object:Gem::Dependency
|
|
48
42
|
name: sparql
|
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|
|
50
44
|
requirements:
|
|
51
45
|
- - "~>"
|
|
52
46
|
- !ruby/object:Gem::Version
|
|
53
|
-
version: '
|
|
47
|
+
version: '3.1'
|
|
54
48
|
type: :runtime
|
|
55
49
|
prerelease: false
|
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
57
51
|
requirements:
|
|
58
52
|
- - "~>"
|
|
59
53
|
- !ruby/object:Gem::Version
|
|
60
|
-
version: '
|
|
54
|
+
version: '3.1'
|
|
61
55
|
- !ruby/object:Gem::Dependency
|
|
62
56
|
name: sxp
|
|
63
57
|
requirement: !ruby/object:Gem::Requirement
|
|
64
58
|
requirements:
|
|
65
59
|
- - "~>"
|
|
66
60
|
- !ruby/object:Gem::Version
|
|
67
|
-
version: '1.
|
|
61
|
+
version: '1.1'
|
|
68
62
|
type: :runtime
|
|
69
63
|
prerelease: false
|
|
70
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
71
65
|
requirements:
|
|
72
66
|
- - "~>"
|
|
73
67
|
- !ruby/object:Gem::Version
|
|
74
|
-
version: '1.
|
|
68
|
+
version: '1.1'
|
|
75
69
|
- !ruby/object:Gem::Dependency
|
|
76
70
|
name: rdf-xsd
|
|
77
71
|
requirement: !ruby/object:Gem::Requirement
|
|
78
72
|
requirements:
|
|
79
73
|
- - "~>"
|
|
80
74
|
- !ruby/object:Gem::Version
|
|
81
|
-
version: '
|
|
75
|
+
version: '3.1'
|
|
82
76
|
type: :runtime
|
|
83
77
|
prerelease: false
|
|
84
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
85
79
|
requirements:
|
|
86
80
|
- - "~>"
|
|
87
81
|
- !ruby/object:Gem::Version
|
|
88
|
-
version: '
|
|
82
|
+
version: '3.1'
|
|
89
83
|
- !ruby/object:Gem::Dependency
|
|
90
84
|
name: json-ld
|
|
91
85
|
requirement: !ruby/object:Gem::Requirement
|
|
92
86
|
requirements:
|
|
93
87
|
- - "~>"
|
|
94
88
|
- !ruby/object:Gem::Version
|
|
95
|
-
version: '
|
|
89
|
+
version: '3.1'
|
|
96
90
|
type: :development
|
|
97
91
|
prerelease: false
|
|
98
92
|
version_requirements: !ruby/object:Gem::Requirement
|
|
99
93
|
requirements:
|
|
100
94
|
- - "~>"
|
|
101
95
|
- !ruby/object:Gem::Version
|
|
102
|
-
version: '
|
|
96
|
+
version: '3.1'
|
|
103
97
|
- !ruby/object:Gem::Dependency
|
|
104
98
|
name: rack
|
|
105
99
|
requirement: !ruby/object:Gem::Requirement
|
|
106
100
|
requirements:
|
|
107
101
|
- - "~>"
|
|
108
102
|
- !ruby/object:Gem::Version
|
|
109
|
-
version: '
|
|
103
|
+
version: '2.0'
|
|
110
104
|
type: :development
|
|
111
105
|
prerelease: false
|
|
112
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
113
107
|
requirements:
|
|
114
108
|
- - "~>"
|
|
115
109
|
- !ruby/object:Gem::Version
|
|
116
|
-
version: '
|
|
110
|
+
version: '2.0'
|
|
117
111
|
- !ruby/object:Gem::Dependency
|
|
118
112
|
name: rdf-spec
|
|
119
113
|
requirement: !ruby/object:Gem::Requirement
|
|
120
114
|
requirements:
|
|
121
115
|
- - "~>"
|
|
122
116
|
- !ruby/object:Gem::Version
|
|
123
|
-
version: '
|
|
117
|
+
version: '3.1'
|
|
124
118
|
type: :development
|
|
125
119
|
prerelease: false
|
|
126
120
|
version_requirements: !ruby/object:Gem::Requirement
|
|
127
121
|
requirements:
|
|
128
122
|
- - "~>"
|
|
129
123
|
- !ruby/object:Gem::Version
|
|
130
|
-
version: '
|
|
124
|
+
version: '3.1'
|
|
131
125
|
- !ruby/object:Gem::Dependency
|
|
132
126
|
name: open-uri-cached
|
|
133
127
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -154,56 +148,56 @@ dependencies:
|
|
|
154
148
|
requirements:
|
|
155
149
|
- - "~>"
|
|
156
150
|
- !ruby/object:Gem::Version
|
|
157
|
-
version: '3.
|
|
151
|
+
version: '3.9'
|
|
158
152
|
type: :development
|
|
159
153
|
prerelease: false
|
|
160
154
|
version_requirements: !ruby/object:Gem::Requirement
|
|
161
155
|
requirements:
|
|
162
156
|
- - "~>"
|
|
163
157
|
- !ruby/object:Gem::Version
|
|
164
|
-
version: '3.
|
|
158
|
+
version: '3.9'
|
|
165
159
|
- !ruby/object:Gem::Dependency
|
|
166
160
|
name: rspec-its
|
|
167
161
|
requirement: !ruby/object:Gem::Requirement
|
|
168
162
|
requirements:
|
|
169
163
|
- - "~>"
|
|
170
164
|
- !ruby/object:Gem::Version
|
|
171
|
-
version: '1.
|
|
165
|
+
version: '1.3'
|
|
172
166
|
type: :development
|
|
173
167
|
prerelease: false
|
|
174
168
|
version_requirements: !ruby/object:Gem::Requirement
|
|
175
169
|
requirements:
|
|
176
170
|
- - "~>"
|
|
177
171
|
- !ruby/object:Gem::Version
|
|
178
|
-
version: '1.
|
|
172
|
+
version: '1.3'
|
|
179
173
|
- !ruby/object:Gem::Dependency
|
|
180
174
|
name: yard
|
|
181
175
|
requirement: !ruby/object:Gem::Requirement
|
|
182
176
|
requirements:
|
|
183
177
|
- - "~>"
|
|
184
178
|
- !ruby/object:Gem::Version
|
|
185
|
-
version:
|
|
179
|
+
version: 0.9.20
|
|
186
180
|
type: :development
|
|
187
181
|
prerelease: false
|
|
188
182
|
version_requirements: !ruby/object:Gem::Requirement
|
|
189
183
|
requirements:
|
|
190
184
|
- - "~>"
|
|
191
185
|
- !ruby/object:Gem::Version
|
|
192
|
-
version:
|
|
186
|
+
version: 0.9.20
|
|
193
187
|
- !ruby/object:Gem::Dependency
|
|
194
188
|
name: webmock
|
|
195
189
|
requirement: !ruby/object:Gem::Requirement
|
|
196
190
|
requirements:
|
|
197
191
|
- - "~>"
|
|
198
192
|
- !ruby/object:Gem::Version
|
|
199
|
-
version: '
|
|
193
|
+
version: '3.7'
|
|
200
194
|
type: :development
|
|
201
195
|
prerelease: false
|
|
202
196
|
version_requirements: !ruby/object:Gem::Requirement
|
|
203
197
|
requirements:
|
|
204
198
|
- - "~>"
|
|
205
199
|
- !ruby/object:Gem::Version
|
|
206
|
-
version: '
|
|
200
|
+
version: '3.7'
|
|
207
201
|
description: |2-
|
|
208
202
|
|
|
209
203
|
Implements the W3C Linked Data Patch Format and operations for RDF.rb.
|
|
@@ -236,7 +230,7 @@ files:
|
|
|
236
230
|
- lib/ld/patch/parser.rb
|
|
237
231
|
- lib/ld/patch/terminals.rb
|
|
238
232
|
- lib/ld/patch/version.rb
|
|
239
|
-
homepage:
|
|
233
|
+
homepage: https://github.com/ruby-rdf/ld-patch
|
|
240
234
|
licenses:
|
|
241
235
|
- Unlicense
|
|
242
236
|
metadata: {}
|
|
@@ -248,17 +242,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
248
242
|
requirements:
|
|
249
243
|
- - ">="
|
|
250
244
|
- !ruby/object:Gem::Version
|
|
251
|
-
version: 2.
|
|
245
|
+
version: '2.4'
|
|
252
246
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
253
247
|
requirements:
|
|
254
248
|
- - ">="
|
|
255
249
|
- !ruby/object:Gem::Version
|
|
256
250
|
version: '0'
|
|
257
251
|
requirements: []
|
|
258
|
-
|
|
259
|
-
rubygems_version: 2.4.8
|
|
252
|
+
rubygems_version: 3.1.3
|
|
260
253
|
signing_key:
|
|
261
254
|
specification_version: 4
|
|
262
255
|
summary: W3C Linked Data Patch Format for RDF.rb.
|
|
263
256
|
test_files: []
|
|
264
|
-
has_rdoc: false
|