lib/advance.rb in advance-0.1.7 vs lib/advance.rb in advance-0.1.8
- old
+ new
@@ -105,34 +105,43 @@
File.join(dir_path, "{file}")
end
end
def work_in_sub_dir(dir_name, existing_message = nil)
- return if Dir.exist? dir_name
+ if $redo_mode == :checking && Dir.exist?(dir_name)
+ return :checking
+ end
+ if Dir.exist? dir_name
+ puts "reprocessing #{dir_name}"
+ FileUtils.rm_rf dir_name
+ end
+
tmp_dir_name = "tmp_#{dir_name}"
FileUtils.rm_rf tmp_dir_name
FileUtils.mkdir_p tmp_dir_name
FileUtils.cd tmp_dir_name
yield
FileUtils.cd ".."
FileUtils.mv tmp_dir_name, dir_name
+ :replacing
end
def step_dir_prefix(step_no)
"step_%03d" % [step_no]
end
def step(label)
+ $redo_mode ||= :checking
$step ||= 0
$step += 1
dir_name = "#{step_dir_prefix($step)}_#{label}"
$previous_dir = File.join(FileUtils.pwd, dir_name)
puts "#{CYAN}step #{$step} #{label}#{WHITE}... #{RESET}"
- work_in_sub_dir(dir_name, "#{GREEN}OK#{RESET}") do
+ $redo_mode = work_in_sub_dir(dir_name, "#{GREEN}OK#{RESET}") do
yield
end
end
def ensure_bin_on_path