spout 0.10.0.rc2 → 0.10.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7449161615e7a639d91a56f1a7a0ad76305bd4aa
4
- data.tar.gz: a3cf532e5429e49c7f8b5631cc89d183e748a257
3
+ metadata.gz: bc9072ee8ab4b9edc7aca6cbcf3deac1beb6e0ae
4
+ data.tar.gz: 5aa46a8c58cee7bd2a42e43e5fe9cf2837d563d5
5
5
  SHA512:
6
- metadata.gz: 1017da75474cb754296d88301fc6a2f81d3b0381dc23a38c0a7e39a322bf7c365af79876af3c792f6d3d02ab015c8671afaffb43b20d07e790f57bef1ed87e0c
7
- data.tar.gz: 2f16bc92bd15d26d33307ab8aece2fe585922b5be8ac82f79cbb2ef4c9c12897ddd283e6f444065720608c4141ba282418cefdae2c9eb1335c1d368975c027c5
6
+ metadata.gz: e88283a8aad7684d12f51051a166d5daddc84455963b593f27903cc5d4b4f84fe51b1c7a9b5f0e0591f60e295b519e0ff6ad9f5f70a424a0cd5696bd59d1df8d
7
+ data.tar.gz: d44f4834ad2a885d8f1c17518dd29924d3de76ee31ffc88d6ebfb85d5a6423f23d3e2fafdab848db8c5310ee29d6f16c009259de1084b6b9035405d6f714de20
@@ -2,6 +2,7 @@ require 'colorize'
2
2
  require 'net/http'
3
3
  require 'io/console'
4
4
 
5
+ require 'spout/helpers/subject_loader'
5
6
  require 'spout/helpers/config_reader'
6
7
  require 'spout/helpers/quietly'
7
8
  require 'spout/helpers/send_file'
@@ -44,7 +45,7 @@ module Spout
44
45
  INDENT_LENGTH = 23
45
46
  INDENT = " "*INDENT_LENGTH
46
47
 
47
- attr_accessor :token, :version, :slug, :url, :config, :environment, :webserver_name
48
+ attr_accessor :token, :version, :slug, :url, :config, :environment, :webserver_name, :subjects
48
49
 
49
50
  def initialize(argv, version)
50
51
  @environment = argv[1].to_s
@@ -71,6 +72,10 @@ module Spout
71
72
  version_check unless @skip_checks
72
73
  test_check unless @skip_checks
73
74
  user_authorization
75
+
76
+ load_subjects_from_csvs unless @skip_graphs and @skip_images
77
+
78
+
74
79
  graph_generation unless @skip_graphs
75
80
  image_generation unless @skip_images
76
81
  dataset_uploads
@@ -80,6 +85,15 @@ module Spout
80
85
  end
81
86
  end
82
87
 
88
+ def load_subjects_from_csvs
89
+ @dictionary_root = Dir.pwd
90
+ @variable_files = Dir.glob(File.join(@dictionary_root, 'variables', '**', '*.json'))
91
+
92
+ @subject_loader = Spout::Helpers::SubjectLoader.new(@variable_files, [], @version, nil, @config.visit)
93
+ @subject_loader.load_subjects_from_csvs!
94
+ @subjects = @subject_loader.subjects
95
+ end
96
+
83
97
  def config_file_load
84
98
  print " `.spout.yml` Check: "
85
99
  @config = Spout::Helpers::ConfigReader.new
@@ -201,7 +215,7 @@ module Spout
201
215
  require 'spout/commands/graphs'
202
216
  argv = []
203
217
  argv << "--clean" if @clean
204
- Spout::Commands::Graphs.new(argv, @version, true, @url, @slug, @token, @webserver_name)
218
+ Spout::Commands::Graphs.new(argv, @version, true, @url, @slug, @token, @webserver_name, @subjects)
205
219
  puts "\r Graph Generation: " + "DONE ".colorize(:green)
206
220
  end
207
221
 
@@ -210,7 +224,7 @@ module Spout
210
224
  require 'spout/commands/images'
211
225
  argv = []
212
226
  argv << "--clean" if @clean
213
- Spout::Commands::Images.new([], [], [], @version, argv, true, @url, @slug, @token, @webserver_name)
227
+ Spout::Commands::Images.new([], [], [], @version, argv, true, @url, @slug, @token, @webserver_name, @subjects)
214
228
  puts "\r Image Generation: " + "DONE ".colorize(:green)
215
229
  end
216
230
 
@@ -17,7 +17,7 @@ require 'spout/version'
17
17
  module Spout
18
18
  module Commands
19
19
  class Graphs
20
- def initialize(variables, standard_version, deploy_mode = false, url = '', slug = '', token = '', webserver_name = '')
20
+ def initialize(variables, standard_version, deploy_mode = false, url = '', slug = '', token = '', webserver_name = '', subjects = nil)
21
21
  @deploy_mode = deploy_mode
22
22
  @url = url
23
23
  @standard_version = standard_version
@@ -67,10 +67,14 @@ module Spout
67
67
  @graphs_folder = File.join("graphs", @standard_version)
68
68
  FileUtils.mkpath @graphs_folder
69
69
 
70
- @subject_loader = Spout::Helpers::SubjectLoader.new(@variable_files, @valid_ids, @standard_version, @number_of_rows, @config.visit)
71
70
 
