require "dotenv" Dotenv.load! require_relative "../lib/models" pp(u1 = User.create(name: "arthur", password: "abcde", mailboxes_next_uid: 3)) pp(u2 = User.create(name: "battou", password: "12345", mailboxes_next_uid: 2)) pp(b1 = Mailbox.create(user: u1, uid: 1, mails_next_uid: 100)) pp(b2 = Mailbox.create(user: u1, uid: 2, path: "INBOX/Sorted", mails_next_uid: 7)) pp(b3 = Mailbox.create(user: u2, uid: 1, path: "INBOX", mails_next_uid: 12)) pp(m0 = Mail.create(user: u1, mailbox: b1, uid: 1, )) pp(m1 = Mail.create(user: u1, mailbox: b2, uid: 1, )) pp(m2 = Mail.create(user: u1, mailbox: b1, uid: 3, flag_flagged: true)) pp(m3 = Mail.create(user: u1, mailbox: b1, uid: 4, flag_seen: true)) pp(m4 = Mail.create(user: u1, mailbox: b1, uid: 9, flag_seen: true, flag_recent: true)) pp(m5 = Mail.create(user: u2, mailbox: b3, uid: 1, flag_seen: true, flag_recent: true)) raw1 = File.read("db/raw1.txt") EOF = "\r\n".freeze head1 = raw1.split("#{EOF}#{EOF}", 2).first.gsub("#{EOF}\t", "").gsub("#{EOF} ", " ") pp(m6 = Mail.create(user: u1, mailbox: b1, uid: 90, flag_seen: true, flag_recent: true, raw: raw1, headers: head1)) # require "pry"; binding.pry