spout 0.10.0.beta6 → 0.10.0.beta7

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: d2c5a33171e6f9d0ed9ea65595d6fa2cc846c522
4
- data.tar.gz: b83e43ccf34a70eac9d4485861a40f4a0f2269dc
3
+ metadata.gz: d4418b6291f10a58bcf649b785114423a462aca8
4
+ data.tar.gz: 16a62a4c3357173af4808bd5a5ab9d767f692296
5
5
  SHA512:
6
- metadata.gz: 8c6f37201645cd745c38d14ad5599ee702d313e41dc6f27cea28883d9a21c7cdf616287f7340df1e2fd1588c621fdb43f3a0c52b584e5744d60a8fcf277d3ade
7
- data.tar.gz: e5d504aa8ab9bf0acdb71e0d0ad5a17fbecf4889b5d577fb1f8ecbca10d21446af6dd0e17ad925db8950af1ea5783a8b8c83b15955f85aeb41c9f19469b4be3a
6
+ metadata.gz: fdaeae598fccf2e5d29be1d491efc4951d02e56eaeb2917fb91a944b8eaea24d5fd4780bebb281116d42e8271fc63798694a53a1bdc3a69d0a926e7535a684de
7
+ data.tar.gz: 38b272dfe518b4e230b6e4eec679b00838259c0fc3b3d0e1b3f5af39a56325ce702c1af3542a885e7c9e71c066ed1a8c38a72fc30a7ae1be6fc593bb07c9f576
@@ -3,6 +3,9 @@ require 'net/http'
3
3
 
4
4
  require 'spout/helpers/config_reader'
5
5
  require 'spout/helpers/quietly'
6
+ require 'spout/helpers/send_file'
7
+ require 'spout/helpers/semantic'
8
+ require 'spout/helpers/json_request'
6
9
 
7
10
  # - **User Authorization**
8
11
  # - User authenticates via token, the user must be a dataset editor
@@ -43,11 +46,14 @@ module Spout
43
46
  attr_accessor :token, :version, :slug, :url, :config, :environment
44
47
 
45
48
  def initialize(argv, version)
46
- # puts "CODE GREEN INITIALIZED...".colorize(:green)
47
- # puts "Deploying to server...".colorize(:red)
48
49
  @environment = argv[1].to_s
49
50
  @version = version
50
- @skip_checks = false
51
+ @skip_checks = (argv.delete('--skip-checks') != nil)
52
+
53
+ @skip_graphs = (argv.delete('--skip-graphs') != nil)
54
+ @skip_images = (argv.delete('--skip-images') != nil)
55
+ @skip_server_updates = (argv.delete('--skip-server-updates') != nil)
56
+
51
57
  run_all
52
58
  end
53
59
 
@@ -57,10 +63,10 @@ module Spout
57
63
  version_check unless @skip_checks
58
64
  test_check unless @skip_checks
59
65
  user_authorization
60
- graph_generation
61
- image_generation
66
+ graph_generation unless @skip_graphs
67
+ image_generation unless @skip_images
62
68
  dataset_uploads
63
- trigger_server_updates
69
+ trigger_server_updates unless @skip_server_updates
64
70
  rescue DeployError
65
71
  end
66
72
  end
@@ -184,17 +190,29 @@ module Spout
184
190
  end
185
191
 
186
192
  def dataset_uploads
187
- print " Dataset Uploads: "
188
- # failure ''
189
- # puts "PASS".colorize(:green)
190
- puts "SKIP".colorize(:blue)
193
+ available_folders = (Dir.exist?('csvs') ? Dir.entries('csvs').select{|e| File.directory? File.join('csvs', e) }.reject{|e| [".",".."].include?(e)}.sort : [])
194
+
195
+ semantic = Spout::Helpers::Semantic.new(@version, available_folders)
196
+
197
+ csv_directory = semantic.selected_folder
198
+
199
+ csv_files = Dir.glob("csvs/#{csv_directory}/*.csv")
200
+
201
+ csv_files.each_with_index do |csv_file, index|
202
+ print "\r Dataset Uploads: " + "#{index + 1} of #{csv_files.count}".colorize(:green)
203
+ response = Spout::Helpers::SendFile.post("#{@url}/datasets/#{@slug}/upload_dataset_csv.json", csv_file, @version, @token)
204
+ end
205
+ puts "\r Dataset Uploads: " + "DONE ".colorize(:green)
191
206
  end
192
207
 
193
208
  def trigger_server_updates
194
209
  print "Launch Server Scripts: "
195
- # failure ''
196
- # puts "PASS".colorize(:green)
197
- puts "SKIP".colorize(:blue)
210
+ response = Spout::Helpers::JsonRequest.get("#{@url}/datasets/#{@slug}/a/#{@token}/refresh_dictionary.json?version=#{@version}")
211
+ if response and response['refresh'] == 'success'
212
+ puts "DONE".colorize(:green)
213
+ else
214
+ puts "FAIL".colorize(:red)
215
+ end
198
216
  end
199
217
 
200
218
  def failure(message)
@@ -0,0 +1,45 @@
1
+ require 'openssl'
2
+ require 'net/http'
3
+ require 'json'
4
+
5
+ module Spout
6
+ module Helpers
7
+ class JsonRequest
8
+ class << self
9
+ def get(*args)
10
+ new(*args).get
11
+ end
12
+ end
13
+
14
+ attr_reader :url
15
+
16
+ def initialize(url)
17
+ begin
18
+ @url = URI.parse(url)
19
+ @http = Net::HTTP.new(@url.host, @url.port)
20
+ if @url.scheme == 'https'
21
+ @http.use_ssl = true
22
+ @http.verify_mode = OpenSSL::SSL::VERIFY_NONE
23
+ end
24
+ rescue
25
+ end
26
+ end
27
+
28
+ def get
29
+ begin
30
+ full_path = @url.path
31
+ full_path += "?#{@url.query}" if @url.query
32
+ req = Net::HTTP::Get.new(full_path)
33
+ response = @http.start do |http|
34
+ http.request(req)
35
+ end
36
+ JSON.parse(response.body)
37
+ rescue
38
+ nil
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+
45
+
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 = "beta6" # nil, "pre", "rc", "rc2"
6
+ BUILD = "beta7" # nil, "pre", "rc", "rc2"
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, BUILD].compact.join('.')
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spout
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0.beta6
4
+ version: 0.10.0.beta7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Remo Mueller
@@ -122,6 +122,7 @@ files:
122
122
  - lib/spout/helpers/config_reader.rb
123
123
  - lib/spout/helpers/iterators.rb
124
124
  - lib/spout/helpers/json_loader.rb
125
+ - lib/spout/helpers/json_request.rb
125
126
  - lib/spout/helpers/number_helper.rb
126
127
  - lib/spout/helpers/quietly.rb
127
128
  - lib/spout/helpers/semantic.rb