72
- @subject_loader.load_subjects_from_csvs!
73
- @subjects = @subject_loader.subjects
71
+ @subjects = if subjects
72
+ subjects
73
+ else
74
+ @subject_loader = Spout::Helpers::SubjectLoader.new(@variable_files, @valid_ids, @standard_version, @number_of_rows, @config.visit)
75
+ @subject_loader.load_subjects_from_csvs!
76
+ @subjects = @subject_loader.subjects
77
+ end
74
78
 
75
79
  load_current_progress
76
80
 
@@ -88,13 +92,25 @@ module Spout
88
92
 
89
93
  def save_current_progress
90
94
  File.open(@progress_file,"w") do |f|
91
- f.write(@progress.to_json)
95
+ f.write(JSON.pretty_generate(@progress) + "\n")
92
96
  end
93
97
  end
94
98
 
95
99
  def compute_tables_and_charts
96
- variable_files_count = @variable_files.count
100
+ begin
101
+ iterate_through_variables
102
+ ensure
103
+ save_current_progress
104
+ end
105
+ end
106
+
107
+ def send_to_server(chart_json_file)
108
+ response = Spout::Helpers::SendFile.post("#{@url}/datasets/#{@slug}/upload_graph.json", chart_json_file, @standard_version, @token)
109
+ end
97
110
 
111
+
112
+ def iterate_through_variables
113
+ variable_files_count = @variable_files.count
98
114
  @variable_files.each_with_index do |variable_file, file_index|
99
115
  variable = Spout::Models::Variable.new(variable_file, @dictionary_root)
100
116
 
@@ -159,16 +175,11 @@ module Spout
159
175
  puts "\nUPLOAD FAILED: ".colorize(:red) + File.basename(chart_json_file)
160
176
  end
161
177
  end
162
-
163
- save_current_progress
164
-
165
178
  end
166
- end
167
179
 
168
- def send_to_server(chart_json_file)
169
- response = Spout::Helpers::SendFile.post("#{@url}/datasets/#{@slug}/upload_graph.json", chart_json_file, @standard_version, @token)
170
180
  end
171
181
 
182
+
172
183
  end
173
184
  end
174
185
  end
@@ -15,7 +15,7 @@ module Spout
15
15
  module Commands
16
16
  class Images
17
17
 
18
- def initialize(types, variable_ids, sizes, standard_version, argv, deploy_mode = false, url = '', slug = '', token = '', webserver_name = '')
18
+ def initialize(types, variable_ids, sizes, standard_version, argv, deploy_mode = false, url = '', slug = '', token = '', webserver_name = '', subjects = nil)
19
19
  @deploy_mode = deploy_mode
20
20
  @url = url
21
21
  @standard_version = standard_version
@@ -42,10 +42,13 @@ module Spout
42
42
  @images_folder = File.join("images", @standard_version)
43
43
  FileUtils.mkpath @images_folder
44
44
 
45
- @subject_loader = Spout::Helpers::SubjectLoader.new(@variable_files, @valid_ids, @standard_version, @number_of_rows, @config.visit)
46
-
47
- @subject_loader.load_subjects_from_csvs!
48
- @subjects = @subject_loader.subjects
45
+ @subjects = if subjects
46
+ subjects
47
+ else
48
+ @subject_loader = Spout::Helpers::SubjectLoader.new(@variable_files, @valid_ids, @standard_version, @number_of_rows, @config.visit)
49
+ @subject_loader.load_subjects_from_csvs!
50
+ @subjects = @subject_loader.subjects
51
+ end
49
52
 
50
53
  load_current_progress
51
54
 
@@ -62,11 +65,19 @@ module Spout
62
65
 
63
66
  def save_current_progress
64
67
  File.open(@progress_file,"w") do |f|
65
- f.write(@progress.to_json)
68
+ f.write(JSON.pretty_generate(@progress) + "\n")
66
69
  end
67
70
  end
68
71
 
69
72
  def compute_images
73
+ begin
74
+ iterate_through_variables
75
+ ensure
76
+ save_current_progress
77
+ end
78
+ end
79
+
80
+ def iterate_through_variables
70
81
 
71
82
  options_folder = "images/#{@standard_version}"
72
83
  FileUtils.mkpath( options_folder )
@@ -138,8 +149,6 @@ module Spout
138
149
  @progress[variable.id]['uploaded'] << @webserver_name if @deploy_mode and @progress[variable.id]['upload_failed'] != true
139
150
  @progress[variable.id].delete('uploaded_files')
140
151
  @progress[variable.id].delete('upload_failed')
141
-
142
- save_current_progress
143
152
  end
144
153
 
145
154
  end
data/lib/spout/version.rb CHANGED
@@ -3,7 +3,7 @@ module Spout
3
3
  MAJOR = 0
4
4
  MINOR = 10
5
5
  TINY = 0
6
- BUILD = "rc2" # nil, "pre", "rc", "rc2"
6
+ BUILD = "rc3" # nil, "pre", "rc", "rc2"
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, BUILD].compact.join('.')
9
9
  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.10.0.rc2
4
+ version: 0.10.0.rc3
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-05 00:00:00.000000000 Z
11
+ date: 2014-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake