Sha256: 57383c287984e459c0adafa71a4f26b68f6f81cae534678fe7b34543f69ce3c1

Contents?: true

Size: 1.45 KB

Versions: 1

Compression:

Stored size: 1.45 KB

Contents

class EcoRake
  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 :target_task

        attr_const :target_enviro, required: true
        option_reopen :enviro, default_lookup: :target_enviro

        attr_const :local_folder, default: '.'
        attr_const :mail_to

        option_reopen :folder, default_lookup: :local_folder

        def task(*_args)
          upsert_local_dir(options[:folder])
          sh_continue rake_sftp_get
          sh rake_decrypt if do_decrypt
          sh_continue rake_sync_command
          return if options[:simulate]
          sh_continue rake_sftp_archive
          sh_continue rake_files_purge('cache')
          sh_continue rake_files_purge('requests')
        end

        private

        def rake_sftp_get
          rake_command('csv:sftp', *forward_options(:enviro, :folder), '-t')
        end

        def rake_sftp_archive
          rake_command('csv:sftp', *forward_options(:enviro, :folder), '-a')
        end

        def rake_decrypt
          array_cmd('rake csv:decrypt', '--', forward_option(:folder)).join(" ")
        end

        def rake_files_purge(folder, operation: '--remove')
          rake_command('logs:purge', *forward_options(:enviro), "-d #{folder}", operation)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eco-rake-0.1.1 lib/eco-rake/lib/people/sync_process.rb