advance 0.2.1 → 0.3.0

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
  SHA256:
3
- metadata.gz: d7f5948d846efa632c923c68ea86b89b1b785f6ffd58fda4f52fc0cac30579d1
4
- data.tar.gz: c29928e7ed6662adb03144adf1029b2b5e834cfe3e2f90ee76babc007425646a
3
+ metadata.gz: 961d5cc4a945b3b3bf404f27ad1e16119d437fec4abce4d21413374087c80e5e
4
+ data.tar.gz: aa4259e85e69a968a0564529433751f6a244ce1257206f7b9b048d182d85944e
5
5
  SHA512:
6
- metadata.gz: 35da400978126d81ce5babf678b0ae68eb2c698fae75e39d28da4d4bdabd68dfc3294b3e7f44d045d5b612f614928e5c8027c1506a8bb2bae5eab72b4b9b3d26
7
- data.tar.gz: 64d1afb3685a4bd9f2a70d7c07cdc1e0ff3f93c553ef3f82d6165ef92e8486622b0577a78f067ece3cdceeb39513ad73c85499396f732f81ddc87f0a433ce257
6
+ metadata.gz: 3eb44f9dbd87f94c865760d6f0ae981647d151f074600bb9fe8a844d63efd0ab819a2de2c44f165408735914528408cf2ec550dd0f0a4f6a53d5daf9b94cdf50
7
+ data.tar.gz: 196d465c18c089a7a3841cc55d4991f736c59366f38a6a1d3d4d933e93bcf1ca8ed292d094601b940c825807a495198f99500f7f89c1881309bf303215b19c46
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- advance (0.2.1)
4
+ advance (0.3.0)
5
5
  team_effort
6
6
 
7
7
  GEM
@@ -1,3 +1,3 @@
1
1
  module Advance
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
data/lib/advance.rb CHANGED
@@ -31,11 +31,23 @@ module Advance
31
31
  dir_name = "#{dir_prefix}_#{label}"
32
32
 
33
33
  puts "#{CYAN}advance #{$step} #{label}#{WHITE}... #{RESET}"
34
- return if $redo_mode == :checking && Dir.exist?(dir_name)
35
34
 
36
- clean_previous_step_dirs(dir_prefix)
35
+ if $redo_mode != :checking || !(File.exist?(dir_name) || File.exist?(dir_name + '.tgz'))
36
+ clean_previous_step_dirs(dir_prefix)
37
37
 
38
- send(processing_mode, command, previous_dir_path, dir_name)
38
+ if previous_dir_path =~ /\.tgz$/
39
+ do_command_wo_log "tar xzf #{previous_dir_path}"
40
+ end
41
+ previous_dir_path = previous_dir_path.gsub(/\.tgz$/, "")
42
+ send(processing_mode, command, previous_dir_path, dir_name)
43
+ end
44
+ previous_dir_path = previous_dir_path.gsub(/\.tgz$/, "")
45
+ if File.basename(previous_dir_path) =~ /^step_/
46
+ if !File.exist?("#{previous_dir_path}.tgz")
47
+ do_command_wo_log "tar czf #{previous_dir_path}.tgz #{File.basename(previous_dir_path)}"
48
+ end
49
+ do_command_wo_log "rm -rf #{previous_dir_path}"
50
+ end
39
51
  end
40
52
 
41
53
  def static(processing_mode, label, command)
@@ -172,7 +184,7 @@ module Advance
172
184
  end
173
185
 
174
186
  def previous_file_path(previous_dir_path)
175
- Find.find(previous_dir_path).reject { |p| FileTest.directory?(p) || File.basename(p) == "log" }.first
187
+ Find.find(previous_dir_path).reject {|p| File.basename(p) =~ %r(^\.) || FileTest.directory?(p) || File.basename(p) == "log"}.first
176
188
  end
177
189
 
178
190
  def file_path_template(dir_path, files)
@@ -204,6 +216,24 @@ module Advance
204
216
  end
205
217
  end
206
218
 
219
+ def do_command_wo_log(command, feedback = true)
220
+ puts "#{YELLOW}#{command}#{RESET} " if feedback
221
+ stdout, stderr, status = Open3.capture3(command)
222
+ if !status.success?
223
+ error_msg = [
224
+ "step #{$step} failed",
225
+ "%%% command: >#{command}<",
226
+ "%%% returned status: >#{status}<",
227
+ "%%% stdout:",
228
+ stdout,
229
+ "%%% stderr:",
230
+ stderr
231
+ ].join("\n")
232
+
233
+ raise error_msg
234
+ end
235
+ end
236
+
207
237
  def ensure_bin_on_path
208
238
  advance_path = File.dirname(__FILE__)
209
239
  add_dir_to_path(advance_path)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: advance
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - janemacfarlane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-10 00:00:00.000000000 Z
11
+ date: 2019-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: team_effort