json-ld 3.1.2 → 3.1.3
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 +4 -4
- data/VERSION +1 -1
- data/lib/json/ld/context.rb +79 -55
- data/lib/json/ld/expand.rb +5 -5
- data/spec/compact_spec.rb +1 -0
- data/spec/context_spec.rb +10 -19
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9799c8872d44570fe8213d9f9f54067ced632dcbfc593cb84f4223889f2530d
|
4
|
+
data.tar.gz: 9854ae82f3e53cb08ce4e5c8f8223d8def8c3bf86cac7ab95a6abbf08a448003
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fb50a75c8d031026e97635ad5305d9318d455af2786b84e5ca42d0f0546ba1f1175dd5dbc05a884798145051aa352a8f1688fdb6a5ad593d057d3900d9c6f21
|
7
|
+
data.tar.gz: a844a733d4f292988638dc2da6be301a78d3294b3a64533398effb0b41b802bf7f48834d5e2754d3d65a6f2f69b802bcfc0ecbc44a159fdf2389ea16ae49bbad
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.1.
|
1
|
+
3.1.3
|
data/lib/json/ld/context.rb
CHANGED
@@ -21,6 +21,11 @@ module JSON::LD
|
|
21
21
|
# @return [Hash{Symbol => Context}]
|
22
22
|
PRELOADED = {}
|
23
23
|
|
24
|
+
##
|
25
|
+
# Defines the maximum number of interned URI references that can be held
|
26
|
+
# cached in memory at any one time.
|
27
|
+
CACHE_SIZE = -1 # unlimited by default
|
28
|
+
|
24
29
|
class << self
|
25
30
|
##
|
26
31
|
# Add preloaded context. In the block form, the context is lazy evaulated on first use.
|
@@ -121,7 +126,7 @@ module JSON::LD
|
|
121
126
|
direction_mapping: nil,
|
122
127
|
reverse_property: false,
|
123
128
|
nest: nil,
|
124
|
-
protected:
|
129
|
+
protected: nil,
|
125
130
|
simple: false,
|
126
131
|
prefix: nil,
|
127
132
|
context: nil)
|
@@ -331,8 +336,18 @@ module JSON::LD
|
|
331
336
|
# @raise [JsonLdError]
|
332
337
|
# on a remote context load error, syntax error, or a reference to a term which is not defined.
|
333
338
|
# @return [Context]
|
334
|
-
def self.parse(local_context,
|
335
|
-
self.new(**options).parse(local_context,
|
339
|
+
def self.parse(local_context, override_protected: false, propagate: true, **options)
|
340
|
+
self.new(**options).parse(local_context, override_protected: override_protected, propagate: propagate)
|
341
|
+
end
|
342
|
+
|
343
|
+
##
|
344
|
+
# Class-level cache used for retaining parsed remote contexts.
|
345
|
+
#
|
346
|
+
# @return [RDF::Util::Cache]
|
347
|
+
# @private
|
348
|
+
def self.cache
|
349
|
+
require 'rdf/util/cache' unless defined?(::RDF::Util::Cache)
|
350
|
+
@cache ||= RDF::Util::Cache.new(CACHE_SIZE)
|
336
351
|
end
|
337
352
|
|
338
353
|
##
|
@@ -522,7 +537,6 @@ module JSON::LD
|
|
522
537
|
#
|
523
538
|
# @param [String, #read, Array, Hash, Context] local_context
|
524
539
|
# @param [Array<String>] remote_contexts
|
525
|
-
# @param [Boolean] protected Make defined terms protected (as if `@protected` were used).
|
526
540
|
# @param [Boolean] override_protected Protected terms may be cleared.
|
527
541
|
# @param [Boolean] propagate
|
528
542
|
# If false, retains any previously defined term, which can be rolled back when the descending into a new node object changes.
|
@@ -535,7 +549,6 @@ module JSON::LD
|
|
535
549
|
# @see https://www.w3.org/TR/json-ld11-api/index.html#context-processing-algorithm
|
536
550
|
def parse(local_context,
|
537
551
|
remote_contexts: [],
|
538
|
-
protected: false,
|
539
552
|
override_protected: false,
|
540
553
|
propagate: true,
|
541
554
|
validate_scoped: true)
|
@@ -561,7 +574,7 @@ module JSON::LD
|
|
561
574
|
end
|
562
575
|
when Context
|
563
576
|
#log_debug("parse") {"context: #{context.inspect}"}
|
564
|
-
result = context
|
577
|
+
result = result.merge(context)
|
565
578
|
when IO, StringIO
|
566
579
|
#log_debug("parse") {"io: #{context}"}
|
567
580
|
# Load context document, if it is an open file
|
@@ -570,7 +583,6 @@ module JSON::LD
|
|
570
583
|
raise JSON::LD::JsonLdError::InvalidRemoteContext, "Context missing @context key" if @options[:validate] && ctx['@context'].nil?
|
571
584
|
result = result.dup.parse(ctx["@context"] ? ctx["@context"].dup : {})
|
572
585
|
result.provided_context = ctx["@context"] if [context] == local_context
|
573
|
-
result
|
574
586
|
rescue JSON::ParserError => e
|
575
587
|
#log_debug("parse") {"Failed to parse @context from remote document at #{context}: #{e.message}"}
|
576
588
|
raise JSON::LD::JsonLdError::InvalidRemoteContext, "Failed to parse remote context at #{context}: #{e.message}" if @options[:validate]
|
@@ -582,7 +594,7 @@ module JSON::LD
|
|
582
594
|
# 3.2.1) Set context to the result of resolving value against the base IRI which is established as specified in section 5.1 Establishing a Base URI of [RFC3986]. Only the basic algorithm in section 5.2 of [RFC3986] is used; neither Syntax-Based Normalization nor Scheme-Based Normalization are performed. Characters additionally allowed in IRI references are treated in the same way that unreserved characters are treated in URI references, per section 6.5 of [RFC3987].
|
583
595
|
context = RDF::URI(result.context_base || options[:base]).join(context)
|
584
596
|
context_canon = context.canonicalize
|
585
|
-
context_canon.scheme
|
597
|
+
context_canon.scheme = 'http' if context_canon.scheme == 'https'
|
586
598
|
|
587
599
|
# If validating a scoped context which has already been loaded, skip to the next one
|
588
600
|
next if !validate_scoped && remote_contexts.include?(context.to_s)
|
@@ -590,11 +602,7 @@ module JSON::LD
|
|
590
602
|
remote_contexts << context.to_s
|
591
603
|
raise JsonLdError::ContextOverflow, "#{context}" if remote_contexts.length >= MAX_CONTEXTS_LOADED
|
592
604
|
|
593
|
-
|
594
|
-
context_no_base.base = nil
|
595
|
-
context_no_base.context_base = context.to_s
|
596
|
-
|
597
|
-
if PRELOADED[context_canon.to_s]
|
605
|
+
cached_context = if PRELOADED[context_canon.to_s]
|
598
606
|
# If we have a cached context, merge it into the current context (result) and use as the new context
|
599
607
|
#log_debug("parse") {"=> cached_context: #{context_canon.to_s.inspect}"}
|
600
608
|
|
@@ -603,10 +611,10 @@ module JSON::LD
|
|
603
611
|
#log_debug("parse") {"=> (call)"}
|
604
612
|
PRELOADED[context_canon.to_s] = PRELOADED[context_canon.to_s].call
|
605
613
|
end
|
606
|
-
|
614
|
+
PRELOADED[context_canon.to_s]
|
607
615
|
else
|
608
616
|
# Load context document, if it is a string
|
609
|
-
begin
|
617
|
+
Context.cache[context_canon.to_s] ||= begin
|
610
618
|
context_opts = @options.merge(
|
611
619
|
profile: 'http://www.w3.org/ns/json-ld#context',
|
612
620
|
requestProfile: 'http://www.w3.org/ns/json-ld#context',
|
@@ -615,29 +623,29 @@ module JSON::LD
|
|
615
623
|
JSON::LD::API.loadRemoteDocument(context.to_s, **context_opts) do |remote_doc|
|
616
624
|
# 3.2.5) Dereference context. If the dereferenced document has no top-level JSON object with an @context member, an invalid remote context has been detected and processing is aborted; otherwise, set context to the value of that member.
|
617
625
|
raise JsonLdError::InvalidRemoteContext, "#{context}" unless remote_doc.document.is_a?(Hash) && remote_doc.document.has_key?('@context')
|
618
|
-
|
626
|
+
|
627
|
+
# Parse stand-alone
|
628
|
+
ctx = Context.new(**options)
|
629
|
+
ctx.context_base = context.to_s
|
630
|
+
ctx = ctx.parse(remote_doc.document['@context'], remote_contexts: remote_contexts.dup)
|
631
|
+
ctx.base = nil
|
632
|
+
ctx
|
619
633
|
end
|
620
634
|
rescue JsonLdError::LoadingDocumentFailed => e
|
621
635
|
#log_debug("parse") {"Failed to retrieve @context from remote document at #{context_no_base.context_base.inspect}: #{e.message}"}
|
622
|
-
raise JsonLdError::LoadingRemoteContextFailed, "#{
|
636
|
+
raise JsonLdError::LoadingRemoteContextFailed, "#{context}: #{e.message}", e.backtrace
|
623
637
|
rescue JsonLdError
|
624
638
|
raise
|
625
639
|
rescue StandardError => e
|
626
640
|
#log_debug("parse") {"Failed to retrieve @context from remote document at #{context_no_base.context_base.inspect}: #{e.message}"}
|
627
|
-
raise JsonLdError::LoadingRemoteContextFailed, "#{
|
641
|
+
raise JsonLdError::LoadingRemoteContextFailed, "#{context}: #{e.message}", e.backtrace
|
628
642
|
end
|
629
|
-
|
630
|
-
# 3.2.6) Set context to the result of recursively calling this algorithm, passing context no base for active context, context for local context, and remote contexts.
|
631
|
-
context = context_no_base.parse(context,
|
632
|
-
remote_contexts: remote_contexts.dup,
|
633
|
-
protected: protected,
|
634
|
-
override_protected: override_protected,
|
635
|
-
propagate: propagate,
|
636
|
-
validate_scoped: validate_scoped)
|
637
|
-
PRELOADED[context_canon.to_s] = context.dup
|
638
|
-
context.provided_context = result.provided_context
|
639
643
|
end
|
640
|
-
|
644
|
+
|
645
|
+
# Merge loaded context noting protected term overriding
|
646
|
+
context = result.merge(cached_context, override_protected: override_protected)
|
647
|
+
|
648
|
+
context.previous_context = self unless propagate
|
641
649
|
result = context
|
642
650
|
#log_debug("parse") {"=> provided_context: #{context.inspect}"}
|
643
651
|
when Hash
|
@@ -665,10 +673,12 @@ module JSON::LD
|
|
665
673
|
requestProfile: 'http://www.w3.org/ns/json-ld#context',
|
666
674
|
base: nil)
|
667
675
|
context_opts.delete(:headers)
|
676
|
+
# FIXME: should cache this, but ContextCache is for parsed contexts
|
668
677
|
JSON::LD::API.loadRemoteDocument(source, **context_opts) do |remote_doc|
|
669
678
|
# Dereference source. If the dereferenced document has no top-level JSON object with an @context member, an invalid remote context has been detected and processing is aborted; otherwise, set context to the value of that member.
|
670
679
|
raise JsonLdError::InvalidRemoteContext, "#{source}" unless remote_doc.document.is_a?(Hash) && remote_doc.document.has_key?('@context')
|
671
680
|
import_context = remote_doc.document['@context']
|
681
|
+
import_context.delete('@base')
|
672
682
|
raise JsonLdError::InvalidRemoteContext, "#{import_context.to_json} must be an object" unless import_context.is_a?(Hash)
|
673
683
|
raise JsonLdError::InvalidContextEntry, "#{import_context.to_json} must not include @import entry" if import_context.has_key?('@import')
|
674
684
|
context.delete(key)
|
@@ -682,7 +692,7 @@ module JSON::LD
|
|
682
692
|
raise JsonLdError::LoadingRemoteContextFailed, "#{source}: #{e.message}", e.backtrace
|
683
693
|
end
|
684
694
|
else
|
685
|
-
result.send(setter, context[key], remote_contexts: remote_contexts
|
695
|
+
result.send(setter, context[key], remote_contexts: remote_contexts)
|
686
696
|
end
|
687
697
|
context.delete(key)
|
688
698
|
end
|
@@ -694,7 +704,7 @@ module JSON::LD
|
|
694
704
|
# ... where key is not @base, @vocab, @language, or @version
|
695
705
|
result.create_term_definition(context, key, defined,
|
696
706
|
override_protected: override_protected,
|
697
|
-
protected: context
|
707
|
+
protected: context['@protected'],
|
698
708
|
remote_contexts: remote_contexts.dup,
|
699
709
|
validate_scoped: validate_scoped
|
700
710
|
) unless NON_TERMDEF_KEYS.include?(key)
|
@@ -711,28 +721,32 @@ module JSON::LD
|
|
711
721
|
# Merge in a context, creating a new context with updates from `context`
|
712
722
|
#
|
713
723
|
# @param [Context] context
|
724
|
+
# @param [Boolean] protected mark resulting context as protected
|
725
|
+
# @param [Boolean] override_protected Allow or disallow protected terms to be changed
|
726
|
+
# @param [Boolean]
|
714
727
|
# @return [Context]
|
715
|
-
def merge(context)
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
728
|
+
def merge(context, override_protected: false)
|
729
|
+
ctx = Context.new(term_definitions: self.term_definitions.dup(), standard_prefixes: options[:standard_prefixes])
|
730
|
+
ctx.context_base = context.context_base || self.context_base
|
731
|
+
ctx.default_language = context.default_language || self.default_language
|
732
|
+
ctx.default_direction = context.default_direction || self.default_direction
|
733
|
+
ctx.vocab = context.vocab || self.vocab
|
734
|
+
ctx.base = context.base || self.base
|
735
|
+
ctx.provided_context = self.provided_context
|
736
|
+
if !override_protected
|
737
|
+
ctx.term_definitions.each do |term, definition|
|
738
|
+
next unless definition.protected? && (other = context.term_definitions[term])
|
739
|
+
unless definition == other
|
740
|
+
raise JSON::LD::JsonLdError::ProtectedTermRedefinition, "Attempt to redefine protected term #{term}"
|
741
|
+
end
|
742
|
+
end
|
743
|
+
end
|
720
744
|
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
def merge!(context)
|
727
|
-
# FIXME: if new context removes the default language, this won't do anything
|
728
|
-
self.default_language = context.default_language if context.default_language
|
729
|
-
self.vocab = context.vocab if context.vocab
|
730
|
-
self.base = context.base if context.base
|
731
|
-
|
732
|
-
# Merge in Term Definitions
|
733
|
-
term_definitions.merge!(context.term_definitions)
|
734
|
-
@inverse_context = nil # Re-build after term definitions set
|
735
|
-
self
|
745
|
+
# Add term definitions
|
746
|
+
context.term_definitions.each do |term, definition|
|
747
|
+
ctx.term_definitions[term] = definition
|
748
|
+
end
|
749
|
+
ctx
|
736
750
|
end
|
737
751
|
|
738
752
|
# The following constants are used to reduce object allocations in #create_term_definition below
|
@@ -768,7 +782,7 @@ module JSON::LD
|
|
768
782
|
# @see https://www.w3.org/TR/json-ld11-api/index.html#create-term-definition
|
769
783
|
def create_term_definition(local_context, term, defined,
|
770
784
|
override_protected: false,
|
771
|
-
protected:
|
785
|
+
protected: nil,
|
772
786
|
remote_contexts: [],
|
773
787
|
validate_scoped: true)
|
774
788
|
# Expand a string value, unless it matches a keyword
|
@@ -985,9 +999,16 @@ module JSON::LD
|
|
985
999
|
|
986
1000
|
if value.has_key?('@context')
|
987
1001
|
begin
|
988
|
-
self.parse(value['@context'],
|
1002
|
+
new_ctx = self.parse(value['@context'],
|
1003
|
+
override_protected: true,
|
1004
|
+
remote_contexts: remote_contexts,
|
1005
|
+
validate_scoped: false)
|
989
1006
|
# Record null context in array form
|
990
|
-
definition.context =
|
1007
|
+
definition.context = case value['@context']
|
1008
|
+
when String then new_ctx.context_base
|
1009
|
+
when nil then [nil]
|
1010
|
+
else value['@context']
|
1011
|
+
end
|
991
1012
|
rescue JsonLdError => e
|
992
1013
|
raise JsonLdError::InvalidScopedContext, "Term definition for #{term.inspect} contains illegal value for @context: #{e.message}"
|
993
1014
|
end
|
@@ -1832,8 +1853,11 @@ module JSON::LD
|
|
1832
1853
|
that = self
|
1833
1854
|
ec = super
|
1834
1855
|
ec.instance_eval do
|
1835
|
-
@term_definitions = that.term_definitions.
|
1856
|
+
@term_definitions = that.term_definitions.inject({}) do |memo, (term, defn)|
|
1857
|
+
memo.merge(term => defn.dup())
|
1858
|
+
end
|
1836
1859
|
@iri_to_term = that.iri_to_term.dup
|
1860
|
+
@inverse_context = nil
|
1837
1861
|
end
|
1838
1862
|
ec
|
1839
1863
|
end
|
data/lib/json/ld/expand.rb
CHANGED
@@ -29,7 +29,7 @@ module JSON::LD
|
|
29
29
|
# Expanding from a map, which could be an `@type` map, so don't clear out context term definitions
|
30
30
|
# @return [Array<Hash{String => Object}>]
|
31
31
|
def expand(input, active_property, context, ordered: false, framing: false, from_map: false)
|
32
|
-
|
32
|
+
log_debug("expand") {"input: #{input.inspect}, active_property: #{active_property.inspect}, context: #{context.inspect}"}
|
33
33
|
framing = false if active_property == '@default'
|
34
34
|
expanded_active_property = context.expand_iri(active_property, vocab: true, as_string: true) if active_property
|
35
35
|
|
@@ -73,7 +73,7 @@ module JSON::LD
|
|
73
73
|
# 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.
|
74
74
|
if input.has_key?('@context')
|
75
75
|
context = context.parse(input.delete('@context'))
|
76
|
-
|
76
|
+
log_debug("expand") {"context: #{context.inspect}"}
|
77
77
|
end
|
78
78
|
|
79
79
|
# Set the type-scoped context to the context on input, for use later
|
@@ -102,7 +102,7 @@ module JSON::LD
|
|
102
102
|
ordered: ordered,
|
103
103
|
framing: framing)
|
104
104
|
|
105
|
-
|
105
|
+
log_debug("output object") {output_object.inspect}
|
106
106
|
|
107
107
|
# If result contains the key @value:
|
108
108
|
if value?(output_object)
|
@@ -161,7 +161,7 @@ module JSON::LD
|
|
161
161
|
if (expanded_active_property || '@graph') == '@graph' &&
|
162
162
|
(output_object.key?('@value') || output_object.key?('@list') ||
|
163
163
|
(output_object.keys - KEY_ID).empty? && !framing)
|
164
|
-
|
164
|
+
log_debug(" =>") { "empty top-level: " + output_object.inspect}
|
165
165
|
return nil
|
166
166
|
end
|
167
167
|
|
@@ -181,7 +181,7 @@ module JSON::LD
|
|
181
181
|
context.expand_value(active_property, input, log_depth: @options[:log_depth])
|
182
182
|
end
|
183
183
|
|
184
|
-
|
184
|
+
log_debug {" => #{result.inspect}"}
|
185
185
|
result
|
186
186
|
end
|
187
187
|
|
data/spec/compact_spec.rb
CHANGED
data/spec/context_spec.rb
CHANGED
@@ -57,14 +57,14 @@ describe JSON::LD::Context do
|
|
57
57
|
context "remote" do
|
58
58
|
|
59
59
|
it "retrieves and parses a remote context document" do
|
60
|
-
JSON::LD::Context
|
60
|
+
JSON::LD::Context.instance_variable_set(:@cache, nil)
|
61
61
|
expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/context", anything).and_yield(remote_doc)
|
62
62
|
ec = subject.parse("http://example.com/context")
|
63
63
|
expect(ec.provided_context).to produce("http://example.com/context", logger)
|
64
64
|
end
|
65
65
|
|
66
66
|
it "fails given a missing remote @context" do
|
67
|
-
JSON::LD::Context
|
67
|
+
JSON::LD::Context.instance_variable_set(:@cache, nil)
|
68
68
|
expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/context", anything).and_raise(IOError)
|
69
69
|
expect {subject.parse("http://example.com/context")}.to raise_error(JSON::LD::JsonLdError::LoadingRemoteContextFailed, %r{http://example.com/context})
|
70
70
|
end
|
@@ -116,7 +116,7 @@ describe JSON::LD::Context do
|
|
116
116
|
documentUrl: "http://example.com/context",
|
117
117
|
contentType: "text/html")
|
118
118
|
|
119
|
-
JSON::LD::Context
|
119
|
+
JSON::LD::Context.instance_variable_set(:@cache, nil)
|
120
120
|
expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/context", anything).and_yield(remote_doc)
|
121
121
|
ec = subject.parse("http://example.com/context")
|
122
122
|
expect(ec.send(:mappings)).to produce({
|
@@ -154,7 +154,7 @@ describe JSON::LD::Context do
|
|
154
154
|
),
|
155
155
|
documentUrl: "http://example.com/context",
|
156
156
|
contentType: "text/html")
|
157
|
-
JSON::LD::Context
|
157
|
+
JSON::LD::Context.instance_variable_set(:@cache, nil)
|
158
158
|
expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/context", anything).and_yield(remote_doc)
|
159
159
|
ec = subject.parse("http://example.com/context")
|
160
160
|
expect(ec.send(:mappings)).to produce({
|
@@ -170,7 +170,7 @@ describe JSON::LD::Context do
|
|
170
170
|
end
|
171
171
|
|
172
172
|
it "parses a referenced context at a relative URI" do
|
173
|
-
JSON::LD::Context
|
173
|
+
JSON::LD::Context.instance_variable_set(:@cache, nil)
|
174
174
|
rd1 = JSON::LD::API::RemoteDocument.new(%({"@context": "context"}), base_uri: "http://example.com/c1")
|
175
175
|
expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/c1", anything).and_yield(rd1)
|
176
176
|
expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/context", anything).and_yield(remote_doc)
|
@@ -185,7 +185,7 @@ describe JSON::LD::Context do
|
|
185
185
|
|
186
186
|
context "remote with local mappings" do
|
187
187
|
let(:ctx) {["http://example.com/context", {"integer" => "xsd:integer"}]}
|
188
|
-
before {JSON::LD::Context
|
188
|
+
before {JSON::LD::Context.instance_variable_set(:@cache, nil)}
|
189
189
|
it "retrieves and parses a remote context document" do
|
190
190
|
expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/context", anything).and_yield(remote_doc)
|
191
191
|
subject.parse(ctx)
|
@@ -206,7 +206,7 @@ describe JSON::LD::Context do
|
|
206
206
|
)
|
207
207
|
JSON::LD::Context.alias_preloaded("https://example.com/preloaded", "http://example.com/preloaded")
|
208
208
|
}
|
209
|
-
after(:all) {JSON::LD::Context
|
209
|
+
after(:all) {JSON::LD::Context.instance_variable_set(:@cache, nil)}
|
210
210
|
|
211
211
|
it "does not load referenced context" do
|
212
212
|
expect(JSON::LD::API).not_to receive(:documentLoader).with(ctx, anything)
|
@@ -249,6 +249,7 @@ describe JSON::LD::Context do
|
|
249
249
|
end
|
250
250
|
|
251
251
|
it "merges definitions from remote contexts" do
|
252
|
+
JSON::LD::Context.instance_variable_set(:@cache, nil)
|
252
253
|
expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/context", anything).and_yield(remote_doc)
|
253
254
|
rd2 = JSON::LD::API::RemoteDocument.new(%q({
|
254
255
|
"@context": {
|
@@ -476,7 +477,7 @@ describe JSON::LD::Context do
|
|
476
477
|
end
|
477
478
|
|
478
479
|
context "@import" do
|
479
|
-
before(:each) {JSON::LD::Context
|
480
|
+
before(:each) {JSON::LD::Context.instance_variable_set(:@cache, nil)}
|
480
481
|
it "generates an InvalidImportValue error if not a string" do
|
481
482
|
expect {subject.parse({'@version' => 1.1, '@import' => true})}.to raise_error(JSON::LD::JsonLdError::InvalidImportValue)
|
482
483
|
end
|
@@ -642,18 +643,8 @@ describe JSON::LD::Context do
|
|
642
643
|
end
|
643
644
|
end
|
644
645
|
|
645
|
-
describe "#merge!" do
|
646
|
-
it "updates context with components from new" do
|
647
|
-
c2 = JSON::LD::Context.parse({'foo' => "http://example.com/"})
|
648
|
-
cm = context.merge!(c2)
|
649
|
-
expect(cm).to equal context
|
650
|
-
expect(cm).not_to equal c2
|
651
|
-
expect(cm.term_definitions).to eq c2.term_definitions
|
652
|
-
end
|
653
|
-
end
|
654
|
-
|
655
646
|
describe "#serialize" do
|
656
|
-
before {JSON::LD::Context
|
647
|
+
before {JSON::LD::Context.instance_variable_set(:@cache, nil)}
|
657
648
|
it "context document" do
|
658
649
|
expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/context", anything).and_yield(remote_doc)
|
659
650
|
ec = subject.parse("http://example.com/context")
|
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.1.
|
4
|
+
version: 3.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gregg Kellogg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdf
|