eco-rake 0.2.22 → 0.2.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 885c49ab28211426eb99a4f2f4fd29444169308929ca69e7f4987a3b74445dfd
4
- data.tar.gz: bf35b6c25a4e1b72bcb45bd390d65e0813dd8badc057828fe33a4702707872b8
3
+ metadata.gz: 6b4ca5dc3ed2e25ec667ed2a8033cebe916e5fecef90938bd730293f61dbd669
4
+ data.tar.gz: 7da0918af8ea0471acffd5e7c0e0bac968911b0b28c80801ce0190209904252d
5
5
  SHA512:
6
- metadata.gz: 54ec3eab079fafacecd8430183ffdd0fb81a1ea893c40251e9e659d5359f8751ade9ddb27da4ffb35ede0f28adac323bb46c592d72cfa8dc6d1a23a899b0b036
7
- data.tar.gz: 2a384df8e189597b3cac6cfe6f8192b2bfcd2604d61f568325a85fd6c16f85d00e5954422051951953743fa5d49d0943a49df1a6fee71bbfcc7924c6458e5b2d
6
+ metadata.gz: 229b3b3ff0c4545446e2291353280b0514ba80a5d449932ddd09bd5aeefb36e05b56ce5e178b402f16f54bfbd1203de7249f52b3236b25451a2dba27a27c9050
7
+ data.tar.gz: d35d3ccd8e5b0c53294530c9f1a9c128c23007970954528bf9042a16baecfa3b36af0719d97f8068cb224d43a1edb5f8c5d2ff4bda8a8041001b509bd69c0dab
data/CHANGELOG.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
- ## [0.2.23] - 2025-03-xx
5
+ ## [0.2.24] - 2025-04-xx
6
6
 
7
7
  ### Added
8
8
 
@@ -10,11 +10,14 @@ All notable changes to this project will be documented in this file.
10
10
 
11
11
  ### Fixed
12
12
 
13
- ## [0.2.22] - 2025-03-26
13
+ ## [0.2.23] - 2025-04-xx
14
14
 
15
15
  ### Added
16
16
 
17
- ### Changed
17
+ - `CLEAN_LOCAL` constant for `People::Sync` process (default: `false`).
18
+ - To ensure input folder is emptied by moving the files therein to an `Archived` subfolder.
19
+
20
+ ## [0.2.22] - 2025-03-26
18
21
 
19
22
  ### Fixed
20
23
 
@@ -4,6 +4,10 @@ class EcoRake
4
4
  # The top level task that organizes all the people sync
5
5
  # @note in integration repos this is used to be called `run:feed`
6
6
  class SyncProcess < EcoRake::Lib::People::SyncRely
7
+ DATA_FILE_EXTENSIONS = %w[
8
+ .csv .json .xml .txt .xlsx xlsm .xlsb
9
+ ].freeze
10
+
7
11
  attr_const :do_decrypt, default: false
8
12
  attr_const :pull_driver, default: :sftp
9
13
  attr_const :target_task
@@ -14,11 +18,15 @@ class EcoRake
14
18
  attr_const :local_folder, default: '.'
15
19
  option_reopen :folder, default_lookup: :local_folder
16
20
 
21
+ attr_const :do_clean_local, default: false
22
+
17
23
  attr_const :mail_to
18
24
  attr_const :remote_archive, default: true
19
25
 
20
26
  def task(*_args)
21
27
  upsert_local_dir(options[:folder])
28
+ archive_local_data_files(options[:folder]) if clean_local_folder_data?
29
+
22
30
  sh_continue pull_file
23
31
  failed_decryption_notify if do_decrypt && !sh_continue(rake_decrypt).zero?
24
32
 
@@ -63,6 +71,31 @@ class EcoRake
63
71
  rake_command('logs:purge', *forward_options(:enviro, :space), "-d #{folder}", operation)
64
72
  end
65
73
 
74
+ def archive_local_data_files(folder)
75
+ data_files = self.class::DATA_FILE_EXTENSIONS.each_with_object([]) do |ext, files|
76
+ ext_files = folder_files(folder, "*#{ext}")
77
+ files.concat(ext_files)
78
+ end
79
+
80
+ return if data_files.empty?
81
+
82
+ dest_folder = File.join(folder, 'archive')
83
+ upsert_local_dir(dest_folder)
84
+
85
+ if options[:simulate]
86
+ msg = "Would have moved these files to '#{dest_folder}' (dry-run):\n"
87
+ msg << ' * '
88
+ msg << data_files.join("\n * ")
89
+ puts msg
90
+ else
91
+ move_file(*data_files, folder: dest_folder, message: 'Archiving these files:')
92
+ end
93
+ end
94
+
95
+ def clean_local_folder_data?
96
+ do_clean_local
97
+ end
98
+
66
99
  def failed_decryption_notify
67
100
  msg = 'File decryption failed'
68
101
  puts msg
@@ -40,7 +40,7 @@ class EcoRake
40
40
 
41
41
  # It identifies files in a folder by using different criteria.
42
42
  # @return [Array<String>] files that match the criteria **sorted** by name ascendant (i.e. abc)
43
- def folder_files(folder = ".", pattern = "*", regexp: nil, older_than: nil)
43
+ def folder_files(folder = '.', pattern = '*', regexp: nil, older_than: nil)
44
44
  target = File.join(File.expand_path(folder), pattern)
45
45
  Dir[target].tap do |dir_files|
46
46
  dir_files.select! {|f| File.file?(f)}
@@ -50,14 +50,14 @@ class EcoRake
50
50
  end
51
51
 
52
52
  # @see #folder_files . Same but fixed to `*.csv` **pattern**
53
- def csv_files(folder = ".", regexp: nil, older_than: nil)
54
- folder_files(folder, "*.csv", regexp: regexp, older_than: older_than)
53
+ def csv_files(folder = '.', regexp: nil, older_than: nil)
54
+ folder_files(folder, '*.csv', regexp: regexp, older_than: older_than)
55
55
  end
56
56
 
57
57
  # @see #folder_files . Same but fixed to `*.csv.gpg` **pattern**
58
- def gpg_files(folder = ".", regexp: nil, older_than: nil)
59
- gpg = folder_files(folder, "*.gpg", regexp: regexp, older_than: older_than)
60
- pgp = folder_files(folder, "*.pgp", regexp: regexp, older_than: older_than)
58
+ def gpg_files(folder = '.', regexp: nil, older_than: nil)
59
+ gpg = folder_files(folder, '*.gpg', regexp: regexp, older_than: older_than)
60
+ pgp = folder_files(folder, '*.pgp', regexp: regexp, older_than: older_than)
61
61
  gpg.concat(pgp)
62
62
  end
63
63
 
@@ -1,5 +1,5 @@
1
1
  require 'rake-commander'
2
2
 
3
3
  class EcoRake < RakeCommander
4
- VERSION = '0.2.22'.freeze
4
+ VERSION = '0.2.23'.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.2.22
4
+ version: 0.2.23
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: 2025-03-25 00:00:00.000000000 Z
11
+ date: 2025-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake