spout 0.1.0.rc → 0.1.0.rc2
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 +4 -4
- data/README.md +11 -2
- data/lib/spout/tasks/engine.rake +1 -1
- data/lib/spout/templates/test/dictionary_test.rb +1 -1
- data/lib/spout/tests/domain_existence_validation.rb +15 -1
- data/lib/spout/tests/json_validation.rb +15 -2
- data/lib/spout/tests/variable_type_validation.rb +9 -2
- data/lib/spout/tests.rb +2 -0
- data/lib/spout/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 107e09d3629aadfb7fd0e06b27c115a2d0e87fbd
|
4
|
+
data.tar.gz: 62ea6faceb8218158e870aebedb42ac3047a2a66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d5710e58b74e66277fa1dd0c6a85fbf63edbea619e5b51c5b7720b00f786d7c43586e07f99733432f61c06ac6f83f8daabcf56d12b924a67acb553bc8bfae3b
|
7
|
+
data.tar.gz: a94c8b3c1bfd03586f62079dd01d91cd4563f2fbed2fabaf34d900ea2bc1d5801c22a8ad61846948b6ca80bce0d535aea8a9d741f82b86a9e3fd2ab5d8aee8bd
|
data/README.md
CHANGED
@@ -25,11 +25,20 @@ spout new my_data_dictionary
|
|
25
25
|
|
26
26
|
cd my_data_dictionary
|
27
27
|
|
28
|
-
spout import
|
28
|
+
spout import data_dictionary.csv
|
29
29
|
```
|
30
30
|
|
31
31
|
### Test your repository
|
32
32
|
|
33
|
+
If you created your data dictionary repository using `spout new`, you can go ahead and test using:
|
34
|
+
|
35
|
+
```
|
36
|
+
spout test
|
37
|
+
```
|
38
|
+
|
39
|
+
If not, you can add the following to your `test` directory to include all Spout tests, or just a subset of Spout tests.
|
40
|
+
|
41
|
+
`test/dictionary_test.rb`
|
33
42
|
|
34
43
|
```
|
35
44
|
require 'spout/tests'
|
@@ -49,7 +58,7 @@ class DictionaryTest < Test::Unit::TestCase
|
|
49
58
|
end
|
50
59
|
```
|
51
60
|
|
52
|
-
Then run either `
|
61
|
+
Then run either `spout test` or `bundle exec rake` to run your tests.
|
53
62
|
|
54
63
|
|
55
64
|
### Create a CSV Data Dictionary from your JSON repository
|
data/lib/spout/tasks/engine.rake
CHANGED
@@ -54,7 +54,7 @@ namespace :dd do
|
|
54
54
|
CSV.parse( File.open(ENV['CSV'].to_s, 'r:iso-8859-1:utf-8'){|f| f.read}, headers: true ) do |line|
|
55
55
|
row = line.to_hash
|
56
56
|
next if row['id'] == ''
|
57
|
-
folder = File.join('variables', row
|
57
|
+
folder = File.join('variables', row.delete('folder').to_s.gsub(':', '/'))
|
58
58
|
FileUtils.mkpath folder
|
59
59
|
hash = {}
|
60
60
|
id = row.delete('id')
|
@@ -2,10 +2,24 @@ module Spout
|
|
2
2
|
module Tests
|
3
3
|
module DomainExistenceValidation
|
4
4
|
|
5
|
+
def assert_domain_existence(item, msg = nil)
|
6
|
+
result = begin
|
7
|
+
domain_name = JSON.parse(File.read(item))["domain"]+".json"
|
8
|
+
File.exists?(File.join("domains", domain_name))
|
9
|
+
rescue JSON::ParserError => e
|
10
|
+
error = e
|
11
|
+
false
|
12
|
+
end
|
13
|
+
full_message = build_message(msg, "The domain \"domains/#{domain_name}\" referenced by ? does not exist.", item)
|
14
|
+
assert_block(full_message) do
|
15
|
+
result
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
5
19
|
Dir.glob("variables/**/*.json").each do |file|
|
6
20
|
if (not [nil, ''].include?(JSON.parse(File.read(file))["domain"]) rescue false)
|
7
21
|
define_method("test_domain_exists: "+file) do
|
8
|
-
|
22
|
+
assert_domain_existence file
|
9
23
|
end
|
10
24
|
end
|
11
25
|
end
|
@@ -2,15 +2,28 @@ module Spout
|
|
2
2
|
module Tests
|
3
3
|
module JsonValidation
|
4
4
|
|
5
|
+
def assert_valid_json(item, msg = nil)
|
6
|
+
result = begin
|
7
|
+
!!JSON.parse(File.read(item))
|
8
|
+
rescue JSON::ParserError => e
|
9
|
+
error = e
|
10
|
+
false
|
11
|
+
end
|
12
|
+
full_message = build_message(msg, "?", error)
|
13
|
+
assert_block(full_message) do
|
14
|
+
result
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
5
18
|
Dir.glob("variables/**/*.json").each do |file|
|
6
19
|
define_method("test_json: "+file) do
|
7
|
-
|
20
|
+
assert_valid_json file
|
8
21
|
end
|
9
22
|
end
|
10
23
|
|
11
24
|
Dir.glob("domains/**/*.json").each do |file|
|
12
25
|
define_method("test_json: "+file) do
|
13
|
-
|
26
|
+
assert_valid_json file
|
14
27
|
end
|
15
28
|
end
|
16
29
|
|
@@ -1,11 +1,18 @@
|
|
1
1
|
module Spout
|
2
2
|
module Tests
|
3
3
|
module VariableTypeValidation
|
4
|
-
VALID_VARIABLE_TYPES = ['identifier', 'choices', 'integer', 'numeric']
|
4
|
+
VALID_VARIABLE_TYPES = ['identifier', 'choices', 'integer', 'numeric'].sort
|
5
|
+
|
6
|
+
def assert_variable_type(item, msg = nil)
|
7
|
+
full_message = build_message(msg, "? invalid variable type. Valid types: #{VALID_VARIABLE_TYPES.join(', ')}", item)
|
8
|
+
assert_block(full_message) do
|
9
|
+
VALID_VARIABLE_TYPES.include?(item)
|
10
|
+
end
|
11
|
+
end
|
5
12
|
|
6
13
|
Dir.glob("variables/**/*.json").each do |file|
|
7
14
|
define_method("test_variable_type: "+file) do
|
8
|
-
|
15
|
+
assert_variable_type begin JSON.parse(File.read(file))["type"] rescue nil end
|
9
16
|
end
|
10
17
|
end
|
11
18
|
|
data/lib/spout/tests.rb
CHANGED
data/lib/spout/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.rc2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Remo Mueller
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-05-
|
11
|
+
date: 2013-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|