Methods
Public Class methods
create_from_line( port )

make _From line

     # File lib/action_mailer/vendor/tmail/mailbox.rb, line 209
209:     def UNIXMbox.create_from_line( port )
210:       sprintf 'From %s %s',
211:               fromaddr(), TextUtils.time2str(File.mtime(port.filename))
212:     end
lock( fname ) {|f| ...}
     # File lib/action_mailer/vendor/tmail/mailbox.rb, line 151
151:     def UNIXMbox.lock( fname )
152:       begin
153:         f = File.open(fname)
154:         f.flock File::LOCK_EX
155:         yield f
156:       ensure
157:         f.flock File::LOCK_UN
158:         f.close if f and not f.closed?
159:       end
160:     end
mkfinal( mh, mboxfile, writeback_p, cleanup_p )
     # File lib/action_mailer/vendor/tmail/mailbox.rb, line 186
186:     def UNIXMbox.mkfinal( mh, mboxfile, writeback_p, cleanup_p )
187:       lambda {
188:           if writeback_p
189:             lock(mboxfile) {|f|
190:                 mh.each_port do |port|
191:                   f.puts create_from_line(port)
192:                   port.ropen {|r|
193:                       f.puts r.read
194:                   }
195:                 end
196:             }
197:           end
198:           if cleanup_p
199:             Dir.foreach(mh.dirname) do |fname|
200:               next if /\A\.\.?\z/ === fname
201:               File.unlink "#{mh.dirname}/#{fname}"
202:             end
203:             Dir.rmdir mh.dirname
204:           end
205:       }
206:     end
new( fname, tmpdir = nil, readonly = false )
     # File lib/action_mailer/vendor/tmail/mailbox.rb, line 166
166:     def UNIXMbox.new( fname, tmpdir = nil, readonly = false )
167:       tmpdir = ENV['TEMP'] || ENV['TMP'] || '/tmp'
168:       newobj(fname, "#{tmpdir}/ruby_tmail_#{$$}_#{rand()}", readonly, false)
169:     end
new( fname, mhdir, readonly, static )
     # File lib/action_mailer/vendor/tmail/mailbox.rb, line 175
175:     def initialize( fname, mhdir, readonly, static )
176:       @filename = fname
177:       @readonly = readonly
178:       @closed = false
179: 
180:       Dir.mkdir mhdir
181:       @real = MhMailbox.new(mhdir)
182:       @finalizer = UNIXMbox.mkfinal(@real, @filename, !@readonly, !static)
183:       ObjectSpace.define_finalizer self, @finalizer
184:     end
static_new( fname, dir, readonly = false )
     # File lib/action_mailer/vendor/tmail/mailbox.rb, line 171
171:     def UNIXMbox.static_new( fname, dir, readonly = false )
172:       newobj(fname, dir, readonly, true)
173:     end
Private Class methods
fromaddr()
     # File lib/action_mailer/vendor/tmail/mailbox.rb, line 214
214:     def UNIXMbox.fromaddr
215:       h = HeaderField.new_from_port(port, 'Return-Path') ||
216:           HeaderField.new_from_port(port, 'From') or return 'nobody'
217:       a = h.addrs[0] or return 'nobody'
218:       a.spec
219:     end
Public Instance methods
close()
     # File lib/action_mailer/vendor/tmail/mailbox.rb, line 222
222:     def close
223:       return if @closed
224: 
225:       ObjectSpace.undefine_finalizer self
226:       @finalizer.call
227:       @finalizer = nil
228:       @real = nil
229:       @closed = true
230:       @updated = nil
231:     end
each( &block )

Alias for each_port

each_mail( &block )

Alias for each_port

each_new_port( mtime = nil ) {|p| ...}
 old #each_mail returns Port

def each_mail( &block )

  each_port do |port|
    yield Mail.new(port)
  end

end

This method is also aliased as each_newmail
     # File lib/action_mailer/vendor/tmail/mailbox.rb, line 256
256:     def each_new_port( mtime = nil )
257:       close_check
258:       update
259:       @real.each_new_port(mtime) {|p| yield p }
260:     end
each_newmail( mtime = nil )

Alias for each_new_port

each_port( &block )
This method is also aliased as each each_mail
     # File lib/action_mailer/vendor/tmail/mailbox.rb, line 233
233:     def each_port( &block )
234:       close_check
235:       update
236:       @real.each_port(&block)
237:     end
new_mail()

Alias for new_port

new_port()
This method is also aliased as new_mail
     # File lib/action_mailer/vendor/tmail/mailbox.rb, line 262
262:     def new_port
263:       close_check
264:       @real.new_port
265:     end
reverse_each( &block )

Alias for reverse_each_port

reverse_each_port( &block )
This method is also aliased as reverse_each
     # File lib/action_mailer/vendor/tmail/mailbox.rb, line 241
241:     def reverse_each_port( &block )
242:       close_check
243:       update
244:       @real.reverse_each_port(&block)
245:     end
Private Instance methods
close_check()
     # File lib/action_mailer/vendor/tmail/mailbox.rb, line 269
269:     def close_check
270:       @closed and raise ArgumentError, 'accessing already closed mbox'
271:     end
fromline2time( line )
     # File lib/action_mailer/vendor/tmail/mailbox.rb, line 304
304:     def fromline2time( line )
305:       m = /\AFrom \S+ \w+ (\w+) (\d+) (\d+):(\d+):(\d+) (\d+)/.match(line) \
306:               or return nil
307:       Time.local(m[6].to_i, m[1], m[2].to_i, m[3].to_i, m[4].to_i, m[5].to_i)
308:     end
update()
     # File lib/action_mailer/vendor/tmail/mailbox.rb, line 273
273:     def update
274:       return if FileTest.zero?(@filename)
275:       return if @updated and File.mtime(@filename) < @updated
276:       w = nil
277:       port = nil
278:       time = nil
279:       UNIXMbox.lock(@filename) {|f|
280:           begin
281:             f.each do |line|
282:               if /\AFrom / === line
283:                 w.close if w
284:                 File.utime time, time, port.filename if time
285: 
286:                 port = @real.new_port
287:                 w = port.wopen
288:                 time = fromline2time(line)
289:               else
290:                 w.print line if w
291:               end
292:             end
293:           ensure
294:             if w and not w.closed?
295:               w.close
296:               File.utime time, time, port.filename if time
297:             end
298:           end
299:           f.truncate(0) unless @readonly
300:           @updated = Time.now
301:       }
302:     end