Class: FakeSMTPd::MessageStore
- Inherits:
-
Object
- Object
- FakeSMTPd::MessageStore
- Defined in:
- lib/fakesmtpd/server.rb
Instance Attribute Summary collapse
-
#message_dir ⇒ Object
readonly
Returns the value of attribute message_dir.
Instance Method Summary collapse
- #[](message_id) ⇒ Object
- #clear ⇒ Object
-
#initialize(message_dir) ⇒ MessageStore
constructor
A new instance of MessageStore.
- #store(message_id, from, recipients, body) ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(message_dir) ⇒ MessageStore
Returns a new instance of MessageStore.
366 367 368 |
# File 'lib/fakesmtpd/server.rb', line 366 def initialize() @message_dir = end |
Instance Attribute Details
#message_dir ⇒ Object (readonly)
Returns the value of attribute message_dir.
364 365 366 |
# File 'lib/fakesmtpd/server.rb', line 364 def @message_dir end |
Instance Method Details
#[](message_id) ⇒ Object
390 391 392 393 394 395 396 |
# File 'lib/fakesmtpd/server.rb', line 390 def []() = "#{}/fakesmtpd-client-#{}.json" if File.exists?() return end nil end |
#clear ⇒ Object
398 399 400 |
# File 'lib/fakesmtpd/server.rb', line 398 def clear FileUtils.rm_f() end |
#store(message_id, from, recipients, body) ⇒ Object
370 371 372 373 374 375 376 377 378 379 380 381 |
# File 'lib/fakesmtpd/server.rb', line 370 def store(, from, recipients, body) outfile = File.join(, "fakesmtpd-client-#{}.json") File.open(outfile, 'w:UTF-8') do |f| f.write JSON.pretty_generate( message_id: , from: from, recipients: recipients, body: body, ) end outfile end |
#to_hash ⇒ Object
383 384 385 386 387 388 |
# File 'lib/fakesmtpd/server.rb', line 383 def to_hash .each_with_object({}) do |filename, h| = File.basename(filename, '.json').gsub(/[^0-9]+/, '') h[] = File.(filename) end end |