diff --git a/.gitignore b/.gitignore index 4aa8162..d089749 100644 --- a/.gitignore +++ b/.gitignore @@ -72,3 +72,4 @@ buildlinux /.build_lin Package.pins Package.resolved +.DS_Store diff --git a/Package.swift b/Package.swift index 95360f9..cedce53 100644 --- a/Package.swift +++ b/Package.swift @@ -1,12 +1,20 @@ +// swift-tools-version:4.2 // Generated automatically by Perfect Assistant Application // Date: 2018-03-02 16:12:45 +0000 import PackageDescription let package = Package( name: "StORM", - targets: [], + products: [ + .library(name: "StORM", targets: ["StORM"]) + ], dependencies: [ - .Package(url: "https://github.com/PerfectlySoft/PerfectLib.git", majorVersion: 3), - .Package(url: "https://github.com/iamjono/SwiftMoment.git", majorVersion: 1), - .Package(url: "https://github.com/iamjono/SwiftString.git", majorVersion: 2), + .package(url: "https://github.com/PerfectlySoft/PerfectLib.git", from: "3.0.0"), + .package(url: "https://github.com/iamjono/SwiftMoment.git", from: "1.0.0") + ], + targets: [ + .target(name: "StORM", dependencies: [ + "SwiftMoment", + "PerfectLib" + ]) ] ) diff --git a/Sources/StORM/Extract.swift b/Sources/StORM/Extract.swift index 65ef8c2..b8ebecc 100644 --- a/Sources/StORM/Extract.swift +++ b/Sources/StORM/Extract.swift @@ -7,7 +7,6 @@ import Foundation import SwiftMoment -import SwiftString extension StORM { @@ -66,26 +65,19 @@ extension StORM { public static func bytes(_ data: [String: Any], _ name: String, _ def: [UInt8]? = [UInt8]()) -> [UInt8]? { return data[name] as? [UInt8] ?? def } - - - - - - - - + // ======================================================================================= // Array Of Strings // ======================================================================================= public static func arrayOfStrings(_ data: [String: Any], _ name: String, _ def: [String]? = [String]()) -> [String]? { - return (data[name] as? String ?? "").split(",").map{ $0.trimmed() } // note default ignored right now + return (data[name] as? String ?? "").split(separator: ",").map{ $0.trimmingCharacters(in: .whitespacesAndNewlines) } // note default ignored right now } // ======================================================================================= // Array Of Integers // ======================================================================================= public static func arrayOfIntegers(_ data: [String: Any], _ name: String, _ def: [Int]? = [Int]()) -> [Int]? { - return (data[name] as? String ?? "").split(",").map{ Int($0.trimmed()) ?? 0 } // note default ignored right now + return (data[name] as? String ?? "").split(separator: ",").map{ Int($0.trimmingCharacters(in: .whitespacesAndNewlines)) ?? 0 } // note default ignored right now } // ======================================================================================= diff --git a/Sources/StORM/StORM.swift b/Sources/StORM/StORM.swift index 6903f37..b992a6e 100644 --- a/Sources/StORM/StORM.swift +++ b/Sources/StORM/StORM.swift @@ -105,20 +105,20 @@ open class StORM { let (_, val) = firstAsKey() // Grab the type of value: - let type = type(of: val) + let theType = type(of: val) // Check if we are nil, we would then of course have an empty primary key. guard String(describing: val) != "nil" else { return true } // For now we will be expecting String & Integer key types: - switch type { + switch theType { case is Int.Type, is Int?.Type: return (val as! Int == 0) case is String.Type, is String?.Type: return (val as! String).isEmpty default: - print("[StORM] WARNING: [\(#function)] Unexpected \(type) for PRIMARY KEY.") + print("[StORM] WARNING: [\(#function)] Unexpected \(theType) for PRIMARY KEY.") return false }