diff options
author | aamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-06-12 16:42:46 +0000 |
---|---|---|
committer | aamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-06-12 16:42:46 +0000 |
commit | 9f32fd3e9a0566e9258dda883e3ecf6f5474096d (patch) | |
tree | 3594690de77e31bad8bd108ea699117f3b7e9ddc /lib/net/pop.rb | |
parent | b0ed08600a71784085b9b4621a4c4fcdbe0ae1cd (diff) |
o protocol.rb, smtp.rb, pop.rb, http.rb: define all#inspect()
o protocol.rb, smtp.rb, pop.rb, http.rb: modify/add documents
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@746 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/net/pop.rb')
-rw-r--r-- | lib/net/pop.rb | 136 |
1 files changed, 58 insertions, 78 deletions
diff --git a/lib/net/pop.rb b/lib/net/pop.rb index 1d3e41a54b..df95bc0c34 100644 --- a/lib/net/pop.rb +++ b/lib/net/pop.rb @@ -7,17 +7,6 @@ written by Minero Aoki <aamine@dp.u-netsurf.ne.jp> This library is distributed under the terms of the Ruby license. You can freely distribute/modify this library. -=end - - -require 'net/protocol' -require 'md5' - - -module Net - - -=begin == Net::POP3 @@ -51,52 +40,16 @@ Net::Protocol an array of ((URL:#POPMail)). This array is renewed when session started. -=end - - class POP3 < Protocol - - protocol_param :port, '110' - protocol_param :command_type, '::Net::POP3Command' - - protocol_param :mail_type, '::Net::POPMail' - - def initialize( addr = nil, port = nil ) - super - @mails = [].freeze - end - - - attr :mails - - def each - @mails.each {|m| yield m } - end - - - private - - def do_start( acnt, pwd ) - @command.auth( acnt, pwd ) - - @mails = [] - t = type.mail_type - @command.list.each_with_index do |size,idx| - if size then - @mails.push t.new( idx, size, @command ) - end - end - @mails.freeze - end +== Net::APOP - end +This class defines no new methods. +Only difference from POP3 is using APOP authentification. - POP = POP3 - POPSession = POP3 - POP3Session = POP3 +=== Super Class +Net::POP3 -=begin == Net::POPMail @@ -107,7 +60,7 @@ A class of mail which exists on POP server. Object -=== Method +=== Methods : all( dest = '' ) : pop @@ -155,6 +108,54 @@ Object =end +require 'net/protocol' +require 'md5' + + +module Net + + class POP3 < Protocol + + protocol_param :port, '110' + protocol_param :command_type, '::Net::POP3Command' + + protocol_param :mail_type, '::Net::POPMail' + + def initialize( addr = nil, port = nil ) + super + @mails = [].freeze + end + + attr :mails + + def each + @mails.each {|m| yield m } + end + + + private + + def do_start( acnt, pwd ) + @command.auth( acnt, pwd ) + + @mails = [] + t = type.mail_type + @command.list.each_with_index do |size,idx| + if size then + @mails.push t.new( idx, size, @command ) + end + end + @mails.freeze + end + + end + + POP = POP3 + POPSession = POP3 + POP3Session = POP3 + + + class POPMail def initialize( n, s, cmd ) @@ -165,9 +166,12 @@ Object @deleted = false end - attr :size + def inspect + "#<#{type} #{@num}#{@deleted ? ' deleted' : ''}>" + end + def all( dest = '' ) if iterator? then dest = ReadAdapter.new( Proc.new ) @@ -202,23 +206,9 @@ Object end -=begin - -== Net::APOP - -This class defines no new methods. -Only difference from POP3 is using APOP authentification. - -=== Super Class - -Net::POP3 - -=end class APOP < POP3 - protocol_param :command_type, 'Net::APOPCommand' - end APOPSession = APOP @@ -234,7 +224,6 @@ Net::POP3 } end - def auth( acnt, pass ) critical { @socket.writeline 'USER ' + acnt @@ -245,7 +234,6 @@ Net::POP3 } end - def list arr = [] critical { @@ -258,7 +246,6 @@ Net::POP3 arr end - def rset critical { getok 'RSET' @@ -273,14 +260,12 @@ Net::POP3 } end - def retr( num, dest = '', &block ) critical { getok sprintf( 'RETR %d', num ) @socket.read_pendstr( dest, &block ) } end - def dele( num ) critical { @@ -288,14 +273,12 @@ Net::POP3 } end - def uidl( num ) critical { getok( sprintf 'UIDL %d', num ).msg.split(' ')[1] } end - def quit critical { getok 'QUIT' @@ -305,7 +288,6 @@ Net::POP3 private - def check_reply_auth begin cod = check_reply( SuccessCode ) @@ -316,7 +298,6 @@ Net::POP3 return cod end - def get_reply str = @socket.readline @@ -343,7 +324,6 @@ Net::POP3 @stamp = m[0] end - def auth( account, pass ) critical { @socket.writeline sprintf( 'APOP %s %s', |