spout 0.10.0.beta8 → 0.10.0.beta9
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/CHANGELOG.md +3 -0
- data/lib/spout/commands/deploy.rb +2 -2
- data/lib/spout/commands/graphs.rb +9 -2
- data/lib/spout/commands/images.rb +6 -2
- data/lib/spout/helpers/chart_types.rb +18 -0
- data/lib/spout/helpers/subject_loader.rb +32 -4
- 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: 1510bf903f7dada97ac4f63538881fe5cddb0825
|
4
|
+
data.tar.gz: 8678041008439bd0eaea5e163eb6d4fc6337469b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 390ca815b08364e3d3f8e068dd1104d784bdc48eb85bd2da9fc6e3d44562aec5ac75e22524d0580c1f0dba8ffec341021e463ac9b57d627ac7ae6b8e85d846f4
|
7
|
+
data.tar.gz: fa7bf7eb06e667c972354bd7b81f4d32e7f0c37de0a7115c06f484361943a7a9b737020b9434c4b7d132403035aa9c9f1caf89fccdfd3cf87e8b0357163fe935
|
data/CHANGELOG.md
CHANGED
@@ -9,6 +9,9 @@
|
|
9
9
|
- Display names that use mixed case are unaffected
|
10
10
|
- `spout import --domains` now marks options as `"missing": true` if the option value starts with a dot `.` or a dash `-`
|
11
11
|
- Display names for domain options are also changed to title case if they are all caps
|
12
|
+
- **Graph Command**
|
13
|
+
- Graphs and tables no longer display missing codes that do not exist in the dataset for variables of type `choices`
|
14
|
+
- Graphs and tables now remove domain values for variables of type `integer` or `numeric`
|
12
15
|
- **Testing Changes**
|
13
16
|
- Tests now include checks to assure that variable display_name fields don't exceed 255 length requirement
|
14
17
|
- `include Spout::Tests::VariableDisplayNameLength`
|
@@ -60,7 +60,7 @@ module Spout
|
|
60
60
|
|
61
61
|
begin
|
62
62
|
run_all
|
63
|
-
rescue Interrupt
|
63
|
+
rescue Interrupt
|
64
64
|
puts "\nINTERRUPTED".colorize(:red)
|
65
65
|
end
|
66
66
|
end
|
@@ -209,7 +209,7 @@ module Spout
|
|
209
209
|
require 'spout/commands/images'
|
210
210
|
argv = []
|
211
211
|
argv << "--clean" if @clean
|
212
|
-
Spout::Commands::Images.new(
|
212
|
+
Spout::Commands::Images.new([], [], [], @version, argv, true, @url, @slug, @token)
|
213
213
|
puts "\r Image Generation: " + "DONE ".colorize(:green)
|
214
214
|
end
|
215
215
|
|
@@ -9,6 +9,7 @@ require 'spout/helpers/subject_loader'
|
|
9
9
|
require 'spout/helpers/chart_types'
|
10
10
|
require 'spout/helpers/config_reader'
|
11
11
|
require 'spout/helpers/send_file'
|
12
|
+
require 'spout/version'
|
12
13
|
|
13
14
|
module Spout
|
14
15
|
module Commands
|
@@ -74,7 +75,8 @@ module Spout
|
|
74
75
|
def load_current_progress
|
75
76
|
@progress_file = File.join(@graphs_folder, ".progress.json")
|
76
77
|
@progress = JSON.parse(File.read(@progress_file)) rescue @progress = {}
|
77
|
-
@progress = {} if @clean
|
78
|
+
@progress = {} if !@progress.kind_of?(Hash) or @clean or @progress['SPOUT_VERSION'] != Spout::VERSION::STRING
|
79
|
+
@progress['SPOUT_VERSION'] = Spout::VERSION::STRING
|
78
80
|
end
|
79
81
|
|
80
82
|
def save_current_progress
|
@@ -137,7 +139,12 @@ module Spout
|
|
137
139
|
|
138
140
|
if @deploy_mode and not @progress[variable_name]['uploaded'] == true
|
139
141
|
response = send_to_server(chart_json_file)
|
140
|
-
|
142
|
+
if response.kind_of?(Hash) and response['upload'] == 'success'
|
143
|
+
@progress[variable_name]['uploaded'] = true
|
144
|
+
else
|
145
|
+
puts "\nUPLOAD FAILED: ".colorize(:red) + File.basename(chart_json_file)
|
146
|
+
@progress[variable_name]['uploaded'] = false
|
147
|
+
end
|
141
148
|
end
|
142
149
|
|
143
150
|
save_current_progress
|
@@ -52,7 +52,8 @@ module Spout
|
|
52
52
|
def load_current_progress
|
53
53
|
@progress_file = File.join(@images_folder, ".progress.json")
|
54
54
|
@progress = JSON.parse(File.read(@progress_file)) rescue @progress = {}
|
55
|
-
@progress = {} if @clean
|
55
|
+
@progress = {} if !@progress.kind_of?(Hash) or @clean or @progress['SPOUT_VERSION'] != Spout::VERSION::STRING
|
56
|
+
@progress['SPOUT_VERSION'] = Spout::VERSION::STRING
|
56
57
|
end
|
57
58
|
|
58
59
|
def save_current_progress
|
@@ -125,7 +126,9 @@ module Spout
|
|
125
126
|
end
|
126
127
|
run_phantom_js(variable_name, "#{variable_name}-lg.png", 600, tmp_options_file) if @sizes.size == 0 or @sizes.include?('lg')
|
127
128
|
run_phantom_js(variable_name, "#{variable_name}.png", 75, tmp_options_file) if @sizes.size == 0 or @sizes.include?('sm')
|
128
|
-
|
129
|
+
|
130
|
+
@progress[variable_name]['uploaded'] = (@deploy_mode and @progress[variable_name]['upload_failed'] != true)
|
131
|
+
|
129
132
|
save_current_progress
|
130
133
|
end
|
131
134
|
|
@@ -161,6 +164,7 @@ module Spout
|
|
161
164
|
if response.kind_of?(Hash) and response['upload'] == 'success'
|
162
165
|
@progress[variable_name]['uploaded_files'] << png_name
|
163
166
|
else
|
167
|
+
puts "\nUPLOAD FAILED: ".colorize(:red) + File.basename(png_name)
|
164
168
|
@progress[variable_name]['upload_failed'] = true
|
165
169
|
end
|
166
170
|
end
|
@@ -72,6 +72,9 @@ module Spout
|
|
72
72
|
|
73
73
|
filtered_subjects = subjects.select{ |s| s.send(method) != nil and s.send(chart_type) != nil }.sort_by(&chart_type.to_sym)
|
74
74
|
|
75
|
+
all_subject_values = filtered_subjects.collect(&method.to_sym).compact.sort
|
76
|
+
domain_json = remove_unused_missing_codes_from_domain(domain_json, all_subject_values.uniq)
|
77
|
+
|
75
78
|
categories = [:quartile_one, :quartile_two, :quartile_three, :quartile_four].collect do |quartile|
|
76
79
|
bucket = filtered_subjects.send(quartile).collect(&chart_type.to_sym)
|
77
80
|
"#{bucket.min} to #{bucket.max}"
|
@@ -168,6 +171,8 @@ module Spout
|
|
168
171
|
return unless domain_json = get_domain(json)
|
169
172
|
|
170
173
|
filtered_subjects = subjects.select{ |s| s.send(method) != nil and s.send(chart_type) != nil }.sort_by(&chart_type.to_sym)
|
174
|
+
all_subject_values = filtered_subjects.collect(&method.to_sym).compact.sort
|
175
|
+
domain_json = remove_unused_missing_codes_from_domain(domain_json, all_subject_values.uniq)
|
171
176
|
|
172
177
|
categories = [:quartile_one, :quartile_two, :quartile_three, :quartile_four].collect do |quartile|
|
173
178
|
bucket = filtered_subjects.send(quartile).collect(&chart_type.to_sym)
|
@@ -216,6 +221,8 @@ module Spout
|
|
216
221
|
units = 'percent'
|
217
222
|
series = []
|
218
223
|
|
224
|
+
all_subject_values = subjects.collect(&method.to_sym).compact.sort
|
225
|
+
domain_json = remove_unused_missing_codes_from_domain(domain_json, all_subject_values.uniq)
|
219
226
|
|
220
227
|
domain_json.each do |option_hash|
|
221
228
|
domain_values = subjects.select{ |s| s.send(method) == option_hash['value'] }
|
@@ -311,6 +318,9 @@ module Spout
|
|
311
318
|
|
312
319
|
filtered_subjects = subjects.select{ |s| s.send(chart_type) != nil }
|
313
320
|
|
321
|
+
all_subject_values = filtered_subjects.collect(&method.to_sym).compact.sort
|
322
|
+
domain_json = remove_unused_missing_codes_from_domain(domain_json, all_subject_values.uniq)
|
323
|
+
|
314
324
|
rows = domain_json.collect do |option_hash|
|
315
325
|
row_subjects = filtered_subjects.select{ |s| s.send(method) == option_hash['value'] }
|
316
326
|
row_cells = chart_variable_domain.collect do |display_name, value|
|
@@ -358,6 +368,9 @@ module Spout
|
|
358
368
|
|
359
369
|
all_subject_values = subjects.collect(&method.to_sym).compact.sort
|
360
370
|
return nil if all_subject_values.count == 0
|
371
|
+
|
372
|
+
domain_json = remove_unused_missing_codes_from_domain(domain_json, all_subject_values.uniq) if domain_json
|
373
|
+
|
361
374
|
categories = pull_categories(json, method, all_subject_values, domain_json)
|
362
375
|
|
363
376
|
buckets = continuous_buckets(all_subject_values)
|
@@ -398,6 +411,11 @@ module Spout
|
|
398
411
|
end
|
399
412
|
data
|
400
413
|
end
|
414
|
+
|
415
|
+
def self.remove_unused_missing_codes_from_domain(domain_json, unique_subject_values)
|
416
|
+
domain_json.select{|option_hash| option_hash['missing'] != true or (option_hash['missing'] == true and unique_subject_values.include?(option_hash['value']))}
|
417
|
+
end
|
418
|
+
|
401
419
|
end
|
402
420
|
end
|
403
421
|
end
|
@@ -40,12 +40,12 @@ module Spout
|
|
40
40
|
|
41
41
|
@csv_files = Dir.glob("csvs/#{@csv_directory}/*.csv")
|
42
42
|
@csv_files.each_with_index do |csv_file, index|
|
43
|
-
count =
|
43
|
+
count = 1 # Includes counting the header row
|
44
44
|
print "\nParsing #{csv_file}"
|
45
45
|
CSV.parse( File.open(csv_file, 'r:iso-8859-1:utf-8'){|f| f.read}, headers: true, header_converters: lambda { |h| h.to_s.downcase } ) do |line|
|
46
46
|
row = line.to_hash
|
47
47
|
count += 1
|
48
|
-
print "\rParsing #{csv_file} -
|
48
|
+
print "\rParsing #{csv_file} - Row ##{count}" if (count % 10 == 0)
|
49
49
|
@subjects << Spout::Models::Subject.create do |t|
|
50
50
|
t._visit = row[@visit]
|
51
51
|
|
@@ -66,8 +66,9 @@ module Spout
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
# puts "Memory Used: " + (`ps -o rss -p #{$$}`.strip.split.last.to_i / 1024).to_s + " MB" if count % 1000 == 0
|
69
|
-
break if @number_of_rows != nil and count >= @number_of_rows
|
69
|
+
break if @number_of_rows != nil and count - 1 >= @number_of_rows
|
70
70
|
end
|
71
|
+
print "\rParsing #{csv_file} - Row ##{count}"
|
71
72
|
puts "\n"
|
72
73
|
end
|
73
74
|
|
@@ -80,7 +81,10 @@ module Spout
|
|
80
81
|
end
|
81
82
|
|
82
83
|
def load_subjects_from_csvs_part_two!
|
83
|
-
@variable_files.
|
84
|
+
variable_count = @variable_files.count
|
85
|
+
print "Converting numeric values to floats"
|
86
|
+
@variable_files.each_with_index do |variable_file, index|
|
87
|
+
print "\rConverting numeric values to floats:#{"% 3d" % ((index+1)*100/variable_count)}%"
|
84
88
|
json = JSON.parse(File.read(variable_file)) rescue json = nil
|
85
89
|
next unless json
|
86
90
|
next unless @valid_ids.include?(json["id"].to_s.downcase) or @valid_ids.size == 0
|
@@ -88,8 +92,16 @@ module Spout
|
|
88
92
|
method = json['id'].to_s.downcase
|
89
93
|
next unless Spout::Models::Subject.method_defined?(method)
|
90
94
|
|
95
|
+
domain_json = get_domain(json)
|
96
|
+
# Make all domain options nil for numerics/integers
|
97
|
+
if domain_json
|
98
|
+
domain_values = domain_json.collect{|option_hash| option_hash['value']}
|
99
|
+
@subjects.each{ |s| domain_values.include?(s.send(method)) ? s.send("#{method}=", nil) : nil }
|
100
|
+
end
|
101
|
+
|
91
102
|
@subjects.each{ |s| s.send(method) != nil ? s.send("#{method}=", s.send("#{method}").to_f) : nil }
|
92
103
|
end
|
104
|
+
puts "\n"
|
93
105
|
@subjects
|
94
106
|
end
|
95
107
|
|
@@ -103,6 +115,22 @@ module Spout
|
|
103
115
|
end
|
104
116
|
@all_domains = @all_domains.compact.uniq.sort
|
105
117
|
end
|
118
|
+
|
119
|
+
def get_json(file_name, file_type)
|
120
|
+
file = Dir.glob("#{file_type.to_s.downcase}s/**/#{file_name.to_s.downcase}.json", File::FNM_CASEFOLD).first
|
121
|
+
json = JSON.parse(File.read(file)) rescue json = nil
|
122
|
+
json
|
123
|
+
end
|
124
|
+
|
125
|
+
def get_variable(variable_name)
|
126
|
+
get_json(variable_name, 'variable')
|
127
|
+
end
|
128
|
+
|
129
|
+
def get_domain(json)
|
130
|
+
get_json(json['domain'], 'domain')
|
131
|
+
end
|
132
|
+
|
133
|
+
|
106
134
|
end
|
107
135
|
end
|
108
136
|
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.10.0.
|
4
|
+
version: 0.10.0.beta9
|
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-10-
|
11
|
+
date: 2014-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|