Class: EcoRake::Lib::Files::Decrypt

Inherits:
BaseTask show all
Defined in:
lib/eco-rake/lib/files/decrypt.rb

Constant Summary

Constants inherited from EcoRake

VERSION

Instance Method Summary collapse

Instance Method Details

#display_target_filesObject



32
33
34
35
# File 'lib/eco-rake/lib/files/decrypt.rb', line 32

def display_target_files
  puts "Source gpg files ('#{source_folder}'):"
  target_files.each {|file| puts "#{File.basename(file)}"}
end

#task(*_args) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/eco-rake/lib/files/decrypt.rb', line 12

def task(*_args)
  return display_target_files if options[:list]
  return warn_missing_file    if target_files.empty?

  status = 0
  target_files.each do |file|
    delete_file(gpg_to_csv_filename(file))

    stat   = sh_continue(
      decrypt_command(file, ignore_mdc_error: ignore_mdc_error)
    )

    status = stat unless stat.zero?
  end

  msg = "Deleting files from '#{source_folder}'"
  delete_file(*target_files, message: msg) unless options[:simulate]
  exit status unless status.zero?
end

#warn_missing_fileObject



37
38
39
# File 'lib/eco-rake/lib/files/decrypt.rb', line 37

def warn_missing_file
  puts "Could not find any file in folder '#{source_folder}'"
end