|
637 | 637 | }] |
638 | 638 | }] |
639 | 639 | }) |
| 640 | + }, |
| 641 | + "library" => { |
| 642 | + frame: %({ |
| 643 | + "@context": { |
| 644 | + "dc": "http://purl.org/dc/elements/1.1/", |
| 645 | + "ex": "http://example.org/vocab#", |
| 646 | + "xsd": "http://www.w3.org/2001/XMLSchema#", |
| 647 | + "ex:contains": { "@type": "@id" } |
| 648 | + }, |
| 649 | + "@type": "ex:Library", |
| 650 | + "ex:contains": {} |
| 651 | + }), |
| 652 | + input: %({ |
| 653 | + "@context": { |
| 654 | + "dc": "http://purl.org/dc/elements/1.1/", |
| 655 | + "ex": "http://example.org/vocab#", |
| 656 | + "xsd": "http://www.w3.org/2001/XMLSchema#" |
| 657 | + }, |
| 658 | + "@id": "http://example.org/library", |
| 659 | + "@type": "ex:Library", |
| 660 | + "dc:name": "Library", |
| 661 | + "ex:contains": { |
| 662 | + "@id": "http://example.org/library/the-republic", |
| 663 | + "@type": "ex:Book", |
| 664 | + "dc:creator": "Plato", |
| 665 | + "dc:title": "The Republic", |
| 666 | + "ex:contains": { |
| 667 | + "@id": "http://example.org/library/the-republic#introduction", |
| 668 | + "@type": "ex:Chapter", |
| 669 | + "dc:description": "An introductory chapter on The Republic.", |
| 670 | + "dc:title": "The Introduction" |
| 671 | + } |
| 672 | + } |
| 673 | + }), |
| 674 | + output: %({ |
| 675 | + "@context": { |
| 676 | + "dc": "http://purl.org/dc/elements/1.1/", |
| 677 | + "ex": "http://example.org/vocab#", |
| 678 | + "xsd": "http://www.w3.org/2001/XMLSchema#", |
| 679 | + "ex:contains": { "@type": "@id" } |
| 680 | + }, |
| 681 | + "@graph": [ |
| 682 | + { |
| 683 | + "@id": "http://example.org/library", |
| 684 | + "@type": "ex:Library", |
| 685 | + "dc:name": "Library", |
| 686 | + "ex:contains": { |
| 687 | + "@id": "http://example.org/library/the-republic", |
| 688 | + "@type": "ex:Book", |
| 689 | + "dc:creator": "Plato", |
| 690 | + "dc:title": "The Republic", |
| 691 | + "ex:contains": { |
| 692 | + "@id": "http://example.org/library/the-republic#introduction", |
| 693 | + "@type": "ex:Chapter", |
| 694 | + "dc:description": "An introductory chapter on The Republic.", |
| 695 | + "dc:title": "The Introduction" |
| 696 | + } |
| 697 | + } |
| 698 | + } |
| 699 | + ] |
| 700 | + }) |
640 | 701 | } |
641 | 702 | }.each do |title, params| |
642 | 703 | it title do |
|
1018 | 1079 |
|
1019 | 1080 | describe "named graphs" do |
1020 | 1081 | { |
1021 | | - #"Frame default graph only" => { |
1022 | | - # frame: %({ |
1023 | | - # "@context": {"@vocab": "urn:"}, |
1024 | | - # "@graph": {} |
1025 | | - # }), |
1026 | | - # input: %({ |
1027 | | - # "@context": {"@vocab": "urn:"}, |
1028 | | - # "@id": "urn:id-1", |
1029 | | - # "@type": "Class", |
1030 | | - # "term": "foo", |
1031 | | - # "ref": { |
1032 | | - # "@id": "urn:id-2", |
1033 | | - # "@graph": { |
1034 | | - # "@id": "urn:id-2", |
1035 | | - # "term": "bar" |
1036 | | - # } |
1037 | | - # } |
1038 | | - # }), |
1039 | | - # output: %({ |
1040 | | - # "@context": {"@vocab": "urn:"}, |
1041 | | - # "@graph": [ |
1042 | | - # { |
1043 | | - # "@id": "urn:id-1", |
1044 | | - # "@type": "Class", |
1045 | | - # "ref": {"@id": "urn:id-2"}, |
1046 | | - # "term": "foo" |
1047 | | - # } |
1048 | | - # ] |
1049 | | - # }) |
1050 | | - #}, |
1051 | | - "Merge graphs" => { |
| 1082 | + "Merge graphs if no outer @graph is used" => { |
1052 | 1083 | frame: %({ |
1053 | 1084 | "@context": {"@vocab": "urn:"}, |
1054 | 1085 | "@type": "Class" |
|
1075 | 1106 | }] |
1076 | 1107 | }) |
1077 | 1108 | }, |
1078 | | - "Preserve graphs" => { |
| 1109 | + "Preserve graphs if outer @graph is used" => { |
1079 | 1110 | frame: %({ |
1080 | 1111 | "@context": {"@vocab": "urn:"}, |
1081 | 1112 | "@type": "Class", |
|
1085 | 1116 | "@context": {"@vocab": "urn:"}, |
1086 | 1117 | "@id": "urn:id-1", |
1087 | 1118 | "@type": "Class", |
1088 | | - "merge": { |
| 1119 | + "preserve": { |
| 1120 | + "@id": "urn:gr-1", |
1089 | 1121 | "@graph": { |
1090 | 1122 | "@id": "urn:id-2", |
1091 | 1123 | "term": "data" |
|
1097 | 1129 | "@graph": [{ |
1098 | 1130 | "@id": "urn:id-1", |
1099 | 1131 | "@type": "Class", |
1100 | | - "merge": { |
1101 | | - "@id": "_:b0", |
| 1132 | + "preserve": { |
| 1133 | + "@id": "urn:gr-1", |
1102 | 1134 | "@graph": [{ |
1103 | 1135 | "@id": "urn:id-2", |
1104 | 1136 | "term": "data" |
|
1205 | 1237 | }] |
1206 | 1238 | }) |
1207 | 1239 | }, |
| 1240 | + "library" => { |
| 1241 | + 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": { |
| 1250 | + "@id": "http://example.org/graphs/books", |
| 1251 | + "@graph": { |
| 1252 | + "@type": "ex:Book" |
| 1253 | + } |
| 1254 | + } |
| 1255 | + }), |
| 1256 | + 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 | + }, |
| 1263 | + "@id": "http://example.org/library", |
| 1264 | + "@type": "ex:Library", |
| 1265 | + "dc:name": "Library", |
| 1266 | + "ex:contains": { |
| 1267 | + "@id": "http://example.org/graphs/books", |
| 1268 | + "@graph": { |
| 1269 | + "@id": "http://example.org/library/the-republic", |
| 1270 | + "@type": "ex:Book", |
| 1271 | + "dc:creator": "Plato", |
| 1272 | + "dc:title": "The Republic", |
| 1273 | + "ex:contains": { |
| 1274 | + "@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" |
| 1278 | + } |
| 1279 | + } |
| 1280 | + } |
| 1281 | + }), |
| 1282 | + 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 | + }, |
| 1289 | + "@graph": [ |
| 1290 | + { |
| 1291 | + "@id": "http://example.org/library", |
| 1292 | + "@type": "ex:Library", |
| 1293 | + "dc:name": "Library", |
| 1294 | + "ex:contains": { |
| 1295 | + "@id": "http://example.org/graphs/books", |
| 1296 | + "@graph": [ |
| 1297 | + { |
| 1298 | + "@id": "http://example.org/library/the-republic", |
| 1299 | + "@type": "ex:Book", |
| 1300 | + "dc:creator": "Plato", |
| 1301 | + "dc:title": "The Republic", |
| 1302 | + "ex:contains": { |
| 1303 | + "@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" |
| 1307 | + } |
| 1308 | + } |
| 1309 | + ] |
| 1310 | + } |
| 1311 | + } |
| 1312 | + ] |
| 1313 | + }) |
| 1314 | + } |
1208 | 1315 | }.each do |title, params| |
1209 | 1316 | it title do |
1210 | 1317 | do_frame(params) |
|
0 commit comments