From f62c44bcdd25fda370c83b3b3e1556a5996b1155 Mon Sep 17 00:00:00 2001 From: Juan Pablo Ortiz Arechiga Date: Thu, 19 Jul 2012 13:14:01 -0500 Subject: [PATCH 1/2] Allow to set a different port than the default. --- lib/ftp_sync.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/ftp_sync.rb b/lib/ftp_sync.rb index ddb0afa..6134e1c 100644 --- a/lib/ftp_sync.rb +++ b/lib/ftp_sync.rb @@ -9,7 +9,7 @@ # newer than that timestamp, or only download files newer than their local copy. class FtpSync - attr_accessor :verbose, :server, :user, :password, :passive + attr_accessor :verbose, :server, :user, :password, :passive, :port # Creates a new instance for accessing a ftp server # requires +server+, +user+, and +password+ options @@ -24,6 +24,7 @@ def initialize(server, user, password, options = {}) @recursion_level = 0 @verbose = options[:verbose] || false @passive = options[:passive] || false + @port = options[:port] || 21 end # Recursively pull down files @@ -167,7 +168,8 @@ def should_ignore?(path) private def connect! - @connection = Net::FTP.new(@server) + @connection = Net::FTP.new + @connection.connect(@server, @port) @connection.passive = @passive @connection.login(@user, @password) log "Opened connection to #{@server}" From 1446808ae0ec49808f84aebc5f5f4bdd694e675b Mon Sep 17 00:00:00 2001 From: Scott Bronson Date: Mon, 21 Mar 2016 15:21:09 -0700 Subject: [PATCH 2/2] make test harness support Net::Ftp connect syntax --- test/net/ftp.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/net/ftp.rb b/test/net/ftp.rb index d8fb311..eda1f05 100644 --- a/test/net/ftp.rb +++ b/test/net/ftp.rb @@ -46,8 +46,12 @@ def listing_overrides=(overrides) @@listing_overrides = overrides end end - - def initialize(server) + + def initialize(server='test.server') + raise SocketError unless server == 'test.server' + end + + def connect(server, port=FTP_PORT) raise SocketError unless server == 'test.server' end