From e09ac9ee00d7d35d17c938ccbbc210e62a43011e Mon Sep 17 00:00:00 2001 From: John Estropia Date: Tue, 12 Feb 2019 18:05:06 +0900 Subject: [PATCH] add macOS playground --- .gitignore | 1 + CoreStore.podspec | 2 +- CoreStore.xcodeproj/project.pbxproj | 6 +- CoreStoreTests/Info.plist | 2 +- Playground_iOS.playground/Contents.swift | 8 +-- Playground_macOS.playground/Contents.swift | 55 +++++++++++++++++++ .../contents.xcplayground | 4 ++ .../contents.xcworkspacedata | 7 +++ .../xcshareddata/IDEWorkspaceChecks.plist | 8 +++ README.md | 6 +- Sources/Info.plist | 2 +- 11 files changed, 89 insertions(+), 12 deletions(-) create mode 100644 Playground_macOS.playground/Contents.swift create mode 100644 Playground_macOS.playground/contents.xcplayground create mode 100644 Playground_macOS.playground/playground.xcworkspace/contents.xcworkspacedata create mode 100644 Playground_macOS.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/.gitignore b/.gitignore index 7581d82..edbb461 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ CoreStore.xcworkspace/xcuserdata DerivedData *.orig build +Playground_macOS.playground/playground.xcworkspace/xcuserdata diff --git a/CoreStore.podspec b/CoreStore.podspec index 13e3077..f284fdd 100644 --- a/CoreStore.podspec +++ b/CoreStore.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "CoreStore" - s.version = "6.0.0" + s.version = "6.1.0" s.swift_version = "4.2" s.license = "MIT" s.homepage = "https://github.com/JohnEstropia/CoreStore" diff --git a/CoreStore.xcodeproj/project.pbxproj b/CoreStore.xcodeproj/project.pbxproj index 64def8c..8a2b3a5 100644 --- a/CoreStore.xcodeproj/project.pbxproj +++ b/CoreStore.xcodeproj/project.pbxproj @@ -880,6 +880,8 @@ B5A1DAC71F111BFA003CF369 /* KeyPath+Querying.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "KeyPath+Querying.swift"; sourceTree = ""; }; B5A261201B64BFDB006EB6D3 /* MigrationType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MigrationType.swift; sourceTree = ""; }; B5A5F2651CAEC50F004AB9AF /* CSSelect.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CSSelect.swift; sourceTree = ""; }; + B5A80DF42212C1AB006096AA /* Playground_macOS.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = Playground_macOS.playground; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; + B5A80DF52212C1BC006096AA /* Playground_iOS.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = Playground_iOS.playground; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; B5A991EB1E9DC2CE0091A2E3 /* VersionLock.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VersionLock.swift; sourceTree = ""; }; B5A9921E1EA898710091A2E3 /* UserInfo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserInfo.swift; sourceTree = ""; }; B5AD60CD1C90141E00F2B2E8 /* Package.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Package.swift; sourceTree = SOURCE_ROOT; }; @@ -961,7 +963,6 @@ B5E84F351AFF85470064E85B /* NSManagedObjectContext+Querying.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSManagedObjectContext+Querying.swift"; sourceTree = ""; }; B5E84F401AFF8CCD0064E85B /* TypeErasedClauses.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TypeErasedClauses.swift; sourceTree = ""; }; B5E8A71F21C1015300EF006A /* CoreStoreObject+Observing.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CoreStoreObject+Observing.swift"; sourceTree = ""; }; - B5E8A72621C3B85000EF006A /* Playground.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = Playground.playground; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; B5ECDBDE1CA6BB2B00C7F112 /* CSBaseDataTransaction+Querying.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "CSBaseDataTransaction+Querying.swift"; sourceTree = ""; }; B5ECDBE41CA6BEA300C7F112 /* CSClauseTypes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CSClauseTypes.swift; sourceTree = ""; }; B5ECDBEB1CA6BF2000C7F112 /* CSFrom.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CSFrom.swift; sourceTree = ""; }; @@ -1052,7 +1053,8 @@ 2F03A52619C5C6DA005002A5 = { isa = PBXGroup; children = ( - B5E8A72621C3B85000EF006A /* Playground.playground */, + B5A80DF52212C1BC006096AA /* Playground_iOS.playground */, + B5A80DF42212C1AB006096AA /* Playground_macOS.playground */, 2F291E3119C6D4D3007AF63F /* Frameworks */, 2F03A53219C5C6DA005002A5 /* Sources */, 2F03A53C19C5C6DA005002A5 /* CoreStoreTests */, diff --git a/CoreStoreTests/Info.plist b/CoreStoreTests/Info.plist index 35cbe3f..1554da6 100644 --- a/CoreStoreTests/Info.plist +++ b/CoreStoreTests/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 6.0.0 + 6.1.0 CFBundleSignature ???? CFBundleVersion diff --git a/Playground_iOS.playground/Contents.swift b/Playground_iOS.playground/Contents.swift index e2147f9..af63d92 100644 --- a/Playground_iOS.playground/Contents.swift +++ b/Playground_iOS.playground/Contents.swift @@ -42,12 +42,12 @@ dataStack.perform(synchronous: { transaction in /// Accessing Objects ===== let bird = dataStack.fetchOne(From().where(\.species == "Sparrow"))! -bird.species.value -bird.color.value +print(bird.species.value) +print(bird.color.value as Any) print(bird) let owner = bird.master.value! -owner.name.value -owner.pets.count +print(owner.name.value) +print(owner.pets.count as Any) print(owner) /// ======================= diff --git a/Playground_macOS.playground/Contents.swift b/Playground_macOS.playground/Contents.swift new file mode 100644 index 0000000..2caabe0 --- /dev/null +++ b/Playground_macOS.playground/Contents.swift @@ -0,0 +1,55 @@ +import AppKit +import CoreStore + +/// Model Declaration ===== +class Animal: CoreStoreObject { + let species = Value.Required("species", initial: "Swift") + let master = Relationship.ToOne("master") + let color = Transformable.Optional("color", initial: .orange) +} + +class Person: CoreStoreObject { + let name = Value.Optional("name") + let pets = Relationship.ToManyUnordered("pets", inverse: { $0.master }) +} +/// ======================= + +/// Stack setup =========== +let dataStack = DataStack( + CoreStoreSchema( + modelVersion: "V1", + entities: [ + Entity("Animal"), + Entity("Person") + ] + ) +) +try dataStack.addStorageAndWait(SQLiteStore(fileName: "data.sqlite")) +/// ======================= + +/// Transactions ========== +try dataStack.perform( + synchronous: { transaction in + + let animal = transaction.create(Into()) + animal.species .= "Sparrow" + animal.color .= .yellow + + let person = transaction.create(Into()) + person.name .= "John" + person.pets.value.insert(animal) +} +) +/// ======================= + +/// Accessing Objects ===== +let bird = try dataStack.fetchOne(From().where(\.species == "Sparrow"))! +print(bird.species.value) +print(bird.color.value as Any) +print(bird) + +let owner = bird.master.value! +print(owner.name.value as Any) +print(owner.pets.count) +print(owner) +/// ======================= diff --git a/Playground_macOS.playground/contents.xcplayground b/Playground_macOS.playground/contents.xcplayground new file mode 100644 index 0000000..a93d484 --- /dev/null +++ b/Playground_macOS.playground/contents.xcplayground @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Playground_macOS.playground/playground.xcworkspace/contents.xcworkspacedata b/Playground_macOS.playground/playground.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/Playground_macOS.playground/playground.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Playground_macOS.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Playground_macOS.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/Playground_macOS.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/README.md b/README.md index 0d44bef..bbe72cf 100644 --- a/README.md +++ b/README.md @@ -1872,7 +1872,7 @@ Once the version lock is set, any changes in the properties or to the model will ### Install with CocoaPods In your `Podfile`, add ``` -pod 'CoreStore', '~> 6.0' +pod 'CoreStore', '~> 6.1' ``` and run ``` @@ -1883,7 +1883,7 @@ This installs CoreStore as a framework. Declare `import CoreStore` in your swift ### Install with Carthage In your `Cartfile`, add ``` -github "JohnEstropia/CoreStore" >= 6.0.0 +github "JohnEstropia/CoreStore" >= 6.1.0 ``` and run ``` @@ -1894,7 +1894,7 @@ This installs CoreStore as a framework. Declare `import CoreStore` in your swift #### Install with Swift Package Manager: ```swift dependencies: [ - .package(url: "https://github.com/JohnEstropia/CoreStore.git", from: "6.0.0")) + .package(url: "https://github.com/JohnEstropia/CoreStore.git", from: "6.1.0")) ] ``` Declare `import CoreStore` in your swift file to use the library. diff --git a/Sources/Info.plist b/Sources/Info.plist index a3d5bd3..94bd648 100644 --- a/Sources/Info.plist +++ b/Sources/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 6.0.0 + 6.1.0 CFBundleSignature ???? CFBundleVersion