json-ld 1.1.5 → 1.1.6
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 +2 -0
- data/VERSION +1 -1
- data/bin/jsonld +2 -2
- data/lib/json/ld/api.rb +9 -3
- data/lib/json/ld/context.rb +252 -117
- data/lib/json/ld/frame.rb +8 -8
- data/lib/json/ld/from_rdf.rb +8 -3
- data/lib/json/ld/writer.rb +9 -2
- data/spec/api_spec.rb +4 -4
- data/spec/compact_spec.rb +11 -11
- data/spec/context_spec.rb +274 -136
- data/spec/expand_spec.rb +15 -15
- data/spec/flatten_spec.rb +1 -1
- data/spec/format_spec.rb +6 -6
- data/spec/frame_spec.rb +54 -1
- data/spec/from_rdf_spec.rb +112 -77
- data/spec/matchers.rb +3 -3
- data/spec/reader_spec.rb +6 -6
- data/spec/resource_spec.rb +6 -6
- data/spec/to_rdf_spec.rb +4 -8
- data/spec/writer_spec.rb +1 -1
- metadata +18 -4
data/spec/matchers.rb
CHANGED
@@ -35,7 +35,7 @@ RSpec::Matchers.define :be_equivalent_graph do |expected, info|
|
|
35
35
|
@actual.isomorphic_with?(@expected)
|
36
36
|
end
|
37
37
|
|
38
|
-
|
38
|
+
failure_message do |actual|
|
39
39
|
info = @info.respond_to?(:information) ? @info.information : @info.inspect
|
40
40
|
if @expected.is_a?(RDF::Enumerable) && @actual.size != @expected.size
|
41
41
|
"Graph entry count differs:\nexpected: #{@expected.size}\nactual: #{@actual.size}"
|
@@ -55,10 +55,10 @@ end
|
|
55
55
|
|
56
56
|
RSpec::Matchers.define :produce do |expected, info|
|
57
57
|
match do |actual|
|
58
|
-
actual.
|
58
|
+
expect(actual).to eq expected
|
59
59
|
end
|
60
60
|
|
61
|
-
|
61
|
+
failure_message do |actual|
|
62
62
|
"Expected: #{expected.is_a?(String) ? expected : expected.to_json(JSON_STATE)}\n" +
|
63
63
|
"Actual : #{actual.is_a?(String) ? actual : actual.to_json(JSON_STATE)}\n" +
|
64
64
|
#(expected.is_a?(Hash) && actual.is_a?(Hash) ? "Diff: #{expected.diff(actual).to_json(JSON_STATE)}\n" : "") +
|
data/spec/reader_spec.rb
CHANGED
@@ -29,7 +29,7 @@ describe JSON::LD::Reader do
|
|
29
29
|
{:content_type => 'application/x-ld+json'},
|
30
30
|
].each do |arg|
|
31
31
|
it "discovers with #{arg.inspect}" do
|
32
|
-
RDF::Reader.for(arg).
|
32
|
+
expect(RDF::Reader.for(arg)).to eq JSON::LD::Reader
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -79,7 +79,7 @@ describe JSON::LD::Reader do
|
|
79
79
|
describe "#initialize" do
|
80
80
|
it "yields reader given string" do
|
81
81
|
inner = double("inner")
|
82
|
-
inner.
|
82
|
+
expect(inner).to receive(:called).with(JSON::LD::Reader)
|
83
83
|
JSON::LD::Reader.new(subject) do |reader|
|
84
84
|
inner.called(reader.class)
|
85
85
|
end
|
@@ -87,21 +87,21 @@ describe JSON::LD::Reader do
|
|
87
87
|
|
88
88
|
it "yields reader given IO" do
|
89
89
|
inner = double("inner")
|
90
|
-
inner.
|
90
|
+
expect(inner).to receive(:called).with(JSON::LD::Reader)
|
91
91
|
JSON::LD::Reader.new(StringIO.new(subject)) do |reader|
|
92
92
|
inner.called(reader.class)
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
96
|
it "returns reader" do
|
97
|
-
JSON::LD::Reader.new(subject).
|
97
|
+
expect(JSON::LD::Reader.new(subject)).to be_a(JSON::LD::Reader)
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
101
101
|
describe "#each_statement" do
|
102
102
|
it "yields statements" do
|
103
103
|
inner = double("inner")
|
104
|
-
inner.
|
104
|
+
expect(inner).to receive(:called).with(RDF::Statement).exactly(3)
|
105
105
|
JSON::LD::Reader.new(subject).each_statement do |statement|
|
106
106
|
inner.called(statement.class)
|
107
107
|
end
|
@@ -111,7 +111,7 @@ describe JSON::LD::Reader do
|
|
111
111
|
describe "#each_triple" do
|
112
112
|
it "yields statements" do
|
113
113
|
inner = double("inner")
|
114
|
-
inner.
|
114
|
+
expect(inner).to receive(:called).exactly(3)
|
115
115
|
JSON::LD::Reader.new(subject).each_triple do |subject, predicate, object|
|
116
116
|
inner.called(subject.class, predicate.class, object.class)
|
117
117
|
end
|
data/spec/resource_spec.rb
CHANGED
@@ -40,25 +40,25 @@ describe JSON::LD::Resource do
|
|
40
40
|
end
|
41
41
|
|
42
42
|
describe "#hash" do
|
43
|
-
specify {subject.hash.
|
43
|
+
specify {expect(subject.hash).to be_a(Fixnum)}
|
44
44
|
|
45
45
|
it "returns the hash of the attributes" do
|
46
|
-
subject.hash.
|
46
|
+
expect(subject.hash).to eq subject.deresolve.hash
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
50
|
describe "#to_json" do
|
51
51
|
it "has JSON" do
|
52
|
-
subject.to_json.
|
53
|
-
JSON.parse(subject.to_json).
|
52
|
+
expect(subject.to_json).to be_a(String)
|
53
|
+
expect(JSON.parse(subject.to_json)).to be_a(Hash)
|
54
54
|
end
|
55
55
|
it "has same ID" do
|
56
|
-
JSON.parse(subject.to_json)['@id'].
|
56
|
+
expect(JSON.parse(subject.to_json)['@id']).to eq subject.id
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
60
|
describe "#each" do
|
61
|
-
specify {expect {|b| subject.each(&b)}.to yield_with_args(
|
61
|
+
specify {expect {|b| subject.each(&b)}.to yield_with_args(subject.statements.first)}
|
62
62
|
end
|
63
63
|
|
64
64
|
describe RDF::Enumerable do
|
data/spec/to_rdf_spec.rb
CHANGED
@@ -306,8 +306,7 @@ describe JSON::LD::API do
|
|
306
306
|
|
307
307
|
context "lists" do
|
308
308
|
{
|
309
|
-
"Empty" =>
|
310
|
-
[
|
309
|
+
"Empty" => [
|
311
310
|
%q({
|
312
311
|
"@context": {"foaf": "http://xmlns.com/foaf/0.1/"},
|
313
312
|
"@id": "http://greggkellogg.net/foaf#me",
|
@@ -317,8 +316,7 @@ describe JSON::LD::API do
|
|
317
316
|
<http://greggkellogg.net/foaf#me> <http://xmlns.com/foaf/0.1/knows> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
|
318
317
|
)
|
319
318
|
],
|
320
|
-
"single value" =>
|
321
|
-
[
|
319
|
+
"single value" => [
|
322
320
|
%q({
|
323
321
|
"@context": {"foaf": "http://xmlns.com/foaf/0.1/"},
|
324
322
|
"@id": "http://greggkellogg.net/foaf#me",
|
@@ -330,8 +328,7 @@ describe JSON::LD::API do
|
|
330
328
|
_:a <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
|
331
329
|
)
|
332
330
|
],
|
333
|
-
"single value (with coercion)" =>
|
334
|
-
[
|
331
|
+
"single value (with coercion)" => [
|
335
332
|
%q({
|
336
333
|
"@context": {
|
337
334
|
"foaf": "http://xmlns.com/foaf/0.1/",
|
@@ -346,8 +343,7 @@ describe JSON::LD::API do
|
|
346
343
|
_:a <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
|
347
344
|
)
|
348
345
|
],
|
349
|
-
"multiple values" =>
|
350
|
-
[
|
346
|
+
"multiple values" => [
|
351
347
|
%q({
|
352
348
|
"@context": {"foaf": "http://xmlns.com/foaf/0.1/"},
|
353
349
|
"@id": "http://greggkellogg.net/foaf#me",
|
data/spec/writer_spec.rb
CHANGED
@@ -20,7 +20,7 @@ describe JSON::LD::Writer do
|
|
20
20
|
{:content_type => 'application/x-ld+json'},
|
21
21
|
].each do |arg|
|
22
22
|
it "discovers with #{arg.inspect}" do
|
23
|
-
expect(RDF::Reader.for(arg)).to
|
23
|
+
expect(RDF::Reader.for(arg)).to eq JSON::LD::Reader
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
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: 1.1.
|
4
|
+
version: 1.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gregg Kellogg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdf
|
@@ -84,14 +84,28 @@ dependencies:
|
|
84
84
|
requirements:
|
85
85
|
- - "~>"
|
86
86
|
- !ruby/object:Gem::Version
|
87
|
-
version: '
|
87
|
+
version: '3.0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
90
|
version_requirements: !ruby/object:Gem::Requirement
|
91
91
|
requirements:
|
92
92
|
- - "~>"
|
93
93
|
- !ruby/object:Gem::Version
|
94
|
-
version: '
|
94
|
+
version: '3.0'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: rspec-its
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - "~>"
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '1.0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - "~>"
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '1.0'
|
95
109
|
- !ruby/object:Gem::Dependency
|
96
110
|
name: rdf-spec
|
97
111
|
requirement: !ruby/object:Gem::Requirement
|