Skip to content

Commit ff4cd63

Browse files
committed
Imperative file tests added
1 parent c6f056e commit ff4cd63

File tree

7 files changed

+208
-94
lines changed

7 files changed

+208
-94
lines changed

CodableCSV.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'CodableCSV'
3-
s.version = '0.5.2'
3+
s.version = '0.5.3'
44
s.summary = "Read and write CSV files row-by-row or through Swift's Codable interface."
55

66
s.homepage = 'https://github.com/dehesa/CodableCSV'
@@ -14,5 +14,5 @@ Pod::Spec.new do |s|
1414
s.tvos.deployment_target = '9.0'
1515
s.watchos.deployment_target = '2.0'
1616

17-
s.source_files = 'Sources/**/*'
17+
s.source_files = 'sources/**/*'
1818
end

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ You can choose to add the library through SPM or Cocoapods:
3838
let package = Package(
3939
/* Your package name, supported platforms, and generated products go here */
4040
dependencies: [
41-
.package(url: "https://github.com/dehesa/CodableCSV.git", .upToNextMinor(from: "0.5.2"))
41+
.package(url: "https://github.com/dehesa/CodableCSV.git", .upToNextMinor(from: "0.5.3"))
4242
],
4343
targets: [
4444
.target(name: /* Your target name here */, dependencies: ["CodableCSV"])
@@ -49,7 +49,7 @@ You can choose to add the library through SPM or Cocoapods:
4949
- [Cocoapods](https://cocoapods.org).
5050

5151
```
52-
pod 'CodableCSV', '~> 0.5.2'
52+
pod 'CodableCSV', '~> 0.5.3'
5353
```
5454

5555
</p></details>

docs/assets/Roadmap.svg

Lines changed: 1 addition & 1 deletion
Loading

sources/imperative/writer/WriterAPI.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ extension CSVWriter {
6666
/// - parameter configuration: Configuration values specifying how the CSV output should look like.
6767
/// - throws: `CSVError<CSVWriter>` exclusively.
6868
/// - returns: Data blob in a CSV format.
69-
@inlinable public static func encode<S:Sequence,C:Collection>(rows: S, configuration: Configuration = .init()) throws -> Data where S.Element==C, C.Element==String {
69+
@inlinable public static func encode<S:Sequence,C:Collection>(rows: S, into type: Data.Type, configuration: Configuration = .init()) throws -> Data where S.Element==C, C.Element==String {
7070
let writer = try CSVWriter(configuration: configuration)
7171
for row in rows {
7272
try writer.write(row: row)
@@ -83,7 +83,7 @@ extension CSVWriter {
8383
/// - throws: `CSVError<CSVWriter>` exclusively.
8484
/// - returns: Swift `String` containing the formatted CSV data.
8585
@inlinable public static func encode<S:Sequence,C:Collection>(rows: S, into type: String.Type, configuration: Configuration = .init()) throws -> String where S.Element==C, C.Element==String {
86-
let data = try CSVWriter.encode(rows: rows, configuration: configuration)
86+
let data = try CSVWriter.encode(rows: rows, into: Data.self, configuration: configuration)
8787
return String(data: data, encoding: configuration.encoding ?? .utf8)!
8888
}
8989

@@ -111,10 +111,10 @@ extension CSVWriter {
111111
/// - parameter configuration: Default configuration values for the `CSVWriter`.
112112
/// - throws: `CSVError<CSVWriter>` exclusively.
113113
/// - returns: Data blob in a CSV format.
114-
@inlinable public static func encode<S:Sequence,C:Collection>(rows: S, setter: (_ configuration: inout Configuration) -> Void) throws -> Data where S.Element==C, C.Element==String {
114+
@inlinable public static func encode<S:Sequence,C:Collection>(rows: S, into type: Data.Type, setter: (_ configuration: inout Configuration) -> Void) throws -> Data where S.Element==C, C.Element==String {
115115
var configuration = Configuration()
116116
setter(&configuration)
117-
return try CSVWriter.encode(rows: rows, configuration: configuration)
117+
return try CSVWriter.encode(rows: rows, into: type, configuration: configuration)
118118
}
119119

120120

@@ -167,9 +167,9 @@ fileprivate extension CSVWriter.Error {
167167
// MARK: - Deprecations
168168

169169
extension CSVWriter {
170-
@available(*, deprecated, renamed: "encode(rows:configuration:)")
170+
@available(*, deprecated, renamed: "encode(rows:into:configuration:)")
171171
public static func serialize<S:Sequence,C:Collection>(rows: S, configuration: Configuration = .init()) throws -> Data where S.Element==C, C.Element==String {
172-
try self.encode(rows: rows, configuration: configuration)
172+
try self.encode(rows: rows, into: Data.self, configuration: configuration)
173173
}
174174

175175
@available(*, deprecated, renamed: "encode(rows:into:configuration:)")
@@ -182,9 +182,9 @@ extension CSVWriter {
182182
try self.encode(rows: rows, into: fileURL, append: append, configuration: configuration)
183183
}
184184

185-
@available(*, deprecated, renamed: "encode(rows:setter:)")
185+
@available(*, deprecated, renamed: "encode(rows:into:setter:)")
186186
public static func serialize<S:Sequence,C:Collection>(rows: S, setter: (_ configuration: inout Configuration) -> Void) throws -> Data where S.Element==C, C.Element==String {
187-
try self.encode(rows: rows, setter: setter)
187+
try self.encode(rows: rows, into: Data.self, setter: setter)
188188
}
189189

190190
@available(*, deprecated, renamed: "encode(rows:into:setter:)")

0 commit comments

Comments
 (0)