json-ld 3.1.2 → 3.1.7
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/README.md +124 -48
- data/VERSION +1 -1
- data/bin/jsonld +27 -30
- data/lib/json/ld.rb +6 -2
- data/lib/json/ld/api.rb +33 -24
- data/lib/json/ld/compact.rb +65 -37
- data/lib/json/ld/conneg.rb +1 -1
- data/lib/json/ld/context.rb +612 -539
- data/lib/json/ld/expand.rb +158 -77
- data/lib/json/ld/format.rb +20 -7
- data/lib/json/ld/from_rdf.rb +40 -17
- data/lib/json/ld/reader.rb +20 -11
- data/lib/json/ld/streaming_reader.rb +578 -0
- data/lib/json/ld/to_rdf.rb +9 -5
- data/lib/json/ld/writer.rb +10 -3
- data/spec/compact_spec.rb +207 -2
- data/spec/context_spec.rb +13 -60
- data/spec/expand_spec.rb +248 -0
- data/spec/from_rdf_spec.rb +181 -0
- data/spec/matchers.rb +1 -1
- data/spec/reader_spec.rb +33 -34
- data/spec/streaming_reader_spec.rb +237 -0
- data/spec/suite_helper.rb +14 -8
- data/spec/suite_to_rdf_spec.rb +1 -0
- data/spec/to_rdf_spec.rb +206 -0
- data/spec/writer_spec.rb +193 -0
- metadata +9 -6
data/lib/json/ld/to_rdf.rb
CHANGED
@@ -16,6 +16,8 @@ module JSON::LD
|
|
16
16
|
# @return RDF::Resource the subject of this item
|
17
17
|
def item_to_rdf(item, graph_name: nil, &block)
|
18
18
|
# Just return value object as Term
|
19
|
+
return unless item
|
20
|
+
|
19
21
|
if value?(item)
|
20
22
|
value, datatype = item.fetch('@value'), item.fetch('@type', nil)
|
21
23
|
|
@@ -76,11 +78,13 @@ module JSON::LD
|
|
76
78
|
return parse_list(item['@list'], graph_name: graph_name, &block)
|
77
79
|
end
|
78
80
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
81
|
+
subject = case item['@id']
|
82
|
+
when nil then node
|
83
|
+
when String then as_resource(item['@id'])
|
84
|
+
when Object
|
85
|
+
# Embedded statement
|
86
|
+
# (No error checking, as this is done in expansion)
|
87
|
+
to_enum(:item_to_rdf, item['@id']).to_a.first
|
84
88
|
end
|
85
89
|
|
86
90
|
#log_debug("item_to_rdf") {"subject: #{subject.to_ntriples rescue 'malformed rdf'}"}
|
data/lib/json/ld/writer.rb
CHANGED
@@ -93,7 +93,7 @@ module JSON::LD
|
|
93
93
|
datatype: RDF::URI,
|
94
94
|
control: :url2,
|
95
95
|
on: ["--context CONTEXT"],
|
96
|
-
description: "Context to use when compacting.") {|arg| RDF::URI(arg)},
|
96
|
+
description: "Context to use when compacting.") {|arg| RDF::URI(arg).absolute? ? RDF::URI(arg) : StringIO.new(File.read(arg))},
|
97
97
|
RDF::CLI::Option.new(
|
98
98
|
symbol: :embed,
|
99
99
|
datatype: %w(@always @once @never),
|
@@ -107,6 +107,13 @@ module JSON::LD
|
|
107
107
|
control: :checkbox,
|
108
108
|
on: ["--[no-]explicit"],
|
109
109
|
description: "Only include explicitly declared properties in output (false)") {|arg| arg},
|
110
|
+
RDF::CLI::Option.new(
|
111
|
+
symbol: :frame,
|
112
|
+
datatype: RDF::URI,
|
113
|
+
control: :url2,
|
114
|
+
use: :required,
|
115
|
+
on: ["--frame FRAME"],
|
116
|
+
description: "Frame to use when serializing.") {|arg| RDF::URI(arg).absolute? ? RDF::URI(arg) : StringIO.new(File.read(arg))},
|
110
117
|
RDF::CLI::Option.new(
|
111
118
|
symbol: :lowercaseLanguage,
|
112
119
|
datatype: TrueClass,
|
@@ -137,7 +144,7 @@ module JSON::LD
|
|
137
144
|
default: 'null',
|
138
145
|
control: :select,
|
139
146
|
on: ["--rdf-direction DIR", %w(i18n-datatype compound-literal)],
|
140
|
-
description: "How to serialize literal direction (i18n-datatype compound-literal)") {|arg|
|
147
|
+
description: "How to serialize literal direction (i18n-datatype compound-literal)") {|arg| arg},
|
141
148
|
RDF::CLI::Option.new(
|
142
149
|
symbol: :requireAll,
|
143
150
|
datatype: TrueClass,
|
@@ -202,7 +209,7 @@ module JSON::LD
|
|
202
209
|
end
|
203
210
|
|
204
211
|
##
|
205
|
-
# Initializes the
|
212
|
+
# Initializes the JSON-LD writer instance.
|
206
213
|
#
|
207
214
|
# @param [IO, File] output
|
208
215
|
# the output stream
|
data/spec/compact_spec.rb
CHANGED
@@ -564,6 +564,7 @@ describe JSON::LD::API do
|
|
564
564
|
documentUrl: "http://example.com/context")
|
565
565
|
end
|
566
566
|
it "uses referenced context" do
|
567
|
+
JSON::LD::Context.instance_variable_set(:@cache, nil)
|
567
568
|
input = ::JSON.parse %({
|
568
569
|
"http://example.com/b": "c"
|
569
570
|
})
|
@@ -3112,6 +3113,210 @@ describe JSON::LD::API do
|
|
3112
3113
|
end
|
3113
3114
|
end
|
3114
3115
|
|
3116
|
+
context "JSON-LD*" do
|
3117
|
+
{
|
3118
|
+
"subject-iii": {
|
3119
|
+
input: %([{
|
3120
|
+
"@id": {
|
3121
|
+
"@id": "http://example/s1",
|
3122
|
+
"http://example/p1": [{"@id": "http://example/o1"}]
|
3123
|
+
},
|
3124
|
+
"http://example/p": [{"@id": "http://example/o"}]
|
3125
|
+
}]),
|
3126
|
+
context: %({"ex": "http://example/"}),
|
3127
|
+
output: %({
|
3128
|
+
"@context": {"ex": "http://example/"},
|
3129
|
+
"@id": {
|
3130
|
+
"@id": "ex:s1",
|
3131
|
+
"ex:p1": {"@id": "ex:o1"}
|
3132
|
+
},
|
3133
|
+
"ex:p": {"@id": "ex:o"}
|
3134
|
+
})
|
3135
|
+
},
|
3136
|
+
"subject-iib": {
|
3137
|
+
input: %([{
|
3138
|
+
"@id": {
|
3139
|
+
"@id": "http://example/s1",
|
3140
|
+
"http://example/p1": [{"@id": "_:o1"}]
|
3141
|
+
},
|
3142
|
+
"http://example/p": [{"@id": "http://example/o"}]
|
3143
|
+
}]),
|
3144
|
+
context: %({"ex": "http://example/"}),
|
3145
|
+
output: %({
|
3146
|
+
"@context": {"ex": "http://example/"},
|
3147
|
+
"@id": {
|
3148
|
+
"@id": "ex:s1",
|
3149
|
+
"ex:p1": {"@id": "_:o1"}
|
3150
|
+
},
|
3151
|
+
"ex:p": {"@id": "ex:o"}
|
3152
|
+
})
|
3153
|
+
},
|
3154
|
+
"subject-iil": {
|
3155
|
+
input: %([{
|
3156
|
+
"@id": {
|
3157
|
+
"@id": "http://example/s1",
|
3158
|
+
"http://example/p1": [{"@value": "o1"}]
|
3159
|
+
},
|
3160
|
+
"http://example/p": [{"@id": "http://example/o"}]
|
3161
|
+
}]),
|
3162
|
+
context: %({"ex": "http://example/"}),
|
3163
|
+
output: %({
|
3164
|
+
"@context": {"ex": "http://example/"},
|
3165
|
+
"@id": {
|
3166
|
+
"@id": "ex:s1",
|
3167
|
+
"ex:p1": "o1"
|
3168
|
+
},
|
3169
|
+
"ex:p": {"@id": "ex:o"}
|
3170
|
+
})
|
3171
|
+
},
|
3172
|
+
"subject-bii": {
|
3173
|
+
input: %([{
|
3174
|
+
"@id": {
|
3175
|
+
"@id": "_:s1",
|
3176
|
+
"http://example/p1": [{"@id": "http://example/o1"}]
|
3177
|
+
},
|
3178
|
+
"http://example/p": [{"@id": "http://example/o"}]
|
3179
|
+
}]),
|
3180
|
+
context: %({"ex": "http://example/"}),
|
3181
|
+
output: %({
|
3182
|
+
"@context": {"ex": "http://example/"},
|
3183
|
+
"@id": {
|
3184
|
+
"@id": "_:s1",
|
3185
|
+
"ex:p1": {"@id": "ex:o1"}
|
3186
|
+
},
|
3187
|
+
"ex:p": {"@id": "ex:o"}
|
3188
|
+
})
|
3189
|
+
},
|
3190
|
+
"subject-bib": {
|
3191
|
+
input: %([{
|
3192
|
+
"@id": {
|
3193
|
+
"@id": "_:s1",
|
3194
|
+
"http://example/p1": [{"@id": "_:o1"}]
|
3195
|
+
},
|
3196
|
+
"http://example/p": [{"@id": "http://example/o"}]
|
3197
|
+
}]),
|
3198
|
+
context: %({"ex": "http://example/"}),
|
3199
|
+
output: %({
|
3200
|
+
"@context": {"ex": "http://example/"},
|
3201
|
+
"@id": {
|
3202
|
+
"@id": "_:s1",
|
3203
|
+
"ex:p1": {"@id": "_:o1"}
|
3204
|
+
},
|
3205
|
+
"ex:p": {"@id": "ex:o"}
|
3206
|
+
})
|
3207
|
+
},
|
3208
|
+
"subject-bil": {
|
3209
|
+
input: %([{
|
3210
|
+
"@id": {
|
3211
|
+
"@id": "_:s1",
|
3212
|
+
"http://example/p1": [{"@value": "o1"}]
|
3213
|
+
},
|
3214
|
+
"http://example/p": [{"@id": "http://example/o"}]
|
3215
|
+
}]),
|
3216
|
+
context: %({"ex": "http://example/"}),
|
3217
|
+
output: %({
|
3218
|
+
"@context": {"ex": "http://example/"},
|
3219
|
+
"@id": {
|
3220
|
+
"@id": "_:s1",
|
3221
|
+
"ex:p1": "o1"
|
3222
|
+
},
|
3223
|
+
"ex:p": {"@id": "ex:o"}
|
3224
|
+
})
|
3225
|
+
},
|
3226
|
+
"object-iii": {
|
3227
|
+
input: %([{
|
3228
|
+
"@id": "http://example/s",
|
3229
|
+
"http://example/p": [{
|
3230
|
+
"@id": {
|
3231
|
+
"@id": "http://example/s1",
|
3232
|
+
"http://example/p1": [{"@id": "http://example/o1"}]
|
3233
|
+
}
|
3234
|
+
}]
|
3235
|
+
}]),
|
3236
|
+
context: %({"ex": "http://example/"}),
|
3237
|
+
output: %({
|
3238
|
+
"@context": {"ex": "http://example/"},
|
3239
|
+
"@id": "ex:s",
|
3240
|
+
"ex:p": {
|
3241
|
+
"@id": {
|
3242
|
+
"@id": "ex:s1",
|
3243
|
+
"ex:p1": {"@id": "ex:o1"}
|
3244
|
+
}
|
3245
|
+
}
|
3246
|
+
})
|
3247
|
+
},
|
3248
|
+
"object-iib": {
|
3249
|
+
input: %([{
|
3250
|
+
"@id": "http://example/s",
|
3251
|
+
"http://example/p": [{
|
3252
|
+
"@id": {
|
3253
|
+
"@id": "http://example/s1",
|
3254
|
+
"http://example/p1": [{"@id": "_:o1"}]
|
3255
|
+
}
|
3256
|
+
}]
|
3257
|
+
}]),
|
3258
|
+
context: %({"ex": "http://example/"}),
|
3259
|
+
output: %({
|
3260
|
+
"@context": {"ex": "http://example/"},
|
3261
|
+
"@id": "ex:s",
|
3262
|
+
"ex:p": {
|
3263
|
+
"@id": {
|
3264
|
+
"@id": "ex:s1",
|
3265
|
+
"ex:p1": {"@id": "_:o1"}
|
3266
|
+
}
|
3267
|
+
}
|
3268
|
+
})
|
3269
|
+
},
|
3270
|
+
"object-iil": {
|
3271
|
+
input: %([{
|
3272
|
+
"@id": "http://example/s",
|
3273
|
+
"http://example/p": [{
|
3274
|
+
"@id": {
|
3275
|
+
"@id": "http://example/s1",
|
3276
|
+
"http://example/p1": [{"@value": "o1"}]
|
3277
|
+
}
|
3278
|
+
}]
|
3279
|
+
}]),
|
3280
|
+
context: %({"ex": "http://example/"}),
|
3281
|
+
output: %({
|
3282
|
+
"@context": {"ex": "http://example/"},
|
3283
|
+
"@id": "ex:s",
|
3284
|
+
"ex:p": {
|
3285
|
+
"@id": {
|
3286
|
+
"@id": "ex:s1",
|
3287
|
+
"ex:p1": "o1"
|
3288
|
+
}
|
3289
|
+
}
|
3290
|
+
})
|
3291
|
+
},
|
3292
|
+
"recursive-subject": {
|
3293
|
+
input: %([{
|
3294
|
+
"@id": {
|
3295
|
+
"@id": {
|
3296
|
+
"@id": "http://example/s2",
|
3297
|
+
"http://example/p2": [{"@id": "http://example/o2"}]
|
3298
|
+
},
|
3299
|
+
"http://example/p1": [{"@id": "http://example/o1"}]
|
3300
|
+
},
|
3301
|
+
"http://example/p": [{"@id": "http://example/o"}]
|
3302
|
+
}]),
|
3303
|
+
context: %({"ex": "http://example/"}),
|
3304
|
+
output: %({
|
3305
|
+
"@context": {"ex": "http://example/"},
|
3306
|
+
"@id": {
|
3307
|
+
"@id": {
|
3308
|
+
"@id": "ex:s2",
|
3309
|
+
"ex:p2": {"@id": "ex:o2"}
|
3310
|
+
},
|
3311
|
+
"ex:p1": {"@id": "ex:o1"}
|
3312
|
+
},
|
3313
|
+
"ex:p": {"@id": "ex:o"}
|
3314
|
+
})
|
3315
|
+
},
|
3316
|
+
}.each do |name, params|
|
3317
|
+
it(name) {run_compact(params.merge(rdfstar: true))}
|
3318
|
+
end
|
3319
|
+
end
|
3115
3320
|
|
3116
3321
|
context "problem cases" do
|
3117
3322
|
{
|
@@ -3199,8 +3404,8 @@ describe JSON::LD::API do
|
|
3199
3404
|
expect(jld).to produce_jsonld(output, logger)
|
3200
3405
|
|
3201
3406
|
# Compare expanded jld/output too to make sure list values remain ordered
|
3202
|
-
exp_jld = JSON::LD::API.expand(jld, processingMode: 'json-ld-1.1')
|
3203
|
-
exp_output = JSON::LD::API.expand(output, processingMode: 'json-ld-1.1')
|
3407
|
+
exp_jld = JSON::LD::API.expand(jld, processingMode: 'json-ld-1.1', rdfstar: params[:rdfstar])
|
3408
|
+
exp_output = JSON::LD::API.expand(output, processingMode: 'json-ld-1.1', rdfstar: params[:rdfstar])
|
3204
3409
|
expect(exp_jld).to produce_jsonld(exp_output, logger)
|
3205
3410
|
end
|
3206
3411
|
end
|
data/spec/context_spec.rb
CHANGED
@@ -56,15 +56,8 @@ describe JSON::LD::Context do
|
|
56
56
|
describe "#parse" do
|
57
57
|
context "remote" do
|
58
58
|
|
59
|
-
it "retrieves and parses a remote context document" do
|
60
|
-
JSON::LD::Context::PRELOADED.clear
|
61
|
-
expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/context", anything).and_yield(remote_doc)
|
62
|
-
ec = subject.parse("http://example.com/context")
|
63
|
-
expect(ec.provided_context).to produce("http://example.com/context", logger)
|
64
|
-
end
|
65
|
-
|
66
59
|
it "fails given a missing remote @context" do
|
67
|
-
JSON::LD::Context
|
60
|
+
JSON::LD::Context.instance_variable_set(:@cache, nil)
|
68
61
|
expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/context", anything).and_raise(IOError)
|
69
62
|
expect {subject.parse("http://example.com/context")}.to raise_error(JSON::LD::JsonLdError::LoadingRemoteContextFailed, %r{http://example.com/context})
|
70
63
|
end
|
@@ -116,7 +109,7 @@ describe JSON::LD::Context do
|
|
116
109
|
documentUrl: "http://example.com/context",
|
117
110
|
contentType: "text/html")
|
118
111
|
|
119
|
-
JSON::LD::Context
|
112
|
+
JSON::LD::Context.instance_variable_set(:@cache, nil)
|
120
113
|
expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/context", anything).and_yield(remote_doc)
|
121
114
|
ec = subject.parse("http://example.com/context")
|
122
115
|
expect(ec.send(:mappings)).to produce({
|
@@ -154,7 +147,7 @@ describe JSON::LD::Context do
|
|
154
147
|
),
|
155
148
|
documentUrl: "http://example.com/context",
|
156
149
|
contentType: "text/html")
|
157
|
-
JSON::LD::Context
|
150
|
+
JSON::LD::Context.instance_variable_set(:@cache, nil)
|
158
151
|
expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/context", anything).and_yield(remote_doc)
|
159
152
|
ec = subject.parse("http://example.com/context")
|
160
153
|
expect(ec.send(:mappings)).to produce({
|
@@ -170,7 +163,7 @@ describe JSON::LD::Context do
|
|
170
163
|
end
|
171
164
|
|
172
165
|
it "parses a referenced context at a relative URI" do
|
173
|
-
JSON::LD::Context
|
166
|
+
JSON::LD::Context.instance_variable_set(:@cache, nil)
|
174
167
|
rd1 = JSON::LD::API::RemoteDocument.new(%({"@context": "context"}), base_uri: "http://example.com/c1")
|
175
168
|
expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/c1", anything).and_yield(rd1)
|
176
169
|
expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/context", anything).and_yield(remote_doc)
|
@@ -185,17 +178,11 @@ describe JSON::LD::Context do
|
|
185
178
|
|
186
179
|
context "remote with local mappings" do
|
187
180
|
let(:ctx) {["http://example.com/context", {"integer" => "xsd:integer"}]}
|
188
|
-
before {JSON::LD::Context
|
181
|
+
before {JSON::LD::Context.instance_variable_set(:@cache, nil)}
|
189
182
|
it "retrieves and parses a remote context document" do
|
190
183
|
expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/context", anything).and_yield(remote_doc)
|
191
184
|
subject.parse(ctx)
|
192
185
|
end
|
193
|
-
|
194
|
-
it "does not use passed context as provided_context" do
|
195
|
-
expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/context", anything).and_yield(remote_doc)
|
196
|
-
ec = subject.parse(ctx)
|
197
|
-
expect(ec.provided_context).to produce(ctx, logger)
|
198
|
-
end
|
199
186
|
end
|
200
187
|
|
201
188
|
context "pre-loaded remote" do
|
@@ -206,7 +193,7 @@ describe JSON::LD::Context do
|
|
206
193
|
)
|
207
194
|
JSON::LD::Context.alias_preloaded("https://example.com/preloaded", "http://example.com/preloaded")
|
208
195
|
}
|
209
|
-
after(:all) {JSON::LD::Context
|
196
|
+
after(:all) {JSON::LD::Context.instance_variable_set(:@cache, nil)}
|
210
197
|
|
211
198
|
it "does not load referenced context" do
|
212
199
|
expect(JSON::LD::API).not_to receive(:documentLoader).with(ctx, anything)
|
@@ -249,6 +236,7 @@ describe JSON::LD::Context do
|
|
249
236
|
end
|
250
237
|
|
251
238
|
it "merges definitions from remote contexts" do
|
239
|
+
JSON::LD::Context.instance_variable_set(:@cache, nil)
|
252
240
|
expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/context", anything).and_yield(remote_doc)
|
253
241
|
rd2 = JSON::LD::API::RemoteDocument.new(%q({
|
254
242
|
"@context": {
|
@@ -476,7 +464,7 @@ describe JSON::LD::Context do
|
|
476
464
|
end
|
477
465
|
|
478
466
|
context "@import" do
|
479
|
-
before(:each) {JSON::LD::Context
|
467
|
+
before(:each) {JSON::LD::Context.instance_variable_set(:@cache, nil)}
|
480
468
|
it "generates an InvalidImportValue error if not a string" do
|
481
469
|
expect {subject.parse({'@version' => 1.1, '@import' => true})}.to raise_error(JSON::LD::JsonLdError::InvalidImportValue)
|
482
470
|
end
|
@@ -642,26 +630,8 @@ describe JSON::LD::Context do
|
|
642
630
|
end
|
643
631
|
end
|
644
632
|
|
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
633
|
describe "#serialize" do
|
656
|
-
before {JSON::LD::Context
|
657
|
-
it "context document" do
|
658
|
-
expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/context", anything).and_yield(remote_doc)
|
659
|
-
ec = subject.parse("http://example.com/context")
|
660
|
-
expect(ec.serialize).to produce({
|
661
|
-
"@context" => "http://example.com/context"
|
662
|
-
}, logger)
|
663
|
-
end
|
664
|
-
|
634
|
+
before {JSON::LD::Context.instance_variable_set(:@cache, nil)}
|
665
635
|
it "context hash" do
|
666
636
|
ctx = {"foo" => "http://example.com/"}
|
667
637
|
|
@@ -693,7 +663,7 @@ describe JSON::LD::Context do
|
|
693
663
|
|
694
664
|
it "term mappings" do
|
695
665
|
c = subject.
|
696
|
-
parse({'foo' => "http://example.com/"})
|
666
|
+
parse({'foo' => "http://example.com/"})
|
697
667
|
expect(c.serialize).to produce({
|
698
668
|
"@context" => {
|
699
669
|
"foo" => "http://example.com/"
|
@@ -705,7 +675,7 @@ describe JSON::LD::Context do
|
|
705
675
|
it "@context" do
|
706
676
|
expect(subject.parse({
|
707
677
|
"foo" => {"@id" => "http://example.com/", "@context" => {"bar" => "http://example.com/baz"}}
|
708
|
-
}).
|
678
|
+
}).
|
709
679
|
serialize).to produce({
|
710
680
|
"@context" => {
|
711
681
|
"foo" => {
|
@@ -721,7 +691,6 @@ describe JSON::LD::Context do
|
|
721
691
|
'xsd' => "http://www.w3.org/2001/XMLSchema#",
|
722
692
|
'homepage' => {'@id' => RDF::Vocab::FOAF.homepage.to_s, '@type' => '@id'}
|
723
693
|
}).
|
724
|
-
send(:clear_provided_context).
|
725
694
|
serialize).to produce({
|
726
695
|
"@context" => {
|
727
696
|
"xsd" => RDF::XSD.to_uri.to_s,
|
@@ -734,7 +703,6 @@ describe JSON::LD::Context do
|
|
734
703
|
expect(subject.parse({
|
735
704
|
'knows' => {'@id' => RDF::Vocab::FOAF.knows.to_s, '@container' => '@list'}
|
736
705
|
}).
|
737
|
-
send(:clear_provided_context).
|
738
706
|
serialize).to produce({
|
739
707
|
"@context" => {
|
740
708
|
"knows" => {"@id" => RDF::Vocab::FOAF.knows.to_s, "@container" => "@list"}
|
@@ -746,7 +714,6 @@ describe JSON::LD::Context do
|
|
746
714
|
expect(subject.parse({
|
747
715
|
"knows" => {"@id" => RDF::Vocab::FOAF.knows.to_s, "@container" => "@set"}
|
748
716
|
}).
|
749
|
-
send(:clear_provided_context).
|
750
717
|
serialize).to produce({
|
751
718
|
"@context" => {
|
752
719
|
"knows" => {"@id" => RDF::Vocab::FOAF.knows.to_s, "@container" => "@set"}
|
@@ -758,7 +725,6 @@ describe JSON::LD::Context do
|
|
758
725
|
expect(subject.parse({
|
759
726
|
"name" => {"@id" => RDF::Vocab::FOAF.name.to_s, "@language" => "en"}
|
760
727
|
}).
|
761
|
-
send(:clear_provided_context).
|
762
728
|
serialize).to produce({
|
763
729
|
"@context" => {
|
764
730
|
"name" => {"@id" => RDF::Vocab::FOAF.name.to_s, "@language" => "en"}
|
@@ -771,7 +737,6 @@ describe JSON::LD::Context do
|
|
771
737
|
"@language" => 'en',
|
772
738
|
"name" => {"@id" => RDF::Vocab::FOAF.name.to_s, "@language" => 'en'}
|
773
739
|
}).
|
774
|
-
send(:clear_provided_context).
|
775
740
|
serialize).to produce({
|
776
741
|
"@context" => {
|
777
742
|
"@language" => 'en',
|
@@ -785,7 +750,6 @@ describe JSON::LD::Context do
|
|
785
750
|
"@language" => 'en',
|
786
751
|
"name" => {"@id" => RDF::Vocab::FOAF.name.to_s, "@language" => "de"}
|
787
752
|
}).
|
788
|
-
send(:clear_provided_context).
|
789
753
|
serialize).to produce({
|
790
754
|
"@context" => {
|
791
755
|
"@language" => 'en',
|
@@ -799,7 +763,6 @@ describe JSON::LD::Context do
|
|
799
763
|
"@language" => 'en',
|
800
764
|
"name" => {"@id" => RDF::Vocab::FOAF.name.to_s, "@language" => nil}
|
801
765
|
}).
|
802
|
-
send(:clear_provided_context).
|
803
766
|
serialize).to produce({
|
804
767
|
"@context" => {
|
805
768
|
"@language" => 'en',
|
@@ -812,7 +775,6 @@ describe JSON::LD::Context do
|
|
812
775
|
expect(subject.parse({
|
813
776
|
"knows" => {"@id" => RDF::Vocab::FOAF.knows.to_s, "@type" => "@id", "@container" => "@list"}
|
814
777
|
}).
|
815
|
-
send(:clear_provided_context).
|
816
778
|
serialize).to produce({
|
817
779
|
"@context" => {
|
818
780
|
"knows" => {"@id" => RDF::Vocab::FOAF.knows.to_s, "@type" => "@id", "@container" => "@list"}
|
@@ -824,7 +786,6 @@ describe JSON::LD::Context do
|
|
824
786
|
expect(subject.parse({
|
825
787
|
"knows" => {"@id" => RDF::Vocab::FOAF.knows.to_s, "@type" => "@id", "@container" => "@set"}
|
826
788
|
}).
|
827
|
-
send(:clear_provided_context).
|
828
789
|
serialize).to produce({
|
829
790
|
"@context" => {
|
830
791
|
"knows" => {"@id" => RDF::Vocab::FOAF.knows.to_s, "@type" => "@id", "@container" => "@set"}
|
@@ -836,7 +797,6 @@ describe JSON::LD::Context do
|
|
836
797
|
expect(subject.parse({
|
837
798
|
"knows" => {"@id" => RDF::Vocab::FOAF.knows.to_s, "@type" => "@json"}
|
838
799
|
}).
|
839
|
-
send(:clear_provided_context).
|
840
800
|
serialize).to produce({
|
841
801
|
"@context" => {
|
842
802
|
"knows" => {"@id" => RDF::Vocab::FOAF.knows.to_s, "@type" => "@json"}
|
@@ -851,7 +811,6 @@ describe JSON::LD::Context do
|
|
851
811
|
"@container" => "@list"
|
852
812
|
}
|
853
813
|
}).
|
854
|
-
send(:clear_provided_context).
|
855
814
|
serialize).to produce({
|
856
815
|
"@context" => {
|
857
816
|
"foaf" => RDF::Vocab::FOAF.to_uri.to_s,
|
@@ -867,7 +826,6 @@ describe JSON::LD::Context do
|
|
867
826
|
"id" => "@id",
|
868
827
|
"knows" => {"@id" => RDF::Vocab::FOAF.knows.to_s, "@container" => "@list"}
|
869
828
|
}).
|
870
|
-
send(:clear_provided_context).
|
871
829
|
serialize).to produce({
|
872
830
|
"@context" => {
|
873
831
|
"id" => "@id",
|
@@ -884,7 +842,6 @@ describe JSON::LD::Context do
|
|
884
842
|
"@type" => "@id"
|
885
843
|
}
|
886
844
|
}).
|
887
|
-
send(:clear_provided_context).
|
888
845
|
serialize).to produce({
|
889
846
|
"@context" => {
|
890
847
|
"foaf" => RDF::Vocab::FOAF.to_uri.to_s,
|
@@ -902,7 +859,6 @@ describe JSON::LD::Context do
|
|
902
859
|
"type" => "@type",
|
903
860
|
"foaf:homepage" => {"@type" => "@id"}
|
904
861
|
}).
|
905
|
-
send(:clear_provided_context).
|
906
862
|
serialize).to produce({
|
907
863
|
"@context" => {
|
908
864
|
"foaf" => RDF::Vocab::FOAF.to_uri.to_s,
|
@@ -917,7 +873,6 @@ describe JSON::LD::Context do
|
|
917
873
|
"container" => "@container",
|
918
874
|
"knows" => {"@id" => RDF::Vocab::FOAF.knows.to_s, "@container" => "@list"}
|
919
875
|
}).
|
920
|
-
send(:clear_provided_context).
|
921
876
|
serialize).to produce({
|
922
877
|
"@context" => {
|
923
878
|
"container" => "@container",
|
@@ -931,7 +886,6 @@ describe JSON::LD::Context do
|
|
931
886
|
"ex" => 'http://example.org/',
|
932
887
|
"term" => {"@id" => "ex:term", "@type" => "ex:datatype"}
|
933
888
|
}).
|
934
|
-
send(:clear_provided_context).
|
935
889
|
serialize).to produce({
|
936
890
|
"@context" => {
|
937
891
|
"ex" => 'http://example.org/',
|
@@ -945,7 +899,6 @@ describe JSON::LD::Context do
|
|
945
899
|
"@vocab" => 'http://example.org/',
|
946
900
|
"term" => {"@id" => "http://example.org/term", "@type" => "datatype"}
|
947
901
|
}).
|
948
|
-
send(:clear_provided_context).
|
949
902
|
serialize).to produce({
|
950
903
|
"@context" => {
|
951
904
|
"@vocab" => 'http://example.org/',
|
@@ -1254,7 +1207,7 @@ describe JSON::LD::Context do
|
|
1254
1207
|
it "does not use @vocab if it would collide with a term" do
|
1255
1208
|
subject.set_mapping("name", "http://xmlns.com/foaf/0.1/name")
|
1256
1209
|
subject.set_mapping("ex", nil)
|
1257
|
-
expect(subject.compact_iri("http://example.org/name",
|
1210
|
+
expect(subject.compact_iri("http://example.org/name", vocab: true)).
|
1258
1211
|
not_to produce("name", logger)
|
1259
1212
|
end
|
1260
1213
|
|
@@ -1537,7 +1490,7 @@ describe JSON::LD::Context do
|
|
1537
1490
|
})
|
1538
1491
|
end
|
1539
1492
|
it "Compact @id that is a property IRI when @container is @list" do
|
1540
|
-
expect(ctx.compact_iri("http://example.org/ns#property",
|
1493
|
+
expect(ctx.compact_iri("http://example.org/ns#property", vocab: false)).
|
1541
1494
|
to produce("ex:property", logger)
|
1542
1495
|
end
|
1543
1496
|
end
|