Class: Imap::Backup::Account::FolderMapper
- Inherits:
-
Object
- Object
- Imap::Backup::Account::FolderMapper
- Defined in:
- lib/imap/backup/account/folder_mapper.rb
Overview
Implements a folder enumerator for backed-up accounts
Instance Method Summary collapse
-
#each {|serializer, folder| ... } ⇒ Enumerator, void
Enumerates backed-up folders When called without a block, returns an Enumerator.
-
#initialize(account:, destination:, destination_delimiter: "/", destination_prefix: "", source_delimiter: "/", source_prefix: "") ⇒ FolderMapper
constructor
A new instance of FolderMapper.
Constructor Details
#initialize(account:, destination:, destination_delimiter: "/", destination_prefix: "", source_delimiter: "/", source_prefix: "") ⇒ FolderMapper
Returns a new instance of FolderMapper.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/imap/backup/account/folder_mapper.rb', line 14 def initialize( account:, destination:, destination_delimiter: "/", destination_prefix: "", source_delimiter: "/", source_prefix: "" ) @account = account @destination = destination @destination_delimiter = destination_delimiter @destination_prefix = destination_prefix @source_delimiter = source_delimiter @source_prefix = source_prefix end |
Instance Method Details
#each {|serializer, folder| ... } ⇒ Enumerator, void
Enumerates backed-up folders When called without a block, returns an Enumerator
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/imap/backup/account/folder_mapper.rb', line 35 def each(&block) return enum_for(:each) if !block_given? glob = File.join(source_local_path, "**", "*.imap") Pathname.glob(glob) do |path| name = source_folder_name(path) serializer = Serializer.new(source_local_path, name) folder = destination_folder_for_path(name) block.call(serializer, folder) end end |