Class: Mailbot::Repository
- Inherits:
-
Object
- Object
- Mailbot::Repository
- Defined in:
- lib/mailbot/repository.rb
Instance Method Summary collapse
-
#entries ⇒ Array<Mailbot::Entry>
An array of all entries in this repository.
-
#initialize(path) ⇒ Repository
constructor
A new instance of Repository.
- #sync ⇒ Object
Constructor Details
#initialize(path) ⇒ Repository
Returns a new instance of Repository.
6 7 8 |
# File 'lib/mailbot/repository.rb', line 6 def initialize(path) @path = path end |
Instance Method Details
#entries ⇒ Array<Mailbot::Entry>
Returns An array of all entries in this repository.
28 29 30 |
# File 'lib/mailbot/repository.rb', line 28 def entries Mailbot::Entry::Parser.new.parse read end |
#sync ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/mailbot/repository.rb', line 10 def sync write(entries.map do |entry| if entry.synced? entry else begin Mailbot::Mailer.deliver subject: entry.subject, body: entry.render_body Mailbot::LOGGER.info "Succeeded to sync an entry: #{entry.subject}" entry.sync rescue => e Mailbot::LOGGER.warn "Failed to sync an entry: #{entry.subject}\n#{e.backtrace.join("\n")}" entry end end end.map(&:text).join("\n")) end |