Skip to content

Commit d9d652d

Browse files
committed
Minor tweaks to graph framing.
1 parent 9754b84 commit d9d652d

File tree

4 files changed

+64
-45
lines changed

4 files changed

+64
-45
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"@context": {
3+
"@vocab": "http://example.org/",
4+
"within": {"@reverse": "contains"}
5+
},
6+
"@type": "Chapter",
7+
"within": {
8+
"@type": "Book",
9+
"within": {
10+
"@type": "Library"
11+
}
12+
}
13+
}

example-files/library.jsonld

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"@context": {
3+
"@vocab": "http://example.org/",
4+
"contains": {"@type": "@id"}
5+
},
6+
"@graph": [{
7+
"@id": "http://example.org/library",
8+
"@type": "Library",
9+
"contains": "http://example.org/library/the-republic"
10+
}, {
11+
"@id": "http://example.org/library/the-republic",
12+
"@type": "Book",
13+
"creator": "Plato",
14+
"title": "The Republic",
15+
"contains": "http://example.org/library/the-republic#introduction"
16+
}, {
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+
}
23+

lib/json/ld/api.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ def self.frame(input, frame, options = {})
402402
}.merge!(options)
403403

404404
framing_state = {
405-
graphMap: {'@default' => {}},
405+
graphMap: {},
406406
graphStack: [],
407407
subjectStack: [],
408408
link: {},

spec/frame_spec.rb

Lines changed: 27 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,7 @@
11061106
}]
11071107
})
11081108
},
1109-
"Preserve graphs if outer @graph is used" => {
1109+
"Frame default graph if outer @graph is used" => {
11101110
frame: %({
11111111
"@context": {"@vocab": "urn:"},
11121112
"@type": "Class",
@@ -1239,71 +1239,54 @@
12391239
},
12401240
"library" => {
12411241
frame: %({
1242-
"@context": {
1243-
"dc": "http://purl.org/dc/elements/1.1/",
1244-
"ex": "http://example.org/vocab#",
1245-
"xsd": "http://www.w3.org/2001/XMLSchema#",
1246-
"ex:contains": { "@type": "@id" }
1247-
},
1248-
"@type": "ex:Library",
1249-
"ex:contains": {
1242+
"@context": {"@vocab": "http://example.org/"},
1243+
"@type": "Library",
1244+
"contains": {
12501245
"@id": "http://example.org/graphs/books",
1251-
"@graph": {
1252-
"@type": "ex:Book"
1253-
}
1246+
"@graph": {"@type": "Book"}
12541247
}
12551248
}),
12561249
input: %({
1257-
"@context": {
1258-
"dc": "http://purl.org/dc/elements/1.1/",
1259-
"ex": "http://example.org/vocab#",
1260-
"xsd": "http://www.w3.org/2001/XMLSchema#",
1261-
"ex:contains": { "@type": "@id" }
1262-
},
1250+
"@context": {"@vocab": "http://example.org/"},
12631251
"@id": "http://example.org/library",
1264-
"@type": "ex:Library",
1265-
"dc:name": "Library",
1266-
"ex:contains": {
1252+
"@type": "Library",
1253+
"name": "Library",
1254+
"contains": {
12671255
"@id": "http://example.org/graphs/books",
12681256
"@graph": {
12691257
"@id": "http://example.org/library/the-republic",
1270-
"@type": "ex:Book",
1271-
"dc:creator": "Plato",
1272-
"dc:title": "The Republic",
1273-
"ex:contains": {
1258+
"@type": "Book",
1259+
"creator": "Plato",
1260+
"title": "The Republic",
1261+
"contains": {
12741262
"@id": "http://example.org/library/the-republic#introduction",
1275-
"@type": "ex:Chapter",
1276-
"dc:description": "An introductory chapter on The Republic.",
1277-
"dc:title": "The Introduction"
1263+
"@type": "Chapter",
1264+
"description": "An introductory chapter on The Republic.",
1265+
"title": "The Introduction"
12781266
}
12791267
}
12801268
}
12811269
}),
12821270
output: %({
1283-
"@context": {
1284-
"dc": "http://purl.org/dc/elements/1.1/",
1285-
"ex": "http://example.org/vocab#",
1286-
"xsd": "http://www.w3.org/2001/XMLSchema#",
1287-
"ex:contains": { "@type": "@id" }
1288-
},
1271+
"@context": {"@vocab": "http://example.org/"},
12891272
"@graph": [
12901273
{
12911274
"@id": "http://example.org/library",
1292-
"@type": "ex:Library",
1293-
"dc:name": "Library",
1294-
"ex:contains": {
1275+
"@type": "Library",
1276+
"name": "Library",
1277+
"contains": {
12951278
"@id": "http://example.org/graphs/books",
12961279
"@graph": [
12971280
{
12981281
"@id": "http://example.org/library/the-republic",
1299-
"@type": "ex:Book",
1300-
"dc:creator": "Plato",
1301-
"dc:title": "The Republic",
1302-
"ex:contains": {
1282+
"@type": "Book",
1283+
"creator": "Plato",
1284+
"title": "The Republic",
1285+
"contains": {
13031286
"@id": "http://example.org/library/the-republic#introduction",
1304-
"@type": "ex:Chapter",
1305-
"dc:description": "An introductory chapter on The Republic.",
1306-
"dc:title": "The Introduction"
1287+
"@type": "Chapter",
1288+
"description": "An introductory chapter on The Republic.",
1289+
"title": "The Introduction"
13071290
}
13081291
}
13091292
]

0 commit comments

Comments
 (0)