-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ivan Rep
committed
Aug 24, 2016
1 parent
d36eff4
commit eaa7f47
Showing
32 changed files
with
1,029 additions
and
1,060 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,34 @@ | ||
PODS: | ||
- Alamofire (3.4.1) | ||
- KeychainAccess (2.3.6) | ||
- Moya (7.0.0): | ||
- Moya/Core (= 7.0.0) | ||
- Moya/Core (7.0.0): | ||
- Alamofire (~> 3.0) | ||
- Result (~> 2.0) | ||
- Moya/RxSwift (7.0.0): | ||
- Moya/Core | ||
- RxSwift (~> 2.0) | ||
- Nimble (4.1.0) | ||
- Quick (0.9.3) | ||
- Result (2.1.3) | ||
- RxAlamofire (2.5): | ||
- RxAlamofire/Core (= 2.5) | ||
- RxAlamofire/Core (2.5): | ||
- Alamofire (~> 3.4) | ||
- RxSwift (~> 2.5) | ||
- RxSwift (2.6.0) | ||
- Simple-KeychainSwift (1.1.6) | ||
- Unbox (1.9) | ||
|
||
DEPENDENCIES: | ||
- Alamofire (~> 3.4) | ||
- KeychainAccess | ||
- Moya | ||
- Moya/RxSwift | ||
- Nimble | ||
- Quick | ||
- RxAlamofire | ||
- RxSwift (~> 2.0) | ||
- Simple-KeychainSwift | ||
- Unbox | ||
|
||
SPEC CHECKSUMS: | ||
Alamofire: 01a82e2f6c0f860ade35534c8dd88be61bdef40c | ||
KeychainAccess: 7f10e2ef998ddf954a64d5d608be08677774684d | ||
Moya: f004b82418fb8165ee1fc9f86190db4b3611fda9 | ||
Nimble: 97a0a4cae5124c117115634b2d055d8c97d0af19 | ||
Quick: 13a2a2b19a5d8e3ed4fd0c36ee46597fd77ebf71 | ||
Result: 18e1a7597fbcca5923c565b40a25a98afafdee02 | ||
RxAlamofire: b4572a077b6b2410c8732a27266299df4c00736e | ||
RxSwift: 77f3a0b15324baa7a1c9bfa9f199648a82424e26 | ||
Simple-KeychainSwift: 44af418ebc152af23c24880dddad9c742a83bec3 | ||
Unbox: a6f56a1682b5fd2ba6aea96d7b1ec17599db4f05 | ||
|
||
PODFILE CHECKSUM: 98f335c7a71ce4996b0b05d095c3680fa2e6dee4 | ||
PODFILE CHECKSUM: 2ae5b2e070693d1c5f33f1af776dc4fbe9baa032 | ||
|
||
COCOAPODS: 1.0.1 |
Large diffs are not rendered by default.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
TransparentDataAccess.xcworkspace/xcshareddata/TransparentDataAccess.xcscmblueprint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "7B1022AC8DCBB9FC8C9CEB942D13A9C1584F4E55", | ||
"DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : { | ||
|
||
}, | ||
"DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : { | ||
"7B1022AC8DCBB9FC8C9CEB942D13A9C1584F4E55" : 0, | ||
"86F222E2E78505FCC1BDEB295F537874DCDE294B" : 0 | ||
}, | ||
"DVTSourceControlWorkspaceBlueprintIdentifierKey" : "D867FCB2-47F1-48FF-9E7C-BA09004736B8", | ||
"DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : { | ||
"7B1022AC8DCBB9FC8C9CEB942D13A9C1584F4E55" : "TransparentDataAccess\/", | ||
"86F222E2E78505FCC1BDEB295F537874DCDE294B" : "EducationalProject\/" | ||
}, | ||
"DVTSourceControlWorkspaceBlueprintNameKey" : "TransparentDataAccess", | ||
"DVTSourceControlWorkspaceBlueprintVersion" : 204, | ||
"DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "TransparentDataAccess.xcworkspace", | ||
"DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [ | ||
{ | ||
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/Rep2\/TransparentDataAccess.git", | ||
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", | ||
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "7B1022AC8DCBB9FC8C9CEB942D13A9C1584F4E55" | ||
}, | ||
{ | ||
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "gitlab.trikoder.net:ivan.rep\/EducationalProject.git", | ||
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", | ||
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "86F222E2E78505FCC1BDEB295F537874DCDE294B" | ||
} | ||
] | ||
} |
Binary file modified
BIN
+34.5 KB
(150%)
...ntDataAccess.xcworkspace/xcuserdata/undabotrep.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
24 changes: 12 additions & 12 deletions
24
TransparentDataAccess/TestGateways/MockGetSetGateway.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import RxSwift | ||
|
||
class MockGetSetGateway<R, T: StorableType>: GetSetGateway<R, T> { | ||
|
||
override func getResource(resourceType: T, forceRefresh: Bool) -> Observable<R> { | ||
return Observable.empty() | ||
} | ||
|
||
override func setResource(resourceType: T, resource: R) { | ||
} | ||
|
||
} | ||
//import RxSwift | ||
// | ||
//class MockGetSetGateway<R, T: StorableType>: GetSetGateway<R, T> { | ||
// | ||
// override func getResource(resourceType: T, forceRefresh: Bool) -> Observable<R> { | ||
// return Observable.empty() | ||
// } | ||
// | ||
// override func setResource(resourceType: T, resource: R) { | ||
// } | ||
// | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,19 @@ | ||
import RxSwift | ||
import Moya | ||
|
||
class TracksInFlightGetGateway<R, T where T:TargetType, T:StorableType>: GetGateway<R, T> { | ||
|
||
let gateway: GetGateway<R, T> | ||
|
||
var numberOfGetRequests: Int = 0 | ||
|
||
init(gateway: GetGateway<R, T>) { | ||
self.gateway = gateway | ||
} | ||
|
||
override func getResource(resourceType: T, forceRefresh: Bool) -> Observable<R> { | ||
numberOfGetRequests += 1 | ||
|
||
return gateway.getResource(resourceType, forceRefresh: forceRefresh) | ||
} | ||
|
||
} | ||
// | ||
//class TracksInFlightGetGateway<R, T where T:TargetType, T:StorableType>: GetGateway<R, T> { | ||
// | ||
// let gateway: GetGateway<R, T> | ||
// | ||
// var numberOfGetRequests: Int = 0 | ||
// | ||
// init(gateway: GetGateway<R, T>) { | ||
// self.gateway = gateway | ||
// } | ||
// | ||
// override func getResource(resourceType: T, forceRefresh: Bool) -> Observable<R> { | ||
// numberOfGetRequests += 1 | ||
// | ||
// return gateway.getResource(resourceType, forceRefresh: forceRefresh) | ||
// } | ||
// | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ enum GatewayError: ErrorType { | |
case .CodingFailed: | ||
return "Resource coding failed" | ||
} | ||
|
||
} | ||
} | ||
|
||
|
58 changes: 58 additions & 0 deletions
58
TransparentDataAccess/TransparentDataAccess/Gateways/CodingGateway.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import RxSwift | ||
|
||
struct CodingGateway { | ||
|
||
func getResource<Resource, Target: StorableTarget>(resourceTarget: Target, forceRefresh: Bool = false) -> Observable<Resource> { | ||
|
||
return Observable.create({ (observer) -> Disposable in | ||
if let data = NSUserDefaults.standardUserDefaults().objectForKey(resourceTarget.key) as? NSData { | ||
if let resource = NSKeyedUnarchiver.unarchiveObjectWithData(data) as? Resource { | ||
observer.onNext(resource) | ||
observer.onCompleted() | ||
} else { | ||
observer.onError(GatewayError.CodingFailed) | ||
} | ||
} else { | ||
observer.onError(GatewayError.NoDataFor(key: resourceTarget.key)) | ||
} | ||
|
||
return NopDisposable.instance | ||
}) | ||
.observeOn(ConcurrentDispatchQueueScheduler(queue: dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0))) | ||
} | ||
|
||
func setResource<R: NSCoding, T: StorableTarget>(resourceType: T, resource: R) { | ||
let data = NSKeyedArchiver.archivedDataWithRootObject(resource) | ||
NSUserDefaults.standardUserDefaults().setObject(data, forKey: resourceType.key) | ||
} | ||
} | ||
|
||
|
||
struct CodingGatewayWithCaching<Resource: NSCoding> { | ||
|
||
var localGateway: LocalGateway<Resource> | ||
let codingGateway: CodingGateway | ||
|
||
init(localGateway: LocalGateway<Resource>, codingGateway: CodingGateway) { | ||
self.localGateway = localGateway | ||
self.codingGateway = codingGateway | ||
} | ||
|
||
mutating func getResource<Target: StorableTarget>(resourceTarget: Target) -> Observable<Resource> { | ||
return Observable | ||
.of( | ||
localGateway.getResource(resourceTarget) | ||
.catchError { error in | ||
return .empty() | ||
}, | ||
codingGateway.getResource(resourceTarget) | ||
.doOnNext { self.localGateway.setResource(resourceTarget, resource: $0) } | ||
) | ||
.merge() | ||
.take(1) | ||
} | ||
|
||
func setResource<Target: StorableTarget>(resourceType: Target, resource: Resource) { | ||
codingGateway.setResource(resourceType, resource: resource) | ||
} | ||
} |
27 changes: 0 additions & 27 deletions
27
TransparentDataAccess/TransparentDataAccess/Gateways/CodingGatewayStorables.swift
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.