eco-rake 0.1.3 → 0.1.5

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: 2267520b8e3a96d2a5f0c6b44aafb129f7d75592b090991d9738f0824f4a397e
4
- data.tar.gz: 75d8139d6dbe8be2a853b083cab99d98f6145b1b5e3ad73620b4569579ae7952
3
+ metadata.gz: 7a95738d0726a071fd9302ea5644ae019f0417577e0b9df2debf9d8e1c06b94f
4
+ data.tar.gz: eb1655d1f8cbc09ca84bc22be350170b122958a37bbbb70a969f038ee5e2afee
5
5
  SHA512:
6
- metadata.gz: a5724ff6fd5ab51f0851783bd04850b972ca5a01f58674e4c02adef49b5c17d30b379d5644a4a2d66925ffa028094c28c727a651b4e22271f295c382c137ed8c
7
- data.tar.gz: edd52995662c0346519bdc764a7241c55213349c9b5d32355333320ea4812496587090a88a041927cf715c082c041e717ec33ff170eb0f51e46b48fef08323da
6
+ metadata.gz: 6cb03e0ca5be560bd0e579851eb4476175e56eff2db1c37f41d2f9b07dfd536284c9cce1bf9ab06ff5b9a70d3f4ad3083f6b8ba81b7cfe0d764f00a7317dd23b
7
+ data.tar.gz: 85c9dda526770a38a72512a593e4d883895056a06073a79fb9f7bd3a4176fada22b98da712636f13ec3f95e5b1d07e47e00b0bce0f713b3eb33631944473a84c
data/CHANGELOG.md CHANGED
@@ -1,14 +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.3] - 2023-06-xx
4
+ ## [0.1.6] - 2024-02-xx
5
5
 
6
6
  ### Added
7
7
  ### Fixed
8
+ ### Changed
9
+
10
+ ## [0.1.5] - 2024-02-xx
11
+
12
+ ### Added
13
+ - new options for file pattern const and remote subfolder for the SFTP task
14
+
15
+ ### Fixed
8
16
 
9
17
  ### Changed
10
18
 
11
- ## [0.1.4] - 2023-06-xx
19
+ ## [0.1.4] - 2023-07-23
12
20
 
13
21
  ### Fixed
14
22
  - Type in `EcoRake::Utils::Mailing#email`
@@ -8,7 +8,9 @@ class EcoRake
8
8
  list: '-list',
9
9
  get_last: '-get-last',
10
10
  get: '-get',
11
- archive: '-archive'
11
+ archive: '-archive',
12
+ file_pattern: ->(str) { "-file-pattern-const #{str}"},
13
+ remote_subfolder: ->(sub) { "-remote-subfolder #{sub}"}
12
14
  }.freeze
13
15
 
14
16
  options_with_defaults true
@@ -19,6 +21,8 @@ class EcoRake
19
21
  option '-g', '--get', TrueClass, desc: 'Gets all available CSV feed files'
20
22
  option '-t', '--get-last', TrueClass, desc: 'Gets the last available CSV feed file'
21
23
  option '-a', '--archive', TrueClass, desc: "Moves the remote CSV feed files to the '/Archive' folder"
24
+ option '-p', '--file-pattern CONST', String, desc: "Specifies a const to use as the target file pattern"
25
+ option '-r', '--remote-subfolder SUBFOLDER', String, desc: "Remote subfolder of the env (at the top of the enviro folder)"
22
26
 
23
27
  option_forwarding(**FORWARD_RULES)
24
28
 
@@ -35,6 +39,7 @@ class EcoRake
35
39
  cmd = [base_command]
36
40
  cmd << forward_option(:folder)
37
41
  cmd << forward_options(:list, :get_last, :get, :archive).compact.first || '-list'
42
+ cmd.push(*forward_options(:remote_subfolder, :file_pattern).compact)
38
43
  cmd << '-no-people'
39
44
  cmd = yield(cmd) if block_given?
40
45
  string_cmd(*cmd)
@@ -9,6 +9,7 @@ class EcoRake
9
9
  option '-o', '--only-stats', TrueClass, desc: 'To display only stats in the feedback'
10
10
  option '-b', '--no-policy', FalseClass, desc: 'To skip the batch policy'
11
11
  option '-n', '--no-get', FalseClass, desc: 'Skip get people step'
12
+ option '-p', '--file-pattern', TrueClass, desc: "Specifies the target file pattern (can use a const)"
12
13
  end
13
14
  end
14
15
  end
@@ -4,6 +4,7 @@ class EcoRake
4
4
  # The top level task that organizes all the people sync
5
5
  class SyncProcess < EcoRake::Lib::People::SyncRely
6
6
  attr_const :do_decrypt, default: false
7
+ attr_const :pull_driver, default: 'sftp'
7
8
  attr_const :target_task
8
9
 
9
10
  attr_const :target_enviro, required: true
@@ -16,23 +17,36 @@ class EcoRake
16
17
 
17
18
  def task(*_args)
18
19
  upsert_local_dir(options[:folder])
19
- sh_continue rake_sftp_get
20
+ sh_continue pull_file
20
21
  if do_decrypt
21
22
  failed_decryption_notify unless 0 == sh_continue(rake_decrypt)
22
23
  end
23
24
  sh_continue rake_sync_command
24
25
  return if options[:simulate]
25
- sh_continue rake_sftp_archive
26
+ sh_continue rake_sftp_archive if pull_driver == 'sftp'
26
27
  sh_continue rake_files_purge('cache')
27
28
  sh_continue rake_files_purge('requests')
28
29
  end
29
30
 
30
31
  private
31
32
 
33
+ def pull_file
34
+ case pull_driver
35
+ when 'sftp'
36
+ rake_sftp_get
37
+ when 'url'
38
+ rake_url_get
39
+ end
40
+ end
41
+
32
42
  def rake_sftp_get
33
43
  rake_command('csv:sftp', *forward_options(:enviro, :folder), '-t')
34
44
  end
35
45
 
46
+ def rake_url_get
47
+ rake_command("csv:#{options[:enviro]}:url", *forward_options(:folder))
48
+ end
49
+
36
50
  def rake_sftp_archive
37
51
  rake_command('csv:sftp', *forward_options(:enviro, :folder), '-a')
38
52
  end
@@ -7,8 +7,8 @@ class EcoRake
7
7
  end
8
8
 
9
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
10
+ has_enviro = enviro && subject && subject.downcase.include?(enviro.downcase)
11
+ subject = "#{enviro.upcase} - #{subject}" if enviro && !has_enviro
12
12
  mailer.mail(**{
13
13
  to: to,
14
14
  subject: subject,
@@ -1,5 +1,5 @@
1
1
  require 'rake-commander'
2
2
 
3
3
  class EcoRake < RakeCommander
4
- VERSION = '0.1.3'.freeze
4
+ VERSION = '0.1.5'.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.3
4
+ version: 0.1.5
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-22 00:00:00.000000000 Z
11
+ date: 2024-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler