json-ld 3.2.4 → 3.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/json/ld/api.rb +807 -771
- data/lib/json/ld/compact.rb +304 -304
- data/lib/json/ld/conneg.rb +179 -161
- data/lib/json/ld/context.rb +2080 -1913
- data/lib/json/ld/expand.rb +745 -666
- data/lib/json/ld/extensions.rb +14 -13
- data/lib/json/ld/flatten.rb +257 -247
- data/lib/json/ld/format.rb +202 -194
- data/lib/json/ld/frame.rb +525 -502
- data/lib/json/ld/from_rdf.rb +223 -204
- data/lib/json/ld/html/nokogiri.rb +123 -121
- data/lib/json/ld/html/rexml.rb +151 -147
- data/lib/json/ld/reader.rb +107 -100
- data/lib/json/ld/resource.rb +224 -205
- data/lib/json/ld/streaming_reader.rb +574 -507
- data/lib/json/ld/streaming_writer.rb +93 -92
- data/lib/json/ld/to_rdf.rb +171 -169
- data/lib/json/ld/utils.rb +270 -264
- data/lib/json/ld/version.rb +24 -14
- data/lib/json/ld/writer.rb +334 -311
- data/lib/json/ld.rb +103 -96
- metadata +55 -198
- data/spec/api_spec.rb +0 -132
- data/spec/compact_spec.rb +0 -3482
- data/spec/conneg_spec.rb +0 -373
- data/spec/context_spec.rb +0 -2056
- data/spec/expand_spec.rb +0 -4496
- data/spec/flatten_spec.rb +0 -1203
- data/spec/format_spec.rb +0 -115
- data/spec/frame_spec.rb +0 -2541
- data/spec/from_rdf_spec.rb +0 -1072
- data/spec/matchers.rb +0 -20
- data/spec/rdfstar_spec.rb +0 -25
- data/spec/reader_spec.rb +0 -883
- data/spec/resource_spec.rb +0 -76
- data/spec/spec_helper.rb +0 -281
- data/spec/streaming_reader_spec.rb +0 -237
- data/spec/streaming_writer_spec.rb +0 -145
- data/spec/suite_compact_spec.rb +0 -22
- data/spec/suite_expand_spec.rb +0 -36
- data/spec/suite_flatten_spec.rb +0 -34
- data/spec/suite_frame_spec.rb +0 -29
- data/spec/suite_from_rdf_spec.rb +0 -22
- data/spec/suite_helper.rb +0 -411
- data/spec/suite_html_spec.rb +0 -22
- data/spec/suite_http_spec.rb +0 -35
- data/spec/suite_remote_doc_spec.rb +0 -22
- data/spec/suite_to_rdf_spec.rb +0 -30
- data/spec/support/extensions.rb +0 -44
- data/spec/test-files/test-1-compacted.jsonld +0 -10
- data/spec/test-files/test-1-context.jsonld +0 -7
- data/spec/test-files/test-1-expanded.jsonld +0 -5
- data/spec/test-files/test-1-input.jsonld +0 -10
- data/spec/test-files/test-1-rdf.ttl +0 -8
- data/spec/test-files/test-2-compacted.jsonld +0 -20
- data/spec/test-files/test-2-context.jsonld +0 -7
- data/spec/test-files/test-2-expanded.jsonld +0 -16
- data/spec/test-files/test-2-input.jsonld +0 -20
- data/spec/test-files/test-2-rdf.ttl +0 -14
- data/spec/test-files/test-3-compacted.jsonld +0 -11
- data/spec/test-files/test-3-context.jsonld +0 -8
- data/spec/test-files/test-3-expanded.jsonld +0 -10
- data/spec/test-files/test-3-input.jsonld +0 -11
- data/spec/test-files/test-3-rdf.ttl +0 -8
- data/spec/test-files/test-4-compacted.jsonld +0 -10
- data/spec/test-files/test-4-context.jsonld +0 -7
- data/spec/test-files/test-4-expanded.jsonld +0 -6
- data/spec/test-files/test-4-input.jsonld +0 -10
- data/spec/test-files/test-4-rdf.ttl +0 -5
- data/spec/test-files/test-5-compacted.jsonld +0 -13
- data/spec/test-files/test-5-context.jsonld +0 -7
- data/spec/test-files/test-5-expanded.jsonld +0 -9
- data/spec/test-files/test-5-input.jsonld +0 -13
- data/spec/test-files/test-5-rdf.ttl +0 -7
- data/spec/test-files/test-6-compacted.jsonld +0 -10
- data/spec/test-files/test-6-context.jsonld +0 -7
- data/spec/test-files/test-6-expanded.jsonld +0 -10
- data/spec/test-files/test-6-input.jsonld +0 -10
- data/spec/test-files/test-6-rdf.ttl +0 -6
- data/spec/test-files/test-7-compacted.jsonld +0 -23
- data/spec/test-files/test-7-context.jsonld +0 -4
- data/spec/test-files/test-7-expanded.jsonld +0 -20
- data/spec/test-files/test-7-input.jsonld +0 -23
- data/spec/test-files/test-7-rdf.ttl +0 -14
- data/spec/test-files/test-8-compacted.jsonld +0 -34
- data/spec/test-files/test-8-context.jsonld +0 -11
- data/spec/test-files/test-8-expanded.jsonld +0 -24
- data/spec/test-files/test-8-frame.jsonld +0 -18
- data/spec/test-files/test-8-framed.jsonld +0 -25
- data/spec/test-files/test-8-input.jsonld +0 -30
- data/spec/test-files/test-8-rdf.ttl +0 -15
- data/spec/test-files/test-9-compacted.jsonld +0 -20
- data/spec/test-files/test-9-context.jsonld +0 -13
- data/spec/test-files/test-9-expanded.jsonld +0 -14
- data/spec/test-files/test-9-input.jsonld +0 -12
- data/spec/to_rdf_spec.rb +0 -1684
- data/spec/writer_spec.rb +0 -427
data/spec/format_spec.rb
DELETED
@@ -1,115 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
require_relative 'spec_helper'
|
3
|
-
require 'rdf/spec/format'
|
4
|
-
|
5
|
-
describe JSON::LD::Format do
|
6
|
-
it_behaves_like 'an RDF::Format' do
|
7
|
-
let(:format_class) {JSON::LD::Format}
|
8
|
-
end
|
9
|
-
|
10
|
-
describe ".for" do
|
11
|
-
formats = [
|
12
|
-
:jsonld,
|
13
|
-
"etc/doap.jsonld",
|
14
|
-
{file_name: 'etc/doap.jsonld'},
|
15
|
-
{file_extension: 'jsonld'},
|
16
|
-
{content_type: 'application/ld+json'},
|
17
|
-
{content_type: 'application/x-ld+json'},
|
18
|
-
].each do |arg|
|
19
|
-
it "discovers with #{arg.inspect}" do
|
20
|
-
expect(RDF::Format.for(arg)).to eq described_class
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
{
|
25
|
-
jsonld: '{"@context" => "foo"}',
|
26
|
-
context: %({\n"@context": {),
|
27
|
-
id: %({\n"@id": {),
|
28
|
-
type: %({\n"@type": {),
|
29
|
-
}.each do |sym, str|
|
30
|
-
it "detects #{sym}" do
|
31
|
-
expect(described_class.for {str}).to eq described_class
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should discover 'jsonld'" do
|
36
|
-
expect(RDF::Format.for(:jsonld).reader).to eq JSON::LD::Reader
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe "#to_sym" do
|
41
|
-
specify {expect(described_class.to_sym).to eq :jsonld}
|
42
|
-
end
|
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
|
-
|
48
|
-
describe ".detect" do
|
49
|
-
{
|
50
|
-
jsonld: '{"@context" => "foo"}',
|
51
|
-
}.each do |sym, str|
|
52
|
-
it "detects #{sym}" do
|
53
|
-
expect(described_class.detect(str)).to be_truthy
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
{
|
58
|
-
n3: "@prefix foo: <bar> .\nfoo:bar = {<a> <b> <c>} .",
|
59
|
-
nquads: "<a> <b> <c> <d> . ",
|
60
|
-
rdfxml: '<rdf:RDF about="foo"></rdf:RDF>',
|
61
|
-
rdfa: '<div about="foo"></div>',
|
62
|
-
microdata: '<div itemref="bar"></div>',
|
63
|
-
ntriples: "<a> <b> <c> .",
|
64
|
-
multi_line: '<a>\n <b>\n "literal"\n .',
|
65
|
-
turtle: "@prefix foo: <bar> .\n foo:a foo:b <c> .",
|
66
|
-
}.each do |sym, str|
|
67
|
-
it "does not detect #{sym}" do
|
68
|
-
expect(described_class.detect(str)).to be_falsey
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
describe ".cli_commands", skip: Gem.win_platform? do
|
74
|
-
require 'rdf/cli'
|
75
|
-
let(:ttl) {File.expand_path("../test-files/test-1-rdf.ttl", __FILE__)}
|
76
|
-
let(:json) {File.expand_path("../test-files/test-1-input.jsonld", __FILE__)}
|
77
|
-
let(:context) {File.expand_path("../test-files/test-1-context.jsonld", __FILE__)}
|
78
|
-
|
79
|
-
describe "#expand" do
|
80
|
-
it "expands RDF" do
|
81
|
-
expect {RDF::CLI.exec(["expand", ttl], format: :ttl, output_format: :jsonld)}.to write.to(:output)
|
82
|
-
end
|
83
|
-
it "expands JSON" do
|
84
|
-
expect {RDF::CLI.exec(["expand", json], format: :jsonld, output_format: :jsonld, validate: false)}.to write.to(:output)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
describe "#compact" do
|
89
|
-
it "compacts RDF" do
|
90
|
-
expect {RDF::CLI.exec(["compact", ttl], context: context, format: :ttl, output_format: :jsonld, validate: false)}.to write.to(:output)
|
91
|
-
end
|
92
|
-
it "compacts JSON" do
|
93
|
-
expect {RDF::CLI.exec(["compact", json], context: context, format: :jsonld, output_format: :jsonld, validate: false)}.to write.to(:output)
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
describe "#flatten" do
|
98
|
-
it "flattens RDF" do
|
99
|
-
expect {RDF::CLI.exec(["flatten", ttl], context: context, format: :ttl, output_format: :jsonld, validate: false)}.to write.to(:output)
|
100
|
-
end
|
101
|
-
it "flattens JSON" do
|
102
|
-
expect {RDF::CLI.exec(["flatten", json], context: context, format: :jsonld, output_format: :jsonld, validate: false)}.to write.to(:output)
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
describe "#frame" do
|
107
|
-
it "frames RDF" do
|
108
|
-
expect {RDF::CLI.exec(["frame", ttl], frame: context, format: :ttl, output_format: :jsonld)}.to write.to(:output)
|
109
|
-
end
|
110
|
-
it "frames JSON" do
|
111
|
-
expect {RDF::CLI.exec(["frame", json], frame: context, format: :jsonld, output_format: :jsonld, validate: false)}.to write.to(:output)
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|