Sha256: c3664a509929114cef3a7b7c616eff0deeffa32aca61184d1a9022b6e1b20ebf

Contents?: true

Size: 1.98 KB

Versions: 2

Compression:

Stored size: 1.98 KB

Contents

module Wordmove
  module Organizers
    module Ftp
      class Pull
        extend ::LightService::Organizer
        include Wordmove::Actions::Helpers
        include Wordmove::Actions::Ftp::Helpers

        def self.call(cli_options:, movefile:)
          logger = Logger.new($stdout, movefile.secrets).tap { |l| l.level = Logger::DEBUG }
          remote_options = movefile.options[movefile.environment]
          ftp_opts = ftp_options(remote_options: remote_options)

          LightService::Configuration.logger = ::Logger.new($stdout) if cli_options[:debug]

          with(
            cli_options: cli_options,
            global_options: movefile.options[:global],
            local_options: movefile.options[:local],
            remote_options: remote_options,
            movefile: movefile,
            guardian: Wordmove::Guardian.new(cli_options: cli_options, action: :pull),
            logger: logger,
            photocopier: Photocopier::FTP
                          .new(ftp_opts)
                          .tap { |c| c.logger = logger }
          ).reduce(actions)
        end

        def self.actions
          [
            Wordmove::Actions::RunBeforePullHook, # Will fail and warn the user
            Wordmove::Actions::FilterAndSetupTasksToRun,
            reduce_if(
              ->(ctx) { ctx.wordpress_task },
              [Wordmove::Actions::Ftp::PullWordpress]
            ),
            iterate(:folder_tasks, [Wordmove::Actions::Ftp::GetDirectory]),
            reduce_if(->(ctx) { ctx.database_task },
                      [
                        Wordmove::Actions::SetupContextForDb,
                        Wordmove::Actions::BackupLocalDb,
                        Wordmove::Actions::Ftp::DownloadRemoteDb,
                        Wordmove::Actions::AdaptRemoteDb,
                        Wordmove::Actions::Ftp::CleanupAfterAdapt
                      ]),
            Wordmove::Actions::RunAfterPullHook # Will fail and warn the user
          ]
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wordmove-6.0.0.alpha.5 lib/wordmove/organizers/ftp/pull.rb
wordmove-6.0.0.alpha.4 lib/wordmove/organizers/ftp/pull.rb