Class: Wordmove::Actions::Ssh::GetDirectory
- Inherits:
-
Object
- Object
- Wordmove::Actions::Ssh::GetDirectory
- Extended by:
- LightService::Action
- Includes:
- Helpers, Helpers, WordpressDirectory::RemoteHelperMethods
- Defined in:
- lib/wordmove/actions/ssh/get_directory.rb
Overview
Syncs a whole directory over SSH protocol from the remote server to local host
Class Method Summary collapse
-
.execute ⇒ LightService::Context
Action’s context.
Class Method Details
.execute ⇒ LightService::Context
Returns Action’s context.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/wordmove/actions/ssh/get_directory.rb', line 30 executed do |context| context.logger.task "Pulling #{context.folder_task}" next context if simulate?(cli_options: context.) command = 'get_directory' # For this action `local_path` and `remote_path` will always be # `:wordpress_path`; specific folder for `context.folder_task` will be included by # `pull_include_paths` local_path = context.[:wordpress_path] remote_path = context.[:wordpress_path] # This action can generate `command_args` by itself, # but it gives the context the chance to ovveride it. # By the way this variable is not `expects`ed. # Note that we do not use the second argument to `fetch` # to express a default value, because it would be greedly interpreted # but if `command_args` is already defined by context, then it's # possible that `"remote_#{context.folder_task}_dir"` could # not be defined. command_args = context.fetch(:command_args) || [ remote_path, local_path, pull_exclude_paths( remote_task_dir: send( "remote_#{context.folder_task}_dir", remote_options: context. ), paths_to_exclude: paths_to_exclude(remote_options: context.) ), pull_include_paths(remote_task_dir: send( "remote_#{context.folder_task}_dir", remote_options: context. )) ] context.logger.task_step false, "#{command}: #{command_args.join(' ')}" result = context.photocopier.send(command, *command_args) next context if result == true context.fail!("Failed to push #{context.folder_task}") end |