json-ld 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. data/History.markdown +3 -0
  2. data/VERSION +1 -1
  3. data/bin/jsonld +134 -0
  4. data/lib/json/ld/api.rb +4 -4
  5. data/lib/json/ld/frame.rb +2 -1
  6. data/lib/json/ld/from_rdf.rb +1 -1
  7. data/spec/api_spec.rb +66 -0
  8. data/spec/compact_spec.rb +420 -0
  9. data/spec/evaluation_context_spec.rb +1039 -0
  10. data/spec/expand_spec.rb +625 -0
  11. data/spec/format_spec.rb +71 -0
  12. data/spec/frame_spec.rb +542 -0
  13. data/spec/from_rdf_spec.rb +316 -0
  14. data/spec/matchers.rb +67 -0
  15. data/spec/reader_spec.rb +79 -0
  16. data/spec/spec_helper.rb +56 -0
  17. data/spec/suite_helper.rb +184 -0
  18. data/spec/suite_spec.rb +104 -0
  19. data/spec/support/extensions.rb +10 -0
  20. data/spec/test-files/test-1-automatic.json +10 -0
  21. data/spec/test-files/test-1-compacted.json +10 -0
  22. data/spec/test-files/test-1-context.json +7 -0
  23. data/spec/test-files/test-1-expanded.json +5 -0
  24. data/spec/test-files/test-1-input.json +10 -0
  25. data/spec/test-files/test-1-normalized.json +8 -0
  26. data/spec/test-files/test-1-rdf.ttl +7 -0
  27. data/spec/test-files/test-2-automatic.json +27 -0
  28. data/spec/test-files/test-2-compacted.json +20 -0
  29. data/spec/test-files/test-2-context.json +7 -0
  30. data/spec/test-files/test-2-expanded.json +16 -0
  31. data/spec/test-files/test-2-input.json +20 -0
  32. data/spec/test-files/test-2-normalized.json +32 -0
  33. data/spec/test-files/test-2-rdf.ttl +14 -0
  34. data/spec/test-files/test-3-compacted.json +11 -0
  35. data/spec/test-files/test-3-context.json +8 -0
  36. data/spec/test-files/test-3-expanded.json +10 -0
  37. data/spec/test-files/test-3-input.json +11 -0
  38. data/spec/test-files/test-3-normalized.json +13 -0
  39. data/spec/test-files/test-3-rdf.ttl +7 -0
  40. data/spec/test-files/test-4-automatic.json +10 -0
  41. data/spec/test-files/test-4-compacted.json +10 -0
  42. data/spec/test-files/test-4-context.json +7 -0
  43. data/spec/test-files/test-4-expanded.json +6 -0
  44. data/spec/test-files/test-4-input.json +10 -0
  45. data/spec/test-files/test-4-rdf.ttl +5 -0
  46. data/spec/test-files/test-5-automatic.json +13 -0
  47. data/spec/test-files/test-5-compacted.json +13 -0
  48. data/spec/test-files/test-5-context.json +7 -0
  49. data/spec/test-files/test-5-expanded.json +9 -0
  50. data/spec/test-files/test-5-input.json +13 -0
  51. data/spec/test-files/test-5-rdf.ttl +6 -0
  52. data/spec/test-files/test-6-automatic.json +10 -0
  53. data/spec/test-files/test-6-compacted.json +10 -0
  54. data/spec/test-files/test-6-context.json +7 -0
  55. data/spec/test-files/test-6-expanded.json +10 -0
  56. data/spec/test-files/test-6-input.json +10 -0
  57. data/spec/test-files/test-6-rdf.ttl +5 -0
  58. data/spec/test-files/test-7-automatic.json +20 -0
  59. data/spec/test-files/test-7-compacted.json +23 -0
  60. data/spec/test-files/test-7-context.json +4 -0
  61. data/spec/test-files/test-7-expanded.json +20 -0
  62. data/spec/test-files/test-7-input.json +23 -0
  63. data/spec/test-files/test-7-rdf.ttl +13 -0
  64. data/spec/test-files/test-8-automatic.json +1 -0
  65. data/spec/test-files/test-8-compacted.json +34 -0
  66. data/spec/test-files/test-8-context.json +11 -0
  67. data/spec/test-files/test-8-expanded.json +24 -0
  68. data/spec/test-files/test-8-frame.json +18 -0
  69. data/spec/test-files/test-8-framed.json +29 -0
  70. data/spec/test-files/test-8-input.json +30 -0
  71. data/spec/test-files/test-8-rdf.ttl +15 -0
  72. data/spec/test-files/test-9-compacted.json +20 -0
  73. data/spec/test-files/test-9-context.json +13 -0
  74. data/spec/test-files/test-9-expanded.json +14 -0
  75. data/spec/test-files/test-9-input.json +12 -0
  76. data/spec/to_rdf_spec.rb +640 -0
  77. data/spec/writer_spec.rb +161 -0
  78. metadata +150 -22
