Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to set a different port than the default. #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/ftp_sync.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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}"
Expand Down
8 changes: 6 additions & 2 deletions test/net/ftp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down