eco-rake 0.1.1 → 0.1.3

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: 2267520b8e3a96d2a5f0c6b44aafb129f7d75592b090991d9738f0824f4a397e
4
+ data.tar.gz: 75d8139d6dbe8be2a853b083cab99d98f6145b1b5e3ad73620b4569579ae7952
5
5
  SHA512:
6
- metadata.gz: cec87e0b5884b049d4a5ae70b92454050c9177b32bde8055a93240dd7138783be6ec65b9b80c2ff8e830c8832958c4714031bf54db03c336e3a5cdd599ef1a24
7
- data.tar.gz: affe3d449e395b6c6b143f71cb2821a2bd08b30e8609cc7df27575ab65faf2d8feead5297e056ad96953c4379b5e16e1be18be1ae5df133073493b50a128225b
6
+ metadata.gz: a5724ff6fd5ab51f0851783bd04850b972ca5a01f58674e4c02adef49b5c17d30b379d5644a4a2d66925ffa028094c28c727a651b4e22271f295c382c137ed8c
7
+ data.tar.gz: edd52995662c0346519bdc764a7241c55213349c9b5d32355333320ea4812496587090a88a041927cf715c082c041e717ec33ff170eb0f51e46b48fef08323da
data/CHANGELOG.md CHANGED
@@ -1,11 +1,22 @@
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.3] - 2023-06-xx
5
5
 
6
6
  ### Added
7
7
  ### Fixed
8
+
9
+ ### Changed
10
+
11
+ ## [0.1.4] - 2023-06-xx
12
+
13
+ ### Fixed
14
+ - Type in `EcoRake::Utils::Mailing#email`
15
+
16
+ ## [0.1.2] - 2023-06-09
17
+
8
18
  ### Changed
19
+ - Notify when file decryption fails
9
20
 
10
21
  ## [0.1.1] - 2023-06-06
11
22
 
@@ -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,19 @@ class EcoRake
6
6
  @mailer ||= EcoRake::Utils::Mailer.new
7
7
  end
8
8
 
9
+ def email(subject:, body:, to:, enviro: nil)
10
+ has_enviro = subject && subject.downcase.include?(enviro.downcase)
11
+ subject = "#{enviro.upcase} - #{subject}" unless !enviro && has_enviro
12
+ mailer.mail(**{
13
+ to: to,
14
+ subject: subject,
15
+ body: body
16
+ })
17
+ end
18
+
9
19
  # Helper to notify that there are no files to be processed
10
20
  def email_missing_files(enviro:, to:)
11
- mailer.mail(**{
21
+ email(**{
12
22
  to: to,
13
23
  subject: "#{enviro.upcase} (No files to be processed)",
14
24
  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.3'.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.3
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-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler