Skip to content

Commit

Permalink
Update MRZParser dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
romanmazeev committed Feb 2, 2025
1 parent 490e61c commit 4e4ae22
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/romanmazeev/MRZParser.git",
"state" : {
"revision" : "f6a0b10395e7cac783189ef2a0c8e1a55296ff37",
"version" : "1.1.4"
"revision" : "6c97a2da4586f2cfb09a18b8ec2cdf231847b205",
"version" : "1.2.0"
}
},
{
Expand Down
11 changes: 3 additions & 8 deletions Example/MRZScannerExample/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,15 @@ struct ContentView: View {
var birthdateString: String?
var expiryDateString: String?

if let birthdate = mrzResult.birthdate {
birthdateString = dateFormatter.string(from: birthdate)
}

if let expiryDate = mrzResult.expiryDate {
expiryDateString = dateFormatter.string(from: expiryDate)
}
birthdateString = dateFormatter.string(from: mrzResult.birthdate)
expiryDateString = dateFormatter.string(from: mrzResult.expiryDate)

return """
Document type: \(mrzResult.documentType)
Country code: \(mrzResult.countryCode)
Surnames: \(mrzResult.surnames)
Given names: \(mrzResult.givenNames)
Document number: \(mrzResult.documentNumber ?? "-")
Document number: \(mrzResult.documentNumber)
nationalityCountryCode: \(mrzResult.nationalityCountryCode)
birthdate: \(birthdateString ?? "-")
sex: \(mrzResult.sex)
Expand Down
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/romanmazeev/MRZParser.git",
"state" : {
"revision" : "f6a0b10395e7cac783189ef2a0c8e1a55296ff37",
"version" : "1.1.4"
"revision" : "6c97a2da4586f2cfb09a18b8ec2cdf231847b205",
"version" : "1.2.0"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let package = Package(
),
],
dependencies: [
.package(url: "https://github.com/romanmazeev/MRZParser.git", from: "1.1.4"),
.package(url: "https://github.com/romanmazeev/MRZParser.git", from: "1.2.0"),
.package(url: "https://github.com/pointfreeco/swift-dependencies", from: "1.3.1"),
.package(url: "https://github.com/pointfreeco/swift-custom-dump.git", from: "1.3.0")
],
Expand Down
2 changes: 1 addition & 1 deletion Sources/MRZScanner/Private/Parser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct Parser: Sendable {
extension Parser: DependencyKey {
static var liveValue: Self {
.init { mrzLines in
MRZParser(isOCRCorrectionEnabled: true).parse(mrzLines: mrzLines)
MRZParser.parse(mrzLines: mrzLines, isOCRCorrectionEnabled: true)
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion Tests/MRZScannerTests/Private/ParserTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ final class ParserTests: XCTestCase {

let mrzStrings = ["IRUTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<", "D231458907UTO7408122F1204159<<<<<<<6"]
let result = ParserResult(
mrzKey: "D23145890774081221204159",
format: .td2,
documentType: .id,
documentTypeAdditional: "R",
Expand All @@ -41,7 +42,7 @@ final class ParserTests: XCTestCase {
birthdate: try XCTUnwrap(dateFormatter.date(from: "740812")),
sex: .female,
expiryDate: try XCTUnwrap(dateFormatter.date(from: "120415")),
optionalData: "",
optionalData: nil,
optionalData2: nil
)

Expand Down
1 change: 1 addition & 0 deletions Tests/MRZScannerTests/Public/ScanningResultTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ final class ScanningResultTests: XCTestCase {
private extension ParserResult {
static var thirdMock: Self {
.init(
mrzKey: "",
format: .td2,
documentType: .id,
documentTypeAdditional: "r",
Expand Down
2 changes: 2 additions & 0 deletions Tests/MRZScannerTests/SharedMocks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Foundation
extension ParserResult {
static var mock: Self {
.init(
mrzKey: "",
format: .td3,
documentType: .passport,
documentTypeAdditional: "A",
Expand All @@ -29,6 +30,7 @@ extension ParserResult {

static var secondMock: Self {
.init(
mrzKey: "",
format: .td1,
documentType: .passport,
documentTypeAdditional: "r",
Expand Down

0 comments on commit 4e4ae22

Please sign in to comment.