json-ld 3.2.0 → 3.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e157972b224a8cbe834defdf32656a0b9f090357760fab179076e728427d1639
4
- data.tar.gz: a63cd584853e5a830c85a427d30711bc84999e958949c81bc7d236df20f14ee6
3
+ metadata.gz: 54bba5db6d794f8e36e96200fb75cce4377021ea02c008bcc09b76a4a6ff95a2
4
+ data.tar.gz: bbd5282a8f1b87d6c44b567a49135f32765f11ada771fffd5e26683481589a19
5
5
  SHA512:
6
- metadata.gz: 77a85aa85eea6844e1adb9107fe0b2d5a4ad82b877456adcdbbc56031f884da21cc992169232c326f255491d8aa6f607aacbeaeb386578fe8a1ac374cc795ff5
7
- data.tar.gz: 2f8353dca7bb6ea9bed3ed7fbea3e0bf883bdec9a3687d3b084f936ae0171a21df1d55bda8cf44fc0ae6d6682d5235234792901fb2fc7ffed327d2956fec289f
6
+ metadata.gz: 7f13bf980c40f0aa82965c6cd6ee9fe5f8c63d91b5206974630d5bfd84ebf9318902654e8937644ef79aa02f1447c41cc3c3ea4382998b74b275f80ebff00f93
7
+ data.tar.gz: 36a5a219f342d13249f1c6a3971448b9dea645640f5bc55d21278b831c3c619d584ad2dda27cee94793b5bd3954c5a0e54507ea6c99a328a3da7feb19730058a
data/README.md CHANGED
@@ -72,7 +72,7 @@ In the first case, the embedded node is not asserted, and only appears as the su
72
72
 
73
73
  #### Serializing a Graph containing embedded statements
74
74
 
75
- require 'json-ld'
75
+ require 'json/ld'
76
76
  statement = RDF::Statement(RDF::URI('bob'), RDF::Vocab::FOAF.age, RDF::Literal(23))
77
77
  graph = RDF::Graph.new << [statement, RDF::URI("ex:certainty"), RDF::Literal(0.9)]
78
78
  graph.dump(:jsonld, validate: false, standard_prefixes: true)
