cid 0.2.3 → 0.3.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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NWE5MjE3MDc5N2RmYmYxYzVkMWI0MWZmZmUwM2I5ODhkOTg2NGUxZQ==
4
+ ZDI2ZmZhYWM1NDJkMTA0OTQ0OTE1YWU3OTA0NjE0ZDdhZjc3NWVhMA==
5
5
  data.tar.gz: !binary |-
6
- NDc4NzgwNWMyMzRhYzVjYjBkMmQ0ZDYxZjgxNjkzMjI3ZTFmMjVhNA==
6
+ ZjE4ZmZkNjVjYjUzY2JmM2IzYWI4MmQxNmMyYmViNWFmNmM2YjNmZg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NDQzZjMwYzM4NWVjYjQ4YmQzYWY0Y2Y5OTQzNGVhMzAyYTJiYmE1NjljYjNl
10
- YWM5ZGIzMjg3YmM2NzM5NGJlZTUyNGRhNzI2NTkwMmZmMDk0OGQzZjYzMGFh
11
- MmI0Y2JlYzM4MTQ2NjM1ZjM0YTVmOTczMGY2MTY0YmEwY2QwMDU=
9
+ MzcyMjQzYWEwYjNjM2NkYjBhOWM5ZjRkZDkxOTJlNTM1ZDA1OTJhZjRhZGEy
10
+ NWI3N2ZjMzZhMWUxNGM5MGM4ZDRjM2Y2MDZkZmE4NjVkYTQzMjJlNWFlNDll
11
+ OTg2ZDMwNTUzNTM0YjFkMzlmNmI2MmM3OTQzYjY2MzYxZjk4ZWU=
12
12
  data.tar.gz: !binary |-
