thecore_ftp_helpers 1.1.25 → 2.0.6
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
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 236e81e8ccdc89a2c890efb0cd85cc50017b15829bac2ba74449f654171cf176
|
4
|
+
data.tar.gz: 9cffb2f02a9bb90babe8ca03c9b8df4d4ce3097560a5a9430517587ec0be6074
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3b8e73c55e8bd677e3370f83d3c6df899531325dbaa8eb0d3a457ba195ff316784cda1ef0585c5ada7d50536d1cfbb57afe3b6f41676dc6b4b68cd1ff6e336e
|
7
|
+
data.tar.gz: fd028abd521cf3f747b48d6b0243f545e07f33e02f5002cacba8a03e72139a683447af299673cb83ca2917d0dc273fb81f2f6b93596b8a0f3916eab576d7e5fc
|
data/lib/thecore_ftp_helpers.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
|
-
require 'thecore'
|
2
|
+
# require 'thecore'
|
3
3
|
require 'net/ftp'
|
4
|
-
require '
|
4
|
+
require 'thecore_backend_commons'
|
5
5
|
require "thecore_ftp_helpers/engine"
|
6
6
|
|
7
7
|
module ThecoreFtpHelpers
|
@@ -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.
|
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
|
@@ -1,9 +1,8 @@
|
|
1
|
-
require 'thecore'
|
2
1
|
module ThecoreFtpHelpers
|
3
2
|
class Engine < ::Rails::Engine
|
4
3
|
|
5
4
|
initializer 'thecore_ftp_helpers.add_to_migrations' do |app|
|
6
|
-
unless app.root.to_s
|
5
|
+
unless app.root.to_s.match root.to_s
|
7
6
|
# APPEND TO MAIN APP MIGRATIONS FROM THIS GEM
|
8
7
|
config.paths['db/migrate'].expanded.each do |expanded_path|
|
9
8
|
app.config.paths['db/migrate'] << expanded_path
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thecore_ftp_helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.6
|
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: 2020-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: thecore_backend_commons
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.3'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.3'
|
27
27
|
description: Thecorized thecore_ftp_helpers full description.
|
28
28
|
email:
|
29
29
|
- gabriele.tassoni@gmail.com
|
@@ -37,7 +37,6 @@ files:
|
|
37
37
|
- app/assets/config/thecore_ftp_helpers_manifest.js
|
38
38
|
- config/initializers/thecore_ftp_helpers_after_initialize.rb
|
39
39
|
- config/routes.rb
|
40
|
-
- lib/abilities_thecore_ftp_helpers_concern.rb
|
41
40
|
- lib/tasks/thecore_ftp_helpers_tasks.rake
|
42
41
|
- lib/thecore_ftp_helpers.rb
|
43
42
|
- lib/thecore_ftp_helpers/engine.rb
|
@@ -61,8 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
60
|
- !ruby/object:Gem::Version
|
62
61
|
version: '0'
|
63
62
|
requirements: []
|
64
|
-
|
65
|
-
rubygems_version: 2.6.14
|
63
|
+
rubygems_version: 3.0.3
|
66
64
|
signing_key:
|
67
65
|
specification_version: 4
|
68
66
|
summary: Thecorized thecore_ftp_helpers
|
@@ -1,23 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'active_support/concern'
|
3
|
-
|
4
|
-
module ThecoreFtpHelperAbilitiesConcern
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
included do
|
7
|
-
def thecore_ftp_helpers_abilities user
|
8
|
-
if user
|
9
|
-
# if the user is logged in, it can do certain tasks regardless his role
|
10
|
-
if user.admin?
|
11
|
-
# if the user is an admin, it can do a lot of things, usually
|
12
|
-
end
|
13
|
-
|
14
|
-
if user.has_role? :role
|
15
|
-
# a specific role, brings specific powers
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
# include the extension
|
23
|
-
TheCoreAbilities.send(:include, ThecoreFtpHelperAbilitiesConcern)
|