This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

add support for port parameter with defaults

  • Loading branch information...
1 parent 9d70fbf commit 9c5026fe6f7464e9a419b30a3de3841098c5e161 @look committed Jan 6, 2008
Showing with 8 additions and 2 deletions.
  1. +5 −1 lib/fetcher/imap.rb
  2. +3 −1 lib/fetcher/pop.rb
View
@@ -3,18 +3,22 @@
module Fetcher
class Imap < Base
+ PORT = 143
+
protected
# Additional Options:
# * <tt>:authentication</tt> - authentication type to use, defaults to PLAIN
+ # * <tt>:port</tt> - port to use (defaults to 143)
def initialize(options={})
@authentication = options.delete(:authentication) || 'PLAIN'
+ @port = options.delete(:port) || PORT
super(options)
end
# Open connection and login to server
def establish_connection
- @connection = Net::IMAP.new(@server)
+ @connection = Net::IMAP.new(@server, @port)
@connection.authenticate(@authentication, @username, @password)
end
View
@@ -7,14 +7,16 @@ class Pop < Base
# Additional Options:
# * <tt>:ssl</tt> - whether or not to use ssl encryption
+ # * <tt>:port</tt> - port to use (defaults to 110)
def initialize(options={})
@ssl = options.delete(:ssl)
+ @port = options.delete(:port) || Net::POP3.default_port
super(options)
end
# Open connection and login to server
def establish_connection
- @connection = Net::POP3.new(@server)
+ @connection = Net::POP3.new(@server, @port)
@connection.enable_ssl(OpenSSL::SSL::VERIFY_NONE) if @ssl
@connection.start(@username, @password)
end

0 comments on commit 9c5026f

Please sign in to comment.