-
Notifications
You must be signed in to change notification settings - Fork 0
/
FileImporter.swift
35 lines (28 loc) · 1.06 KB
/
FileImporter.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//
// FileImporter.swift
// SwiftBeanCountImporter
//
// Created by Steffen Kötte on 2017-08-28.
// Copyright © 2017 Steffen Kötte. All rights reserved.
//
import Foundation
import SwiftBeanCountModel
/// The FileImporterFactory is responsible for the different types of `FileImporter`s.
/// It allow abstraction of the different importers by encapsulation to logic of which one to use.
enum FileImporterFactory {
static var importers: [FileImporter.Type] {
CSVImporterFactory.importers
}
/// Returns the correct FileImporter, or nil if the file cannot be imported
/// - Parameters:
/// - ledger: existing ledger which is used to assist the import,
/// e.g. to read attributes of accounts
/// - url: URL of the file to import
/// - Returns: FileImporter, or nil if the file cannot be imported
static func new(ledger: Ledger?, url: URL?) -> FileImporter? {
CSVImporterFactory.new(ledger: ledger, url: url)
}
}
/// Protocol to represent an Importer which imports a file
protocol FileImporter: Importer {
}