rdf-tabular 0.4.0 → 3.1.0

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.
Files changed (74) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +24 -5
  3. data/VERSION +1 -1
  4. data/etc/csvw.jsonld +135 -50
  5. data/lib/rdf/tabular/csvw.rb +215 -181
  6. data/lib/rdf/tabular/format.rb +8 -6
  7. data/lib/rdf/tabular/literal.rb +1 -1
  8. data/lib/rdf/tabular/metadata.rb +61 -80
  9. data/lib/rdf/tabular/reader.rb +18 -15
  10. data/lib/rdf/tabular/uax35.rb +143 -38
  11. data/spec/data/countries-minimal.json +38 -0
  12. data/spec/data/countries-minimal.ttl +36 -0
  13. data/spec/data/countries-standard.json +86 -0
  14. data/spec/data/countries-standard.ttl +75 -0
  15. data/spec/data/countries.csv +4 -0
  16. data/spec/data/countries.csv-minimal.json +16 -0
  17. data/spec/data/countries.csv-minimal.ttl +19 -0
  18. data/spec/data/countries.csv-standard.json +33 -0
  19. data/spec/data/countries.csv-standard.ttl +44 -0
  20. data/spec/data/countries.html +88 -0
  21. data/spec/data/countries.json +53 -0
  22. data/spec/data/countries_embed-minimal.json +38 -0
  23. data/spec/data/countries_embed-minimal.ttl +36 -0
  24. data/spec/data/countries_embed-standard.json +86 -0
  25. data/spec/data/countries_embed-standard.ttl +75 -0
  26. data/spec/data/countries_embed.html +88 -0
  27. data/spec/data/countries_html-minimal.json +38 -0
  28. data/spec/data/countries_html-minimal.ttl +36 -0
  29. data/spec/data/countries_html-standard.json +86 -0
  30. data/spec/data/countries_html-standard.ttl +75 -0
  31. data/spec/data/country-codes-and-names-minimal.json +19 -0
  32. data/spec/data/country-codes-and-names-minimal.ttl +22 -0
  33. data/spec/data/country-codes-and-names-standard.json +47 -0
  34. data/spec/data/country-codes-and-names-standard.ttl +45 -0
  35. data/spec/data/country-codes-and-names.csv +5 -0
  36. data/spec/data/country_slice.csv +4 -0
  37. data/spec/data/junior-roles.csv +3 -0
  38. data/spec/data/junior-roles.json +54 -0
  39. data/spec/data/roles-minimal.json +32 -0
  40. data/spec/data/roles-minimal.ttl +36 -0
  41. data/spec/data/roles-standard.json +56 -0
  42. data/spec/data/roles-standard.ttl +66 -0
  43. data/spec/data/roles.json +23 -0
  44. data/spec/data/senior-roles.csv +3 -0
  45. data/spec/data/senior-roles.json +52 -0
  46. data/spec/data/test232-metadata.json +10 -0
  47. data/spec/data/test232.csv +3 -0
  48. data/spec/data/tree-ops-atd.json +1 -0
  49. data/spec/data/tree-ops-ext-minimal.json +42 -0
  50. data/spec/data/tree-ops-ext-minimal.ttl +34 -0
  51. data/spec/data/tree-ops-ext-standard.json +93 -0
  52. data/spec/data/tree-ops-ext-standard.ttl +82 -0
  53. data/spec/data/tree-ops-ext.csv +4 -0
  54. data/spec/data/tree-ops-ext.json +81 -0
  55. data/spec/data/tree-ops-minimal.json +18 -0
  56. data/spec/data/tree-ops-minimal.ttl +14 -0
  57. data/spec/data/tree-ops-standard.json +44 -0
  58. data/spec/data/tree-ops-standard.ttl +44 -0
  59. data/spec/data/tree-ops-virtual-minimal.json +32 -0
  60. data/spec/data/tree-ops-virtual-minimal.ttl +25 -0
  61. data/spec/data/tree-ops-virtual-standard.json +49 -0
  62. data/spec/data/tree-ops-virtual-standard.ttl +49 -0
  63. data/spec/data/tree-ops-virtual.json +48 -0
  64. data/spec/data/tree-ops.csv +3 -0
  65. data/spec/data/tree-ops.csv-metadata.json +43 -0
  66. data/spec/data/tree-ops.html +54 -0
  67. data/spec/data/tree-ops.tsv +3 -0
  68. data/spec/format_spec.rb +5 -4
  69. data/spec/metadata_spec.rb +10 -16
  70. data/spec/suite_helper.rb +2 -2
  71. data/spec/suite_spec.rb +5 -6
  72. data/spec/uax35_spec.rb +239 -0
  73. metadata +149 -36
  74. data/lib/rdf/tabular/json.rb +0 -0
