Skip to content

Commit cb40f56

Browse files
committed
Update naming to RDF-star/JSON-LD-star.
Add --rdfstar option to bin/jsonld.
1 parent 00b2961 commit cb40f56

13 files changed

+24
-22
lines changed

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ JSON::LD can now be used to create a _context_ from an RDFS/OWL definition, and
1515

1616
* If the [jsonlint][] gem is installed, it will be used when validating an input document.
1717
* If available, uses [Nokogiri][] and/or [Nokogumbo][] for parsing HTML, falls back to REXML otherwise.
18-
* Provisional support for [JSON-LD*][JSON-LD*].
18+
* Provisional support for [JSON-LD-star][JSON-LD-star].
1919

2020
[Implementation Report](https://ruby-rdf.github.io/json-ld/etc/earl.html)
2121

@@ -37,9 +37,9 @@ The order of triples retrieved from the `RDF::Enumerable` dataset determines the
3737
### MultiJson parser
3838
The [MultiJson](https://rubygems.org/gems/multi_json) gem is used for parsing JSON; this defaults to the native JSON parser, but will use a more performant parser if one is available. A specific parser can be specified by adding the `:adapter` option to any API call. See [MultiJson](https://rubygems.org/gems/multi_json) for more information.
3939

40-
### JSON-LD* (RDFStar)
40+
### JSON-LD-star (RDFStar)
4141

42-
The {JSON::LD::API.expand}, {JSON::LD::API.compact}, {JSON::LD::API.toRdf}, and {JSON::LD::API.fromRdf} API methods, along with the {JSON::LD::Reader} and {JSON::LD::Writer}, include provisional support for [JSON-LD*][JSON-LD*].
42+
The {JSON::LD::API.expand}, {JSON::LD::API.compact}, {JSON::LD::API.toRdf}, and {JSON::LD::API.fromRdf} API methods, along with the {JSON::LD::Reader} and {JSON::LD::Writer}, include provisional support for [JSON-LD-star][JSON-LD-star].
4343

4444
Internally, an `RDF::Statement` is treated as another resource, along with `RDF::URI` and `RDF::Node`, which allows an `RDF::Statement` to have a `#subject` or `#object` which is also an `RDF::Statement`.
4545

@@ -636,7 +636,7 @@ see <https://unlicense.org/> or the accompanying {file:UNLICENSE} file.
636636
[YARD-GS]: https://rubydoc.info/docs/yard/file/docs/GettingStarted.md
637637
[PDD]: https://unlicense.org/#unlicensing-contributions
638638
[RDF.rb]: https://rubygems.org/gems/rdf
639-
[JSON-LD*]: https://json-ld.github.io/json-ld-star/
639+
[JSON-LD-star]: https://json-ld.github.io/json-ld-star/
640640
[Rack::LinkedData]: https://rubygems.org/gems/rack-linkeddata
641641
[Backports]: https://rubygems.org/gems/backports
642642
[JSON-LD]: https://www.w3.org/TR/json-ld11/ "JSON-LD 1.1"

bin/jsonld

+9-7
Original file line numberDiff line numberDiff line change
@@ -26,34 +26,34 @@ def run(input, options, parser_options)
2626
if options[:expand]
2727
parser_options = parser_options.merge(expandContext: parser_options.delete(:context)) if parser_options.key?(:context)
2828
input = JSON::LD::API.fromRdf(reader) if reader
29-
output = JSON::LD::API.expand(input, parser_options)
29+
output = JSON::LD::API.expand(input, **parser_options)
3030
secs = Time.new - start
3131
options[:output].puts output.to_json(JSON::LD::JSON_STATE)
3232
STDERR.puts "Expanded in #{secs} seconds." unless options[:quiet]
3333
elsif options[:compact]
3434
input = JSON::LD::API.fromRdf(reader) if reader
35-
output = JSON::LD::API.compact(input, parser_options[:context], parser_options)
35+
output = JSON::LD::API.compact(input, parser_options[:context], **parser_options)
3636
secs = Time.new - start
3737
options[:output].puts output.to_json(JSON::LD::JSON_STATE)
3838
STDERR.puts "Compacted in #{secs} seconds." unless options[:quiet]
3939
elsif options[:flatten]
4040
input = JSON::LD::API.fromRdf(reader) if reader
41-
output = JSON::LD::API.flatten(input, parser_options[:context], parser_options)
41+
output = JSON::LD::API.flatten(input, parser_options[:context], **parser_options)
4242
secs = Time.new - start
4343
options[:output].puts output.to_json(JSON::LD::JSON_STATE)
4444
STDERR.puts "Flattened in #{secs} seconds." unless options[:quiet]
4545
elsif options[:frame]
4646
input = JSON::LD::API.fromRdf(reader) if reader
47-
output = JSON::LD::API.frame(input, parser_options[:frame], parser_options)
47+
output = JSON::LD::API.frame(input, parser_options[:frame], **parser_options)
4848
secs = Time.new - start
4949
options[:output].puts output.to_json(JSON::LD::JSON_STATE)
5050
STDERR.puts "Framed in #{secs} seconds." unless options[:quiet]
5151
else
5252
parser_options = parser_options.merge(expandContext: parser_options.delete(:context)) if parser_options.key?(:context)
5353
parser_options[:standard_prefixes] = true
54-
reader ||= JSON::LD::Reader.new(input, parser_options)
54+
reader ||= JSON::LD::Reader.new(input, **parser_options)
5555
num = 0
56-
RDF::Writer.for(options[:output_format]).new(options[:output], parser_options) do |w|
56+
RDF::Writer.for(options[:output_format]).new(options[:output], **parser_options) do |w|
5757
reader.each do |statement|
5858
num += 1
5959
w << statement
@@ -113,6 +113,7 @@ OPT_ARGS = [
113113
["--processingMode",GetoptLong::REQUIRED_ARGUMENT,"Set processing mode, defaults to json-ld-1.1"],
114114
["--quiet", GetoptLong::NO_ARGUMENT, "Supress most output other than progress indicators"],
115115
["--rename_bnodes", GetoptLong::OPTIONAL_ARGUMENT,"Rename bnodes as part of expansion, or keep them the same"],
116+
["--rdfstar", GetoptLong::NO_ARGUMENT, "Parse JSON-LD-star"],
116117
["--requireAll", GetoptLong::OPTIONAL_ARGUMENT,"Rename bnodes as part of expansion, or keep them the same"],
117118
["--stream", GetoptLong::NO_ARGUMENT, "Use Streaming reader/writer"],
118119
["--unique_bnodes", GetoptLong::OPTIONAL_ARGUMENT,"Use unique bnode identifiers"],
@@ -158,6 +159,7 @@ opts.each do |opt, arg|
158159
when '--quiet'
159160
options[:quiet] = true
160161
logger.level = Logger::FATAL
162+
when "--rdfstar" then parser_options[:rdfstar] = true
161163
when "--rename_bnodes" then parser_options[:rename_bnodes] = (arg || 'true') == 'true'
162164
when "--requireAll" then parser_options[:requireAll] = (arg || 'true') == 'true'
163165
when '--stream' then parser_options[:stream] = true
@@ -193,7 +195,7 @@ if ARGV.empty?
193195
else
194196
ARGV.each do |file|
195197
# Call with opened files
196-
RDF::Util::File.open_file(file, options) {|f| run(f, options, parser_options)}
198+
RDF::Util::File.open_file(file, **options) {|f| run(f, options, parser_options)}
197199
end
198200
end
199201
puts

lib/json/ld/api.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class API
9090
# Processing mode, json-ld-1.0 or json-ld-1.1.
9191
# If `processingMode` is not specified, a mode of `json-ld-1.0` or `json-ld-1.1` is set, the context used for `expansion` or `compaction`.
9292
# @option options [Boolean] rdfstar (false)
93-
# support parsing JSON-LD* statement resources.
93+
# support parsing JSON-LD-star statement resources.
9494
# @option options [Boolean] :rename_bnodes (true)
9595
# Rename bnodes as part of expansion, or keep them the same.
9696
# @option options [Boolean] :unique_bnodes (false)

lib/json/ld/compact.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def compact(element,
100100
if expanded_property == '@id'
101101
compacted_value = as_array(expanded_value).map do |expanded_id|
102102
if node?(expanded_id) && @options[:rdfstar]
103-
# This can only really happen for valid RDF*
103+
# This can only really happen for valid RDF-star
104104
compact(expanded_id, base: base,
105105
property: '@id',
106106
log_depth: log_depth.to_i + 1)

lib/json/ld/flatten.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module Flatten
99
##
1010
# This algorithm creates a JSON object node map holding an indexed representation of the graphs and nodes represented in the passed expanded document. All nodes that are not uniquely identified by an IRI get assigned a (new) blank node identifier. The resulting node map will have a member for every graph in the document whose value is another object with a member for every node represented in the document. The default graph is stored under the @default member, all other graphs are stored under their graph name.
1111
#
12-
# For RDF*/JSON-LD*:
12+
# For RDF-star/JSON-LD-star:
1313
# * Values of `@id` can be an object (embedded node); when these are used as keys in a Node Map, they are serialized as canonical JSON, and de-serialized when flattening.
1414
# * The presence of `@annotation` implies an embedded node and the annotation object is removed from the node/value object in which it appears.
1515
#

script/parse

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ OPT_ARGS = [
116116
["--output", "-o", GetoptLong::REQUIRED_ARGUMENT, "Where to store output (default STDOUT)"],
117117
["--profile", GetoptLong::NO_ARGUMENT, "Run profiler with output to doc/profiles/"],
118118
["--quiet", GetoptLong::NO_ARGUMENT, "Reduce output"],
119-
["--rdfstar", GetoptLong::NO_ARGUMENT, "RDF* mode"],
119+
["--rdfstar", GetoptLong::NO_ARGUMENT, "RDF-star mode"],
120120
["--stream", GetoptLong::NO_ARGUMENT, "Streaming reader/writer"],
121121
["--uri", GetoptLong::REQUIRED_ARGUMENT, "Run with argument value as base"],
122122
["--validate", GetoptLong::NO_ARGUMENT, "Validate input"],

spec/compact_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3113,7 +3113,7 @@
31133113
end
31143114
end
31153115

3116-
context "JSON-LD*" do
3116+
context "JSON-LD-star" do
31173117
{
31183118
"subject-iii": {
31193119
input: %([{

spec/expand_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3413,7 +3413,7 @@
34133413
end
34143414
end
34153415

3416-
context "JSON-LD*" do
3416+
context "JSON-LD-star" do
34173417
{
34183418
"node with embedded subject without rdfstar option": {
34193419
input: %({

spec/flatten_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@
666666
end
667667
end
668668

669-
context "JSON-LD*" do
669+
context "JSON-LD-star" do
670670
{
671671
"node object with @annotation property is ignored without rdfstar option": {
672672
input: %({

spec/from_rdf_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@
766766
end
767767
end
768768

769-
context "RDF*" do
769+
context "RDF-star" do
770770
{
771771
"subject-iii": {
772772
input: RDF::Statement(

spec/suite_to_rdf_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
m.entries.each do |t|
1010
specify "#{t.property('@id')}: #{t.name}#{' (negative test)' unless t.positiveTest?}" do
1111
pending "Generalized RDF" if t.options[:produceGeneralizedRdf]
12-
pending "RDF*" if t.property('@id') == '#te122'
12+
pending "RDF-star" if t.property('@id') == '#te122'
1313
if %w(#t0118).include?(t.property('@id'))
1414
expect {t.run self}.to write(/Statement .* is invalid/).to(:error)
1515
elsif %w(#te075).include?(t.property('@id'))

spec/to_rdf_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,7 @@
11751175
end
11761176
end
11771177

1178-
context "JSON-LD*" do
1178+
context "JSON-LD-star" do
11791179
{
11801180
"node with embedded subject without rdfstar option": {
11811181
input: %({

spec/writer_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@
189189
end
190190
end
191191

192-
context "RDF*" do
192+
context "RDF-star" do
193193
{
194194
"subject-iii": {
195195
input: RDF::Statement(

0 commit comments

Comments
 (0)