Class: Wordmove::Actions::DeleteLocalFile

Inherits:
Object
  • Object
show all
Extended by:
LightService::Action
Includes:
Helpers
Defined in:
lib/wordmove/actions/delete_local_file.rb

Overview

Note:

This action is not meant to be organized, but as a standalone one.

Delete a local file situated at the given path. Command won’t be run if --simulate flag is present on CLI.

Class Method Summary collapse

Class Method Details

.executeLightService::Context

Returns Action’s context.

Parameters:

  • file_path (String)
  • logger (Wordmove::Logger)
  • cli_options (Hash)

    Command line options (with symbolized keys)

Returns:

  • (LightService::Context)

    Action’s context



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/wordmove/actions/delete_local_file.rb', line 20

executed do |context|
  context.logger.task_step true, "delete: '#{context.file_path}'"

  next context if simulate?(cli_options: context.cli_options)

  unless File.exist?(context.file_path)
    context.logger.info "File #{context.file_path} does not exist. Nothing done."
    next context
  end

  File.delete(context.file_path)
end