@@ -0,0 +1,14 @@
1
+ @prefix : <http://example.org/tree-ops.csv#> .
2
+ @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
3
+
4
+ :gid-1 :GID "1";
5
+ :inventory_date "2010-10-18"^^xsd:date;
6
+ :on_street "ADDISON AV";
7
+ :species "Celtis australis";
8
+ :trim_cycle "Large Tree Routine Prune" .
9
+
10
+ :gid-2 :GID "2";
11
+ :inventory_date "2010-06-02"^^xsd:date;
12
+ :on_street "EMERSON ST";
13
+ :species "Liquidambar styraciflua";
14
+ :trim_cycle "Large Tree Routine Prune" .
@@ -0,0 +1,44 @@
1
+ {
2
+ "tables": [{
3
+ "url": "http://example.org/tree-ops.csv",
4
+ "dc:title": "Tree Operations",
5
+ "dcat:keyword": [
6
+ "tree",
7
+ "street",
8
+ "maintenance"
9
+ ],
10
+ "dc:publisher": "Example Municipality",
11
+ "dc:license": "http://opendefinition.org/licenses/cc-by/",
12
+ "dc:modified": "2010-12-31",
13
+ "row": [
14
+ {
15
+ "url": "http://example.org/tree-ops.csv#row=2",
16
+ "rownum": 1,
17
+ "describes": [
18
+ {
19
+ "@id": "http://example.org/tree-ops.csv#gid-1",
20
+ "GID": "1",
21
+ "on_street": "ADDISON AV",
22
+ "species": "Celtis australis",
23
+ "trim_cycle": "Large Tree Routine Prune",
24
+ "inventory_date": "2010-10-18"
25
+ }
26
+ ]
27
+ },
28
+ {
29
+ "url": "http://example.org/tree-ops.csv#row=3",
30
+ "rownum": 2,
31
+ "describes": [
32
+ {
33
+ "@id": "http://example.org/tree-ops.csv#gid-2",
34
+ "GID": "2",
35
+ "on_street": "EMERSON ST",
36
+ "species": "Liquidambar styraciflua",
37
+ "trim_cycle": "Large Tree Routine Prune",
38
+ "inventory_date": "2010-06-02"
39
+ }
40
+ ]
41
+ }
42
+ ]
43
+ }]
44
+ }
@@ -0,0 +1,44 @@
1
+ @prefix : <http://example.org/tree-ops.csv#> .
2
+ @prefix csvw: <http://www.w3.org/ns/csvw#> .
3
+ @prefix dc: <http://purl.org/dc/terms/> .
4
+ @prefix dcat: <http://www.w3.org/ns/dcat#> .
5
+ @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
6
+ @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
7
+
8
+ :gid-1 :GID "1";
9
+ :inventory_date "2010-10-18"^^xsd:date;
10
+ :on_street "ADDISON AV";
11
+ :species "Celtis australis";
12
+ :trim_cycle "Large Tree Routine Prune" .
13
+
14
+ :gid-2 :GID "2";
15
+ :inventory_date "2010-06-02"^^xsd:date;
16
+ :on_street "EMERSON ST";
17
+ :species "Liquidambar styraciflua";
18
+ :trim_cycle "Large Tree Routine Prune" .
19
+
20
+ [
21
+ a csvw:TableGroup;
22
+ csvw:table [
23
+ a csvw:Table;
24
+ dc:title "Tree Operations"@en;
25
+ dcat:keyword "tree"@en,
26
+ "street"@en,
27
+ "maintenance"@en;
28
+ dc:license <http://opendefinition.org/licenses/cc-by/>;
29
+ dc:modified "2010-12-31"^^xsd:date;
30
+ dc:publisher "Example Municipality"@en;
31
+ csvw:row [
32
+ a csvw:Row;
33
+ csvw:describes :gid-1;
34
+ csvw:rownum 1;
35
+ csvw:url <http://example.org/tree-ops.csv#row=2>
36
+ ], [
37
+ a csvw:Row;
38
+ csvw:describes :gid-2;
39
+ csvw:rownum 2;
40
+ csvw:url <http://example.org/tree-ops.csv#row=3>
41
+ ];
42
+ csvw:url <http://example.org/tree-ops.csv>
43
+ ]
44
+ ] .
@@ -0,0 +1,32 @@
1
+ [
2
+ {
3
+ "@id": "http://example.org/tree-ops.csv#gid-1",
4
+ "schema:url": "http://example.org/tree-ops.csv#gid-1",
5
+ "schema:name": "Celtis australis",
6
+ "trim_cycle": "Large Tree Routine Prune",
7
+ "schema:event": {
8
+ "@id": "http://example.org/tree-ops.csv#event-2010-10-18",
9
+ "schema:startDate": "2010-10-18"
10
+ },
11
+ "schema:location": {
12
+ "@id": "http://example.org/tree-ops.csv#location-1",
13
+ "schema:streetAddress": "ADDISON AV",
14
+ "@type": "schema:PostalAddress"
15
+ }
16
+ },
17
+ {
18
+ "@id": "http://example.org/tree-ops.csv#gid-2",
19
+ "schema:url": "http://example.org/tree-ops.csv#gid-2",
20
+ "schema:name": "Liquidambar styraciflua",
21
+ "trim_cycle": "Large Tree Routine Prune",
22
+ "schema:event": {
23
+ "@id": "http://example.org/tree-ops.csv#event-2010-06-02",
24
+ "schema:startDate": "2010-06-02"
25
+ },
26
+ "schema:location": {
27
+ "@id": "http://example.org/tree-ops.csv#location-2",
28
+ "schema:streetAddress": "EMERSON ST",
29
+ "@type": "schema:PostalAddress"
30
+ }
31
+ }
32
+ ]
@@ -0,0 +1,25 @@
1
+ @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
2
+ @prefix schema: <http://schema.org/> .
3
+ @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
4
+
5
+ <http://example.org/tree-ops.csv#event-2010-10-18> schema:startDate "2010-10-18"^^xsd:date .
6
+
7
+ <http://example.org/tree-ops.csv#gid-1> <http://example.org/tree-ops.csv#trim_cycle> "Large Tree Routine Prune";
8
+ schema:event <http://example.org/tree-ops.csv#event-2010-10-18>;
9
+ schema:location <http://example.org/tree-ops.csv#location-1>;
10
+ schema:name "Celtis australis";
11
+ schema:url <http://example.org/tree-ops.csv#gid-1> .
12
+
13
+ <http://example.org/tree-ops.csv#gid-2> <http://example.org/tree-ops.csv#trim_cycle> "Large Tree Routine Prune";
14
+ schema:event <http://example.org/tree-ops.csv#event-2010-06-02>;
15
+ schema:location <http://example.org/tree-ops.csv#location-2>;
16
+ schema:name "Liquidambar styraciflua";
17
+ schema:url <http://example.org/tree-ops.csv#gid-2> .
18
+
19
+ <http://example.org/tree-ops.csv#location-1> a schema:PostalAddress;
20
+ schema:streetAddress "ADDISON AV" .
21
+
22
+ <http://example.org/tree-ops.csv#location-2> a schema:PostalAddress;
23
+ schema:streetAddress "EMERSON ST" .
24
+
25
+ <http://example.org/tree-ops.csv#event-2010-06-02> schema:startDate "2010-06-02"^^xsd:date .
@@ -0,0 +1,49 @@
1
+ {
2
+ "tables": [{
3
+ "url": "http://example.org/tree-ops.csv",
4
+ "row": [
5
+ {
6
+ "url": "http://example.org/tree-ops.csv#row=2",
7
+ "rownum": 1,
8
+ "describes": [
9
+ {
10
+ "@id": "http://example.org/tree-ops.csv#gid-1",
11
+ "schema:url": "http://example.org/tree-ops.csv#gid-1",
12
+ "schema:name": "Celtis australis",
13
+ "trim_cycle": "Large Tree Routine Prune",
14
+ "schema:event": {
15
+ "@id": "http://example.org/tree-ops.csv#event-2010-10-18",
16
+ "schema:startDate": "2010-10-18"
17
+ },
18
+ "schema:location": {
19
+ "@id": "http://example.org/tree-ops.csv#location-1",
20
+ "schema:streetAddress": "ADDISON AV",
21
+ "@type": "schema:PostalAddress"
22
+ }
23
+ }
24
+ ]
25
+ },
26
+ {
27
+ "url": "http://example.org/tree-ops.csv#row=3",
28
+ "rownum": 2,
29
+ "describes": [
30
+ {
31
+ "@id": "http://example.org/tree-ops.csv#gid-2",
32
+ "schema:url": "http://example.org/tree-ops.csv#gid-2",
33
+ "schema:name": "Liquidambar styraciflua",
34
+ "trim_cycle": "Large Tree Routine Prune",
35
+ "schema:event": {
36
+ "@id": "http://example.org/tree-ops.csv#event-2010-06-02",
37
+ "schema:startDate": "2010-06-02"
38
+ },
39
+ "schema:location": {
40
+ "@id": "http://example.org/tree-ops.csv#location-2",
41
+ "schema:streetAddress": "EMERSON ST",
42
+ "@type": "schema:PostalAddress"
43
+ }
44
+ }
45
+ ]
46
+ }
47
+ ]
48
+ }]
49
+ }
@@ -0,0 +1,49 @@
1
+ @prefix csvw: <http://www.w3.org/ns/csvw#> .
2
+ @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
3
+ @prefix schema: <http://schema.org/> .
4
+ @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
5
+
6
+ [
7
+ a csvw:TableGroup;
8
+ csvw:table [
9
+ a csvw:Table;
10
+ csvw:row [
11
+ a csvw:Row;
12
+ csvw:describes <http://example.org/tree-ops.csv#gid-1>,
13
+ <http://example.org/tree-ops.csv#location-1>,
14
+ <http://example.org/tree-ops.csv#event-2010-10-18>;
15
+ csvw:rownum 1;
16
+ csvw:url <http://example.org/tree-ops.csv#row=2>
17
+ ], [
18
+ a csvw:Row;
19
+ csvw:describes <http://example.org/tree-ops.csv#gid-2>,
20
+ <http://example.org/tree-ops.csv#location-2>,
21
+ <http://example.org/tree-ops.csv#event-2010-06-02>;
22
+ csvw:rownum 2;
23
+ csvw:url <http://example.org/tree-ops.csv#row=3>
24
+ ];
25
+ csvw:url <http://example.org/tree-ops.csv>
26
+ ]
27
+ ] .
28
+
29
+ <http://example.org/tree-ops.csv#gid-1> <http://example.org/tree-ops.csv#trim_cycle> "Large Tree Routine Prune";
30
+ schema:event <http://example.org/tree-ops.csv#event-2010-10-18>;
31
+ schema:location <http://example.org/tree-ops.csv#location-1>;
32
+ schema:name "Celtis australis";
33
+ schema:url <http://example.org/tree-ops.csv#gid-1> .
34
+
35
+ <http://example.org/tree-ops.csv#location-1> rdf:type schema:PostalAddress;
36
+ schema:streetAddress "ADDISON AV" .
37
+
38
+ <http://example.org/tree-ops.csv#event-2010-10-18> schema:startDate "2010-10-18"^^xsd:date .
39
+
40
+ <http://example.org/tree-ops.csv#gid-2> <http://example.org/tree-ops.csv#trim_cycle> "Large Tree Routine Prune";
41
+ schema:event <http://example.org/tree-ops.csv#event-2010-06-02>;
42
+ schema:location <http://example.org/tree-ops.csv#location-2>;
43
+ schema:name "Liquidambar styraciflua";
44
+ schema:url <http://example.org/tree-ops.csv#gid-2> .
45
+
46
+ <http://example.org/tree-ops.csv#location-2> rdf:type schema:PostalAddress;
47
+ schema:streetAddress "EMERSON ST" .
48
+
49
+ <http://example.org/tree-ops.csv#event-2010-06-02> schema:startDate "2010-06-02"^^xsd:date .
@@ -0,0 +1,48 @@
1
+ {
2
+ "url": "tree-ops.csv",
3
+ "@context": ["http://www.w3.org/ns/csvw", {"@language": "en"}],
4
+ "tableSchema": {
5
+ "columns": [{
6
+ "name": "GID",
7
+ "titles": "GID",
8
+ "datatype": "string",
9
+ "propertyUrl": "schema:url",
10
+ "valueUrl": "#gid-{GID}"
11
+ }, {
12
+ "name": "on_street",
13
+ "titles": "On Street",
14
+ "datatype": "string",
15
+ "aboutUrl": "#location-{GID}",
16
+ "propertyUrl": "schema:streetAddress"
17
+ }, {
18
+ "name": "species",
19
+ "titles": "Species",
20
+ "datatype": "string",
21
+ "propertyUrl": "schema:name"
22
+ }, {
23
+ "name": "trim_cycle",
24
+ "titles": "Trim Cycle",
25
+ "datatype": "string"
26
+ }, {
27
+ "name": "inventory_date",
28
+ "titles": "Inventory Date",
29
+ "datatype": {"base": "date", "format": "M/d/yyyy"},
30
+ "aboutUrl": "#event-{inventory_date}",
31
+ "propertyUrl": "schema:startDate"
32
+ }, {
33
+ "propertyUrl": "schema:event",
34
+ "valueUrl": "#event-{inventory_date}",
35
+ "virtual": true
36
+ }, {
37
+ "propertyUrl": "schema:location",
38
+ "valueUrl": "#location-{GID}",
39
+ "virtual": true
40
+ }, {
41
+ "aboutUrl": "#location-{GID}",
42
+ "propertyUrl": "rdf:type",
43
+ "valueUrl": "schema:PostalAddress",
44
+ "virtual": true
45
+ }],
46
+ "aboutUrl": "#gid-{GID}"
47
+ }
48
+ }
@@ -0,0 +1,3 @@
1
+ GID,On Street,Species,Trim Cycle,Inventory Date
2
+ 1,ADDISON AV,Celtis australis,Large Tree Routine Prune,10/18/2010
3
+ 2,EMERSON ST,Liquidambar styraciflua,Large Tree Routine Prune,6/2/2010
@@ -0,0 +1,43 @@
1
+ {
2
+ "url": "tree-ops.csv",
3
+ "@context": ["http://www.w3.org/ns/csvw", {"@language": "en"}],
4
+ "dc:title": "Tree Operations",
5
+ "dcat:keyword": ["tree", "street", "maintenance"],
6
+ "dc:publisher": "Example Municipality",
7
+ "dc:license": {"@id": "http://opendefinition.org/licenses/cc-by/"},
8
+ "dc:modified": {"@value": "2010-12-31", "@type": "xsd:date"},
9
+ "tableSchema": {
10
+ "columns": [{
11
+ "name": "GID",
12
+ "titles": [
13
+ "GID",
14
+ "Generic Identifier"
15
+ ],
16
+ "dc:description": "An identifier for the operation on a tree.",
17
+ "datatype": "string",
18
+ "required": true
19
+ }, {
20
+ "name": "on_street",
21
+ "titles": "On Street",
22
+ "dc:description": "The street that the tree is on.",
23
+ "datatype": "string"
24
+ }, {
25
+ "name": "species",
26
+ "titles": "Species",
27
+ "dc:description": "The species of the tree.",
28
+ "datatype": "string"
29
+ }, {
30
+ "name": "trim_cycle",
31
+ "titles": "Trim Cycle",
32
+ "dc:description": "The operation performed on the tree.",
33
+ "datatype": "string"
34
+ }, {
35
+ "name": "inventory_date",
36
+ "titles": "Inventory Date",
37
+ "dc:description": "The date of the operation that was performed.",
38
+ "datatype": {"base": "date", "format": "M/d/yyyy"}
39
+ }],
40
+ "primaryKey": "GID",
41
+ "aboutUrl": "#gid-{GID}"
42
+ }
43
+ }
@@ -0,0 +1,54 @@
1
+ <html>
2
+ <head>
3
+ <title>Embedding Metadata in HTML</title>
4
+ <script type="application/csvm+json">
5
+ {
6
+ "url": "tree-ops.csv",
7
+ "@context": ["http://www.w3.org/ns/csvw", {"@language": "en"}],
8
+ "dc:title": "Tree Operations",
9
+ "dcat:keyword": ["tree", "street", "maintenance"],
10
+ "dc:publisher": "Example Municipality",
11
+ "dc:license": {"@id": "http://opendefinition.org/licenses/cc-by/"},
12
+ "dc:modified": {"@value": "2010-12-31", "@type": "xsd:date"},
13
+ "tableSchema": {
14
+ "columns": [{
15
+ "name": "GID",
16
+ "titles": [
17
+ "GID",
18
+ "Generic Identifier"
19
+ ],
20
+ "dc:description": "An identifier for the operation on a tree.",
21
+ "datatype": "string",
22
+ "required": true
23
+ }, {
24
+ "name": "on_street",
25
+ "titles": "On Street",
26
+ "dc:description": "The street that the tree is on.",
27
+ "datatype": "string"
28
+ }, {
29
+ "name": "species",
30
+ "titles": "Species",
31
+ "dc:description": "The species of the tree.",
32
+ "datatype": "string"
33
+ }, {
34
+ "name": "trim_cycle",
35
+ "titles": "Trim Cycle",
36
+ "dc:description": "The operation performed on the tree.",
37
+ "datatype": "string"
38
+ }, {
39
+ "name": "inventory_date",
40
+ "titles": "Inventory Date",
41
+ "dc:description": "The date of the operation that was performed.",
42
+ "datatype": {"base": "date", "format": "M/d/yyyy"}
43
+ }],
44
+ "primaryKey": "GID",
45
+ "aboutUrl": "#gid-{GID}"
46
+ }
47
+ }
48
+ </script>
49
+ </head>
50
+ <body>
51
+ <p>This is an example of embedding metadata in a <code>script</code> element.</p>
52
+ </body>
53
+ </html>
54
+
@@ -0,0 +1,3 @@
1
+ GID On Street Species Trim Cycle Inventory Date
2
+ 1 ADDISON AV Celtis australis Large Tree Routine Prune 10/18/2010
3
+ 2 EMERSON ST Liquidambar styraciflua Large Tree Routine Prune 6/2/2010
@@ -31,7 +31,7 @@ describe RDF::Tabular::Format do
31
31
  specify {expect(described_class.to_sym).to eq :tabular}
32
32
  end
33
33
 
34
- describe ".cli_commands" do
34
+ describe ".cli_commands", skip: ("TextMate OptionParser issues" if ENV['TM_SELECTED_FILE']) do
35
35
  before(:each) do
36
36
  WebMock.stub_request(:any, %r(.*example.org.*)).
37
37
  to_return(lambda {|request|
@@ -54,13 +54,14 @@ describe RDF::Tabular::Format do
54
54
  end
55
55
  })
56
56
  end
57
- after(:each) {|example| puts logger.to_s if example.exception}
58
57
 
59
58
  require 'rdf/cli'
60
- let(:input) {File.expand_path("../data/countries.json", __FILE__)}
59
+ let(:input) {"http://example.org/data/countries.json"}
61
60
  describe "#tabular-json" do
62
61
  it "serializes to JSON" do
63
- expect {RDF::CLI.exec(["tabular-json", input], format: :tabular)}.to write.to(:output)
62
+ expect {
63
+ RDF::CLI.exec(["tabular-json", input], format: :tabular)
64
+ }.to write.to(:output)
64
65
  end
65
66
  end
66
67
  end