thecore_ftp_helpers 2.0.1 → 2.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/thecore_ftp_helpers.rb +21 -12
- data/lib/thecore_ftp_helpers/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fb0b198d8af5221a0226d088e046c9e41c16045acf957a837f5d89f3a5bc019
|
4
|
+
data.tar.gz: 62369b565fc2429d0b3fdb88fbb28e106a71c74eecaccaf5a9c40a45fb45804a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd24970e259d08c2a613c03fbfcee2f6e1cd08152cc619ef8e1dd0c05a2cffa0b745e6443a4ebee0ac2ef8521dcf09989fec199a9515b83bef4128e9fc3a2c6b
|
7
|
+
data.tar.gz: fa320d379830939766f0c1ad9b06803253d00de9e7354de2d4d1977979f68a4fe8ab46f1e8d0ef50ae488ab4c36b904f1e60e09fa1784febdc8a147904d60bac
|
data/lib/thecore_ftp_helpers.rb
CHANGED
@@ -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
|
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
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
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 "
|
34
|
-
most_recent = files.sort_by{|f|
|
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
|
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.
|
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:
|
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
|