This is a multi-part message in MIME format.
--Multipart_Sat__1_Mar_2003_17:16:30_-0600_083e7fd0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Hello all. I don't quite know if this is the place to post these types of
submissions but I cannot seem to find anywhere else.
Anyway, I have made an update to pop.rb (from the ruby-1.6.8 distribution)
to give POP3 STAT command functionality (POP3#stat). The method returns an
array of [numMessages, size]. I have also added a BadResponseError class to
the bottom like it is in smtp.rb since I could not find where BadResponse
(in the POP3#list method) was located and it seemed like a problem as it is.
I have attached a diff (pop_diff.txt) to this email and would be more than
willing to send the whole new file on request.
Comments and criticisms are welcome!
--frank
--Multipart_Sat__1_Mar_2003_17:16:30_-0600_083e7fd0
Content-Type: text/plain;
name op_diff.txt"
Content-Disposition: attachment;
filename op_diff.txt"
Content-Transfer-Encoding: 7bit
*** /usr/local/ruby-1.6.8/lib/ruby/1.6/net/pop.rb Wed Feb 12 16:44:24 2003
--- pop_fsf.rb Tue Feb 18 18:53:57 2003
***************
*** 437,442 ****
--- 437,445 ----
end
end
+ def stat
+ command().stat
+ end
def command
io_check
***************
*** 535,547 ****
getok 'LIST'
@socket.read_pendlist do |line|
m \A(\d+)[ \t]+(\d+)/.match(line) or
! raise BadResponse, "illegal response: #{line}"
arr[ m[1].to_i ] [2].to_i
end
}
arr
end
def rset
atomic {
getok 'RSET'
--- 538,563 ----
getok 'LIST'
@socket.read_pendlist do |line|
m \A(\d+)[ \t]+(\d+)/.match(line) or
! raise BadResponseError, "illegal response: #{line}"
arr[ m[1].to_i ] [2].to_i
end
}
arr
end
+ def stat
+ num ize
+ atomic {
+ @socket.writeline 'STAT'
+ line socket.readline
+ m \A\+OK (\d+)[ \t]+(\d+)/.match(line) or
+ raise BadResponseError, "illegal response: #{line}"
+ num [1].to_i
+ size [2].to_i
+ }
+ [num, size]
+ end
+
def rset
atomic {
getok 'RSET'
***************
*** 630,634 ****
--- 646,659 ----
POPSession OP3
POP3Session OP3
APOPSession POP
+
+ class Error < StandardError
+ end
+
+ class ResponseError < Error
+ end
+
+ class BadResponseError < ResponseError
+ end
end # module Net
--Multipart_Sat__1_Mar_2003_17:16:30_-0600_083e7fd0--