spout 0.9.0.beta2 → 0.9.0.rc
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -1
- data/README.md +2 -2
- data/lib/spout/commands/coverage.rb +3 -3
- data/lib/spout/commands/exporter.rb +12 -1
- data/lib/spout/commands/graphs.rb +12 -26
- data/lib/spout/commands/images.rb +6 -11
- data/lib/spout/commands/outliers.rb +4 -3
- data/lib/spout/helpers/config_reader.rb +37 -0
- data/lib/spout/helpers/subject_loader.rb +2 -2
- data/lib/spout/models/outlier_result.rb +2 -1
- data/lib/spout/templates/ruby-version +1 -1
- data/lib/spout/templates/spout.yml +1 -0
- data/lib/spout/templates/travis.yml +1 -1
- data/lib/spout/tests.rb +1 -1
- data/lib/spout/version.rb +1 -1
- data/lib/spout.rb +5 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 903443bf7697903d3e8d78462afdf5dfba77df55
|
4
|
+
data.tar.gz: 011b51f8ef1128790ab7f15ebbd6854f03175a56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c0f00e614dc71910e91102e8ec3c994c88372b42c7977ee7fe860f79b76c83c25ab75e806236a5d5891faac95378fbc1f3dbf0da91adc5a79066c04cd2d9445
|
7
|
+
data.tar.gz: 4d35e2bc0d5e8662c8959ed76d7da8dbbd4e04fe3f864b8a4cea22164cd093c9ba571e2a48a6b486db94795fe19c399bfffe49462ffbe87d1e6795e859145746
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,19 @@
|
|
7
7
|
- Ex: If a dataset exists in folder 0.2.0, then this folder will be used.
|
8
8
|
- Ex: If datasets exist in 0.2.0, 0.2.1.beta2, and 0.2.1, then the exact match, 0.2.1.beta2, will be used.
|
9
9
|
- Ex: If datasets exist in 0.2.0, 0.2.1.beta1, 0.2.1, and 0.3.0, then the highest match on the minor version is used, in this case 0.2.1.
|
10
|
+
- `spout p` command now uses same syntax as `spout g` command to reference variables
|
11
|
+
- `spout p <variable_id>`
|
12
|
+
- `spout p age --size-sm`
|
13
|
+
- The data dictionary slug can now be specified in the `spout.yml` file:
|
14
|
+
- `slug: my-repo-name`
|
15
|
+
- Setting the slug will allow the `spout export` command to export the data dictionary to `my-repo-name-data-dictionary-0.1.0-variables.csv`, etc.
|
16
|
+
- `spout p` and `spout g` now indicate if the target CSV folder is empty
|
17
|
+
- `spout o` now only calculates averages and outliers for `numeric` and `integer` variables
|
18
|
+
- **Testing Changes**
|
19
|
+
- Multi-line assertions now maintain the correct amount of white-space padding
|
20
|
+
- **Gem Changes**
|
21
|
+
- Use of Ruby 2.1.3 is now recommended
|
22
|
+
- Updated to simplecov 0.9.1
|
10
23
|
|
11
24
|
## 0.8.0 (June 27, 2014)
|
12
25
|
|
@@ -71,7 +84,7 @@
|
|
71
84
|
- `spout p --size-sm`
|
72
85
|
- `spout p --type-numeric --size-sm`
|
73
86
|
- For specific variables the following can be used:
|
74
|
-
- `spout p --id-<variable_id>`
|
87
|
+
- `spout p --id-<variable_id>` **NOTE** changed in v0.9.0
|
75
88
|
|
76
89
|
## 0.6.0 (March 7, 2014)
|
77
90
|
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/sleepepi/spout.svg?branch=master)](https://travis-ci.org/sleepepi/spout)
|
4
4
|
[![Dependency Status](https://gemnasium.com/sleepepi/spout.svg)](https://gemnasium.com/sleepepi/spout)
|
5
|
-
[![Code Climate](https://codeclimate.com/github/sleepepi/spout.
|
5
|
+
[![Code Climate](https://codeclimate.com/github/sleepepi/spout/badges/gpa.svg)](https://codeclimate.com/github/sleepepi/spout)
|
6
6
|
|
7
7
|
Turn your CSV data dictionary into a JSON repository. Collaborate with others to update the data dictionary in JSON format. Generate new Data Dictionary from the JSON repository. Test and validate your data dictionary using built-in tests, or add your own tests and validations.
|
8
8
|
|
@@ -232,7 +232,7 @@ The following flags can be passed to the `spout pngs` command:
|
|
232
232
|
- `spout p --type-numeric --size-sm`
|
233
233
|
|
234
234
|
For specific variables the following can be used:
|
235
|
-
- `spout p
|
235
|
+
- `spout p <variable_id>`
|
236
236
|
|
237
237
|
Generated images are placed in: `./images/`
|
238
238
|
|
@@ -5,6 +5,7 @@ require 'fileutils'
|
|
5
5
|
require 'spout/helpers/subject_loader'
|
6
6
|
require 'spout/models/coverage_result'
|
7
7
|
require 'spout/helpers/number_helper'
|
8
|
+
require 'spout/helpers/config_reader'
|
8
9
|
|
9
10
|
module Spout
|
10
11
|
module Commands
|
@@ -19,10 +20,9 @@ module Spout
|
|
19
20
|
@valid_ids = []
|
20
21
|
@number_of_rows = nil
|
21
22
|
|
22
|
-
|
23
|
-
@visit = (spout_config.kind_of?(Hash) ? spout_config['visit'].to_s.strip : '')
|
23
|
+
@config = Spout::Helpers::ConfigReader.new
|
24
24
|
|
25
|
-
@subject_loader = Spout::Helpers::SubjectLoader.new(@variable_files, @valid_ids, @standard_version, @number_of_rows, @visit)
|
25
|
+
@subject_loader = Spout::Helpers::SubjectLoader.new(@variable_files, @valid_ids, @standard_version, @number_of_rows, @config.visit)
|
26
26
|
@subject_loader.load_subjects_from_csvs_part_one! # Not Part Two which is essentially cleaning the data
|
27
27
|
@subjects = @subject_loader.subjects
|
28
28
|
|
@@ -3,12 +3,15 @@ require 'json'
|
|
3
3
|
require 'fileutils'
|
4
4
|
require 'colorize'
|
5
5
|
|
6
|
+
require 'spout/helpers/config_reader'
|
7
|
+
|
6
8
|
module Spout
|
7
9
|
module Commands
|
8
10
|
class Exporter
|
9
11
|
def initialize(standard_version, argv)
|
10
12
|
@csv_file = argv[1].to_s
|
11
13
|
@standard_version = standard_version
|
14
|
+
@config = Spout::Helpers::ConfigReader.new
|
12
15
|
expanded_export!
|
13
16
|
end
|
14
17
|
|
@@ -25,7 +28,7 @@ module Spout
|
|
25
28
|
end
|
26
29
|
|
27
30
|
def generic_export(folder, type, keys, include_domain_name = false)
|
28
|
-
export_file =
|
31
|
+
export_file = export_file_name(type)
|
29
32
|
puts " export".colorize( :blue ) + " #{folder}/#{export_file}"
|
30
33
|
CSV.open("#{folder}/#{export_file}", "wb") do |csv|
|
31
34
|
if include_domain_name
|
@@ -49,6 +52,14 @@ module Spout
|
|
49
52
|
end
|
50
53
|
end
|
51
54
|
|
55
|
+
def export_file_name(type)
|
56
|
+
if @config.slug == ''
|
57
|
+
"#{type}.csv"
|
58
|
+
else
|
59
|
+
"#{@config.slug}-data-dictionary-#{@standard_version}-#{type}.csv"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
52
63
|
def generic_folder_path(file, type)
|
53
64
|
file.gsub(/#{type}\//, '').split('/')[0..-2].join('/')
|
54
65
|
end
|
@@ -6,6 +6,7 @@ require 'yaml'
|
|
6
6
|
|
7
7
|
require 'spout/helpers/subject_loader'
|
8
8
|
require 'spout/helpers/chart_types'
|
9
|
+
require 'spout/helpers/config_reader'
|
9
10
|
|
10
11
|
module Spout
|
11
12
|
module Commands
|
@@ -13,33 +14,18 @@ module Spout
|
|
13
14
|
def initialize(variables, standard_version)
|
14
15
|
@standard_version = standard_version
|
15
16
|
|
16
|
-
|
17
|
+
@config = Spout::Helpers::ConfigReader.new
|
17
18
|
|
18
|
-
@visit
|
19
|
-
|
20
|
-
if spout_config.kind_of?(Hash)
|
21
|
-
@visit = spout_config['visit'].to_s.strip
|
22
|
-
|
23
|
-
chart_variables = if spout_config['charts'].kind_of?(Array)
|
24
|
-
spout_config['charts'].select{|c| c.kind_of?(Hash)}
|
25
|
-
else
|
26
|
-
[]
|
27
|
-
end
|
28
|
-
else
|
29
|
-
puts "The YAML file needs to be in the following format:"
|
30
|
-
puts "---\nvisit: visit_variable_name\ncharts:\n- chart: age_variable_name\n title: Age\n- chart: gender_variable_name\n title: Gender\n- chart: race_variable_name\n title: Race\n"
|
31
|
-
return self
|
32
|
-
end
|
33
|
-
|
34
|
-
if Spout::Helpers::ChartTypes::get_json(@visit, 'variable') == nil
|
35
|
-
if @visit == ''
|
19
|
+
if Spout::Helpers::ChartTypes::get_json(@config.visit, 'variable') == nil
|
20
|
+
if @config.visit == ''
|
36
21
|
puts "The visit variable in .spout.yml can't be blank."
|
37
22
|
else
|
38
|
-
puts "Could not find the following visit variable: #{@visit}"
|
23
|
+
puts "Could not find the following visit variable: #{@config.visit}"
|
39
24
|
end
|
40
25
|
return self
|
41
26
|
end
|
42
|
-
|
27
|
+
|
28
|
+
missing_variables = @config.charts.select{|c| Spout::Helpers::ChartTypes::get_json(c['chart'], 'variable') == nil}
|
43
29
|
if missing_variables.count > 0
|
44
30
|
puts "Could not find the following chart variable#{'s' unless missing_variables.size == 1}: #{missing_variables.join(', ')}"
|
45
31
|
return self
|
@@ -55,20 +41,20 @@ module Spout
|
|
55
41
|
|
56
42
|
@valid_ids = argv_string.split(',').compact.reject{|s| s == ''}
|
57
43
|
|
58
|
-
@chart_variables =
|
44
|
+
@chart_variables = @config.charts.unshift( { "chart" => @config.visit, "title" => 'Histogram' } )
|
59
45
|
|
60
46
|
@variable_files = Dir.glob('variables/**/*.json')
|
61
47
|
|
62
48
|
t = Time.now
|
63
49
|
FileUtils.mkpath "graphs/#{@standard_version}"
|
64
50
|
|
65
|
-
@subject_loader = Spout::Helpers::SubjectLoader.new(@variable_files, @valid_ids, @standard_version, @number_of_rows, @visit)
|
51
|
+
@subject_loader = Spout::Helpers::SubjectLoader.new(@variable_files, @valid_ids, @standard_version, @number_of_rows, @config.visit)
|
66
52
|
|
67
53
|
@subject_loader.load_subjects_from_csvs!
|
68
54
|
@subjects = @subject_loader.subjects
|
69
55
|
compute_tables_and_charts
|
70
56
|
|
71
|
-
puts "Took #{Time.now - t} seconds."
|
57
|
+
puts "Took #{Time.now - t} seconds." if @subjects.size > 0
|
72
58
|
end
|
73
59
|
|
74
60
|
def compute_tables_and_charts
|
@@ -93,7 +79,7 @@ module Spout
|
|
93
79
|
chart_type = chart_type_hash["chart"]
|
94
80
|
chart_title = chart_type_hash["title"].downcase.gsub(' ', '-')
|
95
81
|
|
96
|
-
if chart_type == @visit
|
82
|
+
if chart_type == @config.visit
|
97
83
|
filtered_subjects = @subjects.select{ |s| s.send(chart_type) != nil } # and s.send(variable_name) != nil
|
98
84
|
if filtered_subjects.count > 0
|
99
85
|
stats[:charts][chart_title] = Spout::Helpers::ChartTypes::chart_histogram(chart_type, filtered_subjects, json, variable_name)
|
@@ -121,7 +107,7 @@ module Spout
|
|
121
107
|
# [["Visit 1", "1"], ["Visit 2", "2"], ["CVD Outcomes", "3"]]
|
122
108
|
def visits
|
123
109
|
@visits ||= begin
|
124
|
-
Spout::Helpers::ChartTypes::domain_array(@visit)
|
110
|
+
Spout::Helpers::ChartTypes::domain_array(@config.visit)
|
125
111
|
end
|
126
112
|
end
|
127
113
|
|
@@ -6,6 +6,7 @@ require 'yaml'
|
|
6
6
|
|
7
7
|
require 'spout/helpers/subject_loader'
|
8
8
|
require 'spout/helpers/chart_types'
|
9
|
+
require 'spout/helpers/config_reader'
|
9
10
|
|
10
11
|
module Spout
|
11
12
|
module Commands
|
@@ -22,24 +23,18 @@ module Spout
|
|
22
23
|
|
23
24
|
@number_of_rows = nil
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
@visit = ''
|
28
|
-
|
29
|
-
if spout_config.kind_of?(Hash)
|
30
|
-
@visit = spout_config['visit'].to_s.strip
|
31
|
-
end
|
26
|
+
@config = Spout::Helpers::ConfigReader.new
|
32
27
|
|
33
28
|
t = Time.now
|
34
29
|
FileUtils.mkpath "graphs/#{@standard_version}"
|
35
30
|
|
36
|
-
@subject_loader = Spout::Helpers::SubjectLoader.new(@variable_files, @valid_ids, @standard_version, @number_of_rows, @visit)
|
31
|
+
@subject_loader = Spout::Helpers::SubjectLoader.new(@variable_files, @valid_ids, @standard_version, @number_of_rows, @config.visit)
|
37
32
|
|
38
33
|
@subject_loader.load_subjects_from_csvs!
|
39
34
|
@subjects = @subject_loader.subjects
|
40
35
|
|
41
36
|
compute_images
|
42
|
-
puts "Took #{Time.now - t} seconds."
|
37
|
+
puts "Took #{Time.now - t} seconds." if @subjects.size > 0
|
43
38
|
end
|
44
39
|
|
45
40
|
def compute_images
|
@@ -60,9 +55,9 @@ module Spout
|
|
60
55
|
|
61
56
|
puts "#{file_index+1} of #{variable_files_count}: #{variable_file.gsub(/(^variables\/|\.json$)/, '').gsub('/', ' / ')}"
|
62
57
|
|
63
|
-
filtered_subjects = @subjects.select{ |s| s.send(@visit) != nil }
|
58
|
+
filtered_subjects = @subjects.select{ |s| s.send(@config.visit) != nil }
|
64
59
|
|
65
|
-
chart_json = Spout::Helpers::ChartTypes::chart_histogram(@visit, filtered_subjects, json, variable_name)
|
60
|
+
chart_json = Spout::Helpers::ChartTypes::chart_histogram(@config.visit, filtered_subjects, json, variable_name)
|
66
61
|
|
67
62
|
if chart_json
|
68
63
|
File.open(tmp_options_file, "w") do |outfile|
|
@@ -5,6 +5,7 @@ require 'fileutils'
|
|
5
5
|
require 'spout/helpers/subject_loader'
|
6
6
|
require 'spout/models/outlier_result'
|
7
7
|
require 'spout/helpers/number_helper'
|
8
|
+
require 'spout/helpers/config_reader'
|
8
9
|
|
9
10
|
module Spout
|
10
11
|
module Commands
|
@@ -19,10 +20,9 @@ module Spout
|
|
19
20
|
@valid_ids = []
|
20
21
|
@number_of_rows = nil
|
21
22
|
|
22
|
-
|
23
|
-
@visit = (spout_config.kind_of?(Hash) ? spout_config['visit'].to_s.strip : '')
|
23
|
+
@config = Spout::Helpers::ConfigReader.new
|
24
24
|
|
25
|
-
@subject_loader = Spout::Helpers::SubjectLoader.new(@variable_files, @valid_ids, @standard_version, @number_of_rows, @visit)
|
25
|
+
@subject_loader = Spout::Helpers::SubjectLoader.new(@variable_files, @valid_ids, @standard_version, @number_of_rows, @config.visit)
|
26
26
|
@subject_loader.load_subjects_from_csvs!
|
27
27
|
@subjects = @subject_loader.subjects
|
28
28
|
run_outliers_report!
|
@@ -35,6 +35,7 @@ module Spout
|
|
35
35
|
Spout::Models::OutlierResult.new(@subjects, method, csv_files)
|
36
36
|
end
|
37
37
|
|
38
|
+
@outlier_results.select!{|outlier_result| ['numeric', 'integer'].include?(outlier_result.variable_type) }
|
38
39
|
@outlier_results.sort!{|a,b| [a.weight, a.method] <=> [b.weight, b.method]}
|
39
40
|
|
40
41
|
@overall_results = @subject_loader.csv_files.collect do |csv_file|
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Spout
|
4
|
+
module Helpers
|
5
|
+
class ConfigReader
|
6
|
+
|
7
|
+
attr_reader :slug, :visit, :charts
|
8
|
+
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@slug = ''
|
12
|
+
@visit = ''
|
13
|
+
@charts = []
|
14
|
+
parse_yaml_file
|
15
|
+
end
|
16
|
+
|
17
|
+
def parse_yaml_file
|
18
|
+
spout_config = YAML.load_file('.spout.yml')
|
19
|
+
|
20
|
+
if spout_config.kind_of?(Hash)
|
21
|
+
@slug = spout_config['slug'].to_s.strip
|
22
|
+
@visit = spout_config['visit'].to_s.strip
|
23
|
+
|
24
|
+
@charts = if spout_config['charts'].kind_of?(Array)
|
25
|
+
spout_config['charts'].select{|c| c.kind_of?(Hash)}
|
26
|
+
else
|
27
|
+
[]
|
28
|
+
end
|
29
|
+
else
|
30
|
+
puts "The YAML file needs to be in the following format:"
|
31
|
+
puts "---\nvisit: visit_variable_name\ncharts:\n- chart: age_variable_name\n title: Age\n- chart: gender_variable_name\n title: Gender\n- chart: race_variable_name\n title: Race\n"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -72,9 +72,9 @@ module Spout
|
|
72
72
|
end
|
73
73
|
|
74
74
|
if @csv_directory != @standard_version
|
75
|
-
puts "Using dataset in " + "csvs/#{@csv_directory}/".colorize( :green ) + " for dictionary version " + @standard_version.to_s.colorize( :green ) + "\n\n"
|
75
|
+
puts "#{@csv_files.size == 0 ? 'No CSVs found' : 'Using dataset' } in " + "csvs/#{@csv_directory}/".colorize( :green ) + " for dictionary version " + @standard_version.to_s.colorize( :green ) + "\n\n"
|
76
76
|
else
|
77
|
-
puts "Using dataset in " + "csvs/#{@standard_version}/".colorize( :green ) + "\n\n"
|
77
|
+
puts "#{@csv_files.size == 0 ? 'No CSVs found' : 'Using dataset' } in " + "csvs/#{@standard_version}/".colorize( :green ) + "\n\n"
|
78
78
|
end
|
79
79
|
|
80
80
|
end
|
@@ -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, :display_name, :median
|
7
|
+
attr_reader :csv_files, :method, :major_outliers, :minor_outliers, :outliers, :weight, :units, :display_name, :median, :variable_type
|
8
8
|
|
9
9
|
def initialize(subjects, method, csv_files)
|
10
10
|
@values = subjects.collect(&method.to_sym)
|
@@ -24,6 +24,7 @@ module Spout
|
|
24
24
|
variable = Spout::Helpers::JsonLoader::get_variable(method)
|
25
25
|
@units = (variable.kind_of?(Hash) ? variable['units'] : nil)
|
26
26
|
@display_name = (variable.kind_of?(Hash) ? variable['display_name'] : nil)
|
27
|
+
@variable_type = (variable.kind_of?(Hash) ? variable['type'] : nil)
|
27
28
|
@median = @values.median
|
28
29
|
end
|
29
30
|
|
@@ -1 +1 @@
|
|
1
|
-
ruby-2.1.
|
1
|
+
ruby-2.1.3
|
data/lib/spout/tests.rb
CHANGED
data/lib/spout/version.rb
CHANGED
data/lib/spout.rb
CHANGED
@@ -45,8 +45,8 @@ module Spout
|
|
45
45
|
argv = argv.last(argv.size - 1)
|
46
46
|
require 'spout/commands/images'
|
47
47
|
types = flag_values(argv, 'type')
|
48
|
-
variable_ids = flag_values(argv, 'id')
|
49
48
|
sizes = flag_values(argv, 'size')
|
49
|
+
variable_ids = non_flag_values(argv)
|
50
50
|
Spout::Commands::Images.new(types, variable_ids, sizes, standard_version, argv)
|
51
51
|
end
|
52
52
|
|
@@ -111,4 +111,8 @@ EOT
|
|
111
111
|
flags.select{|f| f =~ /^--#{param}-/}.collect{|f| f[(param.size + 3)..-1]}
|
112
112
|
end
|
113
113
|
|
114
|
+
def self.non_flag_values(flags)
|
115
|
+
flags.reject{|f| f =~ /^--/}
|
116
|
+
end
|
117
|
+
|
114
118
|
end
|
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.9.0.
|
4
|
+
version: 0.9.0.rc
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Remo Mueller
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- lib/spout/commands/project_generator.rb
|
119
119
|
- lib/spout/helpers/array_statistics.rb
|
120
120
|
- lib/spout/helpers/chart_types.rb
|
121
|
+
- lib/spout/helpers/config_reader.rb
|
121
122
|
- lib/spout/helpers/iterators.rb
|
122
123
|
- lib/spout/helpers/json_loader.rb
|
123
124
|
- lib/spout/helpers/number_helper.rb
|
@@ -185,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
186
|
version: 1.3.1
|
186
187
|
requirements: []
|
187
188
|
rubyforge_project:
|
188
|
-
rubygems_version: 2.
|
189
|
+
rubygems_version: 2.4.1
|
189
190
|
signing_key:
|
190
191
|
specification_version: 4
|
191
192
|
summary: Turn your CSV data dictionary into a JSON repository. Collaborate with others
|