yaml-ld 0.0.1 → 0.0.2
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/psych/amazing_print.rb +61 -0
- data/lib/yaml_ld/api.rb +69 -11
- data/lib/yaml_ld/format.rb +25 -0
- data/lib/yaml_ld/reader.rb +3 -1
- data/lib/yaml_ld/representation.rb +256 -0
- data/lib/yaml_ld/version.rb +1 -1
- data/lib/yaml_ld.rb +1 -0
- data/spec/api_spec.rb +21 -27
- data/spec/compact_spec.rb +1 -1
- data/spec/expand_spec.rb +1 -1
- data/spec/format_spec.rb +56 -0
- data/spec/frame_spec.rb +55 -110
- data/spec/from_rdf_spec.rb +3 -3
- data/spec/matchers.rb +2 -2
- data/spec/reader_spec.rb +1 -1
- data/spec/representation_spec.rb +170 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/test-files/test-1-compacted.yamlld +9 -0
- data/spec/test-files/test-1-context.yamlld +6 -0
- data/spec/test-files/test-1-expanded.yamlld +8 -0
- data/spec/test-files/test-1-input.yamlld +1 -0
- data/spec/test-files/test-2-compacted.yamlld +17 -0
- data/spec/test-files/test-2-context.yamlld +5 -0
- data/spec/test-files/test-2-expanded.yamlld +21 -0
- data/spec/test-files/test-3-compacted.yamlld +14 -0
- data/spec/test-files/test-3-context.yamlld +11 -0
- data/spec/test-files/test-3-expanded.yamlld +9 -0
- data/spec/test-files/test-4-compacted.yamlld +10 -0
- data/spec/test-files/test-4-context.yamlld +5 -0
- data/spec/test-files/test-4-expanded.yamlld +9 -0
- data/spec/test-files/test-5-compacted.yamlld +11 -0
- data/spec/test-files/test-5-context.yamlld +5 -0
- data/spec/test-files/test-5-expanded.yamlld +12 -0
- data/spec/test-files/test-6-compacted.yamlld +13 -0
- data/spec/test-files/test-6-context.yamlld +5 -0
- data/spec/test-files/test-6-expanded.yamlld +12 -0
- data/spec/test-files/test-7-compacted.yamlld +17 -0
- data/spec/test-files/test-7-context.yamlld +4 -0
- data/spec/test-files/test-7-expanded.yamlld +23 -0
- data/spec/test-files/test-8-compacted.yamlld +25 -0
- data/spec/test-files/test-8-context.yamlld +12 -0
- data/spec/test-files/test-8-expanded.yamlld +23 -0
- data/spec/test-files/test-8-frame.yamlld +15 -0
- data/spec/test-files/test-8-framed.yamlld +22 -0
- data/spec/test-files/test-9-compacted.yamlld +31 -0
- data/spec/test-files/test-9-context.yamlld +20 -0
- data/spec/test-files/test-9-expanded.yamlld +17 -0
- data/spec/to_rdf_spec.rb +10 -8
- metadata +89 -61
- data/spec/test-files/test-1-expanded.jsonld +0 -5
- 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-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-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-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-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-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-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-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
@@ -0,0 +1,9 @@
|
|
1
|
+
%YAML 1.2
|
2
|
+
---
|
3
|
+
"@context":
|
4
|
+
avatar: http://xmlns.com/foaf/0.1/avatar
|
5
|
+
homepage: http://xmlns.com/foaf/0.1/homepage
|
6
|
+
name: http://xmlns.com/foaf/0.1/name
|
7
|
+
avatar: http://twitter.com/account/profile_image/manusporny
|
8
|
+
homepage: http://manu.sporny.org/
|
9
|
+
name: Manu Sporny
|
@@ -0,0 +1,17 @@
|
|
1
|
+
%YAML 1.2
|
2
|
+
---
|
3
|
+
"@context":
|
4
|
+
dc: http://purl.org/dc/elements/1.1/
|
5
|
+
ex: http://example.org/vocab#
|
6
|
+
"@id": http://example.org/library
|
7
|
+
"@type": ex:Library
|
8
|
+
ex:contains:
|
9
|
+
"@id": http://example.org/library/the-republic
|
10
|
+
"@type": ex:Book
|
11
|
+
dc:creator: Plato
|
12
|
+
dc:title: The Republic
|
13
|
+
ex:contains:
|
14
|
+
"@id": http://example.org/library/the-republic#introduction
|
15
|
+
"@type": ex:Chapter
|
16
|
+
dc:description: An introductory chapter on The Republic.
|
17
|
+
dc:title: The Introduction
|
@@ -0,0 +1,21 @@
|
|
1
|
+
%YAML 1.2
|
2
|
+
---
|
3
|
+
- "@id": http://example.org/library
|
4
|
+
"@type":
|
5
|
+
- http://example.org/vocab#Library
|
6
|
+
http://example.org/vocab#contains:
|
7
|
+
- "@id": http://example.org/library/the-republic
|
8
|
+
"@type":
|
9
|
+
- http://example.org/vocab#Book
|
10
|
+
http://purl.org/dc/elements/1.1/creator:
|
11
|
+
- "@value": Plato
|
12
|
+
http://purl.org/dc/elements/1.1/title:
|
13
|
+
- "@value": The Republic
|
14
|
+
http://example.org/vocab#contains:
|
15
|
+
- "@id": http://example.org/library/the-republic#introduction
|
16
|
+
"@type":
|
17
|
+
- http://example.org/vocab#Chapter
|
18
|
+
http://purl.org/dc/elements/1.1/description:
|
19
|
+
- "@value": An introductory chapter on The Republic.
|
20
|
+
http://purl.org/dc/elements/1.1/title:
|
21
|
+
- "@value": The Introduction
|
@@ -0,0 +1,14 @@
|
|
1
|
+
%YAML 1.2
|
2
|
+
---
|
3
|
+
"@context":
|
4
|
+
xsd: http://www.w3.org/2001/XMLSchema#
|
5
|
+
name: http://xmlns.com/foaf/0.1/name
|
6
|
+
age:
|
7
|
+
"@id": http://xmlns.com/foaf/0.1/age
|
8
|
+
"@type": xsd:integer
|
9
|
+
homepage:
|
10
|
+
"@id": http://xmlns.com/foaf/0.1/homepage
|
11
|
+
"@type": "@id"
|
12
|
+
name: Manu Sporny
|
13
|
+
age: '41'
|
14
|
+
homepage: http://manu.sporny.org/
|
@@ -0,0 +1,12 @@
|
|
1
|
+
%YAML 1.2
|
2
|
+
---
|
3
|
+
- "@id": http://manu.sporny.org/#me
|
4
|
+
"@type":
|
5
|
+
- http://xmlns.com/foaf/0.1/Person
|
6
|
+
http://xmlns.com/foaf/0.1/name:
|
7
|
+
- "@value": Manu Sporny
|
8
|
+
http://xmlns.com/foaf/0.1/knows:
|
9
|
+
- "@type":
|
10
|
+
- http://xmlns.com/foaf/0.1/Person
|
11
|
+
http://xmlns.com/foaf/0.1/name:
|
12
|
+
- "@value": Gregg Kellogg
|
@@ -0,0 +1,12 @@
|
|
1
|
+
%YAML 1.2
|
2
|
+
---
|
3
|
+
- "@id": http://example.org/people#joebob
|
4
|
+
"@type":
|
5
|
+
- http://xmlns.com/foaf/0.1/Person
|
6
|
+
http://xmlns.com/foaf/0.1/name:
|
7
|
+
- "@value": Joe Bob
|
8
|
+
http://xmlns.com/foaf/0.1/nick:
|
9
|
+
- "@list":
|
10
|
+
- "@value": joe
|
11
|
+
- "@value": bob
|
12
|
+
- "@value": jaybe
|
@@ -0,0 +1,17 @@
|
|
1
|
+
%YAML 1.2
|
2
|
+
---
|
3
|
+
"@context":
|
4
|
+
foaf: http://xmlns.com/foaf/0.1/
|
5
|
+
"@graph":
|
6
|
+
- "@id": _:bnode1
|
7
|
+
"@type": foaf:Person
|
8
|
+
foaf:homepage: http://example.com/bob/
|
9
|
+
foaf:name: Bob
|
10
|
+
- "@id": _:bnode2
|
11
|
+
"@type": foaf:Person
|
12
|
+
foaf:homepage: http://example.com/eve/
|
13
|
+
foaf:name: Eve
|
14
|
+
- "@id": _:bnode3
|
15
|
+
"@type": foaf:Person
|
16
|
+
foaf:homepage: http://example.com/manu/
|
17
|
+
foaf:name: Manu
|
@@ -0,0 +1,23 @@
|
|
1
|
+
%YAML 1.2
|
2
|
+
---
|
3
|
+
- "@id": _:bnode1
|
4
|
+
"@type":
|
5
|
+
- http://xmlns.com/foaf/0.1/Person
|
6
|
+
http://xmlns.com/foaf/0.1/homepage:
|
7
|
+
- "@value": http://example.com/bob/
|
8
|
+
http://xmlns.com/foaf/0.1/name:
|
9
|
+
- "@value": Bob
|
10
|
+
- "@id": _:bnode2
|
11
|
+
"@type":
|
12
|
+
- http://xmlns.com/foaf/0.1/Person
|
13
|
+
http://xmlns.com/foaf/0.1/homepage:
|
14
|
+
- "@value": http://example.com/eve/
|
15
|
+
http://xmlns.com/foaf/0.1/name:
|
16
|
+
- "@value": Eve
|
17
|
+
- "@id": _:bnode3
|
18
|
+
"@type":
|
19
|
+
- http://xmlns.com/foaf/0.1/Person
|
20
|
+
http://xmlns.com/foaf/0.1/homepage:
|
21
|
+
- "@value": http://example.com/manu/
|
22
|
+
http://xmlns.com/foaf/0.1/name:
|
23
|
+
- "@value": Manu
|
@@ -0,0 +1,25 @@
|
|
1
|
+
%YAML 1.2
|
2
|
+
---
|
3
|
+
"@context":
|
4
|
+
Book: http://example.org/vocab#Book
|
5
|
+
Chapter: http://example.org/vocab#Chapter
|
6
|
+
contains:
|
7
|
+
"@id": http://example.org/vocab#contains
|
8
|
+
"@type": "@id"
|
9
|
+
creator: http://purl.org/dc/terms/creator
|
10
|
+
description: http://purl.org/dc/terms/description
|
11
|
+
Library: http://example.org/vocab#Library
|
12
|
+
title: http://purl.org/dc/terms/title
|
13
|
+
"@graph":
|
14
|
+
- "@id": http://example.com/library
|
15
|
+
"@type": Library
|
16
|
+
contains: http://example.org/library/the-republic
|
17
|
+
- "@id": http://example.org/library/the-republic
|
18
|
+
"@type": Book
|
19
|
+
creator: Plato
|
20
|
+
title: The Republic
|
21
|
+
contains: http://example.org/library/the-republic#introduction
|
22
|
+
- "@id": http://example.org/library/the-republic#introduction
|
23
|
+
"@type": Chapter
|
24
|
+
description: An introductory chapter on The Republic.
|
25
|
+
title: The Introduction
|
@@ -0,0 +1,12 @@
|
|
1
|
+
%YAML 1.2
|
2
|
+
---
|
3
|
+
"@context":
|
4
|
+
Book: http://example.org/vocab#Book
|
5
|
+
Chapter: http://example.org/vocab#Chapter
|
6
|
+
contains:
|
7
|
+
"@id": http://example.org/vocab#contains
|
8
|
+
"@type": "@id"
|
9
|
+
creator: http://purl.org/dc/terms/creator
|
10
|
+
description: http://purl.org/dc/terms/description
|
11
|
+
Library: http://example.org/vocab#Library
|
12
|
+
title: http://purl.org/dc/terms/title
|
@@ -0,0 +1,23 @@
|
|
1
|
+
%YAML 1.2
|
2
|
+
---
|
3
|
+
- "@id": http://example.com/library
|
4
|
+
"@type":
|
5
|
+
- http://example.org/vocab#Library
|
6
|
+
http://example.org/vocab#contains:
|
7
|
+
- "@id": http://example.org/library/the-republic
|
8
|
+
- "@id": http://example.org/library/the-republic
|
9
|
+
"@type":
|
10
|
+
- http://example.org/vocab#Book
|
11
|
+
http://purl.org/dc/terms/creator:
|
12
|
+
- "@value": Plato
|
13
|
+
http://purl.org/dc/terms/title:
|
14
|
+
- "@value": The Republic
|
15
|
+
http://example.org/vocab#contains:
|
16
|
+
- "@id": http://example.org/library/the-republic#introduction
|
17
|
+
- "@id": http://example.org/library/the-republic#introduction
|
18
|
+
"@type":
|
19
|
+
- http://example.org/vocab#Chapter
|
20
|
+
http://purl.org/dc/terms/description:
|
21
|
+
- "@value": An introductory chapter on The Republic.
|
22
|
+
http://purl.org/dc/terms/title:
|
23
|
+
- "@value": The Introduction
|
@@ -0,0 +1,15 @@
|
|
1
|
+
%YAML 1.2
|
2
|
+
---
|
3
|
+
"@context":
|
4
|
+
Book: http://example.org/vocab#Book
|
5
|
+
Chapter: http://example.org/vocab#Chapter
|
6
|
+
contains: http://example.org/vocab#contains
|
7
|
+
creator: http://purl.org/dc/terms/creator
|
8
|
+
description: http://purl.org/dc/terms/description
|
9
|
+
Library: http://example.org/vocab#Library
|
10
|
+
title: http://purl.org/dc/terms/title
|
11
|
+
"@type": Library
|
12
|
+
contains:
|
13
|
+
"@type": Book
|
14
|
+
contains:
|
15
|
+
"@type": Chapter
|
@@ -0,0 +1,22 @@
|
|
1
|
+
%YAML 1.2
|
2
|
+
---
|
3
|
+
"@context":
|
4
|
+
Book: http://example.org/vocab#Book
|
5
|
+
Chapter: http://example.org/vocab#Chapter
|
6
|
+
contains: http://example.org/vocab#contains
|
7
|
+
creator: http://purl.org/dc/terms/creator
|
8
|
+
description: http://purl.org/dc/terms/description
|
9
|
+
Library: http://example.org/vocab#Library
|
10
|
+
title: http://purl.org/dc/terms/title
|
11
|
+
"@id": http://example.com/library
|
12
|
+
"@type": Library
|
13
|
+
contains:
|
14
|
+
"@id": http://example.org/library/the-republic
|
15
|
+
"@type": Book
|
16
|
+
contains:
|
17
|
+
"@id": http://example.org/library/the-republic#introduction
|
18
|
+
"@type": Chapter
|
19
|
+
description: An introductory chapter on The Republic.
|
20
|
+
title: The Introduction
|
21
|
+
creator: Plato
|
22
|
+
title: The Republic
|
@@ -0,0 +1,31 @@
|
|
1
|
+
%YAML 1.2
|
2
|
+
---
|
3
|
+
"@context":
|
4
|
+
id1: http://example.com/id1
|
5
|
+
t1: http://example.com/t1
|
6
|
+
t2: http://example.com/t2
|
7
|
+
term1: http://example.com/term
|
8
|
+
term2:
|
9
|
+
"@id": http://example.com/term
|
10
|
+
"@type": t2
|
11
|
+
term3:
|
12
|
+
"@id": http://example.com/term
|
13
|
+
"@language": en
|
14
|
+
term4:
|
15
|
+
"@id": http://example.com/term
|
16
|
+
"@container": "@list"
|
17
|
+
term5:
|
18
|
+
"@id": http://example.com/term
|
19
|
+
"@language":
|
20
|
+
"@language": de
|
21
|
+
"@id": http://example.com/id1
|
22
|
+
"@type": t1
|
23
|
+
term1: v1
|
24
|
+
term2: v2
|
25
|
+
term3: v3
|
26
|
+
term4:
|
27
|
+
- 1
|
28
|
+
- 2
|
29
|
+
term5:
|
30
|
+
- v5
|
31
|
+
- plain literal
|
@@ -0,0 +1,20 @@
|
|
1
|
+
%YAML 1.2
|
2
|
+
---
|
3
|
+
"@context":
|
4
|
+
id1: http://example.com/id1
|
5
|
+
t1: http://example.com/t1
|
6
|
+
t2: http://example.com/t2
|
7
|
+
term1: http://example.com/term
|
8
|
+
term2:
|
9
|
+
"@id": http://example.com/term
|
10
|
+
"@type": t2
|
11
|
+
term3:
|
12
|
+
"@id": http://example.com/term
|
13
|
+
"@language": en
|
14
|
+
term4:
|
15
|
+
"@id": http://example.com/term
|
16
|
+
"@container": "@list"
|
17
|
+
term5:
|
18
|
+
"@id": http://example.com/term
|
19
|
+
"@language":
|
20
|
+
"@language": de
|
@@ -0,0 +1,17 @@
|
|
1
|
+
%YAML 1.2
|
2
|
+
---
|
3
|
+
- "@id": http://example.com/id1
|
4
|
+
"@type":
|
5
|
+
- http://example.com/t1
|
6
|
+
http://example.com/term:
|
7
|
+
- "@value": v1
|
8
|
+
"@language": de
|
9
|
+
- "@value": v2
|
10
|
+
"@type": http://example.com/t2
|
11
|
+
- "@value": v3
|
12
|
+
"@language": en
|
13
|
+
- "@list":
|
14
|
+
- "@value": 1
|
15
|
+
- "@value": 2
|
16
|
+
- "@value": v5
|
17
|
+
- "@value": plain literal
|
data/spec/to_rdf_spec.rb
CHANGED
@@ -131,14 +131,14 @@ describe YAML_LD::API do
|
|
131
131
|
http://example.com/foo:
|
132
132
|
- bar
|
133
133
|
- baz
|
134
|
-
|
134
|
+
),
|
135
135
|
%q([ <http://example.com/foo> "bar"^^xsd:string, "baz"^^xsd:string ] .)
|
136
136
|
],
|
137
137
|
"IRI" => [
|
138
138
|
%q(
|
139
139
|
http://example.com/foo:
|
140
140
|
"@id": http://example.com/bar
|
141
|
-
|
141
|
+
),
|
142
142
|
%q([ <http://example.com/foo> <http://example.com/bar> ] .)
|
143
143
|
],
|
144
144
|
"IRIs" => [
|
@@ -146,13 +146,13 @@ describe YAML_LD::API do
|
|
146
146
|
http://example.com/foo:
|
147
147
|
- "@id": http://example.com/bar
|
148
148
|
- "@id": http://example.com/baz
|
149
|
-
|
149
|
+
),
|
150
150
|
%q([ <http://example.com/foo> <http://example.com/bar>, <http://example.com/baz> ] .)
|
151
151
|
],
|
152
|
-
}.each do |title, (
|
152
|
+
}.each do |title, (yaml, ttl)|
|
153
153
|
it title do
|
154
154
|
ttl = "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . #{ttl}"
|
155
|
-
expect(parse(
|
155
|
+
expect(parse(yaml)).to be_equivalent_graph(ttl, logger: logger, inputDocument: yaml)
|
156
156
|
end
|
157
157
|
end
|
158
158
|
end
|
@@ -212,10 +212,10 @@ describe YAML_LD::API do
|
|
212
212
|
<http://greggkellogg.net/foaf#me> <http://purl.org/dc/terms/created> "1957-02-27"^^<http://www.w3.org/2001/XMLSchema#date> .
|
213
213
|
)
|
214
214
|
],
|
215
|
-
}.each do |title, (
|
215
|
+
}.each do |title, (yaml, ttl)|
|
216
216
|
it title do
|
217
217
|
ttl = "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . #{ttl}"
|
218
|
-
expect(parse(
|
218
|
+
expect(parse(yaml)).to be_equivalent_graph(ttl, logger: logger, inputDocument: yaml)
|
219
219
|
end
|
220
220
|
end
|
221
221
|
|
@@ -540,7 +540,9 @@ describe YAML_LD::API do
|
|
540
540
|
def run_to_rdf(params)
|
541
541
|
input, output = params[:input], params[:output]
|
542
542
|
graph = params[:graph] || RDF::Graph.new
|
543
|
-
input = StringIO.new(input)
|
543
|
+
input = StringIO.new(input).tap do |d|
|
544
|
+
d.define_singleton_method(:content_type) {'application/ld+yaml'}
|
545
|
+
end if input.is_a?(String)
|
544
546
|
pending params.fetch(:pending, "test implementation") unless input
|
545
547
|
if params[:exception]
|
546
548
|
expect {YAML_LD::API.toRdf(input, **params)}.to raise_error(params[:exception])
|