13
- NGIyMTdlMDkyZWI0MGIzODIyMmQ5OTNhM2RmNzRmOWUxYjU1YTBkYzA2Mzkx
14
- M2MwMzc2ODRkNGFhZjZmODU1ODMyMGY4OTI3MTMwOTRhOGI1ZjhlMTdhMmUy
15
- NGI2YmU2MDkzOTI5MTY2YTZhNmJhOTIyMWQxZTc5YjhkMmYzODM=
13
+ OGNhMWVlMDhkMGQ2YmIwZGEyZGRiM2FhZTBmMWQ5Mzg2NDUxMTkzMjFlZTg4
14
+ NjUxMTYzNjRiOWJhNjQwNjViMzY5MzAwMDQ4NWQwN2E4ZmI0ODhlZGY0OWE0
15
+ OTNkYTcyZDM3OTY1NjgwNzViNDRkZjgzYmQzYzRjMzE3OGVmN2U=
data/README.md CHANGED
@@ -49,6 +49,40 @@ The schema.json file must match the [JSON table schema](http://dataprotocols.org
49
49
 
50
50
  You can have any number of folders, and each schema must correspond to the files within it.
51
51
 
52
+ Alternatively, you can specify your schema in your `datapackage.json` like so:
53
+
54
+ ```JSON
55
+
56
+ {
57
+ "name": "my-dataset",
58
+ # here we list the data files in this dataset
59
+ "resources": [
60
+ {
61
+ "path": "data.csv",
62
+ "schema": {
63
+ "fields": [
64
+ {
65
+ "name": "var1",
66
+ "type": "string"
67
+ },
68
+ {
69
+ "name": "var2",
70
+ "type": "integer"
71
+ },
72
+ {
73
+ "name": "var3",
74
+ "type": "number"
75
+ }
76
+ ]
77
+ }
78
+ }
79
+ ]
80
+ }
81
+
82
+ ```
83
+
84
+ For more information, check out the [Tabular data package specification](http://dataprotocols.org/tabular-data-package/)
85
+
52
86
  When you run `cid validate` on the command line, Cid loops through each folder and validates each csv against the schema. It also checks for any common errors like ragged rows and missing characters using [csvlint](https://github.com/theodi/csvlint.rb).
53
87
 
54
88
  When you run `cid publish` on the command line, Cid (again), loops through each folder and adds each csv to the `datapackage.json`. It then pushes the changes to the GitHub repo. For this to happen sucessfully, you must have a Github API key, which you can specify either as an environment variable like so:
data/lib/cid.rb CHANGED
@@ -9,6 +9,7 @@ module Cid
9
9
  end
10
10
 
11
11
  require "cid/helpers/github"
12
+ require "cid/helpers/file"
12
13
 
13
14
  require "cid/version"
14
15
  require "cid/validation"
@@ -5,6 +5,8 @@ module Cid
5
5
 
6
6
  class Datapackage
7
7
 
8
+ include Cid::Helpers::File
9
+
8
10
  attr_accessor :json
9
11
 
10
12
  def initialize(path)
@@ -52,6 +54,16 @@ module Cid
52
54
  git.publish
53
55
  end
54
56
 
57
+ def schema_for_file(file)
58
+ path = clean_file(file)
59
+ begin
60
+ schema = @datapackage["resources"].select { |r| r["path"] == path }.first["schema"]
61
+ Csvlint::Schema.from_json_table(nil, schema)
62
+ rescue NoMethodError
63
+ nil
64
+ end
65
+ end
66
+
55
67
  end
56
68
 
57
69
  end
@@ -0,0 +1,8 @@
1
+ module Cid::Helpers::File
2
+
3
+ def clean_file(file)
4
+ clean_file = file.gsub @path, ""
5
+ clean_file.gsub! /^\//, ""
6
+ end
7
+
8
+ end
@@ -4,22 +4,25 @@ module Cid
4
4
 
5
5
  class Validation
6
6
 
7
- def self.validate(path, ignore = [])
7
+ def self.validate(root_path, ignore = [])
8
8
  result = {}
9
9
 
10
- paths = Dir.glob("#{path}/**")
10
+ paths = Dir.glob("#{root_path}/*/")
11
11
 
12
12
  paths.each do |path|
13
13
  next if ignore.include?(path.split("/").last)
14
14
 
15
- begin
16
- schema = Csvlint::Schema.load_from_json_table(File.new(Dir["#{path}/schema.json"][0]))
17
- rescue
15
+ if File.file?("#{path}schema.json")
16
+ schema = Csvlint::Schema.load_from_json_table(File.new(Dir["#{path}schema.json"][0]))
17
+ else
18
18
  schema = nil
19
19
  end
20
20
 
21
- Dir["#{path}/*.csv"].each do |csv|
21
+ Dir["#{path}*.csv"].each do |csv|
22
+ schema = Cid::Datapackage.new(root_path).schema_for_file(csv) if schema.nil?
23
+
22
24
  validator = Csvlint::Validator.new(File.new(csv), nil, schema)
25
+
23
26
  ref = csv.split("/").last(2).join("/")
24
27
  result[ref] = {}
25
28
 
@@ -1,3 +1,3 @@
1
1
  module Cid
2
- VERSION = "0.2.3"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -0,0 +1,83 @@
1
+ {
2
+ "name": "euro-elections",
3
+ "title": "",
4
+ "homepage": "",
5
+ "version": "0.1.0",
6
+ "license": "PDDL-1.0",
7
+ "resources": [
8
+ {
9
+ "name": "votes-1",
10
+ "path": "votes/votes-1.csv",
11
+ "format": "csv",
12
+ "mediatype": "text/csv",
13
+ "bytes": 1752,
14
+ "schema": {
15
+ "fields": [
16
+ {
17
+ "name": "Poll Date",
18
+ "type": "date",
19
+ "description": "Date the poll took place",
20
+ "constraints": {
21
+ "format": "yyyy-mm-dd"
22
+ }
23
+ },
24
+ {
25
+ "name": "Area",
26
+ "type": "string",
27
+ "description": "The name of the area which the result is for",
28
+ "constraints": {
29
+ "required": true
30
+ }
31
+ },
32
+ {
33
+ "name": "Area Code",
34
+ "type": "number",
35
+ "description": "The Office of National Statistics code for the area",
36
+ "constraints": {
37
+ "pattern": "(E|N|S|W)(07|15|08)00000[0-9]",
38
+ "required": true
39
+ }
40
+ },
41
+ {
42
+ "name": "Area URL",
43
+ "type": "string",
44
+ "description": "",
45
+ "constraints": {
46
+ "required": true,
47
+ "pattern": "http://statistics.data.gov.uk/doc/statistical-geography/(E|N|S|W)(07|15|08)00000[0-9]"
48
+ }
49
+ },
50
+ {
51
+ "name": "Party",
52
+ "type": "string",
53
+ "description": "",
54
+ "constraints": {
55
+ "required": true
56
+ }
57
+ },
58
+ {
59
+ "name": "Party ID",
60
+ "type": "string",
61
+ "description": "",
62
+ "constraints": {
63
+ "required": true,
64
+ "pattern": "PPm? [0-9]+"
65
+ }
66
+ },
67
+ {
68
+ "name": "Votes",
69
+ "type": "integer",
70
+ "description": ""
71
+ },
72
+ {
73
+ "name": "Ballots Rejected",
74
+ "type": "integer",
75
+ "description": ""
76
+ }
77
+ ]
78
+ }
79
+ }
80
+ ],
81
+ "description": "",
82
+ "repository": "git://github.com/theodi/euro-elections.git"
83
+ }
@@ -0,0 +1,13 @@
1
+ Poll Date,Area,Area Code,Area URL,Party,Party ID,Votes,Ballots Rejected
2
+ 2009-06-04,West Midlands,E15000005,http://statistics.data.gov.uk/doc/statistical-geography/E15000005,British National Party ,PP 106,121967,9216
3
+ 2009-06-04,West Midlands,E15000005,http://statistics.data.gov.uk/doc/statistical-geography/E15000005,Christian Party,PP 1992,18784,9217
4
+ 2009-06-04,West Midlands,E15000005,http://statistics.data.gov.uk/doc/statistical-geography/E15000005,Conservative Party ,PP 52,396847,9218
5
+ 2009-06-04,West Midlands,E15000005,http://statistics.data.gov.uk/doc/statistical-geography/E15000005,English Democrats Party,PP 17,32455,9219
6
+ 2009-06-04,West Midlands,E15000005,http://statistics.data.gov.uk/doc/statistical-geography/E15000005,Jury Team,PP 999,8721,9220
7
+ 2009-06-04,West Midlands,E15000005,http://statistics.data.gov.uk/doc/statistical-geography/E15000005,Liberal Democrats,PP 90,170246,9221
8
+ 2009-06-04,West Midlands,E15000005,http://statistics.data.gov.uk/doc/statistical-geography/E15000005,No2EU: Yes to Democracy,PP 2164,13415,9222
9
+ 2009-06-04,West Midlands,E15000005,http://statistics.data.gov.uk/doc/statistical-geography/E15000005,Pro Democracy: Libertas.eu ,PP 999,6961,9223
10
+ 2009-06-04,West Midlands,E15000005,http://statistics.data.gov.uk/doc/statistical-geography/E15000005,Socialist Labour Party,PP 73,14724,9224
11
+ 2009-06-04,West Midlands,E15000005,http://statistics.data.gov.uk/doc/statistical-geography/E15000005,The Green Party,PP 63,88244,9225
12
+ 2009-06-04,West Midlands,E15000005,http://statistics.data.gov.uk/doc/statistical-geography/E15000005,The Labour Party,PP 53,240201,9226
13
+ 2009-06-04,West Midlands,E15000005,http://statistics.data.gov.uk/doc/statistical-geography/E15000005,United Kingdom Independence Party,PP 85,300471,9227
@@ -6,40 +6,52 @@
6
6
  "name": "Poll Date",
7
7
  "type": "date",
8
8
  "description": "Date the poll took place",
9
- "format": "yyyy-mm-dd"
9
+ "constraints": {
10
+ "format": "yyyy-mm-dd"
11
+ }
10
12
  },
11
13
  {
12
14
  "name": "Area",
13
15
  "type": "string",
14
16
  "description": "The name of the area which the result is for",
15
- "required": true
17
+ "constraints": {
18
+ "required": true
19
+ }
16
20
  },
17
21
  {
18
22
  "name": "Area Code",
19
23
  "type": "number",
20
24
  "description": "The Office of National Statistics code for the area",
21
- "pattern": "E1500000(0-9)",
22
- "required": true
25
+ "constraints": {
26
+ "pattern": "(E|N|S|W)(07|15|08)00000[0-9]",
27
+ "required": true
28
+ }
23
29
  },
24
30
  {
25
31
  "name": "Area URL",
26
32
  "type": "string",
27
33
  "description": "",
28
- "required": true,
29
- "pattern": "http://statistics.data.gov.uk/doc/statistical-geography/E1500000(0-9)"
34
+ "constraints": {
35
+ "required": true,
36
+ "pattern": "http://statistics.data.gov.uk/doc/statistical-geography/(E|N|S|W)(07|15|08)00000[0-9]"
37
+ }
30
38
  },
31
39
  {
32
40
  "name": "Party",
33
41
  "type": "string",
34
42
  "description": "",
35
- "required": true
43
+ "constraints": {
44
+ "required": true
45
+ }
36
46
  },
37
47
  {
38
48
  "name": "Party ID",
39
49
  "type": "string",
40
50
  "description": "",
41
- "required": true,
42
- "pattern": "PPm? [0-9]+"
51
+ "constraints": {
52
+ "required": true,
53
+ "pattern": "PPm? [0-9]+"
54
+ }
43
55
  },
44
56
  {
45
57
  "name": "Votes",
@@ -6,40 +6,52 @@
6
6
  "name": "Poll Date",
7
7
  "type": "date",
8
8
  "description": "Date the poll took place",
9
- "format": "yyyy-mm-dd"
9
+ "constraints": {
10
+ "format": "yyyy-mm-dd"
11
+ }
10
12
  },
11
13
  {
12
14
  "name": "Area",
13
15
  "type": "string",
14
16
  "description": "The name of the area which the result is for",
15
- "required": true
17
+ "constraints": {
18
+ "required": true
19
+ }
16
20
  },
17
21
  {
18
22
  "name": "Area Code",
19
23
  "type": "number",
20
24
  "description": "The Office of National Statistics code for the area",
21
- "pattern": "E1500000(0-9)",
22
- "required": true
25
+ "constraints": {
26
+ "pattern": "(E|N|S|W)(07|15|08)00000[0-9]",
27
+ "required": true
28
+ }
23
29
  },
24
30
  {
25
31
  "name": "Area URL",
26
32
  "type": "string",
27
33
  "description": "",
28
- "required": true,
29
- "pattern": "http://statistics.data.gov.uk/doc/statistical-geography/E1500000(0-9)"
34
+ "constraints": {
35
+ "required": true,
36
+ "pattern": "http://statistics.data.gov.uk/doc/statistical-geography/(E|N|S|W)(07|15|08)00000[0-9]"
37
+ }
30
38
  },
31
39
  {
32
40
  "name": "Party",
33
41
  "type": "string",
34
42
  "description": "",
35
- "required": true
43
+ "constraints": {
44
+ "required": true
45
+ }
36
46
  },
37
47
  {
38
48
  "name": "Party ID",
39
49
  "type": "string",
40
50
  "description": "",
41
- "required": true,
42
- "pattern": "PPm? [0-9]+"
51
+ "constraints": {
52
+ "required": true,
53
+ "pattern": "PPm? [0-9]+"
54
+ }
43
55
  },
44
56
  {
45
57
  "name": "Votes",
@@ -6,65 +6,85 @@
6
6
  "name": "Poll Date",
7
7
  "type": "date",
8
8
  "description": "Date the poll took place",
9
- "format": "yyyy-mm-dd",
10
- "required": true
9
+ "constraints": {
10
+ "format": "yyyy-mm-dd",
11
+ "required": true
12
+ }
11
13
  },
12
14
  {
13
15
  "name": "Area",
14
16
  "type": "string",
15
17
  "description": "The name of the area which the result is for",
16
- "required": true
18
+ "constraints": {
19
+ "required": true
20
+ }
17
21
  },
18
22
  {
19
23
  "name": "Area Code",
20
24
  "type": "number",
21
25
  "description": "The Office of National Statistics code for the area",
22
- "required": true,
23
- "pattern": "E1500000(0-9)"
26
+ "constraints": {
27
+ "required": true,
28
+ "pattern": "(E|N|S|W)(07|15|08)00000[0-9]"
29
+ }
24
30
  },
25
31
  {
26
32
  "name": "Area URL",
27
33
  "type": "string",
28
34
  "description": "",
29
- "required": true,
30
- "pattern": "http://statistics.data.gov.uk/doc/statistical-geography/E1500000(0-9)"
35
+ "constraints": {
36
+ "required": true,
37
+ "pattern": "http://statistics.data.gov.uk/doc/statistical-geography/(E|N|S|W)(07|15|08)00000[0-9]"
38
+ }
31
39
  },
32
40
  {
33
41
  "name": "Seat",
34
42
  "type": "integer",
35
43
  "description": "",
36
- "required": true
44
+ "constraints": {
45
+ "required": true
46
+ }
37
47
  },
38
48
  {
39
49
  "name": "Party",
40
50
  "type": "string",
41
51
  "description": "",
42
- "required": true
52
+ "constraints": {
53
+ "required": true
54
+ }
43
55
  },
44
56
  {
45
57
  "name": "Party ID",
46
58
  "type": "string",
47
59
  "description": "",
48
- "required": true,
49
- "pattern": "PPm? [0-9]+"
60
+ "constraints": {
61
+ "required": true,
62
+ "pattern": "PPm? [0-9]+"
63
+ }
50
64
  },
51
65
  {
52
66
  "name": "Name",
53
67
  "type": "string",
54
68
  "description": "Name of the candidate elected to the seat",
55
- "required": true
69
+ "constraints": {
70
+ "required": true
71
+ }
56
72
  },
57
73
  {
58
74
  "name": "Address",
59
75
  "type": "string",
60
76
  "description": "Address of the candidate elected to the seat",
61
- "required": true
77
+ "constraints": {
78
+ "required": true
79
+ }
62
80
  },
63
81
  {
64
82
  "name": "Postcode",
65
83
  "type": "string",
66
84
  "description": "Postcode of the candidate elected to the seat",
67
- "pattern": "(GIR 0AA)|((([A-Z-[QVX]][0-9][0-9]?)|(([A-Z-[QVX]][A-Z-[IJZ]][0-9][0-9]?)|(([A-Z-[QVX]][0-9][A-HJKSTUW])|([A-Z-[QVX]][A-Z-[IJZ]][0-9][ABEHMNPRVWXY])))) [0-9][A-Z-[CIKMOV]]{2})"
85
+ "constraints": {
86
+ "pattern": "(GIR 0AA)|((([A-Z-[QVX]][0-9][0-9]?)|(([A-Z-[QVX]][A-Z-[IJZ]][0-9][0-9]?)|(([A-Z-[QVX]][0-9][A-HJKSTUW])|([A-Z-[QVX]][A-Z-[IJZ]][0-9][ABEHMNPRVWXY])))) [0-9][A-Z-[CIKMOV]]{2})"
87
+ }
68
88
  }
69
89
  ]
70
90
  }
