spout 0.10.2 → 0.11.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +36 -0
- data/README.md +3 -30
- data/lib/spout/commands/coverage.rb +2 -1
- data/lib/spout/commands/deploy.rb +82 -77
- data/lib/spout/commands/exporter.rb +2 -3
- data/lib/spout/commands/graphs.rb +68 -67
- data/lib/spout/commands/help.rb +155 -0
- data/lib/spout/helpers/array_statistics.rb +36 -30
- data/lib/spout/helpers/chart_types.rb +2 -2
- data/lib/spout/helpers/config_reader.rb +5 -5
- data/lib/spout/helpers/json_request.rb +1 -2
- data/lib/spout/helpers/json_request_generic.rb +87 -0
- data/lib/spout/helpers/quietly.rb +2 -4
- data/lib/spout/helpers/semantic.rb +7 -11
- data/lib/spout/helpers/send_file.rb +23 -25
- data/lib/spout/helpers/subject_loader.rb +41 -32
- data/lib/spout/helpers/table_formatting.rb +7 -6
- data/lib/spout/models/bucket.rb +5 -4
- data/lib/spout/models/coverage_result.rb +1 -1
- data/lib/spout/models/dictionary.rb +3 -1
- data/lib/spout/models/domain.rb +7 -6
- data/lib/spout/models/empty.rb +17 -0
- data/lib/spout/models/form.rb +8 -5
- data/lib/spout/models/graphables/default.rb +41 -18
- data/lib/spout/models/graphables/histogram.rb +6 -7
- data/lib/spout/models/graphables.rb +3 -5
- data/lib/spout/models/option.rb +6 -2
- data/lib/spout/models/outlier_result.rb +3 -3
- data/lib/spout/models/record.rb +21 -3
- data/lib/spout/models/subject.rb +4 -7
- data/lib/spout/models/tables/choices_vs_choices.rb +29 -17
- data/lib/spout/models/tables/choices_vs_numeric.rb +19 -12
- data/lib/spout/models/tables/default.rb +19 -32
- data/lib/spout/models/tables/numeric_vs_choices.rb +9 -13
- data/lib/spout/models/tables/numeric_vs_numeric.rb +9 -11
- data/lib/spout/models/tables.rb +4 -6
- data/lib/spout/models/variable.rb +51 -13
- data/lib/spout/tasks/engine.rake +1 -1
- data/lib/spout/templates/ruby-version +1 -1
- data/lib/spout/templates/travis.yml +1 -1
- data/lib/spout/tests/domain_format.rb +2 -2
- data/lib/spout/tests/domain_name_format.rb +15 -0
- data/lib/spout/tests/form_name_format.rb +14 -0
- data/lib/spout/tests/variable_name_format.rb +14 -0
- data/lib/spout/tests.rb +18 -13
- data/lib/spout/version.rb +3 -3
- data/lib/spout/views/index.html.erb +2 -2
- data/lib/spout/views/outliers.html.erb +1 -1
- data/lib/spout.rb +13 -58
- data/spout.gemspec +14 -15
- metadata +25 -25
- data/lib/spout/commands/images.rb +0 -199
- data/lib/spout/support/javascripts/data.js +0 -17
- data/lib/spout/support/javascripts/highcharts-convert.js +0 -583
- data/lib/spout/support/javascripts/highcharts-more.js +0 -50
- data/lib/spout/support/javascripts/highstock.js +0 -353
- data/lib/spout/support/javascripts/jquery.1.9.1.min.js +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35179a9011f963b875618eeb8fd07854c58f9cce
|
4
|
+
data.tar.gz: 321e836a1a80d07092e0bbe5d921f712db8dcb18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d811aca192cc49aa05a8fc5dd5c4f1523f977b0fc2eb0e56c6f6ed5cd7f8295d73b69ccd93382183d3199c84986dff828c1faa611a39038b2b2bcb32ef14405f
|
7
|
+
data.tar.gz: 9ba01d7cb5f51f977b9433a8186f69241585bbba0eb2beb238c7794fe3c1eaa548da3450d527692747a950786ca02f609dad7e90058bc539a28ec371fbe4a521
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,39 @@
|
|
1
|
+
## 0.11.0
|
2
|
+
|
3
|
+
### Deprecations
|
4
|
+
- **Image Command**
|
5
|
+
- Spout variable graphs are no longer required as images by the NSRR webserver and have been removed
|
6
|
+
|
7
|
+
### Enhancements
|
8
|
+
- **Deploy Command**
|
9
|
+
- The deploy command can now accept flags and arguments that modify and scope graphs and images
|
10
|
+
- ex: `spout deploy WEBSERVER var1 var2 --rows=100 --clean`
|
11
|
+
- This pushes a clean version of graphs and images based on the first 100 rows in the CSVs for var1 and var2
|
12
|
+
- Spout now provides detailed information when deploying variables, forms, and domains
|
13
|
+
- CSVs can now be grouped into subfolders within their version folders, ex:
|
14
|
+
- `<project_name>/csvs/<VERSION>/dataset-main.csv`
|
15
|
+
- `<project_name>/csvs/<VERSION>/subfolder/dataset-extra-a.csv`
|
16
|
+
- `<project_name>/csvs/<VERSION>/subfolder/dataset-extra-b.csv`
|
17
|
+
- `CHANGELOG.md` and `KNOWNISSUES.md` are now uploaded alongside datasets during a deploy
|
18
|
+
- **Graph Command**
|
19
|
+
- Tables no longer include unknown values for variables that don't exist across other CSVs with the same subject and visit
|
20
|
+
- Tables still track unknown values if the CSV contains a column for the variable, but the cell for subject is blank
|
21
|
+
- Histograms of variables that only contain a small range (less than 12) of integers now use discrete buckets of size 1 instead of creating fractional buckets
|
22
|
+
- Numbers less than one now respect the precision of the number when computing means and related statistics
|
23
|
+
- **Export Command**
|
24
|
+
- Commonly Used attribute is now included in data dictionary exports
|
25
|
+
- **Tests Added**
|
26
|
+
- New tests were added to check the format of variable names, form names, and domain names
|
27
|
+
- **Help Command**
|
28
|
+
- The help command now allows users to learn more about individual commands
|
29
|
+
- ex: `spout help deploy`
|
30
|
+
- **Gem Changes**
|
31
|
+
- Updated to Ruby 2.3.0
|
32
|
+
- Bundler is now a required dependency
|
33
|
+
|
34
|
+
### Refactoring
|
35
|
+
- Started refactoring code base to better adhere to RuboCop style recommendations
|
36
|
+
|
1
37
|
## 0.10.2 (December 29, 2014)
|
2
38
|
|
3
39
|
### Bug Fix
|
data/README.md
CHANGED
@@ -212,31 +212,6 @@ You can optionally provide a version string
|
|
212
212
|
spout export [1.0.0]
|
213
213
|
```
|
214
214
|
|
215
|
-
### Generate images for data in your dataset
|
216
|
-
|
217
|
-
Spout lets you generate images for each variable defined in your dataset. Make sure to run `spout coverage` first to validate that your data dictionary and dataset match.
|
218
|
-
|
219
|
-
This command will take some time, and requires [PhantomJS](http://phantomjs.org/) to be installed on your system.
|
220
|
-
|
221
|
-
```
|
222
|
-
spout pngs
|
223
|
-
```
|
224
|
-
|
225
|
-
The following flags can be passed to the `spout pngs` command:
|
226
|
-
|
227
|
-
- `spout p --type-numeric`
|
228
|
-
- `spout p --type-integer`
|
229
|
-
- `spout p --type-choices`
|
230
|
-
- `spout p --size-lg`
|
231
|
-
- `spout p --size-sm`
|
232
|
-
- `spout p --type-numeric --size-sm`
|
233
|
-
|
234
|
-
For specific variables the following can be used:
|
235
|
-
- `spout p <variable_id>`
|
236
|
-
|
237
|
-
Generated images are placed in: `./images/`
|
238
|
-
|
239
|
-
|
240
215
|
### Generate charts and tables for data in your dataset
|
241
216
|
|
242
217
|
```
|
@@ -274,7 +249,7 @@ spout g ahi bmi
|
|
274
249
|
You can also specify a limit to the amount of rows to read in from the CSV files by specifying the `-rows` flag
|
275
250
|
|
276
251
|
```
|
277
|
-
spout g
|
252
|
+
spout g --rows=10 ahi
|
278
253
|
```
|
279
254
|
|
280
255
|
This will generate a graph for ahi for the first 10 rows of each dataset CSV.
|
@@ -369,13 +344,11 @@ The following steps are run:
|
|
369
344
|
- **Graph Generation**
|
370
345
|
- `spout g` is run
|
371
346
|
- Graphs are pushed to server
|
372
|
-
- **Image Generation**
|
373
|
-
- `spout p` is run
|
374
|
-
- `optipng` is run on image then uploaded to server
|
375
|
-
- Images are pushed to server
|
376
347
|
- **Dataset Uploads**
|
377
348
|
- Dataset CSV data dictionary is generated (variables, domains, forms)
|
378
349
|
- Dataset and data dictionary CSVs uploaded to files section of dataset
|
350
|
+
- **Documentation Uploads**
|
351
|
+
- `README.md` and `KNOWNISSUES.md` are uploaded
|
379
352
|
- **Server-Side Updates**
|
380
353
|
- Server checks out branch of specified tag
|
381
354
|
- Server runs `load_data_dictionary!` for specified dataset slug
|
@@ -6,6 +6,7 @@ require 'spout/helpers/subject_loader'
|
|
6
6
|
require 'spout/models/coverage_result'
|
7
7
|
require 'spout/helpers/number_helper'
|
8
8
|
require 'spout/helpers/config_reader'
|
9
|
+
require 'spout/helpers/array_statistics'
|
9
10
|
|
10
11
|
module Spout
|
11
12
|
module Commands
|
@@ -35,7 +36,7 @@ module Spout
|
|
35
36
|
@matching_results = []
|
36
37
|
|
37
38
|
@subject_loader.all_methods.each do |method, csv_files|
|
38
|
-
scr = Spout::Models::CoverageResult.new(method, @subjects.collect(&method.to_sym).uniq)
|
39
|
+
scr = Spout::Models::CoverageResult.new(method, @subjects.collect(&method.to_sym).compact_empty.uniq)
|
39
40
|
@matching_results << [ csv_files, method, scr ]
|
40
41
|
end
|
41
42
|
|
@@ -21,10 +21,6 @@ require 'spout/helpers/json_request'
|
|
21
21
|
# - **Graph Generation**
|
22
22
|
# - `spout g` is run
|
23
23
|
# - Graphs are pushed to server
|
24
|
-
# - **Image Generation**
|
25
|
-
# - `spout p` is run
|
26
|
-
# - `optipng` is run on image then uploaded to server
|
27
|
-
# - Images are pushed to server
|
28
24
|
# - **Dataset Uploads**
|
29
25
|
# - Dataset CSV data dictionary is generated (variables, domains, forms)
|
30
26
|
# - Dataset and data dictionary CSVs uploaded to files section of dataset
|
@@ -39,25 +35,38 @@ end
|
|
39
35
|
module Spout
|
40
36
|
module Commands
|
41
37
|
class Deploy
|
42
|
-
|
43
38
|
include Spout::Helpers::Quietly
|
44
39
|
|
45
40
|
INDENT_LENGTH = 23
|
46
|
-
INDENT =
|
41
|
+
INDENT = ' ' * INDENT_LENGTH
|
47
42
|
|
48
43
|
attr_accessor :token, :version, :slug, :url, :config, :environment, :webserver_name, :subjects
|
49
44
|
|
50
45
|
def initialize(argv, version)
|
51
|
-
|
46
|
+
argv.shift # Remove 'download' command from argv list
|
47
|
+
@environment = argv.shift
|
52
48
|
@version = version
|
53
|
-
@skip_checks = (argv.delete('--skip-checks')
|
49
|
+
@skip_checks = !(argv.delete('--skip-checks').nil? && argv.delete('--no-checks').nil?)
|
50
|
+
|
51
|
+
@skip_graphs = !(argv.delete('--skip-graphs').nil? && argv.delete('--no-graphs').nil?)
|
52
|
+
@skip_csvs = !(argv.delete('--skip-csvs').nil? && argv.delete('--no-csvs').nil?)
|
53
|
+
@clean = !(argv.delete('--no-resume').nil? && argv.delete('--clean').nil?)
|
54
|
+
@skip_server_updates = !(argv.delete('--skip-server-updates').nil? && argv.delete('--no-server-updates').nil?)
|
55
|
+
|
56
|
+
token_arg = argv.find { |arg| /^--token=/ =~ arg }
|
57
|
+
argv.delete(token_arg)
|
58
|
+
@token = token_arg.gsub(/^--token=/, '') if token_arg
|
59
|
+
|
60
|
+
rows_arg = argv.find { |arg| /^--rows=(\d*)/ =~ arg }
|
61
|
+
argv.delete(rows_arg)
|
62
|
+
@number_of_rows = rows_arg.gsub(/--rows=/, '').to_i if rows_arg
|
54
63
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
64
|
+
# puts "token_arg: #{token_arg}".colorize(:red)
|
65
|
+
# puts "@token: #{@token}".colorize(:red)
|
66
|
+
# puts "rows_arg: #{rows_arg}".colorize(:red)
|
67
|
+
# puts "@number_of_rows: #{@number_of_rows}".colorize(:red)
|
59
68
|
|
60
|
-
@
|
69
|
+
@argv = argv
|
61
70
|
|
62
71
|
begin
|
63
72
|
run_all
|
@@ -67,35 +76,31 @@ module Spout
|
|
67
76
|
end
|
68
77
|
|
69
78
|
def run_all
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
data_dictionary_uploads
|
83
|
-
trigger_server_updates unless @skip_server_updates
|
84
|
-
rescue DeployError
|
85
|
-
end
|
79
|
+
config_file_load
|
80
|
+
version_check unless @skip_checks
|
81
|
+
test_check unless @skip_checks
|
82
|
+
user_authorization
|
83
|
+
load_subjects_from_csvs unless @skip_graphs
|
84
|
+
graph_generation unless @skip_graphs
|
85
|
+
dataset_uploads unless @skip_csvs
|
86
|
+
data_dictionary_uploads unless @skip_csvs
|
87
|
+
markdown_uploads unless @skip_csvs
|
88
|
+
trigger_server_updates unless @skip_server_updates
|
89
|
+
rescue DeployError
|
90
|
+
# Nothing on Deploy Error
|
86
91
|
end
|
87
92
|
|
88
93
|
def load_subjects_from_csvs
|
89
94
|
@dictionary_root = Dir.pwd
|
90
95
|
@variable_files = Dir.glob(File.join(@dictionary_root, 'variables', '**', '*.json'))
|
91
96
|
|
92
|
-
@subject_loader = Spout::Helpers::SubjectLoader.new(@variable_files, [], @version,
|
97
|
+
@subject_loader = Spout::Helpers::SubjectLoader.new(@variable_files, [], @version, @number_of_rows, @config.visit)
|
93
98
|
@subject_loader.load_subjects_from_csvs!
|
94
99
|
@subjects = @subject_loader.subjects
|
95
100
|
end
|
96
101
|
|
97
102
|
def config_file_load
|
98
|
-
print
|
103
|
+
print ' `.spout.yml` Check: '
|
99
104
|
@config = Spout::Helpers::ConfigReader.new
|
100
105
|
|
101
106
|
@slug = @config.slug
|
@@ -110,7 +115,7 @@ module Spout
|
|
110
115
|
failure(message)
|
111
116
|
end
|
112
117
|
|
113
|
-
matching_webservers = @config.webservers.select{|wh| /^#{@environment}/i =~ wh['name'].to_s.downcase}
|
118
|
+
matching_webservers = @config.webservers.select { |wh| /^#{@environment}/i =~ wh['name'].to_s.downcase }
|
114
119
|
if matching_webservers.count == 0
|
115
120
|
message = "#{INDENT}0 webservers match '#{@environment}'.".colorize(:red) + " The following webservers exist in your `.spout.yml` file:\n" + "#{INDENT}#{@config.webservers.collect{|wh| wh['name'].to_s.downcase}.join(', ')}".colorize(:white)
|
116
121
|
failure(message)
|
@@ -127,9 +132,9 @@ module Spout
|
|
127
132
|
failure(message)
|
128
133
|
end
|
129
134
|
|
130
|
-
puts
|
131
|
-
puts
|
132
|
-
puts
|
135
|
+
puts 'PASS'.colorize(:green)
|
136
|
+
puts ' Target Server: ' + "#{@url}".colorize(:white)
|
137
|
+
puts ' Target Dataset: ' + "#{@slug}".colorize(:white)
|
133
138
|
end
|
134
139
|
|
135
140
|
# - **Version Check**
|
@@ -141,11 +146,11 @@ module Spout
|
|
141
146
|
`git status --porcelain`
|
142
147
|
end
|
143
148
|
|
144
|
-
print
|
149
|
+
print ' Git Status Check: '
|
145
150
|
if stdout.to_s.strip == ''
|
146
|
-
puts
|
151
|
+
puts 'PASS'.colorize(:green) + ' ' + 'nothing to commit, working directory clean'.colorize(:white)
|
147
152
|
else
|
148
|
-
message = "#{INDENT}working directory contains uncomitted changes".colorize(:red)
|
153
|
+
message = "#{INDENT}working directory contains uncomitted changes\n#{INDENT}use `".colorize(:red) + '--skip-checks'.colorize(:white) + '` to ignore this step'.colorize(:red)
|
149
154
|
failure message
|
150
155
|
end
|
151
156
|
|
@@ -153,7 +158,7 @@ module Spout
|
|
153
158
|
if changelog.match(/^## #{@version.split('.')[0..2].join('.')}/)
|
154
159
|
puts " CHANGELOG.md: " + "PASS".colorize(:green) + " " + changelog.colorize(:white)
|
155
160
|
else
|
156
|
-
print
|
161
|
+
print ' CHANGELOG.md: '
|
157
162
|
message = "#{INDENT}Expected: ".colorize(:red) + "## #{@version}".colorize(:white) +
|
158
163
|
"\n#{INDENT} Actual: ".colorize(:red) + changelog.colorize(:white)
|
159
164
|
failure message
|
@@ -163,15 +168,14 @@ module Spout
|
|
163
168
|
`git describe --exact-match HEAD --tags`
|
164
169
|
end
|
165
170
|
|
166
|
-
print
|
171
|
+
print ' Version Check: '
|
167
172
|
tag = stdout.to_s.strip
|
168
173
|
if "v#{@version}" != tag
|
169
|
-
message = "#{INDENT}Version specified in `VERSION` file ".colorize(:red) + "'v#{@version}'".colorize(:white) +
|
174
|
+
message = "#{INDENT}Version specified in `VERSION` file ".colorize(:red) + "'v#{@version}'".colorize(:white) + ' does not match git tag on HEAD commit '.colorize(:red) + "'#{tag}'".colorize(:white)
|
170
175
|
failure message
|
171
176
|
else
|
172
|
-
puts
|
177
|
+
puts 'PASS'.colorize(:green) + ' VERSION ' + "'v#{@version}'".colorize(:white) + ' matches git tag ' + "'#{tag}'".colorize(:white)
|
173
178
|
end
|
174
|
-
|
175
179
|
end
|
176
180
|
|
177
181
|
def test_check
|
@@ -182,7 +186,7 @@ module Spout
|
|
182
186
|
end
|
183
187
|
|
184
188
|
if stdout.match(/[^\d]0 failures, 0 errors,/)
|
185
|
-
puts
|
189
|
+
puts 'PASS'.colorize(:green)
|
186
190
|
else
|
187
191
|
message = "#{INDENT}spout t".colorize(:white) + " had errors or failures".colorize(:red) + "\n#{INDENT}Please fix all errors and failures and then run spout deploy again."
|
188
192
|
failure message
|
@@ -198,38 +202,28 @@ module Spout
|
|
198
202
|
|
199
203
|
response = Spout::Helpers::JsonRequest.get("#{@url}/datasets/#{@slug}/a/#{@token}/editor.json")
|
200
204
|
|
201
|
-
if response.
|
202
|
-
puts
|
205
|
+
if response.is_a?(Hash) and response['editor']
|
206
|
+
puts 'AUTHORIZED'.colorize(:green)
|
203
207
|
else
|
204
|
-
puts
|
208
|
+
puts 'UNAUTHORIZED'.colorize(:red)
|
205
209
|
puts "#{INDENT}You are not set as an editor on the #{@slug} dataset or you mistyped your token."
|
206
210
|
raise DeployError
|
207
211
|
end
|
208
212
|
|
209
213
|
# failure ''
|
210
|
-
# puts
|
214
|
+
# puts 'PASS'.colorize(:green)
|
211
215
|
end
|
212
216
|
|
213
217
|
def graph_generation
|
214
218
|
# failure ''
|
215
219
|
require 'spout/commands/graphs'
|
216
|
-
argv
|
217
|
-
argv
|
218
|
-
|
219
|
-
puts "\r Graph Generation: " + "DONE ".colorize(:green)
|
220
|
-
end
|
221
|
-
|
222
|
-
def image_generation
|
223
|
-
# failure ''
|
224
|
-
require 'spout/commands/images'
|
225
|
-
argv = []
|
226
|
-
argv << "--clean" if @clean
|
227
|
-
Spout::Commands::Images.new([], [], [], @version, argv, true, @url, @slug, @token, @webserver_name, @subjects)
|
228
|
-
puts "\r Image Generation: " + "DONE ".colorize(:green)
|
220
|
+
@argv << '--clean' if @clean
|
221
|
+
Spout::Commands::Graphs.new(@argv, @version, true, @url, @slug, @token, @webserver_name, @subjects)
|
222
|
+
puts "\r Graph Generation: " + 'DONE '.colorize(:green)
|
229
223
|
end
|
230
224
|
|
231
225
|
def dataset_uploads
|
232
|
-
available_folders = (Dir.exist?('csvs') ? Dir.entries('csvs').select{|e| File.directory? File.join('csvs', e) }.reject{|e| [
|
226
|
+
available_folders = (Dir.exist?('csvs') ? Dir.entries('csvs').select { |e| File.directory? File.join('csvs', e) }.reject { |e| ['.', '..'].include?(e) }.sort : [])
|
233
227
|
semantic = Spout::Helpers::Semantic.new(@version, available_folders)
|
234
228
|
csv_directory = semantic.selected_folder
|
235
229
|
|
@@ -238,17 +232,18 @@ module Spout
|
|
238
232
|
return
|
239
233
|
end
|
240
234
|
|
241
|
-
csv_files = Dir.glob("csvs/#{csv_directory}
|
235
|
+
csv_files = Dir.glob("csvs/#{csv_directory}/**/*.csv")
|
242
236
|
|
243
237
|
csv_files.each_with_index do |csv_file, index|
|
244
238
|
print "\r Dataset Uploads: " + "#{index + 1} of #{csv_files.count}".colorize(:green)
|
245
|
-
|
239
|
+
folder = csv_file.gsub(/^csvs/, '').gsub(/#{File.basename(csv_file)}$/, '')
|
240
|
+
response = Spout::Helpers::SendFile.post("#{@url}/api/v1/dictionary/upload_dataset_csv.json", csv_file, @version, @token, @slug, folder)
|
246
241
|
end
|
247
242
|
puts "\r Dataset Uploads: " + "DONE ".colorize(:green)
|
248
243
|
end
|
249
244
|
|
250
245
|
def data_dictionary_uploads
|
251
|
-
print
|
246
|
+
print ' Dictionary Uploads:'
|
252
247
|
|
253
248
|
require 'spout/commands/exporter'
|
254
249
|
Spout::Commands::Exporter.new(@version, ['--quiet'])
|
@@ -256,32 +251,42 @@ module Spout
|
|
256
251
|
csv_files = Dir.glob("dd/#{@version}/*.csv")
|
257
252
|
csv_files.each_with_index do |csv_file, index|
|
258
253
|
print "\r Dictionary Uploads: " + "#{index + 1} of #{csv_files.count}".colorize(:green)
|
259
|
-
response = Spout::Helpers::SendFile.post("#{@url}/
|
254
|
+
response = Spout::Helpers::SendFile.post("#{@url}/api/v1/dictionary/upload_dataset_csv.json", csv_file, @version, @token, @slug, nil)
|
255
|
+
end
|
256
|
+
puts "\r Dictionary Uploads: " + 'DONE '.colorize(:green)
|
257
|
+
end
|
258
|
+
|
259
|
+
def markdown_uploads
|
260
|
+
print 'Documentation Uploads:'
|
261
|
+
markdown_files = Dir.glob(%w(CHANGELOG.md KNOWNISSUES.md))
|
262
|
+
markdown_files.each_with_index do |markdown_file, index|
|
263
|
+
print "\rDocumentation Uploads: " + "#{index + 1} of #{markdown_files.count}".colorize(:green)
|
264
|
+
Spout::Helpers::SendFile.post("#{@url}/api/v1/dictionary/upload_dataset_csv.json", markdown_file, @version, @token, @slug, nil)
|
260
265
|
end
|
261
|
-
puts "\
|
266
|
+
puts "\rDocumentation Uploads: " + 'DONE '.colorize(:green)
|
262
267
|
end
|
263
268
|
|
264
269
|
def trigger_server_updates
|
265
|
-
print
|
270
|
+
print 'Launch Server Scripts: '
|
266
271
|
response = Spout::Helpers::JsonRequest.get("#{@url}/datasets/#{@slug}/a/#{@token}/refresh_dictionary.json?version=#{@version}")
|
267
|
-
if response.
|
268
|
-
puts
|
269
|
-
elsif response.
|
270
|
-
puts
|
271
|
-
puts "#{INDENT}Tag not found in repository, resolve using: " +
|
272
|
+
if response.is_a?(Hash) && response['refresh'] == 'success'
|
273
|
+
puts 'DONE'.colorize(:green)
|
274
|
+
elsif response.is_a?(Hash) && response['refresh'] == 'notagfound'
|
275
|
+
puts 'FAIL'.colorize(:red)
|
276
|
+
puts "#{INDENT}Tag not found in repository, resolve using: " + 'git push --tags'.colorize(:white)
|
272
277
|
raise DeployError
|
273
|
-
elsif response.
|
274
|
-
puts
|
278
|
+
elsif response.is_a?(Hash) && response['refresh'] == 'gitrepodoesnotexist'
|
279
|
+
puts 'FAIL'.colorize(:red)
|
275
280
|
puts "#{INDENT}Dataset data dictionary git repository has not been cloned on the server. Contact server admin.".colorize(:white)
|
276
281
|
raise DeployError
|
277
282
|
else
|
278
|
-
puts
|
283
|
+
puts 'FAIL'.colorize(:red)
|
279
284
|
raise DeployError
|
280
285
|
end
|
281
286
|
end
|
282
287
|
|
283
288
|
def failure(message)
|
284
|
-
puts
|
289
|
+
puts 'FAIL'.colorize(:red)
|
285
290
|
puts message
|
286
291
|
raise DeployError
|
287
292
|
end
|
@@ -22,7 +22,7 @@ module Spout
|
|
22
22
|
puts " create".colorize( :green ) + " #{folder}" unless @quiet
|
23
23
|
FileUtils.mkpath folder
|
24
24
|
|
25
|
-
generic_export(folder, 'variables', %w(id display_name description type units domain labels calculation))
|
25
|
+
generic_export(folder, 'variables', %w(id display_name description type units domain labels calculation commonly_used))
|
26
26
|
generic_export(folder, 'domains', %w(value display_name description), true)
|
27
27
|
generic_export(folder, 'forms', %w(id display_name code_book))
|
28
28
|
end
|
@@ -45,7 +45,7 @@ module Spout
|
|
45
45
|
csv << [relative_folder, domain_name] + keys.collect{|key| hash[key]}
|
46
46
|
end
|
47
47
|
else
|
48
|
-
csv << [relative_folder] + keys.collect{|key| json[key].
|
48
|
+
csv << [relative_folder] + keys.collect{|key| json[key].is_a?(Array) ? json[key].join(';') : json[key].to_s}
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
@@ -67,7 +67,6 @@ module Spout
|
|
67
67
|
def extract_domain_name(file)
|
68
68
|
file.gsub(/domains\//, '').split('/').last.to_s.gsub(/.json/, '')
|
69
69
|
end
|
70
|
-
|
71
70
|
end
|
72
71
|
end
|
73
72
|
end
|