spout 0.0.1.pre → 0.1.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -1
- data/README.md +22 -2
- data/bin/spout +1 -1
- data/lib/spout/actions.rb +4 -6
- data/lib/spout/tasks/engine.rake +2 -7
- data/lib/spout/tests.rb +16 -0
- data/lib/spout/tests/domain_existence_validation.rb +15 -0
- data/lib/spout/tests/json_validation.rb +19 -0
- data/lib/spout/tests/variable_type_validation.rb +14 -0
- data/lib/spout/version.rb +2 -2
- metadata +6 -3
- data/lib/spout/test_helpers.rb +0 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 880fd246ea520f004a09cf9bf2b576d5866c9850
|
4
|
+
data.tar.gz: 65d2e48269923e7a46cd7448fa8e265c3ad8ac6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bad0c66a8fc3e992e3affcd6cff667a749f6acd0db8b858cd53d37af5961f1db83003d98b8f4bb205c111074053d19d82689b41a4f3b16ba93d60fd8835983ed
|
7
|
+
data.tar.gz: ec2ce69aa8c5157d7d4345ad12d78c91564951afc1c564868c2c8c17dc6993b6a9d82cd52fd6edca05e0329021e3c62a5442f969ef74bdb39073f78f4296a63b
|
data/CHANGELOG.md
CHANGED
@@ -1 +1,15 @@
|
|
1
|
-
|
1
|
+
## 0.1.0
|
2
|
+
|
3
|
+
### Enhancements
|
4
|
+
- Existing Data Dictionaries can be converted to JSON format from a CSV file
|
5
|
+
- Added a rake task to create CSVs of the JSON data dictionary
|
6
|
+
- Added tests for JSON validity of variables and domains
|
7
|
+
- Added test to check presence/validity of variable type
|
8
|
+
- Added test to check if a domain referenced from a variable exists
|
9
|
+
- Tests can now be added as a group, or on a test-by-test basis
|
10
|
+
- Add `require 'spout/tests'` to your individual tests, or to your `test_helper.rb`
|
11
|
+
- Include the all or some of the tests provided by Spout
|
12
|
+
- `include Spout::Tests` for all tests
|
13
|
+
- `include Spout::Tests::JsonValidation` to verify valid JSON formats of domains and variables
|
14
|
+
- `include Spout::Tests::VariableTypeValidation` to verify valid variable type for variables
|
15
|
+
- `include Spout::Tests::DomainExistenceValidation` to verify existence of domains referenced by variables
|
data/README.md
CHANGED
@@ -30,12 +30,32 @@ bundle exec rake dd:import CSV=data_dictionary.csv
|
|
30
30
|
|
31
31
|
### Test your repository
|
32
32
|
|
33
|
+
|
33
34
|
```
|
34
|
-
spout
|
35
|
+
require 'spout/tests'
|
36
|
+
|
37
|
+
class DictionaryTest < Test::Unit::TestCase
|
38
|
+
include Spout::Tests
|
39
|
+
end
|
35
40
|
```
|
36
41
|
|
42
|
+
```
|
43
|
+
require 'spout/tests'
|
44
|
+
|
45
|
+
class DictionaryTest < Test::Unit::TestCase
|
46
|
+
# Or only include certain tests
|
47
|
+
include Spout::Tests::JsonValidation
|
48
|
+
include Spout::Tests::VariableTypeValidation
|
49
|
+
end
|
50
|
+
```
|
51
|
+
|
52
|
+
Then run either `bundle exec rake` or `spout test` to run your tests
|
53
|
+
|
54
|
+
|
37
55
|
### Create a CSV Data Dictionary from your JSON repository
|
38
56
|
|
57
|
+
Provide an optional version parameter to name the folder the CSVs will be generated in, defaults to 1.0.0 currently.
|
58
|
+
|
39
59
|
```
|
40
|
-
bundle exec rake dd:create
|
60
|
+
bundle exec rake dd:create [VERSION]
|
41
61
|
```
|
data/bin/spout
CHANGED
data/lib/spout/actions.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Spout
|
2
|
-
|
2
|
+
class Actions
|
3
3
|
|
4
|
-
def
|
4
|
+
def help
|
5
5
|
help_message = <<-EOT
|
6
6
|
|
7
7
|
Usage: spout COMMAND [ARGS]
|
@@ -16,16 +16,14 @@ EOT
|
|
16
16
|
puts help_message
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
19
|
+
def interpret(argv)
|
20
20
|
case argv.first
|
21
21
|
when '--version', '-v', 'version'
|
22
22
|
puts "Spout #{Spout::VERSION::STRING}"
|
23
|
-
# exit(0)
|
24
23
|
when 'help', '--help', '-h'
|
25
24
|
help
|
26
|
-
exit(0)
|
27
25
|
else
|
28
|
-
|
26
|
+
system "bundle exec rake"
|
29
27
|
end
|
30
28
|
end
|
31
29
|
|
data/lib/spout/tasks/engine.rake
CHANGED
@@ -1,10 +1,5 @@
|
|
1
1
|
require 'rake/testtask'
|
2
2
|
|
3
|
-
desc 'do something'
|
4
|
-
task :something do
|
5
|
-
puts "something"
|
6
|
-
end
|
7
|
-
|
8
3
|
Rake::TestTask.new do |t|
|
9
4
|
t.libs << "test"
|
10
5
|
t.test_files = FileList['test/**/*_test.rb']
|
@@ -12,6 +7,8 @@ Rake::TestTask.new do |t|
|
|
12
7
|
t.verbose = true
|
13
8
|
end
|
14
9
|
|
10
|
+
task :default => :test
|
11
|
+
|
15
12
|
namespace :dd do
|
16
13
|
require 'csv'
|
17
14
|
require 'fileutils'
|
@@ -79,5 +76,3 @@ namespace :dd do
|
|
79
76
|
end
|
80
77
|
end
|
81
78
|
end
|
82
|
-
|
83
|
-
task :default => :test
|
data/lib/spout/tests.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'turn/autorun'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
require 'spout/tests/domain_existence_validation'
|
7
|
+
require 'spout/tests/json_validation'
|
8
|
+
require 'spout/tests/variable_type_validation'
|
9
|
+
|
10
|
+
module Spout
|
11
|
+
module Tests
|
12
|
+
include Spout::Tests::JsonValidation
|
13
|
+
include Spout::Tests::VariableTypeValidation
|
14
|
+
include Spout::Tests::DomainExistenceValidation
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Spout
|
2
|
+
module Tests
|
3
|
+
module DomainExistenceValidation
|
4
|
+
|
5
|
+
Dir.glob("variables/**/*.json").each do |file|
|
6
|
+
if (not [nil, ''].include?(JSON.parse(File.read(file))["domain"]) rescue false)
|
7
|
+
define_method("test_domain_exists: "+file) do
|
8
|
+
assert_equal true, (File.exists?(File.join("domains", JSON.parse(File.read(file))["domain"]+".json")) rescue false)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Spout
|
2
|
+
module Tests
|
3
|
+
module JsonValidation
|
4
|
+
|
5
|
+
Dir.glob("variables/**/*.json").each do |file|
|
6
|
+
define_method("test_json: "+file) do
|
7
|
+
assert_equal true, (!!JSON.parse(File.read(file)) rescue false)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
Dir.glob("domains/**/*.json").each do |file|
|
12
|
+
define_method("test_json: "+file) do
|
13
|
+
assert_equal true, (!!JSON.parse(File.read(file)) rescue false)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Spout
|
2
|
+
module Tests
|
3
|
+
module VariableTypeValidation
|
4
|
+
VALID_VARIABLE_TYPES = ['identifier', 'choices', 'integer', 'numeric']
|
5
|
+
|
6
|
+
Dir.glob("variables/**/*.json").each do |file|
|
7
|
+
define_method("test_variable_type: "+file) do
|
8
|
+
assert_equal true, (VALID_VARIABLE_TYPES.include?(JSON.parse(File.read(file))["type"]) rescue false)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
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.0.
|
4
|
+
version: 0.1.0.pre
|
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-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -80,7 +80,10 @@ files:
|
|
80
80
|
- lib/spout/application.rb
|
81
81
|
- lib/spout/tasks/engine.rake
|
82
82
|
- lib/spout/tasks.rb
|
83
|
-
- lib/spout/
|
83
|
+
- lib/spout/tests/domain_existence_validation.rb
|
84
|
+
- lib/spout/tests/json_validation.rb
|
85
|
+
- lib/spout/tests/variable_type_validation.rb
|
86
|
+
- lib/spout/tests.rb
|
84
87
|
- lib/spout/version.rb
|
85
88
|
- lib/spout.rb
|
86
89
|
- CHANGELOG.md
|
data/lib/spout/test_helpers.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'turn/autorun'
|
2
|
-
require 'test/unit'
|
3
|
-
require 'rubygems'
|
4
|
-
require 'json'
|
5
|
-
|
6
|
-
module Spout
|
7
|
-
module TestHelpers
|
8
|
-
VALID_VARIABLE_TYPES = ['identifier', 'choices', 'integer', 'numeric']
|
9
|
-
|
10
|
-
class TestCase < Test::Unit::TestCase
|
11
|
-
Dir.glob("domains/**/*.json").each do |file|
|
12
|
-
define_method("test_json: "+file) do
|
13
|
-
assert_equal true, (!!JSON.parse(File.read(file)) rescue false)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
Dir.glob("variables/**/*.json").each do |file|
|
18
|
-
|
19
|
-
define_method("test_json: "+file) do
|
20
|
-
assert_equal true, (!!JSON.parse(File.read(file)) rescue false)
|
21
|
-
end
|
22
|
-
|
23
|
-
define_method("test_variable_type: "+file) do
|
24
|
-
assert_equal true, (::VALID_VARIABLE_TYPES.include?(JSON.parse(File.read(file))["type"]) rescue false)
|
25
|
-
end
|
26
|
-
|
27
|
-
if (not [nil, ''].include?(JSON.parse(File.read(file))["domain"]) rescue false)
|
28
|
-
define_method("test_domain_exists: "+file) do
|
29
|
-
assert_equal true, (File.exists?(File.join("domains", JSON.parse(File.read(file))["domain"]+".json")) rescue false)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
39
|
-
end
|