@@ -6,40 +6,52 @@
6
6
  "name": "Poll Date",
7
7
  "type": "date",
8
8
  "description": "Date the poll took place",
9
- "format": "yyyy-mm-dd"
9
+ "constraints": {
10
+ "format": "yyyy-mm-dd"
11
+ }
10
12
  },
11
13
  {
12
14
  "name": "Area",
13
15
  "type": "string",
14
16
  "description": "The name of the area which the result is for",
15
- "required": true
17
+ "constraints": {
18
+ "required": true
19
+ }
16
20
  },
17
21
  {
18
22
  "name": "Area Code",
19
23
  "type": "number",
20
24
  "description": "The Office of National Statistics code for the area",
21
- "pattern": "E1500000(0-9)",
22
- "required": true
25
+ "constraints": {
26
+ "pattern": "(E|N|S|W)(07|15|08)00000[0-9]",
27
+ "required": true
28
+ }
23
29
  },
24
30
  {
25
31
  "name": "Area URL",
26
32
  "type": "string",
27
33
  "description": "",
28
- "required": true,
29
- "pattern": "http://statistics.data.gov.uk/doc/statistical-geography/E1500000(0-9)"
34
+ "constraints": {
35
+ "required": true,
36
+ "pattern": "http://statistics.data.gov.uk/doc/statistical-geography/(E|N|S|W)(07|15|08)00000[0-9]"
37
+ }
30
38
  },
