yaml-ld 0.0.1
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 +7 -0
- data/AUTHORS +1 -0
- data/README.md +150 -0
- data/UNLICENSE +24 -0
- data/VERSION +1 -0
- data/lib/yaml_ld/api.rb +295 -0
- data/lib/yaml_ld/format.rb +56 -0
- data/lib/yaml_ld/reader.rb +40 -0
- data/lib/yaml_ld/version.rb +20 -0
- data/lib/yaml_ld/writer.rb +42 -0
- data/lib/yaml_ld.rb +37 -0
- data/spec/api_spec.rb +92 -0
- data/spec/compact_spec.rb +358 -0
- data/spec/expand_spec.rb +565 -0
- data/spec/flatten_spec.rb +225 -0
- data/spec/format_spec.rb +54 -0
- data/spec/frame_spec.rb +662 -0
- data/spec/from_rdf_spec.rb +730 -0
- data/spec/matchers.rb +22 -0
- data/spec/reader_spec.rb +138 -0
- data/spec/spec_helper.rb +265 -0
- data/spec/support/extensions.rb +44 -0
- data/spec/test-files/test-1-compacted.jsonld +10 -0
- data/spec/test-files/test-1-context.jsonld +7 -0
- data/spec/test-files/test-1-expanded.jsonld +5 -0
- data/spec/test-files/test-1-input.yamlld +8 -0
- data/spec/test-files/test-1-rdf.ttl +8 -0
- data/spec/test-files/test-2-compacted.jsonld +20 -0
- data/spec/test-files/test-2-context.jsonld +7 -0
- data/spec/test-files/test-2-expanded.jsonld +16 -0
- data/spec/test-files/test-2-input.yamlld +16 -0
- data/spec/test-files/test-2-rdf.ttl +14 -0
- data/spec/test-files/test-3-compacted.jsonld +11 -0
- data/spec/test-files/test-3-context.jsonld +8 -0
- data/spec/test-files/test-3-expanded.jsonld +10 -0
- data/spec/test-files/test-3-input.yamlld +13 -0
- data/spec/test-files/test-3-rdf.ttl +8 -0
- data/spec/test-files/test-4-compacted.jsonld +10 -0
- data/spec/test-files/test-4-context.jsonld +7 -0
- data/spec/test-files/test-4-expanded.jsonld +6 -0
- data/spec/test-files/test-4-input.yamlld +9 -0
- data/spec/test-files/test-4-rdf.ttl +5 -0
- data/spec/test-files/test-5-compacted.jsonld +13 -0
- data/spec/test-files/test-5-context.jsonld +7 -0
- data/spec/test-files/test-5-expanded.jsonld +9 -0
- data/spec/test-files/test-5-input.yamlld +10 -0
- data/spec/test-files/test-5-rdf.ttl +7 -0
- data/spec/test-files/test-6-compacted.jsonld +10 -0
- data/spec/test-files/test-6-context.jsonld +7 -0
- data/spec/test-files/test-6-expanded.jsonld +10 -0
- data/spec/test-files/test-6-input.yamlld +12 -0
- data/spec/test-files/test-6-rdf.ttl +6 -0
- data/spec/test-files/test-7-compacted.jsonld +23 -0
- data/spec/test-files/test-7-context.jsonld +4 -0
- data/spec/test-files/test-7-expanded.jsonld +20 -0
- data/spec/test-files/test-7-input.yamlld +16 -0
- data/spec/test-files/test-7-rdf.ttl +14 -0
- data/spec/test-files/test-8-compacted.jsonld +34 -0
- data/spec/test-files/test-8-context.jsonld +11 -0
- data/spec/test-files/test-8-expanded.jsonld +24 -0
- data/spec/test-files/test-8-frame.jsonld +18 -0
- data/spec/test-files/test-8-framed.jsonld +25 -0
- data/spec/test-files/test-8-input.yamlld +24 -0
- data/spec/test-files/test-8-rdf.ttl +15 -0
- data/spec/test-files/test-9-compacted.jsonld +20 -0
- data/spec/test-files/test-9-context.jsonld +13 -0
- data/spec/test-files/test-9-expanded.jsonld +14 -0
- data/spec/test-files/test-9-input.yamlld +16 -0
- data/spec/to_rdf_spec.rb +556 -0
- data/spec/writer_spec.rb +441 -0
- metadata +350 -0
@@ -0,0 +1,9 @@
|
|
1
|
+
[{
|
2
|
+
"@id": "http://manu.sporny.org/#me",
|
3
|
+
"@type": ["http://xmlns.com/foaf/0.1/Person"],
|
4
|
+
"http://xmlns.com/foaf/0.1/name": [{"@value": "Manu Sporny"}],
|
5
|
+
"http://xmlns.com/foaf/0.1/knows": [{
|
6
|
+
"@type": ["http://xmlns.com/foaf/0.1/Person"],
|
7
|
+
"http://xmlns.com/foaf/0.1/name": [{"@value": "Gregg Kellogg"}]
|
8
|
+
}]
|
9
|
+
}]
|
@@ -0,0 +1,10 @@
|
|
1
|
+
[{
|
2
|
+
"@id": "http://example.org/people#joebob",
|
3
|
+
"@type": ["http://xmlns.com/foaf/0.1/Person"],
|
4
|
+
"http://xmlns.com/foaf/0.1/name": [{"@value": "Joe Bob"}],
|
5
|
+
"http://xmlns.com/foaf/0.1/nick": [{ "@list": [
|
6
|
+
{"@value": "joe"},
|
7
|
+
{"@value": "bob"},
|
8
|
+
{"@value": "jaybe"}
|
9
|
+
]}]
|
10
|
+
}]
|
@@ -0,0 +1,23 @@
|
|
1
|
+
{
|
2
|
+
"@context": { "foaf": "http://xmlns.com/foaf/0.1/" },
|
3
|
+
"@graph": [
|
4
|
+
{
|
5
|
+
"@id": "_:bnode1",
|
6
|
+
"@type": "foaf:Person",
|
7
|
+
"foaf:homepage": "http://example.com/bob/",
|
8
|
+
"foaf:name": "Bob"
|
9
|
+
},
|
10
|
+
{
|
11
|
+
"@id": "_:bnode2",
|
12
|
+
"@type": "foaf:Person",
|
13
|
+
"foaf:homepage": "http://example.com/eve/",
|
14
|
+
"foaf:name": "Eve"
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"@id": "_:bnode3",
|
18
|
+
"@type": "foaf:Person",
|
19
|
+
"foaf:homepage": "http://example.com/manu/",
|
20
|
+
"foaf:name": "Manu"
|
21
|
+
}
|
22
|
+
]
|
23
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"@id": "_:bnode1",
|
4
|
+
"@type": ["http://xmlns.com/foaf/0.1/Person"],
|
5
|
+
"http://xmlns.com/foaf/0.1/homepage": [{"@value": "http://example.com/bob/"}],
|
6
|
+
"http://xmlns.com/foaf/0.1/name": [{"@value": "Bob"}]
|
7
|
+
},
|
8
|
+
{
|
9
|
+
"@id": "_:bnode2",
|
10
|
+
"@type": ["http://xmlns.com/foaf/0.1/Person"],
|
11
|
+
"http://xmlns.com/foaf/0.1/homepage": [{"@value": "http://example.com/eve/"}],
|
12
|
+
"http://xmlns.com/foaf/0.1/name": [{"@value": "Eve"}]
|
13
|
+
},
|
14
|
+
{
|
15
|
+
"@id": "_:bnode3",
|
16
|
+
"@type": ["http://xmlns.com/foaf/0.1/Person"],
|
17
|
+
"http://xmlns.com/foaf/0.1/homepage": [{"@value": "http://example.com/manu/"}],
|
18
|
+
"http://xmlns.com/foaf/0.1/name": [{"@value": "Manu"}]
|
19
|
+
}
|
20
|
+
]
|
@@ -0,0 +1,16 @@
|
|
1
|
+
---
|
2
|
+
"@context":
|
3
|
+
foaf: http://xmlns.com/foaf/0.1/
|
4
|
+
"@graph":
|
5
|
+
- "@id": _:bnode1
|
6
|
+
"@type": foaf:Person
|
7
|
+
foaf:homepage: http://example.com/bob/
|
8
|
+
foaf:name: Bob
|
9
|
+
- "@id": _:bnode2
|
10
|
+
"@type": foaf:Person
|
11
|
+
foaf:homepage: http://example.com/eve/
|
12
|
+
foaf:name: Eve
|
13
|
+
- "@id": _:bnode3
|
14
|
+
"@type": foaf:Person
|
15
|
+
foaf:homepage: http://example.com/manu/
|
16
|
+
foaf:name: Manu
|
@@ -0,0 +1,14 @@
|
|
1
|
+
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
|
2
|
+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
|
3
|
+
|
4
|
+
[ a foaf:Person;
|
5
|
+
foaf:homepage "http://example.com/manu/";
|
6
|
+
foaf:name "Manu"] .
|
7
|
+
|
8
|
+
[ a foaf:Person;
|
9
|
+
foaf:homepage "http://example.com/eve/";
|
10
|
+
foaf:name "Eve"] .
|
11
|
+
|
12
|
+
[ a foaf:Person;
|
13
|
+
foaf:homepage "http://example.com/bob/";
|
14
|
+
foaf:name "Bob"] .
|
@@ -0,0 +1,34 @@
|
|
1
|
+
{
|
2
|
+
"@context": {
|
3
|
+
"Book": "http://example.org/vocab#Book",
|
4
|
+
"Chapter": "http://example.org/vocab#Chapter",
|
5
|
+
"contains": {
|
6
|
+
"@id": "http://example.org/vocab#contains",
|
7
|
+
"@type": "@id"
|
8
|
+
},
|
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
|
+
},
|
14
|
+
"@graph": [
|
15
|
+
{
|
16
|
+
"@id": "http://example.com/library",
|
17
|
+
"@type": "Library",
|
18
|
+
"contains": "http://example.org/library/the-republic"
|
19
|
+
},
|
20
|
+
{
|
21
|
+
"@id": "http://example.org/library/the-republic",
|
22
|
+
"@type": "Book",
|
23
|
+
"creator": "Plato",
|
24
|
+
"title": "The Republic",
|
25
|
+
"contains": "http://example.org/library/the-republic#introduction"
|
26
|
+
},
|
27
|
+
{
|
28
|
+
"@id": "http://example.org/library/the-republic#introduction",
|
29
|
+
"@type": "Chapter",
|
30
|
+
"description": "An introductory chapter on The Republic.",
|
31
|
+
"title": "The Introduction"
|
32
|
+
}
|
33
|
+
]
|
34
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
{
|
2
|
+
"@context": {
|
3
|
+
"Book": "http://example.org/vocab#Book",
|
4
|
+
"Chapter": "http://example.org/vocab#Chapter",
|
5
|
+
"contains": {"@id": "http://example.org/vocab#contains", "@type": "@id"},
|
6
|
+
"creator": "http://purl.org/dc/terms/creator",
|
7
|
+
"description": "http://purl.org/dc/terms/description",
|
8
|
+
"Library": "http://example.org/vocab#Library",
|
9
|
+
"title": "http://purl.org/dc/terms/title"
|
10
|
+
}
|
11
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"@id": "http://example.com/library",
|
4
|
+
"@type": ["http://example.org/vocab#Library"],
|
5
|
+
"http://example.org/vocab#contains": [{
|
6
|
+
"@id": "http://example.org/library/the-republic"
|
7
|
+
}]
|
8
|
+
},
|
9
|
+
{
|
10
|
+
"@id": "http://example.org/library/the-republic",
|
11
|
+
"@type": ["http://example.org/vocab#Book"],
|
12
|
+
"http://purl.org/dc/terms/creator": [{"@value": "Plato"}],
|
13
|
+
"http://purl.org/dc/terms/title": [{"@value": "The Republic"}],
|
14
|
+
"http://example.org/vocab#contains": [{
|
15
|
+
"@id": "http://example.org/library/the-republic#introduction"
|
16
|
+
}]
|
17
|
+
},
|
18
|
+
{
|
19
|
+
"@id": "http://example.org/library/the-republic#introduction",
|
20
|
+
"@type": ["http://example.org/vocab#Chapter"],
|
21
|
+
"http://purl.org/dc/terms/description": [{"@value": "An introductory chapter on The Republic."}],
|
22
|
+
"http://purl.org/dc/terms/title": [{"@value": "The Introduction"}]
|
23
|
+
}
|
24
|
+
]
|
@@ -0,0 +1,18 @@
|
|
1
|
+
{
|
2
|
+
"@context": {
|
3
|
+
"Book": "http://example.org/vocab#Book",
|
4
|
+
"Chapter": "http://example.org/vocab#Chapter",
|
5
|
+
"contains": "http://example.org/vocab#contains",
|
6
|
+
"creator": "http://purl.org/dc/terms/creator",
|
7
|
+
"description": "http://purl.org/dc/terms/description",
|
8
|
+
"Library": "http://example.org/vocab#Library",
|
9
|
+
"title": "http://purl.org/dc/terms/title"
|
10
|
+
},
|
11
|
+
"@type": "Library",
|
12
|
+
"contains": {
|
13
|
+
"@type": "Book",
|
14
|
+
"contains": {
|
15
|
+
"@type": "Chapter"
|
16
|
+
}
|
17
|
+
}
|
18
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
{
|
2
|
+
"@context": {
|
3
|
+
"Book": "http://example.org/vocab#Book",
|
4
|
+
"Chapter": "http://example.org/vocab#Chapter",
|
5
|
+
"contains": "http://example.org/vocab#contains",
|
6
|
+
"creator": "http://purl.org/dc/terms/creator",
|
7
|
+
"description": "http://purl.org/dc/terms/description",
|
8
|
+
"Library": "http://example.org/vocab#Library",
|
9
|
+
"title": "http://purl.org/dc/terms/title"
|
10
|
+
},
|
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
|
+
},
|
22
|
+
"creator": "Plato",
|
23
|
+
"title": "The Republic"
|
24
|
+
}
|
25
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
---
|
2
|
+
"@context":
|
3
|
+
Book: http://example.org/vocab#Book
|
4
|
+
Chapter: http://example.org/vocab#Chapter
|
5
|
+
contains:
|
6
|
+
"@id": http://example.org/vocab#contains
|
7
|
+
"@type": "@id"
|
8
|
+
creator: http://purl.org/dc/terms/creator
|
9
|
+
description: http://purl.org/dc/terms/description
|
10
|
+
Library: http://example.org/vocab#Library
|
11
|
+
title: http://purl.org/dc/terms/title
|
12
|
+
"@graph":
|
13
|
+
- "@id": http://example.com/library
|
14
|
+
"@type": Library
|
15
|
+
contains: http://example.org/library/the-republic
|
16
|
+
- "@id": http://example.org/library/the-republic
|
17
|
+
"@type": Book
|
18
|
+
creator: Plato
|
19
|
+
title: The Republic
|
20
|
+
contains: http://example.org/library/the-republic#introduction
|
21
|
+
- "@id": http://example.org/library/the-republic#introduction
|
22
|
+
"@type": Chapter
|
23
|
+
description: An introductory chapter on The Republic.
|
24
|
+
title: The Introduction
|
@@ -0,0 +1,15 @@
|
|
1
|
+
@prefix dc: <http://purl.org/dc/terms/> .
|
2
|
+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
3
|
+
|
4
|
+
<http://example.com/library> a <http://example.org/vocab#Library>;
|
5
|
+
<http://example.org/vocab#contains> <http://example.org/library/the-republic> .
|
6
|
+
|
7
|
+
<http://example.org/library/the-republic> a <http://example.org/vocab#Book>;
|
8
|
+
dc:title "The Republic";
|
9
|
+
<http://example.org/vocab#contains> <http://example.org/library/the-republic#introduction>;
|
10
|
+
dc:creator "Plato" .
|
11
|
+
|
12
|
+
<http://example.org/library/the-republic#introduction> a <http://example.org/vocab#Chapter>;
|
13
|
+
dc:title "The Introduction";
|
14
|
+
dc:description "An introductory chapter on The Republic." .
|
15
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
{
|
2
|
+
"@context": {
|
3
|
+
"id1": "http://example.com/id1",
|
4
|
+
"t1": "http://example.com/t1",
|
5
|
+
"t2": "http://example.com/t2",
|
6
|
+
"term1": "http://example.com/term",
|
7
|
+
"term2": {"@id": "http://example.com/term", "@type": "t2"},
|
8
|
+
"term3": {"@id": "http://example.com/term", "@language": "en"},
|
9
|
+
"term4": {"@id": "http://example.com/term", "@container": "@list"},
|
10
|
+
"term5": {"@id": "http://example.com/term", "@language": null},
|
11
|
+
"@language": "de"
|
12
|
+
},
|
13
|
+
"@id": "http://example.com/id1",
|
14
|
+
"@type": "t1",
|
15
|
+
"term1": "v1",
|
16
|
+
"term2": "v2",
|
17
|
+
"term3": "v3",
|
18
|
+
"term4": [ 1, 2 ],
|
19
|
+
"term5": [ "v5", "plain literal" ]
|
20
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
{
|
2
|
+
"@context": {
|
3
|
+
"id1": "http://example.com/id1",
|
4
|
+
"t1": "http://example.com/t1",
|
5
|
+
"t2": "http://example.com/t2",
|
6
|
+
"term1": "http://example.com/term",
|
7
|
+
"term2": {"@id": "http://example.com/term", "@type": "t2"},
|
8
|
+
"term3": {"@id": "http://example.com/term", "@language": "en"},
|
9
|
+
"term4": {"@id": "http://example.com/term", "@container": "@list"},
|
10
|
+
"term5": {"@id": "http://example.com/term", "@language": null},
|
11
|
+
"@language": "de"
|
12
|
+
}
|
13
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"@id": "http://example.com/id1",
|
4
|
+
"@type": ["http://example.com/t1"],
|
5
|
+
"http://example.com/term": [
|
6
|
+
{"@value": "v1","@language": "de"},
|
7
|
+
{"@value": "v2","@type": "http://example.com/t2"},
|
8
|
+
{"@value": "v3","@language": "en"},
|
9
|
+
{"@list": [{"@value": 1},{"@value": 2}]},
|
10
|
+
{"@value": "v5"},
|
11
|
+
{"@value": "plain literal"}
|
12
|
+
]
|
13
|
+
}
|
14
|
+
]
|
@@ -0,0 +1,16 @@
|
|
1
|
+
---
|
2
|
+
- "@id": http://example.com/id1
|
3
|
+
"@type":
|
4
|
+
- http://example.com/t1
|
5
|
+
http://example.com/term:
|
6
|
+
- "@value": v1
|
7
|
+
"@language": de
|
8
|
+
- "@value": v2
|
9
|
+
"@type": http://example.com/t2
|
10
|
+
- "@value": v3
|
11
|
+
"@language": en
|
12
|
+
- "@list":
|
13
|
+
- 1
|
14
|
+
- 2
|
15
|
+
- "@value": v5
|
16
|
+
- "@value": plain literal
|