thecore_ftp_helpers 2.0.1 → 2.0.6

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: 0dbd641735f5466ed9d98cf051a0a7f3e3f8d33765cf3cf8abc888af9dec458f
4
- data.tar.gz: e4fabc772235c4218d17a739b9e6993d88872095abc98b34d69784bb16d44f52
3
+ metadata.gz: 236e81e8ccdc89a2c890efb0cd85cc50017b15829bac2ba74449f654171cf176
4
+ data.tar.gz: 9cffb2f02a9bb90babe8ca03c9b8df4d4ce3097560a5a9430517587ec0be6074
5
5
  SHA512:
6
- metadata.gz: 2aa188d8d607ee7cf6ca7d3a1c912ed1cfc558097f8a4c4e6f5bc9b968ef263da03b0aac997ad34018957efbf534d062405787b9cf87e37ac57e4465b88e854d
7
- data.tar.gz: f66cf310f1ea5a1f00672658d6cca91b0ff081d4b7baca47d3de58861c363d46911a74f8adc22a04ea7408300574f9c1ab0ed95f7e43130173f0648f8461c5c4
6
+ metadata.gz: f3b8e73c55e8bd677e3370f83d3c6df899531325dbaa8eb0d3a457ba195ff316784cda1ef0585c5ada7d50536d1cfbb57afe3b6f41676dc6b4b68cd1ff6e336e
7
+ data.tar.gz: fd028abd521cf3f747b48d6b0243f545e07f33e02f5002cacba8a03e72139a683447af299673cb83ca2917d0dc273fb81f2f6b93596b8a0f3916eab576d7e5fc
@@ -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 = '2.0.6'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
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.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriele Tassoni