@@ -565,7 +565,7 @@ The {JSON::LD::ContentNegotiation#call} method looks for a result which includes
565
565
  See [Rack::LinkedData][] to do the same thing with an RDF Graph or Dataset as the source, rather than Ruby objects.
566
566
 
567
567
  ## Documentation
568
- Full documentation available on [RubyDoc](https://rubydoc.info/gems/json-ld/file/README.md)
568
+ Full documentation available on [RubyDoc](https://ruby-rdf.github.io/json-ld/file/README.md)
569
569
 
570
570
  ## Differences from [JSON-LD API][]
571
571
  The specified JSON-LD API is based on a WebIDL definition implementing [Promises][] intended for use within a browser.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.2.0
1
+ 3.2.1
@@ -5,13 +5,6 @@ require 'bigdecimal'
5
5
  require 'set'
6
6
  require 'rdf/util/cache'
7
7
 
8
- begin
9
- # Attempt to load this to avoid unnecessary context fetches
10
- require 'json-ld-preloaded'
11
- rescue LoadError
12
- # Silently allow this to fail
13
- end
14
-
15
8
  module JSON::LD
16
9
  class Context
17
10
  include Utils
@@ -50,6 +43,13 @@ module JSON::LD
50
43
  end
51
44
  end
52
45
 
46
+ begin
47
+ # Attempt to load this to avoid unnecessary context fetches
48
+ require 'json/ld/preloaded'
49
+ rescue LoadError
50
+ # Silently allow this to fail
51
+ end
52
+
53
53
  # The base.
54
54
  #
55
55
  # @return [RDF::URI] Current base IRI, used for expanding relative IRIs.
@@ -88,7 +88,7 @@ module JSON::LD
88
88
 
89
89
  # If element contains the key @context, set active context to the result of the Context Processing algorithm, passing active context and the value of the @context key as local context.
90
90
  if input.key?('@context')
91
- context = context.parse(input.delete('@context'), base: @options[:base])
91
+ context = context.parse(input['@context'], base: @options[:base])
92
92
  log_debug("expand", depth: log_depth.to_i) {"context: #{context.inspect}"}
93
93
  end
94
94
 
@@ -99,7 +99,7 @@ module JSON::LD
99
99
 
100
100
  # See if keys mapping to @type have terms with a local context
101
101
  type_key = nil
102
- input.keys.sort.
102
+ (input.keys - %w(@context)).sort.
103
103
  select {|k| context.expand_iri(k, vocab: true, base: @options[:base]) == '@type'}.
104
104
  each do |tk|
105
105
 
@@ -23,7 +23,8 @@ module JSON::LD
23
23
  class Format < RDF::Format
24
24
  content_type 'application/ld+json',
25
25
  extension: :jsonld,
26
- alias: 'application/x-ld+json'
26
+ alias: 'application/x-ld+json',
27
+ uri: 'http://www.w3.org/ns/formats/JSON-LD'
27
28
  content_encoding 'utf-8'
28
29
 
29
30
  reader { JSON::LD::Reader }
@@ -12,7 +12,7 @@ module JSON::LD
12
12
 
13
13
  ##
14
14
  # JSON-LD Reader options
15
- # @see http://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Reader#options-class_method
15
+ # @see https://ruby-rdf.github.io/rdf/RDF/Reader#options-class_method
16
16
  def self.options
17
17
  super + [
18
18
  RDF::CLI::Option.new(
@@ -11,10 +11,11 @@ module JSON::LD
11
11
  ##
12
12
  # @param [Hash{String => Object}] item
13
13
  # @param [RDF::Resource] graph_name
14
+ # @param [Boolean] emitted triples are quoted triples.
14
15
  # @yield statement
15
16
  # @yieldparam [RDF::Statement] statement
16
17
  # @return RDF::Resource the subject of this item
17
- def item_to_rdf(item, graph_name: nil, &block)
18
+ def item_to_rdf(item, graph_name: nil, quoted: false, &block)
18
19
  # Just return value object as Term
19
20
  return unless item
20
21
 
@@ -82,9 +83,9 @@ module JSON::LD
82
83
  when nil then node
83
84
  when String then as_resource(item['@id'])
84
85
  when Object
85
- # Embedded statement
86
+ # Embedded/quoted statement
86
87
  # (No error checking, as this is done in expansion)
87
- to_enum(:item_to_rdf, item['@id']).to_a.first
88
+ to_enum(:item_to_rdf, item['@id'], quoted: true).to_a.first
88
89
  end
89
90
 
90
91
  #log_debug("item_to_rdf") {"subject: #{subject.to_ntriples rescue 'malformed rdf'}"}
@@ -95,12 +96,12 @@ module JSON::LD
95
96
  values.each do |v|
96
97
  object = as_resource(v)
97
98
  #log_debug("item_to_rdf") {"type: #{object.to_ntriples rescue 'malformed rdf'}"}
98
- yield RDF::Statement(subject, RDF.type, object, graph_name: graph_name)
99
+ yield RDF::Statement(subject, RDF.type, object, graph_name: graph_name, quoted: quoted)
99
100
  end
100
101
  when '@graph'
101
102
  values = [values].compact unless values.is_a?(Array)
102
103
  values.each do |nd|
103
- item_to_rdf(nd, graph_name: subject, &block)
104
+ item_to_rdf(nd, graph_name: subject, quoted: quoted, &block)
104
105
  end
105
106
  when '@reverse'
106
107
  raise "Huh?" unless values.is_a?(Hash)
@@ -113,7 +114,7 @@ module JSON::LD
113
114
  object = item_to_rdf(v, graph_name: graph_name, &block)
114
115
  #log_debug("item_to_rdf") {"subject: #{object.to_ntriples rescue 'malformed rdf'}"}
115
116
  # yield subject, prediate, and literal to results.
116
- yield RDF::Statement(object, predicate, subject, graph_name: graph_name)
117
+ yield RDF::Statement(object, predicate, subject, graph_name: graph_name, quoted: quoted)
117
118
  end
118
119
  end
119
120
  when '@included'
@@ -136,13 +137,13 @@ module JSON::LD
136
137
  object = parse_list(v['@list'], graph_name: graph_name, &block)
137
138
 
138
139
  # Append a triple composed of subject, prediate, and object to results and add all triples from list_results to results.
139
- yield RDF::Statement(subject, predicate, object, graph_name: graph_name)
140
+ yield RDF::Statement(subject, predicate, object, graph_name: graph_name, quoted: quoted)
140
141
  else
141
142
  # Otherwise, item is a value object or a node definition. Generate object as the result of the Object Converstion algorithm passing item.
142
143
  object = item_to_rdf(v, graph_name: graph_name, &block)
143
144
  #log_debug("item_to_rdf") {"object: #{object.to_ntriples rescue 'malformed rdf'}"}
144
145
  # yield subject, prediate, and literal to results.
145
- yield RDF::Statement(subject, predicate, object, graph_name: graph_name)
146
+ yield RDF::Statement(subject, predicate, object, graph_name: graph_name, quoted: quoted)
146
147
  end
147
148
  end
148
149
  end
@@ -71,7 +71,7 @@ module JSON::LD
71
71
 
72
72
  ##
73
73
  # JSON-LD Writer options
74
- # @see http://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Writer#options-class_method
74
+ # @see https://ruby-rdf.github.io/rdf/RDF/Writer#options-class_method
75
75
  def self.options
76
76
  super + [
77
77
  RDF::CLI::Option.new(
data/spec/format_spec.rb CHANGED
@@ -41,6 +41,10 @@ describe JSON::LD::Format do
41
41
  specify {expect(described_class.to_sym).to eq :jsonld}
42
42
  end
43
43
 
44
+ describe "#to_uri" do
45
+ specify {expect(described_class.to_uri).to eq RDF::URI('http://www.w3.org/ns/formats/JSON-LD')}
46
+ end
47
+
44
48
  describe ".detect" do
45
49
  {
46
50
  jsonld: '{"@context" => "foo"}',
@@ -66,7 +70,7 @@ describe JSON::LD::Format do
66
70
  end
67
71
  end
68
72
 
69
- describe ".cli_commands" do
73
+ describe ".cli_commands", skip: Gem.win_platform? do
70
74
  require 'rdf/cli'
71
75
  let(:ttl) {File.expand_path("../test-files/test-1-rdf.ttl", __FILE__)}
72
76
  let(:json) {File.expand_path("../test-files/test-1-input.json", __FILE__)}
data/spec/reader_spec.rb CHANGED
@@ -131,7 +131,7 @@ describe JSON::LD::Reader do
131
131
  {
132
132
  "@context": {"@base": "http://a/bb/ccc/d;p?q", "urn:ex:p": {"@type": "@id"}},
133
133
  "@graph": [
134
- {"@id": "urn:ex:s001", "urn:ex:p": "g:h"},
134
+ {"@id": "urn:ex:s001", "urn:ex:p": "gg:h"},
135
135
  {"@id": "urn:ex:s002", "urn:ex:p": "g"},
136
136
  {"@id": "urn:ex:s003", "urn:ex:p": "./g"},
137
137
  {"@id": "urn:ex:s004", "urn:ex:p": "g/"},
@@ -183,7 +183,7 @@ describe JSON::LD::Reader do
183
183
  {
184
184
  "@context": {"@base": "http://a/bb/ccc/d/", "urn:ex:p": {"@type": "@id"}},
185
185
  "@graph": [
186
- {"@id": "urn:ex:s043", "urn:ex:p": "g:h"},
186
+ {"@id": "urn:ex:s043", "urn:ex:p": "gg:h"},
187
187
  {"@id": "urn:ex:s044", "urn:ex:p": "g"},
188
188
  {"@id": "urn:ex:s045", "urn:ex:p": "./g"},
189
189
  {"@id": "urn:ex:s046", "urn:ex:p": "g/"},
@@ -235,7 +235,7 @@ describe JSON::LD::Reader do
235
235
  {
236
236
  "@context": {"@base": "http://a/bb/ccc/./d;p?q", "urn:ex:p": {"@type": "@id"}},
237
237
  "@graph": [
238
- {"@id": "urn:ex:s085", "urn:ex:p": "g:h"},
238
+ {"@id": "urn:ex:s085", "urn:ex:p": "gg:h"},
239
239
  {"@id": "urn:ex:s086", "urn:ex:p": "g"},
240
240
  {"@id": "urn:ex:s087", "urn:ex:p": "./g"},
241
241
  {"@id": "urn:ex:s088", "urn:ex:p": "g/"},
@@ -287,7 +287,7 @@ describe JSON::LD::Reader do
287
287
  {
288
288
  "@context": {"@base": "http://a/bb/ccc/../d;p?q", "urn:ex:p": {"@type": "@id"}},
289
289
  "@graph": [
290
- {"@id": "urn:ex:s127", "urn:ex:p": "g:h"},
290
+ {"@id": "urn:ex:s127", "urn:ex:p": "gg:h"},
291
291
  {"@id": "urn:ex:s128", "urn:ex:p": "g"},
292
292
  {"@id": "urn:ex:s129", "urn:ex:p": "./g"},
293
293
  {"@id": "urn:ex:s130", "urn:ex:p": "g/"},
@@ -339,7 +339,7 @@ describe JSON::LD::Reader do
339
339
  {
340
340
  "@context": {"@base": "http://a/bb/ccc/.", "urn:ex:p": {"@type": "@id"}},
341
341
  "@graph": [
342
- {"@id": "urn:ex:s169", "urn:ex:p": "g:h"},
342
+ {"@id": "urn:ex:s169", "urn:ex:p": "gg:h"},
343
343
  {"@id": "urn:ex:s170", "urn:ex:p": "g"},
344
344
  {"@id": "urn:ex:s171", "urn:ex:p": "./g"},
345
345
  {"@id": "urn:ex:s172", "urn:ex:p": "g/"},
@@ -391,7 +391,7 @@ describe JSON::LD::Reader do
391
391
  {
392
392
  "@context": {"@base": "http://a/bb/ccc/..", "urn:ex:p": {"@type": "@id"}},
393
393
  "@graph": [
394
- {"@id": "urn:ex:s211", "urn:ex:p": "g:h"},
394
+ {"@id": "urn:ex:s211", "urn:ex:p": "gg:h"},
395
395
  {"@id": "urn:ex:s212", "urn:ex:p": "g"},
396
396
  {"@id": "urn:ex:s213", "urn:ex:p": "./g"},
397
397
  {"@id": "urn:ex:s214", "urn:ex:p": "g/"},
@@ -443,7 +443,7 @@ describe JSON::LD::Reader do
443
443
  {
444
444
  "@context": {"@base": "file:///a/bb/ccc/d;p?q", "urn:ex:p": {"@type": "@id"}},
445
445
  "@graph": [
446
- {"@id": "urn:ex:s253", "urn:ex:p": "g:h"},
446
+ {"@id": "urn:ex:s253", "urn:ex:p": "gg:h"},
447
447
  {"@id": "urn:ex:s254", "urn:ex:p": "g"},
448
448
  {"@id": "urn:ex:s255", "urn:ex:p": "./g"},
449
449
  {"@id": "urn:ex:s256", "urn:ex:p": "g/"},
@@ -523,7 +523,7 @@ describe JSON::LD::Reader do
523
523
  let(:nt) {%q{
524
524
  # RFC3986 normal examples
525
525
 
526
- <urn:ex:s001> <urn:ex:p> <g:h>.
526
+ <urn:ex:s001> <urn:ex:p> <gg:h>.
527
527
  <urn:ex:s002> <urn:ex:p> <http://a/bb/ccc/g>.
528
528
  <urn:ex:s003> <urn:ex:p> <http://a/bb/ccc/g>.
529
529
  <urn:ex:s004> <urn:ex:p> <http://a/bb/ccc/g/>.
@@ -571,7 +571,7 @@ describe JSON::LD::Reader do
571
571
 
572
572
  # RFC3986 normal examples with trailing slash in base IRI
573
573
 
574
- <urn:ex:s043> <urn:ex:p> <g:h>.
574
+ <urn:ex:s043> <urn:ex:p> <gg:h>.
575
575
  <urn:ex:s044> <urn:ex:p> <http://a/bb/ccc/d/g>.
576
576
  <urn:ex:s045> <urn:ex:p> <http://a/bb/ccc/d/g>.
577
577
  <urn:ex:s046> <urn:ex:p> <http://a/bb/ccc/d/g/>.
@@ -619,7 +619,7 @@ describe JSON::LD::Reader do
619
619
 
620
620
  # RFC3986 normal examples with /. in the base IRI
621
621
 
622
- <urn:ex:s085> <urn:ex:p> <g:h>.
622
+ <urn:ex:s085> <urn:ex:p> <gg:h>.
623
623
  <urn:ex:s086> <urn:ex:p> <http://a/bb/ccc/g>.
624
624
  <urn:ex:s087> <urn:ex:p> <http://a/bb/ccc/g>.
625
625
  <urn:ex:s088> <urn:ex:p> <http://a/bb/ccc/g/>.
@@ -667,7 +667,7 @@ describe JSON::LD::Reader do
667
667
 
668
668
  # RFC3986 normal examples with /.. in the base IRI
669
669
 
670
- <urn:ex:s127> <urn:ex:p> <g:h>.
670
+ <urn:ex:s127> <urn:ex:p> <gg:h>.
671
671
  <urn:ex:s128> <urn:ex:p> <http://a/bb/g>.
672
672
  <urn:ex:s129> <urn:ex:p> <http://a/bb/g>.
673
673
  <urn:ex:s130> <urn:ex:p> <http://a/bb/g/>.
@@ -715,7 +715,7 @@ describe JSON::LD::Reader do
715
715
 
716
716
  # RFC3986 normal examples with trailing /. in the base IRI
717
717
 
718
- <urn:ex:s169> <urn:ex:p> <g:h>.
718
+ <urn:ex:s169> <urn:ex:p> <gg:h>.
719
719
  <urn:ex:s170> <urn:ex:p> <http://a/bb/ccc/g>.
720
720
  <urn:ex:s171> <urn:ex:p> <http://a/bb/ccc/g>.
721
721
  <urn:ex:s172> <urn:ex:p> <http://a/bb/ccc/g/>.
@@ -763,7 +763,7 @@ describe JSON::LD::Reader do
763
763
 
764
764
  # RFC3986 normal examples with trailing /.. in the base IRI
765
765
 
766
- <urn:ex:s211> <urn:ex:p> <g:h>.
766
+ <urn:ex:s211> <urn:ex:p> <gg:h>.
767
767
  <urn:ex:s212> <urn:ex:p> <http://a/bb/ccc/g>.
768
768
  <urn:ex:s213> <urn:ex:p> <http://a/bb/ccc/g>.
769
769
  <urn:ex:s214> <urn:ex:p> <http://a/bb/ccc/g/>.
@@ -811,7 +811,7 @@ describe JSON::LD::Reader do
811
811
 
812
812
  # RFC3986 normal examples with file path
813
813
 
814
- <urn:ex:s253> <urn:ex:p> <g:h>.
814
+ <urn:ex:s253> <urn:ex:p> <gg:h>.
815
815
  <urn:ex:s254> <urn:ex:p> <file:///a/bb/ccc/g>.
816
816
  <urn:ex:s255> <urn:ex:p> <file:///a/bb/ccc/g>.
817
817
  <urn:ex:s256> <urn:ex:p> <file:///a/bb/ccc/g/>.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json-ld
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.2.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: 2021-12-12 00:00:00.000000000 Z
11
+ date: 2022-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdf
@@ -411,7 +411,12 @@ files:
411
411
  homepage: https://github.com/ruby-rdf/json-ld
412
412
  licenses:
413
413
  - Unlicense
414
- metadata: {}
414
+ metadata:
415
+ documentation_uri: https://ruby-rdf.github.io/json-ld
416
+ bug_tracker_uri: https://github.com/ruby-rdf/json-ld/issues
417
+ homepage_uri: https://github.com/ruby-rdf/json-ld
418
+ mailing_list_uri: https://lists.w3.org/Archives/Public/public-rdf-ruby/
419
+ source_code_uri: https://github.com/ruby-rdf/json-ld
415
420
  post_install_message:
416
421
  rdoc_options: []
417
422
  require_paths: