Skip to content

Commit

Permalink
Merge pull request #1 from JimRoepcke/feature/swift3
Browse files Browse the repository at this point in the history
Swift 3 support, fix flatMap issue, fork pod
  • Loading branch information
JimRoepcke authored Jan 2, 2017
2 parents 5014045 + 9a0a549 commit 3162cf3
Show file tree
Hide file tree
Showing 45 changed files with 1,496 additions and 1,458 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 3.0.0
1. Separated Metadata from Objects (removed `metadata` from `Persistable`)
2. Updated for Swift 3.0
3. Pod name changed to RCSYapDatabaseExtensions
4. Use `map` instead of `flatMap` when reading multiple objects so the order of the output corresponds to the order of the input.

# 2.6.0
Updated for Swift 2.3 - sorry it's taken so long!

Expand Down
5 changes: 2 additions & 3 deletions Cartfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
github "danthorpe/ValueCoding" "1.5.0"
github "CocoaLumberjack/CocoaLumberjack" "2.4.0"
github "yapstudios/YapDatabase" "2.9.2"
github "danthorpe/ValueCoding" "2.1.0"
github "yapstudios/YapDatabase" "2.9.3"
7 changes: 3 additions & 4 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
github "CocoaLumberjack/CocoaLumberjack" "2.4.0"
github "tonymillion/Reachability" "c4d225a479379f9998dbd5b55070427373d20574"
github "danthorpe/ValueCoding" "1.5.0"
github "yapstudios/YapDatabase" "2.9.2"
github "CocoaLumberjack/CocoaLumberjack" "3.0.0"
github "danthorpe/ValueCoding" "2.1.0"
github "yapstudios/YapDatabase" "2.9.3"
7 changes: 4 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ GEM
netrc (= 0.7.8)
cocoapods-try (1.1.0)
colored (1.2)
commander (4.4.1)
commander (4.4.3)
highline (~> 1.7.2)
credentials_manager (0.16.2)
credentials_manager (0.16.4)
colored
commander (>= 4.3.5)
highline (>= 1.7.1)
Expand Down Expand Up @@ -299,9 +299,10 @@ PLATFORMS
DEPENDENCIES
cocoapods
cocoapods-keys
credentials_manager (= 0.16.4)
fastlane
slather
xcpretty

BUNDLED WITH
1.13.6
1.13.7
30 changes: 15 additions & 15 deletions YapDatabaseExtensions.podspec → RCSYapDatabaseExtensions.podspec
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
Pod::Spec.new do |s|
s.name = "YapDatabaseExtensions"
s.version = "2.6.0"
s.name = "RCSYapDatabaseExtensions"
s.version = "3.0.0"
s.summary = "Helpers for using value types with YapDatabase."
s.description = <<-DESC
Defines APIs to conveniently read, write and remove objects and values
to or from YapDatabse. See ValueCoding for value type support.
Fork of danthorpe's YapDatabaseExtensions with Swift 3 support and
metadata separated from objects.
DESC
s.homepage = "https://github.com/danthorpe/YapDatabaseExtensions"
s.homepage = "https://github.com/JimRoepcke/YapDatabaseExtensions"
s.license = 'MIT'
s.author = { "Daniel Thorpe" => "@danthorpe" }
s.source = { :git => "https://github.com/danthorpe/YapDatabaseExtensions.git", :tag => s.version.to_s }
s.module_name = 'YapDatabaseExtensions'
s.social_media_url = 'https://twitter.com/danthorpe'
s.authors = { "Daniel Thorpe" => "@danthorpe", "Jim Roepcke" => "@JimRoepcke" }
s.source = { :git => "https://github.com/JimRoepcke/YapDatabaseExtensions.git", :tag => s.version.to_s }
s.module_name = 'RCSYapDatabaseExtensions'
s.social_media_url = 'https://twitter.com/JimRoepcke'
s.requires_arc = true
s.default_subspec = 'Persitable'
s.ios.deployment_target = '8.0'
s.osx.deployment_target = '10.10'
s.ios.deployment_target = '9.0'
s.osx.deployment_target = '10.11'

s.dependency 'ValueCoding', '~> 1.5'
s.dependency 'ValueCoding', '~> 2.1.0'
s.dependency 'YapDatabase', '2.9.2'

# Ensure the correct version of Swift is used
s.pod_target_xcconfig = { 'SWIFT_VERSION' => '2.3' }

s.subspec 'Core' do |ss|
ss.source_files = [
'Sources/YapDatabaseExtensions.swift',
Expand All @@ -33,12 +33,12 @@ Pod::Spec.new do |s|
end

s.subspec 'Functional' do |ss|
ss.dependency 'YapDatabaseExtensions/Core'
ss.dependency 'RCSYapDatabaseExtensions/Core'
ss.source_files = 'Sources/Functional_*.swift'
end

s.subspec 'Persitable' do |ss|
ss.dependency 'YapDatabaseExtensions/Functional'
ss.dependency 'RCSYapDatabaseExtensions/Functional'
ss.source_files = [
'Sources/Read.swift',
'Sources/Persistable_*.swift'
Expand Down
26 changes: 13 additions & 13 deletions Sources/Curried_ObjectWithNoMetadata.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ extension Persistable where
- returns: a (ReadTransaction) -> Self? closure.
*/
public static func readAtIndex<
ReadTransaction where
ReadTransaction: ReadTransactionType>(index: YapDB.Index) -> ReadTransaction -> Self? {
ReadTransaction>(_ index: YapDB.Index) -> (ReadTransaction) -> Self? where
ReadTransaction: ReadTransactionType {
return { $0.readAtIndex(index) }
}

Expand All @@ -35,10 +35,10 @@ extension Persistable where
- returns: a (ReadTransaction) -> [Self] closure.
*/
public static func readAtIndexes<
Indexes, ReadTransaction where
Indexes: SequenceType,
Indexes.Generator.Element == YapDB.Index,
ReadTransaction: ReadTransactionType>(indexes: Indexes) -> ReadTransaction -> [Self] {
Indexes, ReadTransaction>(_ indexes: Indexes) -> (ReadTransaction) -> [Self?] where
Indexes: Sequence,
Indexes.Iterator.Element == YapDB.Index,
ReadTransaction: ReadTransactionType {
return { $0.readAtIndexes(indexes) }
}

Expand All @@ -50,8 +50,8 @@ extension Persistable where
- returns: a (ReadTransaction) -> Self? closure.
*/
public static func readByKey<
ReadTransaction where
ReadTransaction: ReadTransactionType>(key: String) -> ReadTransaction -> Self? {
ReadTransaction>(_ key: String) -> (ReadTransaction) -> Self? where
ReadTransaction: ReadTransactionType {
return { $0.readByKey(key) }
}

Expand All @@ -63,10 +63,10 @@ extension Persistable where
- returns: a (ReadTransaction) -> [Self] closure.
*/
public static func readByKeys<
Keys, ReadTransaction where
Keys: SequenceType,
Keys.Generator.Element == String,
ReadTransaction: ReadTransactionType>(keys: Keys) -> ReadTransaction -> [Self] {
Keys, ReadTransaction>(_ keys: Keys) -> (ReadTransaction) -> [Self?] where
Keys: Sequence,
Keys.Iterator.Element == String,
ReadTransaction: ReadTransactionType {
return { $0.readAtIndexes(Self.indexesWithKeys(keys)) }
}

Expand All @@ -77,7 +77,7 @@ extension Persistable where
- warning: Be aware that this will capure `self`.
- returns: a (WriteTransaction) -> Self closure
*/
public func write<WriteTransaction: WriteTransactionType>() -> WriteTransaction -> Self {
public func write<WriteTransaction: WriteTransactionType>() -> (WriteTransaction) -> Self {
return { $0.write(self) }
}
}
28 changes: 14 additions & 14 deletions Sources/Curried_ObjectWithObjectMetadata.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ extension Persistable where
- returns: a (ReadTransaction) -> Self? closure.
*/
public static func readWithMetadataAtIndex<
ReadTransaction, Metadata where
ReadTransaction, Metadata>(_ index: YapDB.Index) -> (ReadTransaction) -> YapItem<Self, Metadata>? where
ReadTransaction: ReadTransactionType,
Metadata: NSCoding>(index: YapDB.Index) -> ReadTransaction -> YapItem<Self, Metadata>? {
Metadata: NSCoding {
return { $0.readWithMetadataAtIndex(index) }
}

Expand All @@ -36,11 +36,11 @@ extension Persistable where
- returns: a (ReadTransaction) -> [Self] closure.
*/
public static func readWithMetadataAtIndexes<
Indexes, ReadTransaction, Metadata where
Indexes: SequenceType,
Indexes.Generator.Element == YapDB.Index,
Indexes, ReadTransaction, Metadata>(_ indexes: Indexes) -> (ReadTransaction) -> [YapItem<Self, Metadata>?] where
Indexes: Sequence,
Indexes.Iterator.Element == YapDB.Index,
ReadTransaction: ReadTransactionType,
Metadata: NSCoding>(indexes: Indexes) -> ReadTransaction -> [YapItem<Self, Metadata>] {
Metadata: NSCoding {
return { $0.readWithMetadataAtIndexes(indexes) }
}

Expand All @@ -52,9 +52,9 @@ extension Persistable where
- returns: a (ReadTransaction) -> Self? closure.
*/
public static func readWithMetadataByKey<
ReadTransaction, Metadata where
ReadTransaction, Metadata>(_ key: String) -> (ReadTransaction) -> YapItem<Self, Metadata>? where
ReadTransaction: ReadTransactionType,
Metadata: NSCoding>(key: String) -> ReadTransaction -> YapItem<Self, Metadata>? {
Metadata: NSCoding {
return { $0.readWithMetadataByKey(key) }
}

Expand All @@ -66,11 +66,11 @@ extension Persistable where
- returns: a (ReadTransaction) -> [Self] closure.
*/
public static func readWithMetadataByKeys<
Keys, ReadTransaction, Metadata where
Keys: SequenceType,
Keys.Generator.Element == String,
Keys, ReadTransaction, Metadata>(_ keys: Keys) -> (ReadTransaction) -> [YapItem<Self, Metadata>?] where
Keys: Sequence,
Keys.Iterator.Element == String,
ReadTransaction: ReadTransactionType,
Metadata: NSCoding>(keys: Keys) -> ReadTransaction -> [YapItem<Self, Metadata>] {
Metadata: NSCoding {
return { $0.readWithMetadataAtIndexes(Self.indexesWithKeys(keys)) }
}

Expand All @@ -82,9 +82,9 @@ extension Persistable where
- returns: a (WriteTransaction) -> Self closure
*/
public func writeWithMetadata<
WriteTransaction, Metadata where
WriteTransaction, Metadata>(_ metadata: Metadata? = nil) -> (WriteTransaction) -> YapItem<Self, Metadata> where
WriteTransaction: WriteTransactionType,
Metadata: NSCoding>(metadata: Metadata? = nil) -> WriteTransaction -> YapItem<Self, Metadata> {
Metadata: NSCoding {
return { $0.writeWithMetadata(YapItem(self, metadata)) }
}
}
28 changes: 14 additions & 14 deletions Sources/Curried_ObjectWithValueMetadata.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ extension Persistable where
- returns: a (ReadTransaction) -> Self? closure.
*/
public static func readWithMetadataAtIndex<
ReadTransaction, Metadata where
ReadTransaction, Metadata>(_ index: YapDB.Index) -> (ReadTransaction) -> YapItem<Self, Metadata>? where
ReadTransaction: ReadTransactionType,
Metadata: ValueCoding,
Metadata.Coder: NSCoding,
Metadata.Coder.ValueType == Metadata>(index: YapDB.Index) -> ReadTransaction -> YapItem<Self, Metadata>? {
Metadata.Coder.Value == Metadata {
return { $0.readWithMetadataAtIndex(index) }
}

Expand All @@ -38,13 +38,13 @@ extension Persistable where
- returns: a (ReadTransaction) -> [Self] closure.
*/
public static func readWithMetadataAtIndexes<
Indexes, ReadTransaction, Metadata where
Indexes: SequenceType,
Indexes.Generator.Element == YapDB.Index,
Indexes, ReadTransaction, Metadata>(_ indexes: Indexes) -> (ReadTransaction) -> [YapItem<Self, Metadata>?] where
Indexes: Sequence,
Indexes.Iterator.Element == YapDB.Index,
ReadTransaction: ReadTransactionType,
Metadata: ValueCoding,
Metadata.Coder: NSCoding,
Metadata.Coder.ValueType == Metadata>(indexes: Indexes) -> ReadTransaction -> [YapItem<Self, Metadata>] {
Metadata.Coder.Value == Metadata {
return { $0.readWithMetadataAtIndexes(indexes) }
}

Expand All @@ -56,11 +56,11 @@ extension Persistable where
- returns: a (ReadTransaction) -> Self? closure.
*/
public static func readWithMetadataByKey<
ReadTransaction, Metadata where
ReadTransaction, Metadata>(_ key: String) -> (ReadTransaction) -> YapItem<Self, Metadata>? where
ReadTransaction: ReadTransactionType,
Metadata: ValueCoding,
Metadata.Coder: NSCoding,
Metadata.Coder.ValueType == Metadata>(key: String) -> ReadTransaction -> YapItem<Self, Metadata>? {
Metadata.Coder.Value == Metadata {
return { $0.readWithMetadataByKey(key) }
}

Expand All @@ -72,13 +72,13 @@ extension Persistable where
- returns: a (ReadTransaction) -> [Self] closure.
*/
public static func readWithMetadataByKeys<
Keys, ReadTransaction, Metadata where
Keys: SequenceType,
Keys.Generator.Element == String,
Keys, ReadTransaction, Metadata>(_ keys: Keys) -> (ReadTransaction) -> [YapItem<Self, Metadata>?] where
Keys: Sequence,
Keys.Iterator.Element == String,
ReadTransaction: ReadTransactionType,
Metadata: ValueCoding,
Metadata.Coder: NSCoding,
Metadata.Coder.ValueType == Metadata>(keys: Keys) -> ReadTransaction -> [YapItem<Self, Metadata>] {
Metadata.Coder.Value == Metadata {
return { $0.readWithMetadataAtIndexes(Self.indexesWithKeys(keys)) }
}

Expand All @@ -90,11 +90,11 @@ extension Persistable where
- returns: a (WriteTransaction) -> Self closure
*/
public func writeWithMetadata<
WriteTransaction, Metadata where
WriteTransaction, Metadata>(_ metadata: Metadata? = nil) -> (WriteTransaction) -> YapItem<Self, Metadata> where
WriteTransaction: WriteTransactionType,
Metadata: ValueCoding,
Metadata.Coder: NSCoding,
Metadata.Coder.ValueType == Metadata>(metadata: Metadata? = nil) -> WriteTransaction -> YapItem<Self, Metadata> {
Metadata.Coder.Value == Metadata {
return { $0.writeWithMetadata(YapItem(self, metadata)) }
}
}
28 changes: 14 additions & 14 deletions Sources/Curried_ValueWithNoMetadata.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import ValueCoding
extension Persistable where
Self: ValueCoding,
Self.Coder: NSCoding,
Self.Coder.ValueType == Self {
Self.Coder.Value == Self {

/**
Returns a closure which, given a read transaction will return
Expand All @@ -24,8 +24,8 @@ extension Persistable where
- returns: a (ReadTransaction) -> Self? closure.
*/
public static func readAtIndex<
ReadTransaction where
ReadTransaction: ReadTransactionType>(index: YapDB.Index) -> ReadTransaction -> Self? {
ReadTransaction>(_ index: YapDB.Index) -> (ReadTransaction) -> Self? where
ReadTransaction: ReadTransactionType {
return { $0.readAtIndex(index) }
}

Expand All @@ -37,10 +37,10 @@ extension Persistable where
- returns: a (ReadTransaction) -> [Self] closure.
*/
public static func readAtIndexes<
Indexes, ReadTransaction where
Indexes: SequenceType,
Indexes.Generator.Element == YapDB.Index,
ReadTransaction: ReadTransactionType>(indexes: Indexes) -> ReadTransaction -> [Self] {
Indexes, ReadTransaction>(_ indexes: Indexes) -> (ReadTransaction) -> [Self?] where
Indexes: Sequence,
Indexes.Iterator.Element == YapDB.Index,
ReadTransaction: ReadTransactionType {
return { $0.readAtIndexes(indexes) }
}

Expand All @@ -52,8 +52,8 @@ extension Persistable where
- returns: a (ReadTransaction) -> Self? closure.
*/
public static func readByKey<
ReadTransaction where
ReadTransaction: ReadTransactionType>(key: String) -> ReadTransaction -> Self? {
ReadTransaction>(_ key: String) -> (ReadTransaction) -> Self? where
ReadTransaction: ReadTransactionType {
return { $0.readByKey(key) }
}

Expand All @@ -65,10 +65,10 @@ extension Persistable where
- returns: a (ReadTransaction) -> [Self] closure.
*/
public static func readByKeys<
Keys, ReadTransaction where
Keys: SequenceType,
Keys.Generator.Element == String,
ReadTransaction: ReadTransactionType>(keys: Keys) -> ReadTransaction -> [Self] {
Keys, ReadTransaction>(_ keys: Keys) -> (ReadTransaction) -> [Self?] where
Keys: Sequence,
Keys.Iterator.Element == String,
ReadTransaction: ReadTransactionType {
return { $0.readAtIndexes(Self.indexesWithKeys(keys)) }
}

Expand All @@ -79,7 +79,7 @@ extension Persistable where
- warning: Be aware that this will capure `self`.
- returns: a (WriteTransaction) -> Self closure
*/
public func write<WriteTransaction: WriteTransactionType>() -> WriteTransaction -> Self {
public func write<WriteTransaction: WriteTransactionType>() -> (WriteTransaction) -> Self {
return { $0.write(self) }
}
}
Loading

0 comments on commit 3162cf3

Please sign in to comment.