diff --git a/Xcode/CoreModel/CoreModel.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata similarity index 70% rename from Xcode/CoreModel/CoreModel.xcodeproj/project.xcworkspace/contents.xcworkspacedata rename to .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata index 24649c6..919434a 100644 --- a/Xcode/CoreModel/CoreModel.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:"> diff --git a/Cartfile b/Cartfile deleted file mode 100644 index 147fb4b..0000000 --- a/Cartfile +++ /dev/null @@ -1 +0,0 @@ -github "PureSwift/Predicate" "master" \ No newline at end of file diff --git a/Cartfile.resolved b/Cartfile.resolved deleted file mode 100644 index 6800500..0000000 --- a/Cartfile.resolved +++ /dev/null @@ -1 +0,0 @@ -github "PureSwift/Predicate" "8474eac6e3d483b25d1f1ef1cfd852d8f90f928b" diff --git a/Package.swift b/Package.swift index cc3a7a4..a64e6cd 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:4.1 +// swift-tools-version:5.7 import PackageDescription let package = Package( @@ -15,16 +15,10 @@ let package = Package( targets: [ "CoreDataModel" ] - ), - .library( - name: "SQLiteModel", - targets: [ - "SQLiteModel" - ] ) ], dependencies: [ - .package(url: "https://github.com/PureSwift/Predicate.git", .branch("master")) + .package(url: "https://github.com/PureSwift/Predicate.git", branch: "master") ], targets: [ .target( @@ -39,18 +33,11 @@ let package = Package( "CoreModel" ] ), - .target( - name: "SQLiteModel", - dependencies: [ - "CoreModel" - ] - ), .testTarget( name: "CoreModelTests", dependencies: [ "CoreModel" ] ) - ], - swiftLanguageVersions: [4] + ] ) diff --git a/README.md b/README.md index 050e8fc..5b36100 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,10 @@ # CoreModel -[![Swift](https://img.shields.io/badge/swift-4.1-orange.svg?style=flat)](https://developer.apple.com/swift/) +[![Swift](https://img.shields.io/badge/swift-5.7-orange.svg?style=flat)](https://developer.apple.com/swift/) [![License MIT](https://img.shields.io/badge/License-MIT-blue.svg?style=flat)](https://tldrlegal.com/license/mit-license) [![Release](https://img.shields.io/github/release/pureswift/CoreModel.svg)](https://github.com/PureSwift/CoreModel/releases) [![Build Status](https://travis-ci.org/PureSwift/CoreModel.svg?branch=master)](https://travis-ci.org/PureSwift/CoreModel) [![SPM compatible](https://img.shields.io/badge/SPM-compatible-4BC51D.svg?style=flat)](https://github.com/apple/swift-package-manager) -[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) Swift Object Graph diff --git a/Sources/CoreModel/Entity.swift b/Sources/CoreModel/Entity.swift index 3cec761..4f5bb77 100644 --- a/Sources/CoreModel/Entity.swift +++ b/Sources/CoreModel/Entity.swift @@ -15,10 +15,11 @@ public struct Entity: Codable, Equatable { public var relationships: [Relationship] - public init(name: String, - attributes: [Attribute], - relationships: [Relationship]) { - + public init( + name: String, + attributes: [Attribute], + relationships: [Relationship] + ) { self.name = name self.attributes = attributes self.relationships = relationships @@ -28,12 +29,10 @@ public struct Entity: Codable, Equatable { public extension Entity { subscript (attribute propertyName: String) -> Attribute? { - return attributes.first { $0.name == propertyName } } subscript (relationship propertyName: String) -> Relationship? { - return relationships.first { $0.name == propertyName } } } diff --git a/Sources/CoreModel/InMemoryStore.swift b/Sources/CoreModel/InMemoryStore.swift index f7267f8..3104f78 100644 --- a/Sources/CoreModel/InMemoryStore.swift +++ b/Sources/CoreModel/InMemoryStore.swift @@ -16,7 +16,6 @@ public final class InMemoryStore: StoreProtocol { private var data = [Identifier: Cache]() public init(model: Model) { - self.model = model } @@ -26,12 +25,10 @@ public final class InMemoryStore: StoreProtocol { var identifiers = data.keys.filter { $0.entity == fetchRequest.entity } if fetchRequest.fetchOffset > 0 { - identifiers = Array(identifiers.suffix(fetchRequest.fetchOffset)) } if fetchRequest.fetchLimit > 0 { - identifiers = Array(identifiers.prefix(fetchRequest.fetchLimit)) } @@ -94,14 +91,14 @@ public final class InMemoryStore: StoreProtocol { public extension InMemoryStore { - public struct Identifier: Equatable, Hashable { + struct Identifier: Equatable, Hashable { public let entity: String public let uuid: UUID } - public final class ManagedObject: CoreModel.ManagedObject { + final class ManagedObject: CoreModel.ManagedObject { public private(set) weak var store: InMemoryStore? @@ -277,9 +274,8 @@ public extension InMemoryStore { } - public var hashValue: Int { - - return identifier.hashValue + public func hash(into hasher: inout Hasher) { + identifier.hash(into: &hasher) } public static func == (lhs: ManagedObject, rhs: ManagedObject) -> Bool { @@ -308,7 +304,6 @@ private extension InMemoryStore { extension InMemoryStore.ManagedObject: PredicateEvaluatable { public func evaluate(with predicate: Predicate) throws -> Bool { - - + false } } diff --git a/Sources/CoreModel/ManagedObject.swift b/Sources/CoreModel/ManagedObject.swift index 77c9382..d932abd 100644 --- a/Sources/CoreModel/ManagedObject.swift +++ b/Sources/CoreModel/ManagedObject.swift @@ -8,8 +8,8 @@ import Foundation /// CoreModel Managed Object -public protocol ManagedObject: class, Hashable { - +public protocol ManagedObject: AnyObject, Hashable { + /// Whether the object has been deleted. var isDeleted: Bool { get } diff --git a/Sources/CoreModel/Store.swift b/Sources/CoreModel/Store.swift index 63ff044..5970260 100644 --- a/Sources/CoreModel/Store.swift +++ b/Sources/CoreModel/Store.swift @@ -7,7 +7,7 @@ // /// CoreModel Store Protocol -public protocol StoreProtocol: class { +public protocol StoreProtocol: AnyObject { associatedtype ManagedObject: CoreModel.ManagedObject diff --git a/Sources/SQLiteModel/SQLite.swift b/Sources/SQLiteModel/SQLite.swift deleted file mode 100644 index 8b13789..0000000 --- a/Sources/SQLiteModel/SQLite.swift +++ /dev/null @@ -1 +0,0 @@ - diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift deleted file mode 100755 index 0f7ad36..0000000 --- a/Tests/LinuxMain.swift +++ /dev/null @@ -1,6 +0,0 @@ -import XCTest -@testable import CoreModelTests - -XCTMain([ - testCase(CoreModelTests.allTests) - ]) diff --git a/Xcode/CoreModel/CoreModel.xcodeproj/project.pbxproj b/Xcode/CoreModel/CoreModel.xcodeproj/project.pbxproj deleted file mode 100644 index f563a2f..0000000 --- a/Xcode/CoreModel/CoreModel.xcodeproj/project.pbxproj +++ /dev/null @@ -1,493 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - 4479AFCF1C1FC895000255CB /* CoreDataModel.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 449BBF921C1F2B800001D7BE /* CoreDataModel.xcdatamodeld */; }; - 4479AFD01C1FC898000255CB /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 448799E31C1FC01C002D2B40 /* CoreData.framework */; }; - 4479AFD21C1FC89F000255CB /* TestCocoaExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 449BBF941C1F2B800001D7BE /* TestCocoaExtensions.swift */; }; - 4479AFD31C1FC8A3000255CB /* TestEntity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 449BBF951C1F2B800001D7BE /* TestEntity.swift */; }; - 4479AFD41C1FC8A7000255CB /* TestEntity+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 449BBF961C1F2B800001D7BE /* TestEntity+CoreDataProperties.swift */; }; - 448799EF1C1FC20E002D2B40 /* CoreModel.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6EC90CBE1C1A68530068944A /* CoreModel.framework */; }; - 448799FC1C1FC2F6002D2B40 /* CoreModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 449BBF891C1F28D70001D7BE /* CoreModelTests.swift */; }; - 6EC90CC21C1A68530068944A /* CoreModel.h in Headers */ = {isa = PBXBuildFile; fileRef = 6EC90CC11C1A68530068944A /* CoreModel.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 6EC90CEA1C1A68830068944A /* Entity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EC90CD51C1A68830068944A /* Entity.swift */; }; - 6EC90CEB1C1A68830068944A /* FetchRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EC90CD61C1A68830068944A /* FetchRequest.swift */; }; - 6EC90CED1C1A68830068944A /* Property.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EC90CD81C1A68830068944A /* Property.swift */; }; - 6EC90CEF1C1A68830068944A /* SortDescriptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EC90CDA1C1A68830068944A /* SortDescriptor.swift */; }; - 6EC90CF01C1A68830068944A /* Store.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EC90CDB1C1A68830068944A /* Store.swift */; }; - 6EC90CF31C1A68830068944A /* ValueType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EC90CDE1C1A68830068944A /* ValueType.swift */; }; -/* End PBXBuildFile section */ - -/* Begin PBXContainerItemProxy section */ - 448799F01C1FC20E002D2B40 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 6EC90CB51C1A68530068944A /* Project object */; - proxyType = 1; - remoteGlobalIDString = 6EC90CBD1C1A68530068944A; - remoteInfo = "CoreModel OS X"; - }; -/* End PBXContainerItemProxy section */ - -/* Begin PBXFileReference section */ - 448799E31C1FC01C002D2B40 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; }; - 448799EA1C1FC20E002D2B40 /* CoreModelTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CoreModelTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 449BBF891C1F28D70001D7BE /* CoreModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoreModelTests.swift; sourceTree = ""; }; - 449BBF8B1C1F28D70001D7BE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 449BBF931C1F2B800001D7BE /* CoreDataModel.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = CoreDataModel.xcdatamodel; sourceTree = ""; }; - 449BBF941C1F2B800001D7BE /* TestCocoaExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestCocoaExtensions.swift; sourceTree = ""; }; - 449BBF951C1F2B800001D7BE /* TestEntity.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestEntity.swift; sourceTree = ""; }; - 449BBF961C1F2B800001D7BE /* TestEntity+CoreDataProperties.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "TestEntity+CoreDataProperties.swift"; sourceTree = ""; }; - 6EC90CBE1C1A68530068944A /* CoreModel.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CoreModel.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 6EC90CC11C1A68530068944A /* CoreModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CoreModel.h; sourceTree = ""; }; - 6EC90CC31C1A68530068944A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 6EC90CD51C1A68830068944A /* Entity.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Entity.swift; sourceTree = ""; }; - 6EC90CD61C1A68830068944A /* FetchRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FetchRequest.swift; sourceTree = ""; }; - 6EC90CD81C1A68830068944A /* Property.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Property.swift; sourceTree = ""; }; - 6EC90CDA1C1A68830068944A /* SortDescriptor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SortDescriptor.swift; sourceTree = ""; }; - 6EC90CDB1C1A68830068944A /* Store.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Store.swift; sourceTree = ""; }; - 6EC90CDE1C1A68830068944A /* ValueType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueType.swift; sourceTree = ""; }; - 6EC90CF51C1A6DD10068944A /* Package.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = Package.swift; path = ../../Package.swift; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 448799E71C1FC20E002D2B40 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 448799EF1C1FC20E002D2B40 /* CoreModel.framework in Frameworks */, - 4479AFD01C1FC898000255CB /* CoreData.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 6EC90CBA1C1A68530068944A /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 448799EB1C1FC20E002D2B40 /* CoreModelTests */ = { - isa = PBXGroup; - children = ( - 448799E31C1FC01C002D2B40 /* CoreData.framework */, - 449BBF921C1F2B800001D7BE /* CoreDataModel.xcdatamodeld */, - 449BBF941C1F2B800001D7BE /* TestCocoaExtensions.swift */, - 449BBF951C1F2B800001D7BE /* TestEntity.swift */, - 449BBF961C1F2B800001D7BE /* TestEntity+CoreDataProperties.swift */, - 449BBF891C1F28D70001D7BE /* CoreModelTests.swift */, - 449BBF8B1C1F28D70001D7BE /* Info.plist */, - ); - path = CoreModelTests; - sourceTree = ""; - }; - 6EC90CB41C1A68530068944A = { - isa = PBXGroup; - children = ( - 6EC90CF51C1A6DD10068944A /* Package.swift */, - 6EC90CC91C1A68830068944A /* Source */, - 6EC90CC01C1A68530068944A /* CoreModel */, - 448799EB1C1FC20E002D2B40 /* CoreModelTests */, - 6EC90CBF1C1A68530068944A /* Products */, - ); - indentWidth = 4; - sourceTree = ""; - tabWidth = 4; - }; - 6EC90CBF1C1A68530068944A /* Products */ = { - isa = PBXGroup; - children = ( - 6EC90CBE1C1A68530068944A /* CoreModel.framework */, - 448799EA1C1FC20E002D2B40 /* CoreModelTests.xctest */, - ); - name = Products; - sourceTree = ""; - }; - 6EC90CC01C1A68530068944A /* CoreModel */ = { - isa = PBXGroup; - children = ( - 6EC90CC11C1A68530068944A /* CoreModel.h */, - 6EC90CC31C1A68530068944A /* Info.plist */, - ); - path = CoreModel; - sourceTree = ""; - }; - 6EC90CC91C1A68830068944A /* Source */ = { - isa = PBXGroup; - children = ( - 6EC90CD51C1A68830068944A /* Entity.swift */, - 6EC90CD61C1A68830068944A /* FetchRequest.swift */, - 6EC90CD81C1A68830068944A /* Property.swift */, - 6EC90CDA1C1A68830068944A /* SortDescriptor.swift */, - 6EC90CDB1C1A68830068944A /* Store.swift */, - 6EC90CDE1C1A68830068944A /* ValueType.swift */, - ); - name = Source; - path = ../../Source; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXHeadersBuildPhase section */ - 6EC90CBB1C1A68530068944A /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - 6EC90CC21C1A68530068944A /* CoreModel.h in Headers */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXHeadersBuildPhase section */ - -/* Begin PBXNativeTarget section */ - 448799E91C1FC20E002D2B40 /* CoreModelTests */ = { - isa = PBXNativeTarget; - buildConfigurationList = 448799F21C1FC20E002D2B40 /* Build configuration list for PBXNativeTarget "CoreModelTests" */; - buildPhases = ( - 448799E61C1FC20E002D2B40 /* Sources */, - 4479AFCE1C1FC858000255CB /* Run Carthage Copy Script */, - 448799E71C1FC20E002D2B40 /* Frameworks */, - 448799E81C1FC20E002D2B40 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - 448799F11C1FC20E002D2B40 /* PBXTargetDependency */, - ); - name = CoreModelTests; - productName = CoreModelTests; - productReference = 448799EA1C1FC20E002D2B40 /* CoreModelTests.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; - 6EC90CBD1C1A68530068944A /* CoreModel OS X */ = { - isa = PBXNativeTarget; - buildConfigurationList = 6EC90CC61C1A68530068944A /* Build configuration list for PBXNativeTarget "CoreModel OS X" */; - buildPhases = ( - 6EC90CB91C1A68530068944A /* Sources */, - 6EC90CBA1C1A68530068944A /* Frameworks */, - 6EC90CBB1C1A68530068944A /* Headers */, - 6EC90CBC1C1A68530068944A /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = "CoreModel OS X"; - productName = CoreModel; - productReference = 6EC90CBE1C1A68530068944A /* CoreModel.framework */; - productType = "com.apple.product-type.framework"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 6EC90CB51C1A68530068944A /* Project object */ = { - isa = PBXProject; - attributes = { - LastSwiftUpdateCheck = 0720; - LastUpgradeCheck = 0720; - ORGANIZATIONNAME = PureSwift; - TargetAttributes = { - 448799E91C1FC20E002D2B40 = { - CreatedOnToolsVersion = 7.2; - }; - 6EC90CBD1C1A68530068944A = { - CreatedOnToolsVersion = 7.2; - }; - }; - }; - buildConfigurationList = 6EC90CB81C1A68530068944A /* Build configuration list for PBXProject "CoreModel" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 0; - knownRegions = ( - en, - ); - mainGroup = 6EC90CB41C1A68530068944A; - productRefGroup = 6EC90CBF1C1A68530068944A /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 6EC90CBD1C1A68530068944A /* CoreModel OS X */, - 448799E91C1FC20E002D2B40 /* CoreModelTests */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 448799E81C1FC20E002D2B40 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 6EC90CBC1C1A68530068944A /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXShellScriptBuildPhase section */ - 4479AFCE1C1FC858000255CB /* Run Carthage Copy Script */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "$(SRCROOT)/../../Carthage/Build/Mac/SwiftFoundation.framework", - ); - name = "Run Carthage Copy Script"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "/usr/local/bin/carthage copy-frameworks"; - }; -/* End PBXShellScriptBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 448799E61C1FC20E002D2B40 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 4479AFD31C1FC8A3000255CB /* TestEntity.swift in Sources */, - 4479AFD21C1FC89F000255CB /* TestCocoaExtensions.swift in Sources */, - 4479AFCF1C1FC895000255CB /* CoreDataModel.xcdatamodeld in Sources */, - 4479AFD41C1FC8A7000255CB /* TestEntity+CoreDataProperties.swift in Sources */, - 448799FC1C1FC2F6002D2B40 /* CoreModelTests.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 6EC90CB91C1A68530068944A /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 6EC90CED1C1A68830068944A /* Property.swift in Sources */, - 6EC90CF01C1A68830068944A /* Store.swift in Sources */, - 6EC90CEB1C1A68830068944A /* FetchRequest.swift in Sources */, - 6EC90CEA1C1A68830068944A /* Entity.swift in Sources */, - 6EC90CF31C1A68830068944A /* ValueType.swift in Sources */, - 6EC90CEF1C1A68830068944A /* SortDescriptor.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXTargetDependency section */ - 448799F11C1FC20E002D2B40 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 6EC90CBD1C1A68530068944A /* CoreModel OS X */; - targetProxy = 448799F01C1FC20E002D2B40 /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - -/* Begin XCBuildConfiguration section */ - 448799F31C1FC20E002D2B40 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COMBINE_HIDPI_IMAGES = YES; - FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/../../Carthage/Build/Mac"; - INFOPLIST_FILE = CoreModelTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.11; - PRODUCT_BUNDLE_IDENTIFIER = org.pureswift.CoreModelTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Debug; - }; - 448799F41C1FC20E002D2B40 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COMBINE_HIDPI_IMAGES = YES; - FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/../../Carthage/Build/Mac"; - INFOPLIST_FILE = CoreModelTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.11; - PRODUCT_BUNDLE_IDENTIFIER = org.pureswift.CoreModelTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Release; - }; - 6EC90CC41C1A68530068944A /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_IDENTITY = "-"; - COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.9; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = macosx; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Debug; - }; - 6EC90CC51C1A68530068944A /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_IDENTITY = "-"; - COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.9; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = macosx; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Release; - }; - 6EC90CC71C1A68530068944A /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CODE_SIGN_IDENTITY = ""; - COMBINE_HIDPI_IMAGES = YES; - DEFINES_MODULE = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - FRAMEWORK_SEARCH_PATHS = $SRCROOT/../../Carthage/Build/Mac; - FRAMEWORK_VERSION = A; - INFOPLIST_FILE = CoreModel/Info.plist; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = org.pureswift.CoreModel; - PRODUCT_NAME = CoreModel; - SKIP_INSTALL = YES; - }; - name = Debug; - }; - 6EC90CC81C1A68530068944A /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CODE_SIGN_IDENTITY = ""; - COMBINE_HIDPI_IMAGES = YES; - DEFINES_MODULE = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - FRAMEWORK_SEARCH_PATHS = $SRCROOT/../../Carthage/Build/Mac; - FRAMEWORK_VERSION = A; - INFOPLIST_FILE = CoreModel/Info.plist; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = org.pureswift.CoreModel; - PRODUCT_NAME = CoreModel; - SKIP_INSTALL = YES; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 448799F21C1FC20E002D2B40 /* Build configuration list for PBXNativeTarget "CoreModelTests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 448799F31C1FC20E002D2B40 /* Debug */, - 448799F41C1FC20E002D2B40 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 6EC90CB81C1A68530068944A /* Build configuration list for PBXProject "CoreModel" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 6EC90CC41C1A68530068944A /* Debug */, - 6EC90CC51C1A68530068944A /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 6EC90CC61C1A68530068944A /* Build configuration list for PBXNativeTarget "CoreModel OS X" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 6EC90CC71C1A68530068944A /* Debug */, - 6EC90CC81C1A68530068944A /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - -/* Begin XCVersionGroup section */ - 449BBF921C1F2B800001D7BE /* CoreDataModel.xcdatamodeld */ = { - isa = XCVersionGroup; - children = ( - 449BBF931C1F2B800001D7BE /* CoreDataModel.xcdatamodel */, - ); - currentVersion = 449BBF931C1F2B800001D7BE /* CoreDataModel.xcdatamodel */; - path = CoreDataModel.xcdatamodeld; - sourceTree = ""; - versionGroupType = wrapper.xcdatamodel; - }; -/* End XCVersionGroup section */ - }; - rootObject = 6EC90CB51C1A68530068944A /* Project object */; -} diff --git a/Xcode/CoreModel/CoreModel.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Xcode/CoreModel/CoreModel.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d9810..0000000 --- a/Xcode/CoreModel/CoreModel.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/Xcode/CoreModel/CoreModel.xcodeproj/xcshareddata/xcschemes/CoreModel OS X.xcscheme b/Xcode/CoreModel/CoreModel.xcodeproj/xcshareddata/xcschemes/CoreModel OS X.xcscheme deleted file mode 100644 index ac4ba18..0000000 --- a/Xcode/CoreModel/CoreModel.xcodeproj/xcshareddata/xcschemes/CoreModel OS X.xcscheme +++ /dev/null @@ -1,99 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Xcode/CoreModel/CoreModel.xcodeproj/xcuserdata/coleman.xcuserdatad/xcschemes/xcschememanagement.plist b/Xcode/CoreModel/CoreModel.xcodeproj/xcuserdata/coleman.xcuserdatad/xcschemes/xcschememanagement.plist deleted file mode 100644 index 0e00c61..0000000 --- a/Xcode/CoreModel/CoreModel.xcodeproj/xcuserdata/coleman.xcuserdatad/xcschemes/xcschememanagement.plist +++ /dev/null @@ -1,22 +0,0 @@ - - - - - SchemeUserState - - CoreModel OS X.xcscheme_^#shared#^_ - - orderHint - 0 - - - SuppressBuildableAutocreation - - 6EC90CBD1C1A68530068944A - - primary - - - - - diff --git a/Xcode/CoreModel/CoreModel/CoreModel.h b/Xcode/CoreModel/CoreModel/CoreModel.h deleted file mode 100644 index 1840a44..0000000 --- a/Xcode/CoreModel/CoreModel/CoreModel.h +++ /dev/null @@ -1,19 +0,0 @@ -// -// CoreModel.h -// CoreModel -// -// Created by Alsey Coleman Miller on 12/10/15. -// Copyright © 2015 PureSwift. All rights reserved. -// - -#import - -//! Project version number for CoreModel. -FOUNDATION_EXPORT double CoreModelVersionNumber; - -//! Project version string for CoreModel. -FOUNDATION_EXPORT const unsigned char CoreModelVersionString[]; - -// In this header, you should import all the public headers of your framework using statements like #import - - diff --git a/Xcode/CoreModel/CoreModel/Info.plist b/Xcode/CoreModel/CoreModel/Info.plist deleted file mode 100644 index 6b2d9e4..0000000 --- a/Xcode/CoreModel/CoreModel/Info.plist +++ /dev/null @@ -1,28 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - FMWK - CFBundleShortVersionString - 1.0.0 - CFBundleSignature - ???? - CFBundleVersion - $(CURRENT_PROJECT_VERSION) - NSHumanReadableCopyright - Copyright © 2015 PureSwift. All rights reserved. - NSPrincipalClass - - - diff --git a/Xcode/CoreModel/CoreModelTests/CoreDataModel.xcdatamodeld/CoreDataModel.xcdatamodel/contents b/Xcode/CoreModel/CoreModelTests/CoreDataModel.xcdatamodeld/CoreDataModel.xcdatamodel/contents deleted file mode 100644 index 7ba75a5..0000000 --- a/Xcode/CoreModel/CoreModelTests/CoreDataModel.xcdatamodeld/CoreDataModel.xcdatamodel/contents +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/Xcode/CoreModel/CoreModelTests/CoreModelTests.swift b/Xcode/CoreModel/CoreModelTests/CoreModelTests.swift deleted file mode 100644 index dc0851e..0000000 --- a/Xcode/CoreModel/CoreModelTests/CoreModelTests.swift +++ /dev/null @@ -1,309 +0,0 @@ -// -// CoreModelTests.swift -// CoreModelTests -// -// Created by Alsey Coleman Miller on 6/24/15. -// Copyright © 2015 PureSwift. All rights reserved. -// - -import XCTest -import CoreModel -import CoreData -import SwiftFoundation - -class CoreModelTests: XCTestCase { - static var managedObjectModel: NSManagedObjectModel! - static var managedObjectContext: NSManagedObjectContext! - static var temporaryFolder: NSURL! - - static var store: StoreType! - static var model: Model! - - static let testEntityName = "TestEntity" - static let testIdentifiers = ["red", "green", "blue", "purple", "grey"] - - var resourceRed: Resource! - var resourceBlue: Resource! - var entity: Entity! - - override class func setUp() { - super.setUp() - - let bundle = NSBundle(forClass: self) - guard let modelURL = bundle.URLForResource("CoreDataModel", withExtension: "momd"), - mom = NSManagedObjectModel(contentsOfURL: modelURL) else { - return - } - - managedObjectModel = mom - - let man = NSFileManager.defaultManager() - let persistentStoreCoordinator = NSPersistentStoreCoordinator(managedObjectModel: managedObjectModel) - - do { - temporaryFolder = try man.URLForDirectory(.ItemReplacementDirectory, inDomain: .UserDomainMask, appropriateForURL: bundle.resourceURL, create: true) - try persistentStoreCoordinator.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: temporaryFolder.URLByAppendingPathComponent("CoreDataModelTest.store"), options: nil) - } catch { - fatalError("Couldn't create a temporary folder or a persistent store") - } - - managedObjectContext = NSManagedObjectContext(concurrencyType: .MainQueueConcurrencyType) - managedObjectContext.persistentStoreCoordinator = persistentStoreCoordinator - - guard let m = CoreModelTests.managedObjectModel.toModel(), - let st = CoreDataStore(model: m, managedObjectContext: CoreModelTests.managedObjectContext) else { - XCTFail("Expected to be able to convert the NSManagedObjectModel to a CoreModel.Model and to build a CoreDataStore") - return - } - - model = m - store = st - - // Test data - - let colours = [NSColor.redColor(), NSColor.greenColor(), NSColor.blueColor(), NSColor.purpleColor(), NSColor.grayColor()] - - let zipt = zip(testIdentifiers, colours) - - var integer = 47 - var yn = false - - zipt.forEach { key, colour in - let nte = Resource(testEntityName, key) - let vals: ValuesObject = [ - "myInteger": .Attribute(.Number(.Integer(integer))), - "myBool": .Attribute(.Number(.Boolean(yn))), - "myColour": .Attribute(.Transformable(colour)) - ] - - do { - try store.create(nte, initialValues: vals) - } catch { - XCTFail("Unable to create test entity \(key) with values \(vals)") - } - - integer += 1 - yn = !yn - } - - InstantiatorRegistry.register(typeName: "NSColor", instantiator: NSColor.fromData) - } - - override class func tearDown() { - guard let psc = managedObjectContext.persistentStoreCoordinator else { - fatalError("No persistent store coordinator") - } - - let man = NSFileManager.defaultManager() - - do { - try psc.persistentStores.forEach { store in - try psc.removePersistentStore(store) - } - - try man.removeItemAtURL(temporaryFolder) - } catch { - fatalError("Failed to cleanup the persistent store and temporary folder \(temporaryFolder): \(error)") - } - - super.tearDown() - } - - override func setUp() { - super.setUp() - - guard let firstID = CoreModelTests.testIdentifiers.first else { - XCTFail("testIdentifiers should not have been empty") - return - } - - entity = CoreModelTests.model[CoreModelTests.testEntityName] - - var fetcher = FetchRequest(entityName: CoreModelTests.testEntityName) - let comparison = ComparisonPredicate(propertyName: "id", value: .Attribute(.String(firstID))) - fetcher.predicate = Predicate.Comparison(comparison) - - let bluePredicate = ComparisonPredicate(propertyName: "id", value: .Attribute(.String("blue"))) - - do { - let results = try CoreModelTests.store.fetch(fetcher) - - resourceRed = results.first - - fetcher.predicate = Predicate.Comparison(bluePredicate) - - let moreResults = try CoreModelTests.store.fetch(fetcher) - - resourceBlue = moreResults.first - - } catch { - XCTFail("Error when fetching resources: \(error)") - } - - } - - override func tearDown() { - // Put teardown code here. This method is called after the invocation of each test method in the class. - super.tearDown() - } - - func testToJSON() { - XCTAssertNotNil(resourceBlue) - - var values: ValuesObject? = nil - - do { - values = try CoreModelTests.store.values(resourceBlue) - } catch { - XCTFail("Failed to retrieve the values for resource \(resourceBlue) with error: \(error)") - return - } - - guard let unwrappedValues = values else { - XCTFail("No values retrieved for resource \(resourceBlue)") - return - } - - let json = JSON.Value.Object(JSON.fromValues(unwrappedValues)) - - let jsonString: String! - - do { - jsonString = try json.toString() - } catch { - XCTFail("Couldn't print \(json) because of error: \(error)") - return - } - - let expectedJSON = "{\"myBool\":false,\"myColour\":\"NSColor&IzAwMDBmZg==\",\"myInteger\":49}" - - XCTAssertEqual(jsonString, expectedJSON, "JSON output should have been \(expectedJSON); got \(jsonString)") - } - - func testFromJSON() { - let jsonValuesString = "{\"myBool\":true,\"myColour\":\"NSColor&I0ZGMDAwMA==\",\"myInteger\":26}" - - var values: ValuesObject! - - do { - let json = try JSON.Value(string: jsonValuesString) - - if let jobj = json.objectValue { - values = entity.convert(jobj) - - XCTAssertNotNil(values, "This JSON values string parsed as empty, yet didn't throw an error: \(jsonValuesString)") - } - } catch { - XCTFail("Failed to parse JSON string: \"\(jsonValuesString)\"; Error: \(error)") - } - - do { - try CoreModelTests.store.edit(resourceRed, changes: values) - } catch { - XCTFail("Failed to edit \(resourceRed) with changes: \(values). Error: \(error)") - } - - do { - let changedValues = try CoreModelTests.store.values(resourceRed) - - if let v = values { - - for (attrName, _) in entity.attributes { - - guard let vattr = v[attrName], - let chattr = changedValues[attrName] else { - continue - } - - XCTAssert(vattr == chattr, "Parsed \(attrName) doesn't match stored version: \(vattr) vs. \(chattr)") - } - } - } catch { - XCTFail("Couldn't retrieve values") - } - } - - func testModelConversion() { - guard let _ = CoreModelTests.managedObjectModel.toModel() else { - XCTFail("Expected to be able to convert the NSManagedObjectModel to a CoreModel.Model") - return - } - - XCTAssert(true, "Successfully converted the NSManagedObjectModel to a CoreModel.Model") - } - - func testStoreConversion() { - guard let model = CoreModelTests.managedObjectModel.toModel(), - let _ = CoreDataStore(model: model, managedObjectContext: CoreModelTests.managedObjectContext) else { - XCTFail("Expected to be able to convert the NSManagedObjectModel to a CoreModel.Model and to build a CoreDataStore") - return - } - - XCTAssert(true, "Built a CoreDataStore") - } - - - func testValidInsertAndCheck() { - guard let _ = CoreModelTests.model[CoreModelTests.testEntityName] else { - XCTFail("Unable to find an entity named \(CoreModelTests.testEntityName) in the model \(CoreModelTests.model)") - return - } - - let identifier = "88" - - let newTestEntity = Resource(CoreModelTests.testEntityName, identifier) - let valuesObject: ValuesObject = [ - "myInteger": .Attribute(.Number(.Integer(Int(arc4random())))), - "myBool": .Attribute(.Number(.Boolean(true))), - "myColour": .Attribute(.Transformable(NSColor.blueColor())) - ] - - do { - try CoreModelTests.store.create(newTestEntity, initialValues: valuesObject) - } catch { - XCTFail("Failed to create a new test entity in the store. Error: \(error)") - return - } - - XCTAssert(true, "Created a new test entity in the store.") - - let entity = Resource(CoreModelTests.testEntityName, identifier) - - do { - let yupNope = try CoreModelTests.store.exists(entity) - - XCTAssert(yupNope, "The entity with identifier \(identifier) should exist in the store") - } catch { - XCTFail("Resource \(identifier) added successfully above yet doesn't exist in the store any longer.") - } - } - - func testBadAttribute() { - guard let _ = CoreModelTests.model[CoreModelTests.testEntityName] else { - XCTFail("Unable to find an entity named \(CoreModelTests.testEntityName) in the model \(CoreModelTests.model)") - return - } - - let impossibleResource = Resource(CoreModelTests.testEntityName, "impossibleResource") - let valuesObject: ValuesObject = ["missingAttribute": .Attribute(.Number(.Double(98.76543)))] - - do { - try CoreModelTests.store.create(impossibleResource, initialValues: valuesObject) - } catch StoreError.InvalidValues { - XCTAssert(true, "Caught that missingAttribute isn't a valid Attribute name") - } catch { - XCTFail("Shouldn't have gotten an error like \(error) here") - return - } - - do { - // Confirm that there was no impossible resource created - - let shouldBeFalse = try CoreModelTests.store.exists(impossibleResource) - - XCTAssertFalse(shouldBeFalse, "Shouldn't have created this TestEntity after the StoreError.InvalidValues error, right?") - } catch { - // Should there be an error, or just the expected ```false``` above? - } - } -} diff --git a/Xcode/CoreModel/CoreModelTests/Info.plist b/Xcode/CoreModel/CoreModelTests/Info.plist deleted file mode 100644 index ba72822..0000000 --- a/Xcode/CoreModel/CoreModelTests/Info.plist +++ /dev/null @@ -1,24 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1 - - diff --git a/Xcode/CoreModel/CoreModelTests/TestCocoaExtensions.swift b/Xcode/CoreModel/CoreModelTests/TestCocoaExtensions.swift deleted file mode 100644 index 60555be..0000000 --- a/Xcode/CoreModel/CoreModelTests/TestCocoaExtensions.swift +++ /dev/null @@ -1,140 +0,0 @@ - -import Cocoa -import CoreModel -import SwiftFoundation - -public class ColourToDataTransformer: NSValueTransformer { - - override public class func transformedValueClass() -> AnyClass { - return NSColor.self - } - - override public class func allowsReverseTransformation() -> Bool { - return true - } - - override public func transformedValue(value: AnyObject?) -> AnyObject? { - - guard let c = value as? NSColor else { - return nil - } - - let hexstring = c.hexValue as NSString - return hexstring.dataUsingEncoding(NSUTF8StringEncoding) - } - - override public func reverseTransformedValue(value: AnyObject?) -> AnyObject? { - - guard let d = value as? NSData else { - return nil - } - - guard let hexstring = NSString(data: d, encoding: NSUTF8StringEncoding), - let colour = NSColor(hexString: hexstring as String) else { - return nil - } - - return colour - } -} - -let transformer = ColourToDataTransformer() - -extension NSColor { - - public var hexValue: String { - - guard let convertedColor = colorUsingColorSpaceName(NSCalibratedRGBColorSpace) else { - fatalError("Unable to convert to RGB Color Space") - } - - var redFloat: CGFloat = 0.0 - var greenFloat: CGFloat = 0.0 - var blueFloat: CGFloat = 0.0 - var alphaFloat: CGFloat = 0.0 - - convertedColor.getRed(&redFloat, green: &greenFloat, blue: &blueFloat, alpha: &alphaFloat) - - let redInt = Int(redFloat * 255.0) - let greenInt = Int(greenFloat * 255.0) - let blueInt = Int(blueFloat * 255.0) - - let redHex = NSString(format: "%02x", redInt) - let greenHex = NSString(format: "%02x", greenInt) - let blueHex = NSString(format: "%02x", blueInt) - - return "#\(redHex)\(greenHex)\(blueHex)" - } - - public convenience init?(hexString: String) { - - let pattern = "#{0,1}([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})" - let reggy: RegularExpression - - do { - reggy = try RegularExpression(pattern, options: [.ExtendedSyntax, .CaseInsensitive]) - } catch { - assertionFailure("Couldn't make a regular expression from: \(pattern)") - return nil - } - - guard let match = reggy.match(hexString) where match.subexpressionRanges.count == 3, - let redString = hexString.substring(match.subexpressionRanges[0]), - let greenString = hexString.substring(match.subexpressionRanges[1]), - let blueString = hexString.substring(match.subexpressionRanges[2]) else { - assertionFailure("The hexString \(hexString) didn't match the regular expression \(reggy.pattern)") - return nil - } - - guard let red = Int(redString, radix: 16), - let green = Int(greenString, radix: 16), - let blue = Int(blueString, radix: 16) else { - assertionFailure("Unable to parse the hexadecimal Int values for \(redString), \(greenString), or \(blueString)") - return nil - } - - let redFloat = CGFloat(red) / 255.0 - let greenFloat = CGFloat(green) / 255.0 - let blueFloat = CGFloat(blue) / 255.0 - - self.init(calibratedRed: redFloat, green: greenFloat, blue: blueFloat, alpha: 1.0) - } - -} - -extension NSColor: DataConvertible { - public func toData() -> Data { - - guard let nsd = transformer.transformedValue(self) as? NSData else { - fatalError("\(transformer) failed to convert \(self) to NSData") - } - - return nsd.toData() - } - - public static func fromData(data: Data) -> DataConvertible { - - let nsd = NSData(bytes: data) - - guard let nsc = transformer.reverseTransformedValue(nsd) as? NSColor else { - fatalError("\(transformer) failed to convert \(data) back to NSColor") - } - - return nsc - } - - public func toJSON() -> JSON.Value { - let d = toData() - - let encoded = Base64.encode(d) - - var b64 = "" - - encoded.forEach({ b64.append(UnicodeScalar($0)) }) - - let jsonned = "NSColor&\(b64)" - - return JSON.Value.String(jsonned) - } -} - diff --git a/Xcode/CoreModel/CoreModelTests/TestEntity+CoreDataProperties.swift b/Xcode/CoreModel/CoreModelTests/TestEntity+CoreDataProperties.swift deleted file mode 100644 index fbaf038..0000000 --- a/Xcode/CoreModel/CoreModelTests/TestEntity+CoreDataProperties.swift +++ /dev/null @@ -1,11 +0,0 @@ - -import Cocoa -import CoreData - -extension TestEntity { - - @NSManaged var myInteger: NSNumber? - @NSManaged var myBool: NSNumber? - @NSManaged var myColour: NSColor? - -} diff --git a/Xcode/CoreModel/CoreModelTests/TestEntity.swift b/Xcode/CoreModel/CoreModelTests/TestEntity.swift deleted file mode 100644 index 49b071b..0000000 --- a/Xcode/CoreModel/CoreModelTests/TestEntity.swift +++ /dev/null @@ -1,8 +0,0 @@ - -import Foundation -import CoreData - -@objc(TestEntity) -class TestEntity: NSManagedObject { - -}