31
39
  {
32
40
  "name": "Party",
33
41
  "type": "string",
34
42
  "description": "",
35
- "required": true
43
+ "constraints": {
44
+ "required": true
45
+ }
36
46
  },
37
47
  {
38
48
  "name": "Party ID",
39
49
  "type": "string",
40
50
  "description": "",
41
- "required": true,
42
- "pattern": "PPm? [0-9]+"
51
+ "constraints": {
52
+ "required": true,
53
+ "pattern": "PPm? [0-9]+"
54
+ }
43
55
  },
44
56
  {
45
57
  "name": "Votes",
@@ -17,40 +17,52 @@
17
17
  "name": "Poll Date",
18
18
  "type": "date",
19
19
  "description": "Date the poll took place",
20
- "format": "yyyy-mm-dd"
20
+ "constraints": {
21
+ "format": "yyyy-mm-dd"
22
+ }
21
23
  },
22
24
  {
23
25
  "name": "Area",
24
26
  "type": "string",
25
27
  "description": "The name of the area which the result is for",
26
- "required": true
28
+ "constraints": {
29
+ "required": true
30
+ }
27
31
  },
28
32
  {
29
33
  "name": "Area Code",
30
34
  "type": "number",
31
35
  "description": "The Office of National Statistics code for the area",
32
- "pattern": "E1500000(0-9)",
33
- "required": true
36
+ "constraints": {
37
+ "pattern": "(E|N|S|W)(07|15|08)00000[0-9]",
38
+ "required": true
39
+ }
34
40
  },
