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 21, 2025
1 parent 1f1e8a7 commit cc4ffaa
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 81 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "e35717c356258e6e90769a7fcfe2ad05da44c7a097dd924aa65b646a0f3b8594",
"originHash" : "ac7e7cc0e53ac69ab0496d2fa9ac62eb79de65fb639ee854c714910eac1d991f",
"pins" : [
{
"identity" : "combine-schedulers",
Expand All @@ -15,8 +15,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/romanmazeev/MRZParser.git",
"state" : {
"revision" : "c33e3f3c5b6bac59521222af7253ac55358bb924",
"version" : "1.2.1"
"revision" : "9ecd6c63d155e2441465627fc256c9e3ce035c0b",
"version" : "1.3.0"
}
},
{
Expand Down
4 changes: 2 additions & 2 deletions Example/MRZScannerExample/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ struct ContentView: View {
return """
Document type: \(mrzResult.documentType)
Country code: \(mrzResult.countryCode)
Surnames: \(mrzResult.surnames)
Given names: \(mrzResult.givenNames)
Surnames: \(mrzResult.names.surnames)
Given names: \(mrzResult.names.givenNames ?? "-")
Document number: \(mrzResult.documentNumber)
nationalityCountryCode: \(mrzResult.nationalityCountryCode)
birthdate: \(birthdateString ?? "-")
Expand Down
6 changes: 3 additions & 3 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "e35717c356258e6e90769a7fcfe2ad05da44c7a097dd924aa65b646a0f3b8594",
"originHash" : "ac7e7cc0e53ac69ab0496d2fa9ac62eb79de65fb639ee854c714910eac1d991f",
"pins" : [
{
"identity" : "combine-schedulers",
Expand All @@ -15,8 +15,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/romanmazeev/MRZParser.git",
"state" : {
"revision" : "c33e3f3c5b6bac59521222af7253ac55358bb924",
"version" : "1.2.1"
"revision" : "9ecd6c63d155e2441465627fc256c9e3ce035c0b",
"version" : "1.3.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.2.1"),
.package(url: "https://github.com/romanmazeev/MRZParser.git", from: "1.3.0"),
.package(url: "https://github.com/pointfreeco/swift-dependencies", from: "1.7.0"),
.package(url: "https://github.com/pointfreeco/swift-custom-dump.git", from: "1.3.3")
],
Expand Down
4 changes: 2 additions & 2 deletions Sources/MRZScanner/Private/Parser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Dependencies
import DependenciesMacros
import MRZParser

public typealias ParserResult = MRZResult
public typealias ParserResult = MRZCode

@DependencyClient
struct Parser: Sendable {
Expand All @@ -19,7 +19,7 @@ struct Parser: Sendable {
extension Parser: DependencyKey {
static var liveValue: Self {
.init { mrzLines in
MRZParser.parse(mrzLines: mrzLines, isOCRCorrectionEnabled: true)
ParserResult(mrzLines: mrzLines, isOCRCorrectionEnabled: true)
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions Sources/MRZScanner/Private/Validator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import Dependencies
import DependenciesMacros
import MRZParser

@DependencyClient
struct Validator: Sendable {
Expand All @@ -26,7 +25,7 @@ extension Validator: DependencyKey {
.init { possibleLines in
var validLines: [Result] = []

for validMRZCode in MRZFormat.allCases {
for validMRZCode in [ParserResult.Format.td1, .td2(isVisaDocument: false), .td3(isVisaDocument: false)] {
guard validLines.count < validMRZCode.linesCount else { break }
for (index, lines) in possibleLines.enumerated() {
guard validLines.count < validMRZCode.linesCount else { break }
Expand Down
1 change: 0 additions & 1 deletion Sources/MRZScanner/Public/ScanningResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//

import CoreImage
import MRZParser

/// Bounding rectangles of the scanned text.
/// - Note: Rects are normalized and use a bottom-right coordinate system.
Expand Down
58 changes: 0 additions & 58 deletions Tests/MRZScannerTests/Private/ParserTests.swift

This file was deleted.

2 changes: 1 addition & 1 deletion Tests/MRZScannerTests/Private/TextRecognizerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Created by Roman Mazeev on 02/12/2023.
//

@testable import MRZScanner
import CoreImage
@testable import MRZScanner
import XCTest

final class TextRecognizerTests: XCTestCase {
Expand Down
5 changes: 2 additions & 3 deletions Tests/MRZScannerTests/Public/ScanningResultTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,11 @@ private extension ParserResult {
static var thirdMock: Self {
.init(
mrzKey: "",
format: .td2,
format: .td2(isVisaDocument: false),
documentType: .id,
documentTypeAdditional: "r",
countryCode: "thirdTest",
surnames: "thirdTest",
givenNames: "thirdTest",
names: .init(surnames: "thirdTest", givenNames: "thirdTest"),
documentNumber: "thirdTest",
nationalityCountryCode: "thirdTest",
birthdate: .mock,
Expand Down
8 changes: 3 additions & 5 deletions Tests/MRZScannerTests/SharedMocks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ extension ParserResult {
static var mock: Self {
.init(
mrzKey: "",
format: .td3,
format: .td3(isVisaDocument: false),
documentType: .passport,
documentTypeAdditional: "A",
countryCode: "test",
surnames: "test",
givenNames: "test",
names: .init(surnames: "test", givenNames: "test"),
documentNumber: "test",
nationalityCountryCode: "test",
birthdate: .mock,
Expand All @@ -35,8 +34,7 @@ extension ParserResult {
documentType: .passport,
documentTypeAdditional: "r",
countryCode: "secondTest",
surnames: "secondTest",
givenNames: "secondTest",
names: .init(surnames: "secondTest", givenNames: "secondTest"),
documentNumber: "secondTest",
nationalityCountryCode: "secondTest",
birthdate: .mock,
Expand Down

0 comments on commit cc4ffaa

Please sign in to comment.