Some syntax bits

This commit is contained in:
Samuel Cochran 2012-07-25 11:47:12 +08:00
parent d74b700216
commit a2f9808c75
2 changed files with 3 additions and 3 deletions

View File

@ -185,7 +185,7 @@ module_function
rescue RuntimeError rescue RuntimeError
if $!.to_s =~ /\bno acceptor\b/ if $!.to_s =~ /\bno acceptor\b/
puts "~~> ERROR: Something's using port #{port}. Are you already running MailCatcher?" puts "~~> ERROR: Something's using port #{port}. Are you already running MailCatcher?"
exit -1 exit(-1)
else else
raise raise
end end

View File

@ -43,7 +43,7 @@ module_function
@@add_message_query ||= db.prepare("INSERT INTO message (sender, recipients, subject, source, type, size, created_at) VALUES (?, ?, ?, ?, ?, ?, datetime('now'))") @@add_message_query ||= db.prepare("INSERT INTO message (sender, recipients, subject, source, type, size, created_at) VALUES (?, ?, ?, ?, ?, ?, datetime('now'))")
mail = Mail.new(message[:source]) mail = Mail.new(message[:source])
result = @@add_message_query.execute(message[:sender], message[:recipients].to_json, mail.subject, message[:source], mail.mime_type || 'text/plain', message[:source].length) @@add_message_query.execute(message[:sender], message[:recipients].to_json, mail.subject, message[:source], mail.mime_type || 'text/plain', message[:source].length)
message_id = db.last_insert_row_id message_id = db.last_insert_row_id
parts = mail.all_parts parts = mail.all_parts
parts = [mail] if parts.empty? parts = [mail] if parts.empty?
@ -139,7 +139,7 @@ module_function
def message_part_cid(message_id, cid) def message_part_cid(message_id, cid)
@@message_part_cid_query ||= db.prepare 'SELECT * FROM message_part WHERE message_id = ?' @@message_part_cid_query ||= db.prepare 'SELECT * FROM message_part WHERE message_id = ?'
@@message_part_cid_query.execute(message_id).map do |row| @@message_part_cid_query.execute(message_id).map do |row|
part = Hash[row.fields.zip(row)] Hash[row.fields.zip(row)]
end.find do |part| end.find do |part|
part["cid"] == cid part["cid"] == cid
end end