Skip to content

Commit

Permalink
Convert to Swift 4.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
enums committed Dec 9, 2018
1 parent 95495eb commit 0cf8c2c
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 30 deletions.
34 changes: 17 additions & 17 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
// swift-tools-version:4.2
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

#if os(OSX)
let package = Package(
name: "Pjango",
targets: [],
dependencies: [
.Package(url: "https://github.com/PerfectlySoft/Perfect-HTTPServer.git", majorVersion: 3, minor: 0),
.Package(url: "https://github.com/PerfectlySoft/Perfect-Mustache.git", majorVersion: 3, minor: 0),
.Package(url: "https://github.com/enums/SwiftyJSON.git", majorVersion: 4),
]
)
#else
let package = Package(
name: "Pjango",
targets: [],
products: [
.library(
name: "Pjango",
targets: ["Pjango"]),
],
dependencies: [
.Package(url: "https://github.com/PerfectlySoft/Perfect-HTTPServer.git", majorVersion: 2, minor: 0),
.Package(url: "https://github.com/PerfectlySoft/Perfect-Mustache.git", majorVersion: 2, minor: 0),
.Package(url: "https://github.com/enums/SwiftyJSON.git", majorVersion: 4),
]
.package(url:"https://github.com/PerfectlySoft/Perfect-HTTPServer.git" , from: "3.0.19"),
.package(url:"https://github.com/PerfectlySoft/Perfect-Mustache.git" , from: "3.0.2"),
.package(url:"https://github.com/enums/Pjango-SwiftyJSON" , from: "1.0.0"),
],
targets: [
.target(
name: "Pjango",
dependencies: ["PerfectHTTPServer", "PerfectMustache", "SwiftyJSON"])
]
)
#endif


10 changes: 5 additions & 5 deletions Source/Pjango/DB/PCDataBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ open class PCDataBase {
return nil
}

open let config: PCDataBaseConfig
public let config: PCDataBaseConfig
open var state: PCDataBaseState

open let _pjango_core_database_lock = NSLock.init()
public let _pjango_core_database_lock = NSLock.init()

public init(config: PCDataBaseConfig) {
self.config = config
self.state = .inited
}

open static var empty: PCDataBase {
public static var empty: PCDataBase {
let database = PCDataBase.init(config: PCDataBaseConfig.init())
database.state = .empty
return database
Expand Down Expand Up @@ -151,7 +151,7 @@ open class PCDataBase {

@discardableResult
open func insertModel(_ model: PCModel) -> Bool {
let record = model._pjango_core_model_fields.flatMap { (field) -> String? in
let record = model._pjango_core_model_fields.compactMap { (field) -> String? in
switch field.type {
case .string: return field.strValue
case .int: return "\(field.intValue)"
Expand All @@ -174,7 +174,7 @@ open class PCDataBase {
guard let id = model._pjango_core_model_id else {
return false
}
let updateStr = model._pjango_core_model_fields_key.flatMap { (key) -> String? in
let updateStr = model._pjango_core_model_fields_key.compactMap { (key) -> String? in
guard let type = model._pjango_core_model_fields_type[key], let value = model._pjango_core_model_get_filed_data(key: key) else {
return nil
}
Expand Down
6 changes: 3 additions & 3 deletions Source/Pjango/DB/PCFileDBDataBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ open class PCFileDBDataBase: PCDataBase {

@discardableResult
open override func insertModel(_ model: PCModel) -> Bool {
var record = model._pjango_core_model_fields.flatMap { (field) -> String? in
var record = model._pjango_core_model_fields.compactMap { (field) -> String? in
switch field.type {
case .string: return field.strValue
case .int: return "\(field.intValue)"
Expand Down Expand Up @@ -147,7 +147,7 @@ open class PCFileDBDataBase: PCDataBase {
guard let id = model._pjango_core_model_id else {
return false
}
let updateStr = model._pjango_core_model_fields_key.flatMap { (key) -> String? in
let updateStr = model._pjango_core_model_fields_key.compactMap { (key) -> String? in
guard let type = model._pjango_core_model_fields_type[key], let value = model._pjango_core_model_get_filed_data(key: key) else {
return nil
}
Expand Down Expand Up @@ -215,7 +215,7 @@ open class PCFileDBDataBase: PCDataBase {
"objs": [[String]]()
])
} else {
json = JSON.parse(str)
json = JSON.init(parseJSON: str)
}
guard let jsonArray = json["objs"].array else {
return nil
Expand Down
4 changes: 2 additions & 2 deletions Source/Pjango/Model/PCModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ open class PCModel: PCObject, PCViewable {
_pjango_core_model_cache_time[_pjango_core_class_name] = nowTime.timeIntervalSince1970
records = recordsFromDB
}
return records.flatMap { record in
return records.compactMap { record in
var record = record
let idStr = record.removeFirst()
guard let id = Int64(idStr) else {
Expand Down Expand Up @@ -146,7 +146,7 @@ open class PCModel: PCObject, PCViewable {
}
}

open static var meta: PCMetaModel {
public static var meta: PCMetaModel {
return self.init()
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Pjango/Plugin/PCPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public typealias PCMetaPlugin = PCPlugin

open class PCPlugin: PCObject, PCRunable {

open static var meta: PCMetaPlugin {
public static var meta: PCMetaPlugin {
return self.init()
}

Expand Down
4 changes: 2 additions & 2 deletions Source/Pjango/View/PCView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ open class PCView: PCObject {
return viewParam ?? PCViewParam()
}

open static var meta: PCView {
public static var meta: PCView {
return self.init()
}

Expand All @@ -39,7 +39,7 @@ open class PCView: PCObject {

open weak var currentRequest: HTTPRequest? = nil

open static func asHandle() -> PCUrlHandle {
public static func asHandle() -> PCUrlHandle {
let handle: RequestHandler = { req, res in
let view = self.init()
view.currentRequest = req
Expand Down

0 comments on commit 0cf8c2c

Please sign in to comment.