thecore_ftp_helpers 2.0.1 → 2.1.3

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: 0dbd641735f5466ed9d98cf051a0a7f3e3f8d33765cf3cf8abc888af9dec458f
4
- data.tar.gz: e4fabc772235c4218d17a739b9e6993d88872095abc98b34d69784bb16d44f52
3
+ metadata.gz: 5fb0b198d8af5221a0226d088e046c9e41c16045acf957a837f5d89f3a5bc019
4
+ data.tar.gz: 62369b565fc2429d0b3fdb88fbb28e106a71c74eecaccaf5a9c40a45fb45804a
5
5
  SHA512:
6
- metadata.gz: 2aa188d8d607ee7cf6ca7d3a1c912ed1cfc558097f8a4c4e6f5bc9b968ef263da03b0aac997ad34018957efbf534d062405787b9cf87e37ac57e4465b88e854d
7
- data.tar.gz: f66cf310f1ea5a1f00672658d6cca91b0ff081d4b7baca47d3de58861c363d46911a74f8adc22a04ea7408300574f9c1ab0ed95f7e43130173f0648f8461c5c4
6
+ metadata.gz: dd24970e259d08c2a613c03fbfcee2f6e1cd08152cc619ef8e1dd0c05a2cffa0b745e6443a4ebee0ac2ef8521dcf09989fec199a9515b83bef4128e9fc3a2c6b
7
+ data.tar.gz: fa320d379830939766f0c1ad9b06803253d00de9e7354de2d4d1977979f68a4fe8ab46f1e8d0ef50ae488ab4c36b904f1e60e09fa1784febdc8a147904d60bac
@@ -11,30 +11,39 @@ module ThecoreFtpHelpers
11
11
  puts "Connecting to FTP"
12
12
  ftp = Net::FTP.open address, username, password
13
13
  # ftp.passive = false
14
- puts "Entering directory: #{directory}"
15
- ftp.chdir(directory)
14
+ # puts "Entering directory: #{directory}"
15
+ # ftp.chdir(directory)
16
16
  puts "Listing all files which respond to this pattern: #{pattern}"
17
17
  begin
18
- files = ftp.nlst(pattern)
18
+ # files = ftp.nlst(pattern)
19
+ files=ftp.mlsd directory
19
20
  rescue => exception
20
21
  # If we are here, maybe it's beacause of passive mode and the network too secure
21
22
  # let's switch to active mode and try again
22
23
  ftp.passive = false
23
- files = ftp.nlst(pattern)
24
+ files=ftp.mlsd directory
24
25
  end
25
26
 
26
27
  puts "Last import time: #{from.strftime('%Y-%m-%d %H:%M:%S.%N')}"
27
- files = files.select {|f|
28
- puts "For file: #{f}"
29
- puts "Filetime: #{ftp.mtime(f).strftime('%Y-%m-%d %H:%M:%S.%N')}"
30
- puts "File chosen? #{ftp.mtime(f).to_f > from.to_f}"
31
- ftp.mtime(f).to_f > from.to_f
28
+ most_recent = nil
29
+ # puts "SELECTING FILES"
30
+ files = files.select {|f|
31
+ f.pathname.starts_with?(pattern) && f.modify.to_f > from.to_f
32
32
  } unless from.blank?
33
- puts "Chosen files: #{files.inspect}"
34
- most_recent = files.sort_by{|f| ftp.mtime(f).to_f}.last
33
+ # puts "SELECTED FILES: #{files.inspect}"
34
+ most_recent = files.sort_by{|f| f.modify.to_f}.last.pathname
35
+ # puts "MOST RECENT IS: #{most_recent}"
36
+ # files.select {|f|
37
+ # puts "For file: #{f}"
38
+ # puts "Filetime: #{ftp.mtime(f).strftime('%Y-%m-%d %H:%M:%S.%N')}"
39
+ # puts "File chosen? #{ftp.mtime(f).to_f > from.to_f}"
40
+ # ftp.mtime(f).to_f > from.to_f
41
+ # } unless from.blank?
42
+ # puts "Chosen files: #{files.inspect}"
43
+ # most_recent = files.sort_by{|f| ftp.mtime(f).to_f}.last
35
44
  puts "Opening File: #{most_recent || "No file has been chosen."}"
36
45
  ftp.close if close
37
- [most_recent, ftp]
46
+ ["#{directory}/#{most_recent}", ftp]
38
47
  end
39
48
 
40
49
  # If destination is nil, the file will just be downloaded to RAM
@@ -1,3 +1,3 @@
1
1
  module ThecoreFtpHelpers
2
- VERSION = '2.0.1'.freeze
2
+ VERSION = "#{`git describe --tags $(git rev-list --tags --max-count=1)`.chomp}"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thecore_ftp_helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriele Tassoni
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-07 00:00:00.000000000 Z
11
+ date: 2021-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thecore_backend_commons