35
41
  {
36
42
  "name": "Area URL",
37
43
  "type": "string",
38
44
  "description": "",
39
- "required": true,
40
- "pattern": "http://statistics.data.gov.uk/doc/statistical-geography/E1500000(0-9)"
45
+ "constraints": {
46
+ "required": true,
47
+ "pattern": "http://statistics.data.gov.uk/doc/statistical-geography/(E|N|S|W)(07|15|08)00000[0-9]"
48
+ }
41
49
  },
42
50
  {
43
51
  "name": "Party",
44
52
  "type": "string",
45
53
  "description": "",
46
- "required": true
54
+ "constraints": {
55
+ "required": true
56
+ }
47
57
  },
48
58
  {
49
59
  "name": "Party ID",
50
60
  "type": "string",
51
61
  "description": "",
52
- "required": true,
53
- "pattern": "PPm? [0-9]+"
62
+ "constraints": {
63
+ "required": true,
64
+ "pattern": "PPm? [0-9]+"
65
+ }
54
66
  },
55
67
  {
56
68
  "name": "Votes",
@@ -6,40 +6,52 @@
6
6
  "name": "Poll Date",
7
7
  "type": "date",
8
8
  "description": "Date the poll took place",
9
- "format": "yyyy-mm-dd"
9
+ "constraints": {
10
+ "format": "yyyy-mm-dd"
11
+ }
10
12
  },
