eco-rake 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 06f88149753ab7424d569e1875bb0d0d5a914c3566b07a254fdcc6e71b101eb0
4
- data.tar.gz: 06cac6560a9d130b858de701ac45a7015ffff6382d2a9418ba7e2f9fcbf37fbd
3
+ metadata.gz: fa7405fb06b10d3052ffacab860fb0025d531991d75bfc1a1b9459045b13d301
4
+ data.tar.gz: a8ee96250e7234e34308f0d713ec5353cee15f808bfd777587927409c407d5ce
5
5
  SHA512:
6
- metadata.gz: cec87e0b5884b049d4a5ae70b92454050c9177b32bde8055a93240dd7138783be6ec65b9b80c2ff8e830c8832958c4714031bf54db03c336e3a5cdd599ef1a24
7
- data.tar.gz: affe3d449e395b6c6b143f71cb2821a2bd08b30e8609cc7df27575ab65faf2d8feead5297e056ad96953c4379b5e16e1be18be1ae5df133073493b50a128225b
6
+ metadata.gz: 951153395cdc3d54497af9dbc34b1c6a4814726de827c823f6d4a93215a86767f40d7c13b6a096890b65e9e2a9454c573414f30ff36ba59a98dc99413788c133
7
+ data.tar.gz: 18daed0a491aec28f760208eb48fde5675b00986574f78fe09a886ffd8ccb98cb71330129cc8a195780152f42a7c142f57497abddfedd666aabf0a3daf822bdb
data/CHANGELOG.md CHANGED
@@ -1,11 +1,17 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
- ## [0.1.1] - 2023-06-xx
4
+ ## [0.1.2] - 2023-06-xx
5
5
 
6
6
  ### Added
7
7
  ### Fixed
8
8
  ### Changed
9
+ - Notify when file decryption fails
10
+
11
+ ## [0.1.2] - 2023-06-09
12
+
13
+ ### Changed
14
+ - Notify when file decryption fails
9
15
 
10
16
  ## [0.1.1] - 2023-06-06
11
17
 
@@ -12,11 +12,14 @@ class EcoRake
12
12
  def task(*_args)
13
13
  return display_target_files if options[:list]
14
14
  return warn_missing_file if target_files.empty?
15
+ status = 0
15
16
  target_files.each do |file|
16
17
  delete_file(gpg_to_csv_filename(file))
17
- sh decrypt_command(file, ignore_mdc_error: ignore_mdc_error)
18
+ stat = sh_continue(decrypt_command(file, ignore_mdc_error: ignore_mdc_error))
19
+ status = stat unless stat == 0
18
20
  end
19
21
  delete_file(*target_files, message: "Deleting files from '#{source_folder}'") unless options[:simulate]
22
+ exit status unless status == 0
20
23
  end
21
24
 
22
25
  def display_target_files
@@ -17,7 +17,9 @@ class EcoRake
17
17
  def task(*_args)
18
18
  upsert_local_dir(options[:folder])
19
19
  sh_continue rake_sftp_get
20
- sh rake_decrypt if do_decrypt
20
+ if do_decrypt
21
+ failed_decryption_notify unless 0 == sh_continue(rake_decrypt)
22
+ end
21
23
  sh_continue rake_sync_command
22
24
  return if options[:simulate]
23
25
  sh_continue rake_sftp_archive
@@ -42,6 +44,15 @@ class EcoRake
42
44
  def rake_files_purge(folder, operation: '--remove')
43
45
  rake_command('logs:purge', *forward_options(:enviro), "-d #{folder}", operation)
44
46
  end
47
+
48
+ def failed_decryption_notify
49
+ msg = 'File decryption failed'
50
+ puts msg
51
+ exit 1 if options[:simulate]
52
+ exit 1 unless inbox = mail_to
53
+ email(enviro: target_enviro, to: inbox, subject: msg, body: msg)
54
+ exit 1
55
+ end
45
56
  end
46
57
  end
47
58
  end
@@ -52,6 +52,7 @@ class EcoRake
52
52
  msg = "Command failed (status = #{res.exitstatus})"
53
53
  puts "#{msg}\n • #{comm}"
54
54
  end
55
+ res.exitstatus
55
56
  end
56
57
  end
57
58
  end
@@ -6,9 +6,18 @@ class EcoRake
6
6
  @mailer ||= EcoRake::Utils::Mailer.new
7
7
  end
8
8
 
9
+ def email(subject:, body:, to:, enviro: nil)
10
+ subject = "#{enviro.upcase} - #{subject}" unless !enviro && subject.downcase.include?(enviro.downcase)
11
+ mailer.mail(**{
12
+ to: to,
13
+ subject: subject,
14
+ body: body
15
+ })
16
+ end
17
+
9
18
  # Helper to notify that there are no files to be processed
10
19
  def email_missing_files(enviro:, to:)
11
- mailer.mail(**{
20
+ email(**{
12
21
  to: to,
13
22
  subject: "#{enviro.upcase} (No files to be processed)",
14
23
  body: 'No files found to be processed. Aborting...'
@@ -1,5 +1,5 @@
1
1
  require 'rake-commander'
2
2
 
3
3
  class EcoRake < RakeCommander
4
- VERSION = '0.1.1'.freeze
4
+ VERSION = '0.1.2'.freeze
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eco-rake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura Samper
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-06 00:00:00.000000000 Z
11
+ date: 2023-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler