spout 0.11.0 → 0.11.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/spout/commands/coverage.rb +2 -0
- data/lib/spout/commands/deploy.rb +2 -0
- data/lib/spout/commands/exporter.rb +2 -0
- data/lib/spout/commands/graphs.rb +36 -33
- data/lib/spout/commands/help.rb +2 -0
- data/lib/spout/commands/importer.rb +2 -0
- data/lib/spout/commands/outliers.rb +2 -0
- data/lib/spout/commands/project_generator.rb +2 -0
- data/lib/spout/helpers/array_statistics.rb +2 -0
- data/lib/spout/helpers/chart_types.rb +2 -0
- data/lib/spout/helpers/config_reader.rb +2 -0
- data/lib/spout/helpers/iterators.rb +2 -0
- data/lib/spout/helpers/json_loader.rb +2 -0
- data/lib/spout/helpers/json_request.rb +2 -0
- data/lib/spout/helpers/json_request_generic.rb +2 -0
- data/lib/spout/helpers/number_helper.rb +2 -0
- data/lib/spout/helpers/quietly.rb +2 -0
- data/lib/spout/helpers/semantic.rb +2 -0
- data/lib/spout/helpers/send_file.rb +2 -0
- data/lib/spout/helpers/subject_loader.rb +5 -2
- data/lib/spout/helpers/table_formatting.rb +2 -0
- data/lib/spout/models/bucket.rb +2 -0
- data/lib/spout/models/coverage_result.rb +2 -0
- data/lib/spout/models/dictionary.rb +2 -0
- data/lib/spout/models/domain.rb +2 -0
- data/lib/spout/models/empty.rb +2 -0
- data/lib/spout/models/form.rb +2 -0
- data/lib/spout/models/graphables/choices_vs_choices.rb +2 -0
- data/lib/spout/models/graphables/choices_vs_numeric.rb +2 -0
- data/lib/spout/models/graphables/default.rb +2 -0
- data/lib/spout/models/graphables/histogram.rb +2 -0
- data/lib/spout/models/graphables/numeric_vs_choices.rb +2 -0
- data/lib/spout/models/graphables/numeric_vs_numeric.rb +2 -0
- data/lib/spout/models/graphables.rb +2 -0
- data/lib/spout/models/option.rb +2 -0
- data/lib/spout/models/outlier_result.rb +2 -0
- data/lib/spout/models/record.rb +2 -0
- data/lib/spout/models/subject.rb +2 -0
- data/lib/spout/models/tables/choices_vs_choices.rb +2 -0
- data/lib/spout/models/tables/choices_vs_numeric.rb +2 -0
- data/lib/spout/models/tables/default.rb +2 -0
- data/lib/spout/models/tables/numeric_vs_choices.rb +2 -0
- data/lib/spout/models/tables/numeric_vs_numeric.rb +2 -0
- data/lib/spout/models/tables.rb +2 -0
- data/lib/spout/models/variable.rb +2 -0
- data/lib/spout/tasks/engine.rake +2 -0
- data/lib/spout/tasks.rb +2 -0
- data/lib/spout/templates/test/dictionary_test.rb +2 -0
- data/lib/spout/templates/test/test_helper.rb +2 -0
- data/lib/spout/tests/domain_existence_validation.rb +2 -0
- data/lib/spout/tests/domain_format.rb +2 -0
- data/lib/spout/tests/domain_name_format.rb +2 -0
- data/lib/spout/tests/domain_name_uniqueness.rb +2 -0
- data/lib/spout/tests/domain_specified.rb +2 -0
- data/lib/spout/tests/form_existence_validation.rb +2 -0
- data/lib/spout/tests/form_name_format.rb +2 -0
- data/lib/spout/tests/form_name_match.rb +2 -0
- data/lib/spout/tests/form_name_uniqueness.rb +2 -0
- data/lib/spout/tests/json_helper.rb +2 -0
- data/lib/spout/tests/json_validation.rb +2 -0
- data/lib/spout/tests/variable_display_name_length.rb +2 -2
- data/lib/spout/tests/variable_name_format.rb +2 -0
- data/lib/spout/tests/variable_name_match.rb +2 -0
- data/lib/spout/tests/variable_name_uniqueness.rb +2 -0
- data/lib/spout/tests/variable_type_validation.rb +6 -5
- data/lib/spout/tests.rb +2 -0
- data/lib/spout/version.rb +4 -2
- data/lib/spout.rb +2 -0
- 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: be0327cbf6a23831a9d083cb661fad0dde046ca7
|
4
|
+
data.tar.gz: d67d665c3054ae148b984cabfe06a1bb11f981bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ec0a4511d1b4b1a13dd1cc17c2941dc7d10dac65b9879a4fe808e0463ab6541bfd13104abdc93e88a591fccbdf04f196b4397a75f8fafc98800f0657825d1ec
|
7
|
+
data.tar.gz: 8296234875bf25d5cb5c5e0ee8c126e99a5677bb9557a797dfdcf69dc9b29df0f376a66de60957812063ec553ee5647f5fdab95dc25d134bd001e9c98c837a90
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'csv'
|
2
4
|
require 'fileutils'
|
3
5
|
require 'rubygems'
|
@@ -104,7 +106,6 @@ module Spout
|
|
104
106
|
|
105
107
|
next unless variable.errors.size == 0
|
106
108
|
next unless @valid_ids.include?(variable.id) || @valid_ids.size == 0
|
107
|
-
next unless %w(numeric integer choices).include?(variable.type)
|
108
109
|
next unless Spout::Models::Subject.method_defined?(variable.id)
|
109
110
|
|
110
111
|
if @deploy_mode
|
@@ -117,37 +118,7 @@ module Spout
|
|
117
118
|
@progress[variable.id]['uploaded'] ||= []
|
118
119
|
next if (!@deploy_mode && @progress[variable.id]['generated'] == true) || (@deploy_mode && @progress[variable.id]['uploaded'].include?(@webserver_name))
|
119
120
|
|
120
|
-
stats =
|
121
|
-
charts: {},
|
122
|
-
tables: {}
|
123
|
-
}
|
124
|
-
|
125
|
-
@chart_variables.each do |chart_type_hash|
|
126
|
-
chart_type = chart_type_hash['chart']
|
127
|
-
chart_title = chart_type_hash['title'].downcase.gsub(' ', '-')
|
128
|
-
chart_variable = Spout::Models::Variable.find_by_id(chart_type)
|
129
|
-
|
130
|
-
filtered_subjects = @subjects.reject { |s| s.send(chart_type).nil? || s.send(variable.id).nil? }
|
131
|
-
|
132
|
-
next if filtered_subjects.collect(&variable.id.to_sym).compact_empty.count == 0
|
133
|
-
if chart_type == @config.visit
|
134
|
-
graph = Spout::Models::Graphables.for(variable, chart_variable, nil, filtered_subjects)
|
135
|
-
stats[:charts][chart_title] = graph.to_hash
|
136
|
-
table = Spout::Models::Tables.for(variable, chart_variable, filtered_subjects, nil, totals: false)
|
137
|
-
stats[:tables][chart_title] = table.to_hash
|
138
|
-
else
|
139
|
-
graph = Spout::Models::Graphables.for(variable, chart_variable, @stratification_variable, filtered_subjects)
|
140
|
-
stats[:charts][chart_title] = graph.to_hash
|
141
|
-
stats[:tables][chart_title] = @stratification_variable.domain.options.collect do |option|
|
142
|
-
visit_subjects = filtered_subjects.select { |s| s._visit == option.value }
|
143
|
-
Spout::Models::Tables.for(variable, chart_variable, visit_subjects, option.display_name).to_hash
|
144
|
-
end.compact
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
chart_json_file = File.join(@graphs_folder, "#{variable.id}.json")
|
149
|
-
File.open(chart_json_file, 'w') { |file| file.write(JSON.pretty_generate(stats) + "\n") }
|
150
|
-
@progress[variable.id]['generated'] = true
|
121
|
+
stats = compute_stats(variable)
|
151
122
|
|
152
123
|
if @deploy_mode && !@progress[variable.id]['uploaded'].include?(@webserver_name)
|
153
124
|
values = @subjects.collect(&variable.id.to_sym).compact_empty
|
@@ -166,6 +137,39 @@ module Spout
|
|
166
137
|
end
|
167
138
|
end
|
168
139
|
|
140
|
+
def compute_stats(variable)
|
141
|
+
stats = { charts: {}, tables: {} }
|
142
|
+
return stats unless %w(numeric integer choices).include?(variable.type)
|
143
|
+
|
144
|
+
@chart_variables.each do |chart_type_hash|
|
145
|
+
chart_type = chart_type_hash['chart']
|
146
|
+
chart_title = chart_type_hash['title'].downcase.tr(' ', '-')
|
147
|
+
chart_variable = Spout::Models::Variable.find_by_id(chart_type)
|
148
|
+
|
149
|
+
filtered_subjects = @subjects.reject { |s| s.send(chart_type).nil? || s.send(variable.id).nil? }
|
150
|
+
|
151
|
+
next if filtered_subjects.collect(&variable.id.to_sym).compact_empty.count == 0
|
152
|
+
if chart_type == @config.visit
|
153
|
+
graph = Spout::Models::Graphables.for(variable, chart_variable, nil, filtered_subjects)
|
154
|
+
stats[:charts][chart_title] = graph.to_hash
|
155
|
+
table = Spout::Models::Tables.for(variable, chart_variable, filtered_subjects, nil, totals: false)
|
156
|
+
stats[:tables][chart_title] = table.to_hash
|
157
|
+
else
|
158
|
+
graph = Spout::Models::Graphables.for(variable, chart_variable, @stratification_variable, filtered_subjects)
|
159
|
+
stats[:charts][chart_title] = graph.to_hash
|
160
|
+
stats[:tables][chart_title] = @stratification_variable.domain.options.collect do |option|
|
161
|
+
visit_subjects = filtered_subjects.select { |s| s._visit == option.value }
|
162
|
+
Spout::Models::Tables.for(variable, chart_variable, visit_subjects, option.display_name).to_hash
|
163
|
+
end.compact
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
chart_json_file = File.join(@graphs_folder, "#{variable.id}.json")
|
168
|
+
File.open(chart_json_file, 'w') { |file| file.write(JSON.pretty_generate(stats) + "\n") }
|
169
|
+
@progress[variable.id]['generated'] = true
|
170
|
+
stats
|
171
|
+
end
|
172
|
+
|
169
173
|
def send_variable_params_to_server(variable, stats)
|
170
174
|
params = { auth_token: @token, version: @standard_version,
|
171
175
|
dataset: @slug, variable: variable.deploy_params,
|
@@ -174,7 +178,6 @@ module Spout
|
|
174
178
|
params[:variable][:spout_stats] = stats.to_json
|
175
179
|
(response, status) = Spout::Helpers::JsonRequestGeneric.post("#{@url}/api/v1/variables/create_or_update.json", params)
|
176
180
|
if response.is_a?(Hash) && status.is_a?(Net::HTTPSuccess)
|
177
|
-
# puts "response: #{response}".colorize(:blue)
|
178
181
|
@progress[variable.id]['uploaded'] << @webserver_name
|
179
182
|
else
|
180
183
|
puts "\nUPLOAD FAILED: ".colorize(:red) + variable.id
|
data/lib/spout/commands/help.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'colorize'
|
2
4
|
require 'csv'
|
3
5
|
require 'json'
|
@@ -129,8 +131,9 @@ module Spout
|
|
129
131
|
|
130
132
|
def get_json(file_name, file_type)
|
131
133
|
file = Dir.glob("#{file_type.to_s.downcase}s/**/#{file_name.to_s.downcase}.json", File::FNM_CASEFOLD).first
|
132
|
-
|
133
|
-
|
134
|
+
JSON.parse(File.read(file))
|
135
|
+
rescue
|
136
|
+
nil
|
134
137
|
end
|
135
138
|
|
136
139
|
def get_variable(variable_name)
|
data/lib/spout/models/bucket.rb
CHANGED
data/lib/spout/models/domain.rb
CHANGED
data/lib/spout/models/empty.rb
CHANGED
data/lib/spout/models/form.rb
CHANGED
data/lib/spout/models/option.rb
CHANGED
data/lib/spout/models/record.rb
CHANGED
data/lib/spout/models/subject.rb
CHANGED
data/lib/spout/models/tables.rb
CHANGED
data/lib/spout/tasks/engine.rake
CHANGED
data/lib/spout/tasks.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Spout
|
2
4
|
module Tests
|
3
5
|
module VariableDisplayNameLength
|
4
|
-
|
5
6
|
Dir.glob("variables/**/*.json").each do |file|
|
6
7
|
define_method("test_variable_display_name_length: "+file) do
|
7
8
|
assert_operator 255, :>=, (begin JSON.parse(File.read(file))["display_name"].size rescue 0 end)
|
8
9
|
end
|
9
10
|
end
|
10
|
-
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -1,19 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Spout
|
2
4
|
module Tests
|
3
5
|
module VariableTypeValidation
|
4
|
-
VALID_VARIABLE_TYPES =
|
6
|
+
VALID_VARIABLE_TYPES = %w(identifier choices integer numeric string text date time file datetime).sort
|
5
7
|
|
6
8
|
def assert_variable_type(item)
|
7
9
|
message = "#{item} invalid variable type. Valid types: #{VALID_VARIABLE_TYPES.join(', ')}"
|
8
10
|
assert VALID_VARIABLE_TYPES.include?(item), message
|
9
11
|
end
|
10
12
|
|
11
|
-
Dir.glob(
|
12
|
-
define_method("test_variable_type: "
|
13
|
-
assert_variable_type begin JSON.parse(File.read(file))[
|
13
|
+
Dir.glob('variables/**/*.json').each do |file|
|
14
|
+
define_method("test_variable_type: #{file}") do
|
15
|
+
assert_variable_type begin JSON.parse(File.read(file))['type'] rescue nil end
|
14
16
|
end
|
15
17
|
end
|
16
|
-
|
17
18
|
end
|
18
19
|
end
|
19
20
|
end
|
data/lib/spout/tests.rb
CHANGED
data/lib/spout/version.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Spout
|
2
4
|
module VERSION #:nodoc:
|
3
5
|
MAJOR = 0
|
4
6
|
MINOR = 11
|
5
|
-
TINY =
|
7
|
+
TINY = 1
|
6
8
|
BUILD = nil # 'pre', 'rc', 'rc2', nil
|
7
9
|
|
8
|
-
STRING = [MAJOR, MINOR, TINY, BUILD].compact.join('.')
|
10
|
+
STRING = [MAJOR, MINOR, TINY, BUILD].compact.join('.').freeze
|
9
11
|
end
|
10
12
|
end
|
data/lib/spout.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.11.
|
4
|
+
version: 0.11.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Remo Mueller
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|