11
13
  {
12
14
  "name": "Area",
13
15
  "type": "string",
14
16
  "description": "The name of the area which the result is for",
15
- "required": true
17
+ "constraints": {
18
+ "required": true
19
+ }
16
20
  },
17
21
  {
18
22
  "name": "Area Code",
19
23
  "type": "number",
20
24
  "description": "The Office of National Statistics code for the area",
21
- "pattern": "E1500000(0-9)",
22
- "required": true
25
+ "constraints": {
26
+ "pattern": "(E|N|S|W)(07|15|08)00000[0-9]",
27
+ "required": true
28
+ }
23
29
  },
24
30
  {
25
31
  "name": "Area URL",
26
32
  "type": "string",
27
33
  "description": "",
28
- "required": true,
29
- "pattern": "http://statistics.data.gov.uk/doc/statistical-geography/E1500000(0-9)"
34
+ "constraints": {
35
+ "required": true,
36
+ "pattern": "http://statistics.data.gov.uk/doc/statistical-geography/(E|N|S|W)(07|15|08)00000[0-9]"
37
+ }
30
38
  },
31
39
  {
32
40
  "name": "Party",
33
41
  "type": "string",
34
42
  "description": "",
35
- "required": true
43
+ "constraints": {
44
+ "required": true
45
+ }
36
46
  },
37
47
  {
38
48
  "name": "Party ID",
39
49
  "type": "string",
40
50
  "description": "",
41
- "required": true,
42
- "pattern": "PPm? [0-9]+"
51
+ "constraints": {
52
+ "required": true,
53
+ "pattern": "PPm? [0-9]+"
54
+ }
43
55
  },
44
56
  {
45
57
  "name": "Votes",
@@ -67,4 +67,13 @@ describe Cid::Validation do
67
67
  validation["votes/votes-1.csv"][:warnings].should == []
68
68
  end
69
69
 
70
+ it "supports schemas within the datapackage.json" do
71
+ Csvlint::Validator.should_receive(:new).once.and_call_original
72
+
73
+ validation = Cid::Validation.validate(File.join(File.dirname(__FILE__), 'fixtures', 'datapackage_valid'))
74
+
75
+ validation["votes/votes-1.csv"][:errors].should == []
76
+ validation["votes/votes-1.csv"][:warnings].should == []
77
+ end
78
+
70
79
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - pezholio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-25 00:00:00.000000000 Z
11
+ date: 2014-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: csvlint
@@ -328,6 +328,7 @@ files:
328
328
  - lib/cid.rb
329
329
  - lib/cid/bootstrap.rb
330
330
  - lib/cid/datapackage.rb
331
+ - lib/cid/helpers/file.rb
331
332
  - lib/cid/helpers/github.rb
332
333
  - lib/cid/publish.rb
333
334
  - lib/cid/validation.rb
@@ -340,6 +341,8 @@ files:
340
341
  - spec/cassettes/Cid_Publish/should_be_able_to_get_latest_commit_SHA_on_a_branch.yml
341
342
  - spec/cassettes/Cid_Publish/should_push_to_the_default_branch.yml
342
343
  - spec/datapackage_spec.rb
344
+ - spec/fixtures/datapackage_valid/datapackage.json
345
+ - spec/fixtures/datapackage_valid/votes/votes-1.csv
343
346
  - spec/fixtures/invalid/votes/schema.json
344
347
  - spec/fixtures/invalid/votes/votes-1.csv
345
348
  - spec/fixtures/multiple_files/datapackage.json
@@ -397,6 +400,8 @@ test_files:
397
400
  - spec/cassettes/Cid_Publish/should_be_able_to_get_latest_commit_SHA_on_a_branch.yml
398
401
  - spec/cassettes/Cid_Publish/should_push_to_the_default_branch.yml
399
402
  - spec/datapackage_spec.rb
403
+ - spec/fixtures/datapackage_valid/datapackage.json
404
+ - spec/fixtures/datapackage_valid/votes/votes-1.csv
400
405
  - spec/fixtures/invalid/votes/schema.json
401
406
  - spec/fixtures/invalid/votes/votes-1.csv
402
407
  - spec/fixtures/multiple_files/datapackage.json