spectre-ftp 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/spectre/ftp.rb +39 -15
- metadata +14 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd410767dd2b22162bb39bd0cf4d2a156a62191f78e44788fa1081e0584ad9a7
|
4
|
+
data.tar.gz: b5c08c45e0b927750aff016e7eb0330861f090d85f7e2b59fe48584bade65638
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2aa8e992057d7d78f0ba9e5e3b64696e69602a590bdf4bf3fd85674b629caa280fc07fbc3785d49b454a0ede3028e7ed734e9bf7eac0858a436ef9b3f5a405e
|
7
|
+
data.tar.gz: d1bc7ce67d4dd0168e8c987cc657c28b49355f60fd8c54e5ab8be66ae2563a5b01fb3fb0b2a06edc597bb769bbaace65cd6995fe071d7f5966c6ee3532e05817
|
data/lib/spectre/ftp.rb
CHANGED
@@ -19,8 +19,17 @@ module Spectre
|
|
19
19
|
@__opts = opts
|
20
20
|
end
|
21
21
|
|
22
|
+
def username user
|
23
|
+
@__username = user
|
24
|
+
end
|
25
|
+
|
26
|
+
def password pass
|
27
|
+
@__password = pass
|
28
|
+
end
|
29
|
+
|
22
30
|
def connect!
|
23
31
|
return unless @__session == nil or @__session.closed?
|
32
|
+
|
24
33
|
@__logger.info "Connecting to '#{@__host}' with user '#{@__username}'"
|
25
34
|
@__session = Net::FTP.new(@__host, @__opts)
|
26
35
|
@__session.login @__username, @__password
|
@@ -28,6 +37,7 @@ module Spectre
|
|
28
37
|
|
29
38
|
def close
|
30
39
|
return unless @__session and not @__session.closed?
|
40
|
+
|
31
41
|
@__session.close
|
32
42
|
end
|
33
43
|
|
@@ -42,25 +52,24 @@ module Spectre
|
|
42
52
|
|
43
53
|
def download remotefile, to: File.basename(remotefile)
|
44
54
|
connect!
|
45
|
-
@__logger.info
|
55
|
+
@__logger.info("Downloading '#{@__username}@#{@__host}:#{File.join @__session.pwd, remotefile}' to '#{File.expand_path to}'")
|
46
56
|
@__session.getbinaryfile(remotefile, to)
|
47
57
|
end
|
48
58
|
|
49
59
|
def upload localfile, to: File.basename(localfile)
|
50
60
|
connect!
|
51
|
-
@__logger.info
|
61
|
+
@__logger.info("Uploading '#{File.expand_path localfile}' to '#{@__username}@#{@__host}:#{File.join @__session.pwd, to}'")
|
52
62
|
@__session.putbinaryfile(localfile, to)
|
53
63
|
end
|
54
64
|
|
55
65
|
def list
|
56
66
|
connect!
|
57
67
|
file_list = @__session.list
|
58
|
-
@__logger.info
|
68
|
+
@__logger.info("Listing files in #{@__session.pwd}\n#{file_list}")
|
59
69
|
file_list
|
60
70
|
end
|
61
71
|
end
|
62
72
|
|
63
|
-
|
64
73
|
class SFTPConnection < DslClass
|
65
74
|
def initialize host, username, opts, logger
|
66
75
|
opts[:non_interactive] = true
|
@@ -72,8 +81,27 @@ module Spectre
|
|
72
81
|
@__opts = opts
|
73
82
|
end
|
74
83
|
|
84
|
+
def username user
|
85
|
+
@__username = user
|
86
|
+
end
|
87
|
+
|
88
|
+
def password pass
|
89
|
+
@__opts[:password] = pass
|
90
|
+
@__opts[:auth_methods].push 'password' unless @__opts[:auth_methods].include? 'password'
|
91
|
+
end
|
92
|
+
|
93
|
+
def private_key file_path
|
94
|
+
@__opts[:keys] = [file_path]
|
95
|
+
@__opts[:auth_methods].push 'publickey' unless @__opts[:auth_methods].include? 'publickey'
|
96
|
+
end
|
97
|
+
|
98
|
+
def passphrase phrase
|
99
|
+
@__opts[:passphrase] = phrase
|
100
|
+
end
|
101
|
+
|
75
102
|
def connect!
|
76
103
|
return unless @__session == nil or @__session.closed?
|
104
|
+
|
77
105
|
@__logger.info "Connecting to '#{@__host}' with user '#{@__username}'"
|
78
106
|
@__session = Net::SFTP.start(@__host, @__username, @__opts)
|
79
107
|
@__session.connect!
|
@@ -81,6 +109,7 @@ module Spectre
|
|
81
109
|
|
82
110
|
def close
|
83
111
|
return unless @__session and not @__session.closed?
|
112
|
+
|
84
113
|
# @__session.close!
|
85
114
|
end
|
86
115
|
|
@@ -94,14 +123,14 @@ module Spectre
|
|
94
123
|
end
|
95
124
|
|
96
125
|
def download remotefile, to: File.basename(remotefile)
|
97
|
-
@__logger.info "Downloading '#{@__username}@#{@__host}:#{remotefile}' to '#{File.expand_path to}'"
|
98
126
|
connect!
|
127
|
+
@__logger.info "Downloading '#{@__username}@#{@__host}:#{remotefile}' to '#{File.expand_path to}'"
|
99
128
|
@__session.download!(remotefile, to)
|
100
129
|
end
|
101
130
|
|
102
131
|
def upload localfile, to: File.basename(localfile)
|
103
|
-
@__logger.info "Uploading '#{File.expand_path localfile}' to '#{@__username}@#{@__host}:#{to}'"
|
104
132
|
connect!
|
133
|
+
@__logger.info "Uploading '#{File.expand_path localfile}' to '#{@__username}@#{@__host}:#{to}'"
|
105
134
|
@__session.upload!(localfile, to)
|
106
135
|
end
|
107
136
|
|
@@ -114,10 +143,10 @@ module Spectre
|
|
114
143
|
|
115
144
|
def exists path
|
116
145
|
begin
|
117
|
-
|
118
|
-
|
146
|
+
@__session.stat! path
|
119
147
|
rescue Net::SFTP::StatusException => e
|
120
148
|
return false if e.description == 'no such file'
|
149
|
+
|
121
150
|
raise e
|
122
151
|
end
|
123
152
|
|
@@ -128,7 +157,6 @@ module Spectre
|
|
128
157
|
|
129
158
|
class << self
|
130
159
|
def ftp name, config={}, &block
|
131
|
-
raise "FTP connection '#{name}' not configured" unless @@cfg.key?(name) or config.count > 0
|
132
160
|
cfg = @@cfg[name] || {}
|
133
161
|
|
134
162
|
host = config[:host] || cfg['host'] || name
|
@@ -139,8 +167,6 @@ module Spectre
|
|
139
167
|
opts[:ssl] = config[:ssl]
|
140
168
|
opts[:port] = config[:port] || cfg['port'] || 21
|
141
169
|
|
142
|
-
@@logger.info "Connecting to #{host} with user #{username}"
|
143
|
-
|
144
170
|
ftp_conn = FTPConnection.new(host, username, password, opts, @@logger)
|
145
171
|
|
146
172
|
begin
|
@@ -151,8 +177,6 @@ module Spectre
|
|
151
177
|
end
|
152
178
|
|
153
179
|
def sftp name, config={}, &block
|
154
|
-
raise "FTP connection '#{name}' not configured" unless @@cfg.key?(name) or config.count > 0
|
155
|
-
|
156
180
|
cfg = @@cfg[name] || {}
|
157
181
|
|
158
182
|
host = config[:host] || cfg['host'] || name
|
@@ -180,7 +204,7 @@ module Spectre
|
|
180
204
|
end
|
181
205
|
|
182
206
|
Spectre.register do |config|
|
183
|
-
@@logger = ::
|
207
|
+
@@logger = Spectre::Logging::ModuleLogger.new(config, 'spectre/ftp')
|
184
208
|
|
185
209
|
if config.key? 'ftp'
|
186
210
|
|
@@ -192,4 +216,4 @@ module Spectre
|
|
192
216
|
|
193
217
|
Spectre.delegate :ftp, :sftp, to: self
|
194
218
|
end
|
195
|
-
end
|
219
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spectre-ftp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Neubauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-sftp
|
@@ -16,44 +16,43 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 4.0.0
|
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: 4.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: spectre-core
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
33
|
+
version: 1.14.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.
|
41
|
-
description: Adds FTP
|
40
|
+
version: 1.14.0
|
41
|
+
description: Adds FTP functionality to the spectre framework
|
42
42
|
email:
|
43
|
-
-
|
43
|
+
- christian.neubauer@ionos.com
|
44
44
|
executables: []
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
48
|
- lib/spectre/ftp.rb
|
49
|
-
homepage: https://
|
49
|
+
homepage: https://github.com/ionos-spectre/spectre-ftp
|
50
50
|
licenses:
|
51
51
|
- MIT
|
52
52
|
metadata:
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
changelog_uri: https://bitbucket.org/cneubaur/spectre-ftp/src/master/CHANGELOG.md
|
53
|
+
homepage_uri: https://github.com/ionos-spectre/spectre-ftp
|
54
|
+
source_code_uri: https://github.com/ionos-spectre/spectre-ftp
|
55
|
+
changelog_uri: https://github.com/ionos-spectre/spectre-ftp/src/master/CHANGELOG.md
|
57
56
|
post_install_message:
|
58
57
|
rdoc_options: []
|
59
58
|
require_paths:
|
@@ -62,14 +61,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
62
61
|
requirements:
|
63
62
|
- - ">="
|
64
63
|
- !ruby/object:Gem::Version
|
65
|
-
version:
|
64
|
+
version: 3.0.0
|
66
65
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
66
|
requirements:
|
68
67
|
- - ">="
|
69
68
|
- !ruby/object:Gem::Version
|
70
69
|
version: '0'
|
71
70
|
requirements: []
|
72
|
-
rubygems_version: 3.
|
71
|
+
rubygems_version: 3.3.26
|
73
72
|
signing_key:
|
74
73
|
specification_version: 4
|
75
74
|
summary: FTP module for spectre
|