lib/eco-rake/lib/people/sync_process.rb in eco-rake-0.1.4 vs lib/eco-rake/lib/people/sync_process.rb in eco-rake-0.1.5
- old
+ new
@@ -2,10 +2,11 @@
module Lib
module People
# The top level task that organizes all the people sync
class SyncProcess < EcoRake::Lib::People::SyncRely
attr_const :do_decrypt, default: false
+ attr_const :pull_driver, default: 'sftp'
attr_const :target_task
attr_const :target_enviro, required: true
option_reopen :enviro, default_lookup: :target_enviro
@@ -14,24 +15,37 @@
option_reopen :folder, default_lookup: :local_folder
def task(*_args)
upsert_local_dir(options[:folder])
- sh_continue rake_sftp_get
+ sh_continue pull_file
if do_decrypt
failed_decryption_notify unless 0 == sh_continue(rake_decrypt)
end
sh_continue rake_sync_command
return if options[:simulate]
- sh_continue rake_sftp_archive
+ sh_continue rake_sftp_archive if pull_driver == 'sftp'
sh_continue rake_files_purge('cache')
sh_continue rake_files_purge('requests')
end
private
+ def pull_file
+ case pull_driver
+ when 'sftp'
+ rake_sftp_get
+ when 'url'
+ rake_url_get
+ end
+ end
+
def rake_sftp_get
rake_command('csv:sftp', *forward_options(:enviro, :folder), '-t')
+ end
+
+ def rake_url_get
+ rake_command("csv:#{options[:enviro]}:url", *forward_options(:folder))
end
def rake_sftp_archive
rake_command('csv:sftp', *forward_options(:enviro, :folder), '-a')
end