-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjust account meta data to allow specifying separately per account
Currently the keys are applied to all account types. This change refactors the meta data handling, so that for every type the Wealthsimple accounts can be set separately. It also now only requires one entry if an account is only used for one type. To see how to apply meta data now, see the readme. Fixes #41
- Loading branch information
Showing
9 changed files
with
158 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
Sources/SwiftBeanCountWealthsimpleMapper/Extensions/String+KebabCase.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Foundation | ||
|
||
/// extension to convert strings from camelCase to kebab-case | ||
extension String { | ||
|
||
func camelCaseToKebabCase() -> String { | ||
["([A-Z]+)([A-Z][a-z]|[0-9])", "([a-z])([A-Z]|[0-9])", "([0-9])([A-Z])"] | ||
.map { try! NSRegularExpression(pattern: $0, options: []) } // swiftlint:disable:this force_try | ||
.reduce(self) { $1.stringByReplacingMatches(in: $0, range: NSRange($0.startIndex..., in: $0), withTemplate: "$1-$2") } | ||
.lowercased() | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
Tests/SwiftBeanCountWealthsimpleMapperTests/Extensions/StringKebabCaseTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
@testable import SwiftBeanCountWealthsimpleMapper | ||
import XCTest | ||
|
||
final class StringKebabCaseTests: XCTestCase { | ||
|
||
func testCamelCaseToKebabCase() { | ||
XCTAssertEqual("TEST123".camelCaseToKebabCase(), "test-123") | ||
XCTAssertEqual("TEST1Test".camelCaseToKebabCase(), "test-1-test") | ||
XCTAssertEqual("EURTest".camelCaseToKebabCase(), "eur-test") | ||
XCTAssertEqual("ThisIsATest".camelCaseToKebabCase(), "this-is-a-test") | ||
XCTAssertEqual("1234ThisIsATest".camelCaseToKebabCase(), "1234-this-is-a-test") | ||
XCTAssertEqual("test123".camelCaseToKebabCase(), "test-123") | ||
XCTAssertEqual("test".camelCaseToKebabCase(), "test") | ||
XCTAssertEqual("123".camelCaseToKebabCase(), "123") | ||
XCTAssertEqual("".camelCaseToKebabCase(), "") | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.