Class: Imap::Backup::Migrator
- Inherits:
-
Object
- Object
- Imap::Backup::Migrator
- Defined in:
- lib/imap/backup/migrator.rb
Instance Attribute Summary collapse
-
#folder ⇒ Object
readonly
Returns the value of attribute folder.
-
#reset ⇒ Object
readonly
Returns the value of attribute reset.
-
#serializer ⇒ Object
readonly
Returns the value of attribute serializer.
Instance Method Summary collapse
-
#initialize(serializer, folder, reset: false) ⇒ Migrator
constructor
A new instance of Migrator.
- #run ⇒ Object
Constructor Details
#initialize(serializer, folder, reset: false) ⇒ Migrator
Returns a new instance of Migrator.
9 10 11 12 13 |
# File 'lib/imap/backup/migrator.rb', line 9 def initialize(serializer, folder, reset: false) @folder = folder @reset = reset @serializer = serializer end |
Instance Attribute Details
#folder ⇒ Object (readonly)
Returns the value of attribute folder.
5 6 7 |
# File 'lib/imap/backup/migrator.rb', line 5 def folder @folder end |
#reset ⇒ Object (readonly)
Returns the value of attribute reset.
6 7 8 |
# File 'lib/imap/backup/migrator.rb', line 6 def reset @reset end |
#serializer ⇒ Object (readonly)
Returns the value of attribute serializer.
7 8 9 |
# File 'lib/imap/backup/migrator.rb', line 7 def serializer @serializer end |
Instance Method Details
#run ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/imap/backup/migrator.rb', line 15 def run count = serializer.uids.count folder.create folder.clear if reset Logger.logger.debug "[#{folder.name}] #{count} to migrate" serializer.(serializer.uids).with_index do |, i| next if .nil? log_prefix = "[#{folder.name}] uid: #{.uid} (#{i + 1}/#{count}) -" Logger.logger.debug( "#{log_prefix} #{.body.size} bytes" ) begin folder.append() rescue StandardError => e Logger.logger.warn "#{log_prefix} append error: #{e}" end end end |