Updated package file and removed dep

This commit is contained in:
Kyle Jessup 2019-03-26 12:20:00 -04:00
parent 653f4bdfa6
commit fe48e5f421
4 changed files with 19 additions and 18 deletions

1
.gitignore vendored
View File

@ -72,3 +72,4 @@ buildlinux
/.build_lin
Package.pins
Package.resolved
.DS_Store

View File

@ -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"
])
]
)

View File

@ -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
}
// =======================================================================================

View File

@ -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
}