lib/eco-rake/lib/people/sync_launch.rb in eco-rake-0.2.0 vs lib/eco-rake/lib/people/sync_launch.rb in eco-rake-0.2.1
- old
+ new
@@ -27,25 +27,26 @@
option_forwarding(**FORWARD_RULES)
def task(*_args)
return missing_files_notify unless latest_file
return process_deltas if delta?
- return process_full_file if full?
+ return process_full_file if full? || delta_last?
end
private
def process_full_file
- sh people_get_command unless options[:no_get]
+ sh people_get_command unless options[:no_get] || delta_last?
sh_continue sync_command(latest_file)
clear_files unless options[:simulate]
end
def process_deltas
target_files.each do |file|
sh sync_command(file)
next if options[:simulate]
+
puts "Deleting file #{file}"
File.delete(file)
end
end
@@ -64,11 +65,11 @@
def sync_command(file)
cmd = []
cmd << ruby_runner
cmd << forward_option(:enviro)
cmd << forward_option(:schema)
- cmd << '-get-partial' if delta?
+ cmd << '-get-partial' if delta? || delta_last?
cmd << base_command(file)
cmd.concat(forward_options(*self.class::ADDITIONAL_OPTIONS))
cmd = yield(cmd) if block_given?
string_cmd(*cmd)
end
@@ -85,11 +86,11 @@
usecase = base_usecase.to_sym
case usecase
when :hris
msg = "Inconsistent configuration in #{self.class}. BASE_USECASE is '#{usecase}', "
msg << "but file SNAPSHOT_MODE is '#{snapshot_mode}'"
- raise msg if delta?
+ raise msg if delta? || delta_last?
"-hris-from #{double_quote(file_or_folder)}"
when :upsert
"-upsert-from #{double_quote(file_or_folder)}"
else
raise ArgumentError, "Unknown use case '#{usecase}'"
@@ -101,9 +102,13 @@
end
def delta?
mode = snapshot_mode.to_s.downcase.to_sym
%i[partial delta].any? {|m| m == mode}
+ end
+
+ def last_delta?
+ snapshot_mode.to_s.downcase.to_sym == :delta_last
end
# Amont the `target_files` the last in alphabetic order.
def latest_file
@latest_file ||= target_files.last