json-ld 1.0.5 → 1.0.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 +8 -8
- data/README.md +9 -8
- data/VERSION +1 -1
- data/bin/jsonld +2 -1
- data/lib/json/ld.rb +43 -42
- data/lib/json/ld/api.rb +184 -39
- data/lib/json/ld/compact.rb +1 -1
- data/lib/json/ld/context.rb +88 -58
- data/lib/json/ld/expand.rb +27 -25
- data/lib/json/ld/extensions.rb +0 -23
- data/lib/json/ld/flatten.rb +1 -1
- data/lib/json/ld/reader.rb +2 -2
- data/lib/json/ld/resource.rb +1 -1
- data/spec/api_spec.rb +3 -1
- data/spec/compact_spec.rb +6 -4
- data/spec/context_spec.rb +20 -35
- data/spec/expand_spec.rb +42 -22
- data/spec/frame_spec.rb +1 -1
- data/spec/from_rdf_spec.rb +4 -22
- data/spec/suite_compact_spec.rb +2 -19
- data/spec/suite_error_spec.rb +17 -0
- data/spec/suite_expand_spec.rb +2 -16
- data/spec/suite_flatten_spec.rb +2 -16
- data/spec/suite_frame_spec.rb +2 -16
- data/spec/suite_from_rdf_spec.rb +2 -18
- data/spec/suite_helper.rb +218 -60
- data/spec/suite_remote_doc_spec.rb +17 -0
- data/spec/suite_to_rdf_spec.rb +2 -19
- data/spec/to_rdf_spec.rb +5 -5
- data/spec/writer_spec.rb +3 -3
- metadata +8 -6
- data/spec/suite_error_expand_spec.rb +0 -23
@@ -0,0 +1,17 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
$:.unshift "."
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe JSON::LD do
|
6
|
+
describe "test suite" do
|
7
|
+
require 'suite_helper'
|
8
|
+
m = Fixtures::SuiteTest::Manifest.open("#{Fixtures::SuiteTest::SUITE}tests/remote-doc-manifest.jsonld")
|
9
|
+
describe m.name do
|
10
|
+
m.entries.each do |t|
|
11
|
+
specify "#{t.property('input')}: #{t.name}#{' (negative test)' unless t.positiveTest?}" do
|
12
|
+
t.run self
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end unless ENV['CI']
|
data/spec/suite_to_rdf_spec.rb
CHANGED
@@ -8,25 +8,8 @@ describe JSON::LD do
|
|
8
8
|
m = Fixtures::SuiteTest::Manifest.open("#{Fixtures::SuiteTest::SUITE}tests/toRdf-manifest.jsonld")
|
9
9
|
describe m.name do
|
10
10
|
m.entries.each do |t|
|
11
|
-
specify "#{t.property('input')}: #{t.name}" do
|
12
|
-
|
13
|
-
t.debug = ["test: #{t.inspect}", "source: #{t.input.read}"]
|
14
|
-
quads = JSON::LD::API.toRDF(t.input, nil,
|
15
|
-
:base => t.base,
|
16
|
-
:debug => t.debug
|
17
|
-
).map do |statement|
|
18
|
-
t.to_quad(statement)
|
19
|
-
end
|
20
|
-
|
21
|
-
sorted_expected = t.expect.readlines.uniq.sort.join("")
|
22
|
-
quads.uniq.sort.join("").should produce(sorted_expected, t.debug)
|
23
|
-
rescue JSON::LD::ProcessingError => e
|
24
|
-
fail("Processing error: #{e.message}")
|
25
|
-
rescue JSON::LD::InvalidContext => e
|
26
|
-
fail("Invalid Context: #{e.message}")
|
27
|
-
rescue JSON::LD::InvalidFrame => e
|
28
|
-
fail("Invalid Frame: #{e.message}")
|
29
|
-
end
|
11
|
+
specify "#{t.property('input')}: #{t.name}#{' (negative test)' unless t.positiveTest?}" do
|
12
|
+
t.run self
|
30
13
|
end
|
31
14
|
end
|
32
15
|
end
|
data/spec/to_rdf_spec.rb
CHANGED
@@ -575,13 +575,13 @@ describe JSON::LD::API do
|
|
575
575
|
context "blank node predicates" do
|
576
576
|
subject {%q({"@id": "http://example/subj", "_:foo": "bar"})}
|
577
577
|
|
578
|
-
it "outputs statements with blank node predicates if :
|
579
|
-
graph = parse(subject, :
|
578
|
+
it "outputs statements with blank node predicates if :produceGeneralizedRdf is true" do
|
579
|
+
graph = parse(subject, :produceGeneralizedRdf => true)
|
580
580
|
expect(graph.count).to eq 1
|
581
581
|
end
|
582
582
|
|
583
|
-
it "rejects statements with blank node predicates if :
|
584
|
-
graph = parse(subject, :
|
583
|
+
it "rejects statements with blank node predicates if :produceGeneralizedRdf is false" do
|
584
|
+
graph = parse(subject, :produceGeneralizedRdf => false)
|
585
585
|
expect(graph.count).to eq 0
|
586
586
|
end
|
587
587
|
end
|
@@ -646,7 +646,7 @@ describe JSON::LD::API do
|
|
646
646
|
@debug = []
|
647
647
|
graph = options[:graph] || RDF::Graph.new
|
648
648
|
options = {:debug => @debug, :validate => true, :canonicalize => false}.merge(options)
|
649
|
-
JSON::LD::API.toRDF(StringIO.new(input),
|
649
|
+
JSON::LD::API.toRDF(StringIO.new(input), options) {|st| graph << st}
|
650
650
|
graph
|
651
651
|
end
|
652
652
|
end
|
data/spec/writer_spec.rb
CHANGED
@@ -83,17 +83,17 @@ describe JSON::LD::Writer do
|
|
83
83
|
'@id' => ":b",
|
84
84
|
":c" => {"@id" => ":d"}
|
85
85
|
}, @debug)
|
86
|
-
rescue JSON::LD::
|
86
|
+
rescue JSON::LD::JsonLdError, JSON::LD::JsonLdError, TypeError => e
|
87
87
|
fail("#{e.class}: #{e.message}\n" +
|
88
88
|
"#{@debug.join("\n")}\n" +
|
89
89
|
"Backtrace:\n#{e.backtrace.join("\n")}")
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
|
-
it "should use terms if no suffix" do
|
93
|
+
it "should not use terms if no suffix" do
|
94
94
|
input = %(<http://xmlns.com/foaf/0.1/> <http://xmlns.com/foaf/0.1/> <http://xmlns.com/foaf/0.1/> .)
|
95
95
|
serialize(input, :standard_prefixes => true).
|
96
|
-
|
96
|
+
should_not produce({
|
97
97
|
"@context" => {"foaf" => "http://xmlns.com/foaf/0.1/"},
|
98
98
|
'@id' => "foaf",
|
99
99
|
"foaf" => {"@id" => "foaf"}
|
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.0.
|
4
|
+
version: 1.0.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: 2013-
|
11
|
+
date: 2013-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdf
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ! '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.0.
|
19
|
+
version: 1.0.8
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ! '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.0.
|
26
|
+
version: 1.0.8
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: json
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -205,12 +205,13 @@ files:
|
|
205
205
|
- spec/resource_spec.rb
|
206
206
|
- spec/spec_helper.rb
|
207
207
|
- spec/suite_compact_spec.rb
|
208
|
-
- spec/
|
208
|
+
- spec/suite_error_spec.rb
|
209
209
|
- spec/suite_expand_spec.rb
|
210
210
|
- spec/suite_flatten_spec.rb
|
211
211
|
- spec/suite_frame_spec.rb
|
212
212
|
- spec/suite_from_rdf_spec.rb
|
213
213
|
- spec/suite_helper.rb
|
214
|
+
- spec/suite_remote_doc_spec.rb
|
214
215
|
- spec/suite_to_rdf_spec.rb
|
215
216
|
- spec/support/extensions.rb
|
216
217
|
- spec/to_rdf_spec.rb
|
@@ -310,12 +311,13 @@ test_files:
|
|
310
311
|
- spec/resource_spec.rb
|
311
312
|
- spec/spec_helper.rb
|
312
313
|
- spec/suite_compact_spec.rb
|
313
|
-
- spec/
|
314
|
+
- spec/suite_error_spec.rb
|
314
315
|
- spec/suite_expand_spec.rb
|
315
316
|
- spec/suite_flatten_spec.rb
|
316
317
|
- spec/suite_frame_spec.rb
|
317
318
|
- spec/suite_from_rdf_spec.rb
|
318
319
|
- spec/suite_helper.rb
|
320
|
+
- spec/suite_remote_doc_spec.rb
|
319
321
|
- spec/suite_to_rdf_spec.rb
|
320
322
|
- spec/support/extensions.rb
|
321
323
|
- spec/to_rdf_spec.rb
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
$:.unshift "."
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe JSON::LD do
|
6
|
-
describe "test suite" do
|
7
|
-
require 'suite_helper'
|
8
|
-
m = Fixtures::SuiteTest::Manifest.open("#{Fixtures::SuiteTest::SUITE}tests/error-expand-manifest.jsonld")
|
9
|
-
describe m.name do
|
10
|
-
m.entries.each do |t|
|
11
|
-
specify "#{t.property('input')}: #{t.name}" do
|
12
|
-
begin
|
13
|
-
t.debug = ["test: #{t.inspect}", "source: #{t.input.read}"]
|
14
|
-
t.debug << "context: #{t.context.read}" if t.property('context')
|
15
|
-
lambda {
|
16
|
-
JSON::LD::API.expand(t.input, nil, :base => t.base, :validate => true)
|
17
|
-
}.should raise_error
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end unless ENV['CI']
|