Class: Wordmove::Hook

Inherits:
Object
  • Object
show all
Defined in:
lib/wordmove/hook.rb

Defined Under Namespace

Classes: Config, Local, Remote

Class Method Summary collapse

Class Method Details

.loggerObject



3
4
5
# File 'lib/wordmove/hook.rb', line 3

def self.logger
  Logger.new(STDOUT).tap { |l| l.level = Logger::DEBUG }
end

.run(action, step, cli_options) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/wordmove/hook.rb', line 7

def self.run(action, step, cli_options)
  movefile = Wordmove::Movefile.new(cli_options[:config])
  options = movefile.fetch(false)
  environment = movefile.environment(cli_options)

  hooks = Wordmove::Hook::Config.new(
    options[environment][:hooks],
    action,
    step
  )

  unless hooks.local_hooks.empty?
    Wordmove::Hook::Local.run(hooks.local_hooks, options[:local], cli_options[:simulate])
  end

  return if hooks.remote_hooks.empty?

  if options[environment][:ftp]
    logger.debug "You have configured remote hooks to run over "\
                 "an FTP connection, but this is not possible. Skipping."

    return
  end

  Wordmove::Hook::Remote.run(
    hooks.remote_hooks, options[environment], cli_options[:simulate]
  )
end