Skip to content

Commit

Permalink
renamed BundleURL to CardScan (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaimejiyepark committed Jan 29, 2020
1 parent 36f4fca commit f883ee9
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 14 deletions.
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 @@ -142,7 +142,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)
}
}

0 comments on commit f883ee9

Please sign in to comment.