@@ -0,0 +1,20 @@
1
+ {
2
+ "@context": {
3
+ "dc": "http://purl.org/dc/elements/1.1/",
4
+ "ex": "http://example.org/vocab#"
5
+ },
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"
18
+ }
19
+ }
20
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "@context": {
3
+ "dc": "http://purl.org/dc/elements/1.1/",
4
+ "ex": "http://example.org/vocab#"
5
+ }
6
+
7
+ }
@@ -0,0 +1,16 @@
1
+ [{
2
+ "@id": "http://example.org/library",
3
+ "@type": ["http://example.org/vocab#Library"],
4
+ "http://example.org/vocab#contains": [{
5
+ "@id": "http://example.org/library/the-republic",
6
+ "@type": ["http://example.org/vocab#Book"],
7
+ "http://purl.org/dc/elements/1.1/creator": [{"@value": "Plato"}],
8
+ "http://purl.org/dc/elements/1.1/title": [{"@value": "The Republic"}],
9
+ "http://example.org/vocab#contains": [{
10
+ "@id": "http://example.org/library/the-republic#introduction",
11
+ "@type": ["http://example.org/vocab#Chapter"],
12
+ "http://purl.org/dc/elements/1.1/description": [{"@value": "An introductory chapter on The Republic."}],
13
+ "http://purl.org/dc/elements/1.1/title": [{"@value": "The Introduction"}]
14
+ }]
15
+ }]
16
+ }]
@@ -0,0 +1,20 @@
1
+ {
2
+ "@context": {
3
+ "dc": "http://purl.org/dc/elements/1.1/",
4
+ "ex": "http://example.org/vocab#"
5
+ },
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"
18
+ }
19
+ }
20
+ }
@@ -0,0 +1,32 @@
1
+ [{
2
+ "@id": {
3
+ "@id": "http://example.org/library"
4
+ },
5
+ "http://example.org/vocab#contains": {
6
+ "@id": "http://example.org/library/the-republic"
7
+ },
8
+ "http://www.w3.org/1999/02/22-rdf-syntax-ns#type": {
9
+ "@id": "http://example.org/vocab#Library"
10
+ }
11
+ }, {
12
+ "@id": {
13
+ "@id": "http://example.org/library/the-republic"
14
+ },
15
+ "http://example.org/vocab#contains": {
16
+ "@id": "http://example.org/library/the-republic#introduction"
17
+ },
18
+ "http://purl.org/dc/elements/1.1/creator": "Plato",
19
+ "http://purl.org/dc/elements/1.1/title": "The Republic",
20
+ "@type": {
21
+ "@id": "http://example.org/vocab#Book"
22
+ }
23
+ }, {
24
+ "@id": {
25
+ "@id": "http://example.org/library/the-republic#introduction"
26
+ },
27
+ "http://purl.org/dc/elements/1.1/description": "An introductory chapter on The Republic.",
28
+ "http://purl.org/dc/elements/1.1/title": "The Introduction",
29
+ "@type": {
30
+ "@id": "http://example.org/vocab#Chapter"
31
+ }
32
+ }]
@@ -0,0 +1,14 @@
1
+ @prefix dc: <http://purl.org/dc/elements/1.1/> .
2
+ @prefix ex: <http://example.org/vocab#> .
3
+
4
+ <http://example.org/library> a ex:Library;
5
+ ex:contains <http://example.org/library/the-republic> .
6
+
7
+ <http://example.org/library/the-republic> a ex:Book;
8
+ ex:contains <http://example.org/library/the-republic#introduction>;
9
+ dc:creator "Plato";
10
+ dc:title "The Republic" .
11
+
12
+ <http://example.org/library/the-republic#introduction> a ex:Chapter;
13
+ dc:description "An introductory chapter on The Republic.";
14
+ dc:title "The Introduction" .
@@ -0,0 +1,11 @@
1
+ {
2
+ "@context": {
3
+ "xsd": "http://www.w3.org/2001/XMLSchema#",
4
+ "name": "http://xmlns.com/foaf/0.1/name",
5
+ "age": {"@id": "http://xmlns.com/foaf/0.1/age", "@type": "xsd:integer"},
6
+ "homepage": {"@id": "http://xmlns.com/foaf/0.1/homepage", "@type": "@id"}
7
+ },
8
+ "name": "Manu Sporny",
9
+ "age": "41",
10
+ "homepage": "http://manu.sporny.org/"
11
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "@context": {
3
+ "xsd": "http://www.w3.org/2001/XMLSchema#",
4
+ "name": "http://xmlns.com/foaf/0.1/name",
5
+ "age": {"@id": "http://xmlns.com/foaf/0.1/age", "@type": "xsd:integer"},
6
+ "homepage": {"@id": "http://xmlns.com/foaf/0.1/homepage", "@type": "@id"}
7
+ }
8
+ }
@@ -0,0 +1,10 @@
1
+ [{
2
+ "http://xmlns.com/foaf/0.1/name": [{"@value": "Manu Sporny"}],
3
+ "http://xmlns.com/foaf/0.1/age": [{
4
+ "@type": "http://www.w3.org/2001/XMLSchema#integer",
5
+ "@value": "41"
6
+ }],
7
+ "http://xmlns.com/foaf/0.1/homepage": [{
8
+ "@id": "http://manu.sporny.org/"
9
+ }]
10
+ }]
@@ -0,0 +1,11 @@
1
+ {
2
+ "@context": {
3
+ "xsd": "http://www.w3.org/2001/XMLSchema#",
4
+ "name": "http://xmlns.com/foaf/0.1/name",
5
+ "age": {"@id": "http://xmlns.com/foaf/0.1/age", "@type": "xsd:integer"},
6
+ "homepage": {"@id": "http://xmlns.com/foaf/0.1/homepage", "@type": "@id"}
7
+ },
8
+ "name": "Manu Sporny",
9
+ "age": "41",
10
+ "homepage": "http://manu.sporny.org/"
11
+ }
@@ -0,0 +1,13 @@
1
+ [{
2
+ "@id": {
3
+ "@id": "_:c14n0"
4
+ },
5
+ "http://xmlns.com/foaf/0.1/age": {
6
+ "@type": "http://www.w3.org/2001/XMLSchema#integer",
7
+ "@value": "41"
8
+ },
9
+ "http://xmlns.com/foaf/0.1/homepage": {
10
+ "@id": "http://manu.sporny.org/"
11
+ },
12
+ "http://xmlns.com/foaf/0.1/name": "Manu Sporny"
13
+ }]
@@ -0,0 +1,7 @@
1
+ @prefix age: <http://xmlns.com/foaf/0.1/age> .
2
+ @prefix homepage: <http://xmlns.com/foaf/0.1/homepage> .
3
+ @prefix name: <http://xmlns.com/foaf/0.1/name> .
4
+
5
+ [ age: 41;
6
+ homepage: <http://manu.sporny.org/>;
7
+ name: "Manu Sporny"] .
@@ -0,0 +1,10 @@
1
+ {
2
+ "@context": [
3
+ { "foaf": "http://xmlns.com/foaf/0.1/" },
4
+ { "foaf:homepage": { "@coerce": "@id" } }
5
+ ],
6
+ "@id": "http://manu.sporny.org/#me",
7
+ "@type": "foaf:Person",
8
+ "foaf:homepage": "http://manu.sporny.org/",
9
+ "foaf:name": "Manu Sporny"
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "@context": {
3
+ "": "http://manu.sporny.org/",
4
+ "foaf": "http://xmlns.com/foaf/0.1/"
5
+ },
6
+ "@id": ":#me",
7
+ "@type": "foaf:Person",
8
+ "foaf:name": "Manu Sporny",
9
+ "foaf:homepage": { "@id": "" }
10
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "@context": {
3
+ "": "http://manu.sporny.org/",
4
+ "foaf": "http://xmlns.com/foaf/0.1/"
5
+ }
6
+ }
7
+
@@ -0,0 +1,6 @@
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/homepage": [{ "@id": "http://manu.sporny.org/" }]
6
+ }]
@@ -0,0 +1,10 @@
1
+ {
2
+ "@context": {
3
+ "": "http://manu.sporny.org/",
4
+ "foaf": "http://xmlns.com/foaf/0.1/"
5
+ },
6
+ "@id": ":#me",
7
+ "@type": "foaf:Person",
8
+ "foaf:name": "Manu Sporny",
9
+ "foaf:homepage": { "@id": ":" }
10
+ }
@@ -0,0 +1,5 @@
1
+ @prefix foaf: <http://xmlns.com/foaf/0.1/> .
2
+
3
+ <http://manu.sporny.org/#me> a foaf:Person;
4
+ foaf:homepage <http://manu.sporny.org/>;
5
+ foaf:name "Manu Sporny" .
@@ -0,0 +1,13 @@
1
+ {
2
+ "@context": [
3
+ { "foaf": "http://xmlns.com/foaf/0.1/" },
4
+ { "foaf:knows": { "@coerce": "@id" } }
5
+ ],
6
+ "@id": "http://manu.sporny.org/#me",
7
+ "@type": "foaf:Person",
8
+ "foaf:name": "Manu Sporny",
9
+ "foaf:knows": {
10
+ "@type": "foaf:Person",
11
+ "foaf:name": "Gregg Kellogg"
12
+ }
13
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "@context": {
3
+ "": "http://manu.sporny.org/",
4
+ "foaf": "http://xmlns.com/foaf/0.1/"
5
+ },
6
+ "@id": ":#me",
7
+ "@type": "foaf:Person",
8
+ "foaf:name": "Manu Sporny",
9
+ "foaf:knows": {
10
+ "@type": "foaf:Person",
11
+ "foaf:name": "Gregg Kellogg"
12
+ }
13
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "@context": {
3
+ "": "http://manu.sporny.org/",
4
+ "foaf": "http://xmlns.com/foaf/0.1/"
5
+ }
6
+ }
7
+
@@ -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,13 @@
1
+ {
2
+ "@context": {
3
+ "": "http://manu.sporny.org/",
4
+ "foaf": "http://xmlns.com/foaf/0.1/"
5
+ },
6
+ "@id": ":#me",
7
+ "@type": "foaf:Person",
8
+ "foaf:name": "Manu Sporny",
9
+ "foaf:knows": {
10
+ "@type": "foaf:Person",
11
+ "foaf:name": "Gregg Kellogg"
12
+ }
13
+ }
@@ -0,0 +1,6 @@
1
+ @prefix foaf: <http://xmlns.com/foaf/0.1/> .
2
+
3
+ <http://manu.sporny.org/#me> a foaf:Person;
4
+ foaf:knows [ a foaf:Person;
5
+ foaf:name "Gregg Kellogg"];
6
+ foaf:name "Manu Sporny" .
@@ -0,0 +1,10 @@
1
+ {
2
+ "@context": [
3
+ { "foaf": "http://xmlns.com/foaf/0.1/" },
4
+ { "foaf:nick": { "@coerce": "@id", "@list": true } }
5
+ ],
6
+ "@id": "http://example.org/people#joebob",
7
+ "@type": "foaf:Person",
8
+ "foaf:name": "Joe Bob",
9
+ "foaf:nick": [ "joe", "bob", "jaybe" ]
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "@context": {
3
+ "": "http://manu.sporny.org/",
4
+ "foaf": "http://xmlns.com/foaf/0.1/"
5
+ },
6
+ "@id": "http://example.org/people#joebob",
7
+ "@type": "foaf:Person",
8
+ "foaf:name": "Joe Bob",
9
+ "foaf:nick": { "@list": [ "joe", "bob", "jaybe" ] }
10
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "@context": {
3
+ "": "http://manu.sporny.org/",
4
+ "foaf": "http://xmlns.com/foaf/0.1/"
5
+ }
6
+
7
+ }
@@ -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,10 @@
1
+ {
2
+ "@context": {
3
+ "": "http://manu.sporny.org/",
4
+ "foaf": "http://xmlns.com/foaf/0.1/"
5
+ },
6
+ "@id": "http://example.org/people#joebob",
7
+ "@type": "foaf:Person",
8
+ "foaf:name": "Joe Bob",
9
+ "foaf:nick": { "@list": [ "joe", "bob", "jaybe" ] }
10
+ }
@@ -0,0 +1,5 @@
1
+ @prefix foaf: <http://xmlns.com/foaf/0.1/> .
2
+
3
+ <http://example.org/people#joebob> a foaf:Person;
4
+ foaf:name "Joe Bob";
5
+ foaf:nick ("joe" "bob" "jaybe") .
@@ -0,0 +1,20 @@
1
+ {
2
+ "@context": { "foaf": "http://xmlns.com/foaf/0.1/" },
3
+ "@id": [
4
+ {
5
+ "@type": "foaf:Person",
6
+ "foaf:homepage": "http://example.com/bob/",
7
+ "foaf:name": "Bob"
8
+ },
9
+ {
10
+ "@type": "foaf:Person",
11
+ "foaf:homepage": "http://example.com/eve/",
12
+ "foaf:name": "Eve"
13
+ },
14
+ {
15
+ "@type": "foaf:Person",
16
+ "foaf:homepage": "http://example.com/manu/",
17
+ "foaf:name": "Manu"
18
+ }
19
+ ]
20
+ }
@@ -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,4 @@
1
+ {
2
+ "@context": { "foaf": "http://xmlns.com/foaf/0.1/" }
3
+ }
4
+