thecore_ftp_helpers 2.0.0 → 2.1.2

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: d56ac25275f502a29e707b7b5b61ae04c08cd1ca2c9a2381b36cef86e3425ef8
4
- data.tar.gz: fc2ac8cbaf047d70b4688420c44807b659d6b9fba04421abffc0f71535ff4657
3
+ metadata.gz: 191e64ce1ad125e28d8048ab0eb2e48aad46eed966b6997a85725798c41a7829
4
+ data.tar.gz: c94b6751008ee7c995a3c41358707cbb3a0afe12a7b3d6c80b8d13bba0624537
5
5
  SHA512:
6
- metadata.gz: 627294d678c45e82694d4ff4aa68224bc03dca8088681abc1e9df73577ed1bfc1cf2a6acac35b9219387760430769acfba61fdad51084bddcddc6e6b3d24a605
7
- data.tar.gz: ba44f7334d3720214c3186e6747958553f68ee44bfb2746cab5900c2cb653d27e31532ba79b59205781feb6a6237f168c6fb7eafba1721a23f1ee56e6b50963e
6
+ metadata.gz: c3d9e5ea9d63a9974ca857b9bfea69ee057fe7c90adb73ab1852fb3089c8eb0f6cb434578b68049b4ddc42f6c5bb70ce26051d26e896000ec6234bc4a0f75665
7
+ data.tar.gz: f78df11c7aa112c675a6fb5779a0abafe15c94d61be3b2d52b997ca208380915484c37a50c451a36660a56d448f8d8338040b24b4a314b7b82005a7ea166deb9
@@ -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,4 +1,3 @@
1
- require 'thecore'
2
1
  module ThecoreFtpHelpers
3
2
  class Engine < ::Rails::Engine
4
3
 
@@ -1,3 +1,3 @@
1
1
  module ThecoreFtpHelpers
2
- VERSION = '2.0.0'.freeze
2
+ VERSION = "#{`git describe --tags $(git rev-list --tags --max-count=1)`}"
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.0
4
+ version: 2.1.2
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-06 00:00:00.000000000 Z
11
+ date: 2020-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thecore_backend_commons