Class: TMail::UNIXMbox
- Defined in:
- lib/action_mailer/vendor/tmail-1.1.0/tmail/mailbox.rb,
lib/action_mailer/vendor/tmail-1.1.0/tmail/obsolete.rb
Class Method Summary collapse
-
.create_from_line(port) ⇒ Object
make _From line.
- .lock(fname) ⇒ Object
- .mkfinal(mh, mboxfile, writeback_p, cleanup_p) ⇒ Object
- .new(fname, tmpdir = nil, readonly = false) ⇒ Object
- .newobj ⇒ Object
- .static_new(fname, dir, readonly = false) ⇒ Object
Instance Method Summary collapse
- #close ⇒ Object
-
#each_new_port(mtime = nil) ⇒ Object
(also: #each_newmail)
old #each_mail returns Port def each_mail( &block ) each_port do |port| yield Mail.new(port) end end.
- #each_port(&block) ⇒ Object (also: #each, #each_mail)
-
#initialize(fname, mhdir, readonly, static) ⇒ UNIXMbox
constructor
A new instance of UNIXMbox.
- #new_port ⇒ Object (also: #new_mail)
- #reverse_each_port(&block) ⇒ Object (also: #reverse_each)
Constructor Details
#initialize(fname, mhdir, readonly, static) ⇒ UNIXMbox
Returns a new instance of UNIXMbox.
177 178 179 180 181 182 183 184 185 186 |
# File 'lib/action_mailer/vendor/tmail-1.1.0/tmail/mailbox.rb', line 177 def initialize( fname, mhdir, readonly, static ) @filename = fname @readonly = readonly @closed = false Dir.mkdir mhdir @real = MhMailbox.new(mhdir) @finalizer = UNIXMbox.mkfinal(@real, @filename, !@readonly, !static) ObjectSpace.define_finalizer self, @finalizer end |
Class Method Details
.create_from_line(port) ⇒ Object
make _From line
211 212 213 214 |
# File 'lib/action_mailer/vendor/tmail-1.1.0/tmail/mailbox.rb', line 211 def UNIXMbox.create_from_line( port ) sprintf 'From %s %s', fromaddr(), TextUtils.time2str(File.mtime(port.filename)) end |
.lock(fname) ⇒ Object
153 154 155 156 157 158 159 160 161 162 |
# File 'lib/action_mailer/vendor/tmail-1.1.0/tmail/mailbox.rb', line 153 def UNIXMbox.lock( fname ) begin f = File.open(fname) f.flock File::LOCK_EX yield f ensure f.flock File::LOCK_UN f.close if f and not f.closed? end end |
.mkfinal(mh, mboxfile, writeback_p, cleanup_p) ⇒ Object
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/action_mailer/vendor/tmail-1.1.0/tmail/mailbox.rb', line 188 def UNIXMbox.mkfinal( mh, mboxfile, writeback_p, cleanup_p ) lambda { if writeback_p lock(mboxfile) {|f| mh.each_port do |port| f.puts create_from_line(port) port.ropen {|r| f.puts r.read } end } end if cleanup_p Dir.foreach(mh.dirname) do |fname| next if /\A\.\.?\z/ === fname File.unlink "#{mh.dirname}/#{fname}" end Dir.rmdir mh.dirname end } end |
.new(fname, tmpdir = nil, readonly = false) ⇒ Object
168 169 170 171 |
# File 'lib/action_mailer/vendor/tmail-1.1.0/tmail/mailbox.rb', line 168 def UNIXMbox.new( fname, tmpdir = nil, readonly = false ) tmpdir = ENV['TEMP'] || ENV['TMP'] || '/tmp' newobj(fname, "#{tmpdir}/ruby_tmail_#{$$}_#{rand()}", readonly, false) end |
.newobj ⇒ Object
165 |
# File 'lib/action_mailer/vendor/tmail-1.1.0/tmail/mailbox.rb', line 165 alias newobj new |
Instance Method Details
#close ⇒ Object
224 225 226 227 228 229 230 231 232 233 |
# File 'lib/action_mailer/vendor/tmail-1.1.0/tmail/mailbox.rb', line 224 def close return if @closed ObjectSpace.undefine_finalizer self @finalizer.call @finalizer = nil @real = nil @closed = true @updated = nil end |
#each_new_port(mtime = nil) ⇒ Object Also known as: each_newmail
old #each_mail returns Port def each_mail( &block )
each_port do |port|
yield Mail.new(port)
end
end
258 259 260 261 262 |
# File 'lib/action_mailer/vendor/tmail-1.1.0/tmail/mailbox.rb', line 258 def each_new_port( mtime = nil ) close_check update @real.each_new_port(mtime) {|p| yield p } end |
#each_port(&block) ⇒ Object Also known as: each, each_mail
235 236 237 238 239 |
# File 'lib/action_mailer/vendor/tmail-1.1.0/tmail/mailbox.rb', line 235 def each_port( &block ) close_check update @real.each_port(&block) end |
#new_port ⇒ Object Also known as: new_mail
264 265 266 267 |
# File 'lib/action_mailer/vendor/tmail-1.1.0/tmail/mailbox.rb', line 264 def new_port close_check @real.new_port end |
#reverse_each_port(&block) ⇒ Object Also known as: reverse_each
243 244 245 246 247 |
# File 'lib/action_mailer/vendor/tmail-1.1.0/tmail/mailbox.rb', line 243 def reverse_each_port( &block ) close_check update @real.reverse_each_port(&block) end |