Class: Wordmove::Actions::FilterAndSetupTasksToRun

Inherits:
Object
  • Object
show all
Extended by:
LightService::Action
Includes:
Helpers, Ssh::Helpers, WordpressDirectory::RemoteHelperMethods
Defined in:
lib/wordmove/actions/filter_and_setup_tasks_to_run.rb

Overview

Given the command line options and given the denied-by-config actions, selects the actions to be run altering the context.

Class Method Summary collapse

Class Method Details

.executeLightService::Context

Returns Action’s context.

Parameters:

Returns:

  • (LightService::Context)

    Action’s context



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/wordmove/actions/filter_and_setup_tasks_to_run.rb', line 22

executed do |context|
  all_tasks = Wordmove::CLI::PullPushShared::WORDPRESS_OPTIONS

  requested_tasks = all_tasks.select do |task|
    context.cli_options[task] ||
      (context.cli_options[:all] && context.cli_options[task] != false)
  end

  allowed_tasks = requested_tasks.select do |task|
    context.guardian.allow? task
  end

  # Since we `promises` the following variables, we cannot set them as `nil`
  context.database_task = allowed_tasks.delete(:db) || false
  context.wordpress_task = allowed_tasks.delete(:wordpress) || false
  # :db and :wordpress were just removed, so we consider
  # the reminders as folder tasks. It's a weak assumption
  # though.
  context.folder_tasks = allowed_tasks
end