Method: Wordmove::Deployer::Base.deployer_for

Defined in:
lib/wordmove/deployer/base.rb

.deployer_for(cli_options) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/wordmove/deployer/base.rb', line 17

def deployer_for(cli_options)
  options = fetch_movefile(cli_options[:config])
  available_enviroments = extract_available_envs(options)
  options.merge!(cli_options).recursive_symbolize_keys!

  if available_enviroments.size > 1 && options[:environment].nil?
    raise "You need to specify an environment with --environment parameter"
  end
  environment = (options[:environment] || available_enviroments.first).to_sym

  if options[environment][:ftp]
    require 'wordmove/deployer/ftp'
    FTP.new(environment, options)
  elsif options[environment][:ssh]
    require 'wordmove/deployer/ssh'
    SSH.new(environment, options)
  else
    raise StandardError, "No valid adapter found."
  end
end