Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

renamed BundleURL to CardScan #114

Merged
merged 1 commit into from
Jan 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CardScan/Classes/API.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public struct Api {
}

static func getSdkVersion() -> String? {
guard let bundle = BundleURL.bundle() else {
guard let bundle = CardScan.bundle() else {
return nil
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
public struct BundleURL {
//
// CardScan.swift
// CardScan
//
// Created by Jaime Park on 1/29/20.
//

import Foundation

public class CardScan {
// If you change the bundle name make sure to set these before
// initializing the library
public static var bundleName = "CardScan"
Expand Down
4 changes: 2 additions & 2 deletions CardScan/Classes/FindFourOcr.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ struct FindFourOcr {

static func initializeModels() {
if FindFourOcr.recognizeModel == nil {
guard let fourRecognizeUrl = BundleURL.compiledModel(forResource: fourRecognizeResource, withExtension: fourRecognizeExtension) else {
guard let fourRecognizeUrl = CardScan.compiledModel(forResource: fourRecognizeResource, withExtension: fourRecognizeExtension) else {
print("Could not find URL for FourRecognize")
return
}
Expand All @@ -101,7 +101,7 @@ struct FindFourOcr {
FindFourOcr.recognizeModel = recognizeModel
}
if FindFourOcr.detectModel == nil {
guard let findFourUrl = BundleURL.compiledModel(forResource: findFourResource, withExtension: findFourExtension) else {
guard let findFourUrl = CardScan.compiledModel(forResource: findFourResource, withExtension: findFourExtension) else {
print("Could not find URL for FindFour")
return
}
Expand Down
2 changes: 1 addition & 1 deletion CardScan/Classes/ScanBaseViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public protocol TestingImageDataSource: AnyObject {
}

@objc static public func cameraImage() -> UIImage? {
guard let bundle = BundleURL.bundle() else {
guard let bundle = CardScan.bundle() else {
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion CardScan/Classes/ScanViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ import UIKit

// The forced unwrap here is intentional -- we expect this to crash
// if someone uses it with an invalid bundle
let bundle = BundleURL.bundle()!
let bundle = CardScan.bundle()!

let storyboard = UIStoryboard(name: "CardScan", bundle: bundle)
let viewController = storyboard.instantiateViewController(withIdentifier: "scanCardViewController") as! ScanViewController
Expand Down
8 changes: 4 additions & 4 deletions Example/CardScan/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let bundle = BundleURL.bundle()
BundleURL.cardScanBundle = bundle
BundleURL.bundleName = ""
BundleURL.extensionName = ""
let bundle = CardScan.bundle()
CardScan.cardScanBundle = bundle
CardScan.bundleName = ""
CardScan.extensionName = ""
ScanViewController.configure()
return true
}
Expand Down
8 changes: 4 additions & 4 deletions Example/CardScan_ExampleTests/CardScan_BundleTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ class CardScan_BundleTests: XCTestCase {
}

func testForResource() {
var findFourURl = BundleURL.compiledModel(forResource: "feefifofum", withExtension: "bin")
var findFourURl = CardScan.compiledModel(forResource: "feefifofum", withExtension: "bin")
XCTAssert(findFourURl == nil)

findFourURl = BundleURL.compiledModel(forResource: "FindFour", withExtension: "mlmodelc")
findFourURl = CardScan.compiledModel(forResource: "FindFour", withExtension: "mlmodelc")
XCTAssert(findFourURl != nil)
}

func testWithExtension() {
var findFourURl = BundleURL.compiledModel(forResource: "FindFour", withExtension: "fee")
var findFourURl = CardScan.compiledModel(forResource: "FindFour", withExtension: "fee")
XCTAssert(findFourURl == nil)

findFourURl = BundleURL.compiledModel(forResource: "FindFour", withExtension: "mlmodelc")
findFourURl = CardScan.compiledModel(forResource: "FindFour", withExtension: "mlmodelc")
XCTAssert(findFourURl != nil)
}
}