spectre-ftp 2.0.1 → 2.0.3

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/spectre/ftp.rb +36 -21
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '055907f899bb094c17845e01db766dd1d643ef78d87981fc4bd007bf3b430b2e'
4
- data.tar.gz: 3b9fb444b4949712f8df4891c4276a938aa04b4c34b9a5b7789023234a572722
3
+ metadata.gz: 7e46fba6cb0d3e4b4d028a9c6a55f83560a4f17bd35d7539e250806c234eca1d
4
+ data.tar.gz: a0d862670094baa553b7a23d46eaac7b3a6bbde87f2ad8b0f432ee2dbe560667
5
5
  SHA512:
6
- metadata.gz: 3d0f4f82bf15afe3d0927a86af940ca8dfa291fdb4f4958f66811541666f202fec7922f8a38515a2500da14b70dd01276733ff607bc57b029539b6213f81c11f
7
- data.tar.gz: 5ef3c799773931a559725d3f296358451e4e7db8c424deec11b7a549357db5716652511a3a582aab7ed7a47aa06dd4aa5f811e15bbda2bad7b4b9867a59d0345
6
+ metadata.gz: dc6eeb05d1e853f16351a8dbb598e0bd5768bb13ac9af72235ecb64fa599d7505ffc703c99a75c87e7fda80bcdf1dca9c23a55e34f8180ca5c0801757f5a01db
7
+ data.tar.gz: 50cec5fc3bef75a2ad843ee618580bf6025691076cc8d5989818ec2b90d65d8e3af5590471979fd97266b780925a2f1ebeb8bd8685f6ca0b239cbec393c1f635
data/lib/spectre/ftp.rb CHANGED
@@ -291,18 +291,34 @@ module Spectre
291
291
  @logger = logger
292
292
  end
293
293
 
294
+ def ftps(name, config = {}, &)
295
+ config[:ssl] = true
296
+ config[:port] ||= 990
297
+ config[:implicit] = true
298
+
299
+ ftp(name, config, &)
300
+ end
301
+
302
+ def ftpes(name, config = {}, &)
303
+ config[:ssl] = true
304
+ config[:port] ||= 21
305
+ config[:implicit] = false
306
+
307
+ ftp(name, config, &)
308
+ end
309
+
294
310
  def ftp(name, config = {}, &)
295
311
  cfg = @config[name] || {}
296
312
 
297
- host = config[:host] || cfg['host'] || name
298
- username = config[:username] || cfg['username']
299
- password = config[:password] || cfg['password']
313
+ hostname = config.delete(:host) || cfg['host'] || name
314
+ username = config.delete(:username) || cfg['username']
315
+ password = config.delete(:password) || cfg['password']
300
316
 
301
- opts = {}
302
- opts[:ssl] = config[:ssl]
303
- opts[:port] = config[:port] || cfg['port'] || 21
317
+ config[:port] = config[:port] || cfg['port'] || 21
318
+ config[:ssl] = config[:ssl] || cfg['ssl'] || false
319
+ config[:implicit_ftps] = config.delete(:implicit) || cfg['implicit'] || false
304
320
 
305
- ftp_conn = FTPConnection.new(host, username, password, opts, @logger)
321
+ ftp_conn = FTPConnection.new(hostname, username, password, config, @logger)
306
322
 
307
323
  begin
308
324
  ftp_conn.instance_eval(&)
@@ -314,23 +330,22 @@ module Spectre
314
330
  def sftp(name, config = {}, &)
315
331
  cfg = @config[name] || {}
316
332
 
317
- host = config[:host] || cfg['host'] || name
318
- username = config[:username] || cfg['username']
319
- password = config[:password] || cfg['password']
333
+ host = config.delete(:host) || cfg['host'] || name
334
+ username = config.delete(:username) || cfg['username']
335
+ password = config.delete(:password) || cfg['password']
320
336
 
321
- opts = {}
322
- opts[:password] = password
323
- opts[:port] = config[:port] || cfg['port'] || 22
324
- opts[:keys] = [cfg['key']] if cfg.key? 'key'
325
- opts[:passphrase] = cfg['passphrase'] if cfg.key? 'passphrase'
337
+ config[:password] = password
338
+ config[:port] ||= cfg['port'] || 22
339
+ config[:keys] = [cfg['key']] if cfg.key? 'key'
340
+ config[:passphrase] = cfg['passphrase'] if cfg.key? 'passphrase'
326
341
 
327
- opts[:auth_methods] = []
328
- opts[:auth_methods].push 'publickey' if opts[:keys]
329
- opts[:auth_methods].push 'password' if opts[:password]
342
+ config[:auth_methods] = []
343
+ config[:auth_methods].push 'publickey' if config[:keys]
344
+ config[:auth_methods].push 'password' if config[:password]
330
345
 
331
- opts[:non_interactive] = true
346
+ config[:non_interactive] = true
332
347
 
333
- sftp_con = SFTPConnection.new(host, username, opts, @logger)
348
+ sftp_con = SFTPConnection.new(host, username, config, @logger)
334
349
 
335
350
  begin
336
351
  sftp_con.instance_eval(&)
@@ -341,5 +356,5 @@ module Spectre
341
356
  end
342
357
  end
343
358
 
344
- Engine.register(FTP::Client, :ftp, :sftp) if defined? Engine
359
+ Engine.register(FTP::Client, :ftp, :sftp, :ftps, :ftpes) if defined? Engine
345
360
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spectre-ftp
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Neubauer