spout 0.8.0.beta12 → 0.8.0.beta13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +49 -0
- data/lib/spout/commands/exporter.rb +1 -0
- data/lib/spout/models/outlier_result.rb +2 -1
- data/lib/spout/tests/form_existence_validation.rb +30 -0
- data/lib/spout/tests/form_name_match.rb +11 -0
- data/lib/spout/tests/form_name_uniqueness.rb +10 -0
- data/lib/spout/tests/json_validation.rb +6 -0
- data/lib/spout/tests.rb +6 -0
- data/lib/spout/version.rb +1 -1
- data/lib/spout/views/outliers.html.erb +2 -0
- metadata +4 -2
- data/lib/spout/actions.rb +0 -92
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8fa45a4222ddcbf78606e4f3e36aad831162ce3
|
4
|
+
data.tar.gz: 134a7e8590e72a7be9067504cd680a91e564516d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d74fa1bf7c3d79da5900a485961d574f07b4031ec0b39c62c62938b85cf3499d46c8bab9f570849604c2b51aaadd79e1dfaa761d8eedf26af090727a3d0abc8
|
7
|
+
data.tar.gz: c5bf687c4da5159804b1746bfa7580a8eb4030ed0034a72191b29b9bc3141165fd0e9ecadf0688c78a16c18d074b822a8c3a61012d18160127cda7a7d44db3b4
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
## 0.8.0
|
2
2
|
|
3
3
|
### Enhancements
|
4
|
+
- Tests now include check for variables that reference one or more forms
|
5
|
+
- `include Spout::Tests::FormExistenceValidation`
|
6
|
+
- `include Spout::Tests::FormNameUniqueness`
|
7
|
+
- `include Spout::Tests::FormNameMatch`
|
4
8
|
- Added `spout graphs` command that generates JSON charts and tables of each variable in a dataset
|
5
9
|
- This command requires a .spout.yml file to be specified to identify the following variables:
|
6
10
|
- `visit`: This variable is used to separate subject encounters in a histogram
|
data/README.md
CHANGED
@@ -120,6 +120,9 @@ class DictionaryTest < Test::Unit::TestCase
|
|
120
120
|
include Spout::Tests::DomainExistenceValidation
|
121
121
|
include Spout::Tests::DomainFormat
|
122
122
|
include Spout::Tests::DomainNameUniqueness
|
123
|
+
include Spout::Tests::FormExistenceValidation
|
124
|
+
include Spout::Tests::FormNameUniqueness
|
125
|
+
include Spout::Tests::FormNameMatch
|
123
126
|
end
|
124
127
|
```
|
125
128
|
|
@@ -233,3 +236,49 @@ This will generate a graph for ahi for the first 10 rows of each dataset CSV.
|
|
233
236
|
|
234
237
|
|
235
238
|
This will generate charts and tables for each variable in the dataset plotted against the variables listed under `charts`.
|
239
|
+
|
240
|
+
### Example Variable that references a Domain and a Form
|
241
|
+
|
242
|
+
`variables/Demographics/gender.json`
|
243
|
+
```json
|
244
|
+
{
|
245
|
+
"id": "gender",
|
246
|
+
"display_name": "Gender",
|
247
|
+
"description": "Gender as reported by subject",
|
248
|
+
"type": "choices",
|
249
|
+
"domain": "gender12",
|
250
|
+
"labels": [
|
251
|
+
"gender"
|
252
|
+
],
|
253
|
+
"commonly_used": true,
|
254
|
+
"forms": [
|
255
|
+
"intake_questionnaire"
|
256
|
+
]
|
257
|
+
}
|
258
|
+
```
|
259
|
+
|
260
|
+
`domains/gender12.json`
|
261
|
+
```json
|
262
|
+
[
|
263
|
+
{
|
264
|
+
"value": "1",
|
265
|
+
"display_name": "Male",
|
266
|
+
"description": ""
|
267
|
+
},
|
268
|
+
{
|
269
|
+
"value": "2",
|
270
|
+
"display_name": "Female",
|
271
|
+
"description": ""
|
272
|
+
}
|
273
|
+
]
|
274
|
+
```
|
275
|
+
|
276
|
+
`forms/Baseline Visit/intake_questionnaire.json`
|
277
|
+
```json
|
278
|
+
{
|
279
|
+
"id": "intake_questionnaire",
|
280
|
+
"display_name": "Intake Questionnaire at Baseline Visit",
|
281
|
+
"code_book": "Baseline-Visit-Intake-Questionnaire.pdf"
|
282
|
+
}
|
283
|
+
```
|
284
|
+
|
@@ -4,7 +4,7 @@ require 'spout/helpers/json_loader'
|
|
4
4
|
module Spout
|
5
5
|
module Models
|
6
6
|
class OutlierResult
|
7
|
-
attr_reader :csv_files, :method, :major_outliers, :minor_outliers, :outliers, :weight, :units, :median
|
7
|
+
attr_reader :csv_files, :method, :major_outliers, :minor_outliers, :outliers, :weight, :units, :display_name, :median
|
8
8
|
|
9
9
|
def initialize(subjects, method, csv_files)
|
10
10
|
@values = subjects.collect(&method.to_sym)
|
@@ -23,6 +23,7 @@ module Spout
|
|
23
23
|
end
|
24
24
|
variable = Spout::Helpers::JsonLoader::get_variable(method)
|
25
25
|
@units = (variable.kind_of?(Hash) ? variable['units'] : nil)
|
26
|
+
@display_name = (variable.kind_of?(Hash) ? variable['display_name'] : nil)
|
26
27
|
@median = @values.median
|
27
28
|
end
|
28
29
|
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Spout
|
2
|
+
module Tests
|
3
|
+
module FormExistenceValidation
|
4
|
+
|
5
|
+
def assert_form_existence(item, msg = nil)
|
6
|
+
form_names = Dir.glob("forms/**/*.json").collect{|file| file.split('/').last.to_s.downcase.split('.json').first}
|
7
|
+
|
8
|
+
result = begin
|
9
|
+
(form_names | JSON.parse(File.read(item))["forms"]).size == form_names.size
|
10
|
+
rescue JSON::ParserError
|
11
|
+
false
|
12
|
+
end
|
13
|
+
|
14
|
+
full_message = build_message(msg, "One or more forms referenced by ? does not exist.", item)
|
15
|
+
assert_block(full_message) do
|
16
|
+
result
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
Dir.glob("variables/**/*.json").each do |file|
|
21
|
+
if (not [nil, ''].include?(JSON.parse(File.read(file))["forms"]) rescue false)
|
22
|
+
define_method("test_form_exists: "+file) do
|
23
|
+
assert_form_existence file
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Spout
|
2
|
+
module Tests
|
3
|
+
module FormNameMatch
|
4
|
+
Dir.glob("forms/**/*.json").each do |file|
|
5
|
+
define_method("test_form_name_match: "+file) do
|
6
|
+
assert_equal file.gsub(/^.*\//, '').gsub('.json', '').downcase, (begin JSON.parse(File.read(file))["id"] rescue nil end)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
data/lib/spout/tests.rb
CHANGED
@@ -11,6 +11,9 @@ require 'spout/tests/domain_existence_validation'
|
|
11
11
|
require 'spout/tests/domain_format'
|
12
12
|
require 'spout/tests/domain_name_uniqueness'
|
13
13
|
require 'spout/tests/domain_specified'
|
14
|
+
require 'spout/tests/form_existence_validation'
|
15
|
+
require 'spout/tests/form_name_uniqueness'
|
16
|
+
require 'spout/tests/form_name_match'
|
14
17
|
|
15
18
|
module Spout
|
16
19
|
module Tests
|
@@ -22,6 +25,9 @@ module Spout
|
|
22
25
|
include Spout::Tests::DomainFormat
|
23
26
|
include Spout::Tests::DomainNameUniqueness
|
24
27
|
include Spout::Tests::DomainSpecified
|
28
|
+
include Spout::Tests::FormExistenceValidation
|
29
|
+
include Spout::Tests::FormNameUniqueness
|
30
|
+
include Spout::Tests::FormNameMatch
|
25
31
|
|
26
32
|
Turn.config.trace = 1
|
27
33
|
end
|
data/lib/spout/version.rb
CHANGED
@@ -115,6 +115,7 @@ tfoot td {
|
|
115
115
|
<tr>
|
116
116
|
<th>CSV</th>
|
117
117
|
<th>Column</th>
|
118
|
+
<th>Display Name</th>
|
118
119
|
<th>Median</th>
|
119
120
|
<th>Major Outliers</th>
|
120
121
|
<th>Minor Outliers</th>
|
@@ -130,6 +131,7 @@ tfoot td {
|
|
130
131
|
<code class="<%= css_class %>"><%= csv_file %></code><br />
|
131
132
|
<% end %></td>
|
132
133
|
<td><%= outlier_result.method %></td>
|
134
|
+
<td><%= outlier_result.display_name.to_s[0..20] %></td>
|
133
135
|
<td>
|
134
136
|
<% if outlier_result.median.kind_of?(Numeric) %>
|
135
137
|
<code class="default"><%= number_with_delimiter(outlier_result.median.round(2)) %></code>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.0.
|
4
|
+
version: 0.8.0.beta13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Remo Mueller
|
@@ -95,7 +95,6 @@ files:
|
|
95
95
|
- Rakefile
|
96
96
|
- bin/spout
|
97
97
|
- lib/spout.rb
|
98
|
-
- lib/spout/actions.rb
|
99
98
|
- lib/spout/application.rb
|
100
99
|
- lib/spout/commands/coverage.rb
|
101
100
|
- lib/spout/commands/exporter.rb
|
@@ -135,6 +134,9 @@ files:
|
|
135
134
|
- lib/spout/tests/domain_format.rb
|
136
135
|
- lib/spout/tests/domain_name_uniqueness.rb
|
137
136
|
- lib/spout/tests/domain_specified.rb
|
137
|
+
- lib/spout/tests/form_existence_validation.rb
|
138
|
+
- lib/spout/tests/form_name_match.rb
|
139
|
+
- lib/spout/tests/form_name_uniqueness.rb
|
138
140
|
- lib/spout/tests/json_helper.rb
|
139
141
|
- lib/spout/tests/json_validation.rb
|
140
142
|
- lib/spout/tests/variable_name_match.rb
|
data/lib/spout/actions.rb
DELETED
@@ -1,92 +0,0 @@
|
|
1
|
-
# module Spout
|
2
|
-
# class Actions
|
3
|
-
|
4
|
-
# def interpret(argv)
|
5
|
-
# # case argv.first.to_s.scan(/\w/).first
|
6
|
-
# case argv.first
|
7
|
-
# when 'new', 'n', 'ne', '-new', '-n', '-ne'
|
8
|
-
# new_template_dictionary(argv)
|
9
|
-
# when '--version', '-v', '-ve', '-ver', 'version', 'v', 've', 'ver'
|
10
|
-
# puts "Spout #{Spout::VERSION::STRING}"
|
11
|
-
# when 'test', 't', 'te', 'tes', '--test', '-t', '-te', '-tes'
|
12
|
-
# system "bundle exec rake HIDE_PASSING_TESTS=true"
|
13
|
-
# # when 'tv'
|
14
|
-
# # system "bundle exec rake"
|
15
|
-
# when 'import', 'i', 'im', 'imp', '--import', '-i', '-im', '-imp'
|
16
|
-
# import_from_csv(argv)
|
17
|
-
# when 'import_domain', '--import_domain', 'import_domains', '--import_domains'
|
18
|
-
# import_from_csv(argv, 'domains')
|
19
|
-
# when 'export', 'e', 'ex', 'exp', '--export', '-e', '-ex', '-exp'
|
20
|
-
# new_data_dictionary_export(argv)
|
21
|
-
# when 'coverage', '-coverage', '--coverage', 'c', '-c'
|
22
|
-
# coverage_report(argv)
|
23
|
-
# when 'pngs', '-pngs', '--pngs', 'p', '-p'
|
24
|
-
# generate_images(argv.last(argv.size - 1))
|
25
|
-
# when 'graphs', '-graphs', '--graphs', 'g', '-g'
|
26
|
-
# generate_charts_and_tables(argv.last(argv.size - 1))
|
27
|
-
# when 'outliers', '-outliers', '--outliers', 'o', '-o'
|
28
|
-
# outliers_report(argv)
|
29
|
-
# # else
|
30
|
-
# # help
|
31
|
-
# end
|
32
|
-
# end
|
33
|
-
|
34
|
-
# protected
|
35
|
-
|
36
|
-
# def csv_usage
|
37
|
-
# usage = <<-EOT
|
38
|
-
|
39
|
-
# Usage: spout import CSVFILE
|
40
|
-
|
41
|
-
# The CSVFILE must be the location of a valid CSV file.
|
42
|
-
|
43
|
-
# EOT
|
44
|
-
# usage
|
45
|
-
# end
|
46
|
-
|
47
|
-
# def import_from_csv(argv, type = "")
|
48
|
-
# csv_file = File.join(argv[1].to_s.strip)
|
49
|
-
# if File.exists?(csv_file)
|
50
|
-
# system "bundle exec rake spout:import CSV=#{csv_file} #{'TYPE='+type if type.to_s != ''}"
|
51
|
-
# else
|
52
|
-
# puts csv_usage
|
53
|
-
# end
|
54
|
-
# end
|
55
|
-
|
56
|
-
# def new_data_dictionary_export(argv)
|
57
|
-
# version = argv[1].to_s.gsub(/[^a-zA-Z0-9\.-]/, '_').strip
|
58
|
-
# version_string = (version == '' ? "" : "VERSION=#{version}")
|
59
|
-
# system "bundle exec rake spout:create #{version_string}"
|
60
|
-
# end
|
61
|
-
|
62
|
-
# def coverage_report(argv)
|
63
|
-
# require 'spout/commands/coverage'
|
64
|
-
# Spout::Commands::Coverage.new(standard_version, argv)
|
65
|
-
# # system "bundle exec rake spout:coverage"
|
66
|
-
# end
|
67
|
-
|
68
|
-
# def outliers_report(argv)
|
69
|
-
# system "bundle exec rake spout:outliers"
|
70
|
-
# end
|
71
|
-
|
72
|
-
# def flag_values(flags, param)
|
73
|
-
# flags.select{|f| f[0..((param.size + 3) - 1)] == "--#{param}-" and f.length > param.size + 3}.collect{|f| f[(param.size + 3)..-1]}
|
74
|
-
# end
|
75
|
-
|
76
|
-
# def generate_images(flags)
|
77
|
-
# params = {}
|
78
|
-
# params['types'] = flag_values(flags, 'type')
|
79
|
-
# params['variable_ids'] = flag_values(flags, 'id')
|
80
|
-
# params['sizes'] = flag_values(flags, 'size')
|
81
|
-
|
82
|
-
# params_string = params.collect{|key, values| "#{key}=#{values.join(',')}"}.join(' ')
|
83
|
-
|
84
|
-
# system "bundle exec rake spout:images #{params_string}"
|
85
|
-
# end
|
86
|
-
|
87
|
-
# def generate_charts_and_tables(variables)
|
88
|
-
# system "bundle exec rake spout:json variables=#{variables.join(',')}"
|
89
|
-
# end
|
90
|
-
|
91
|
-
# end
|
92
|
-
# end
|