motion-yapper 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/.travis.yml +6 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +63 -0
- data/README.md +16 -0
- data/Rakefile +20 -0
- data/app/app_delegate.rb +5 -0
- data/lib/yapper.rb +30 -0
- data/lib/yapper/attachment.rb +48 -0
- data/lib/yapper/bson.rb +20 -0
- data/lib/yapper/config.rb +18 -0
- data/lib/yapper/db.rb +151 -0
- data/lib/yapper/document.rb +54 -0
- data/lib/yapper/document/attachment.rb +26 -0
- data/lib/yapper/document/callbacks.rb +86 -0
- data/lib/yapper/document/persistance.rb +171 -0
- data/lib/yapper/document/relation.rb +84 -0
- data/lib/yapper/document/selection.rb +100 -0
- data/lib/yapper/extensions.rb +80 -0
- data/lib/yapper/log.rb +5 -0
- data/lib/yapper/sync.rb +134 -0
- data/lib/yapper/sync/data.rb +12 -0
- data/lib/yapper/sync/event.rb +194 -0
- data/lib/yapper/sync/queue.rb +164 -0
- data/lib/yapper/timestamps.rb +16 -0
- data/lib/yapper/version.rb +3 -0
- data/lib/yapper/yapper.rb +2 -0
- data/spec/helpers/time_helper.rb +3 -0
- data/spec/integration/all_spec.rb +40 -0
- data/spec/integration/callback_spec.rb +87 -0
- data/spec/integration/db_spec.rb +40 -0
- data/spec/integration/find_spec.rb +51 -0
- data/spec/integration/persistance_spec.rb +118 -0
- data/spec/integration/relation_spec.rb +174 -0
- data/spec/integration/sync_spec.rb +42 -0
- data/spec/integration/timestamps_spec.rb +34 -0
- data/spec/integration/types_spec.rb +23 -0
- data/spec/integration/when_spec.rb +29 -0
- data/spec/integration/where_spec.rb +132 -0
- data/vendor/Podfile.lock +24 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPClient.h +641 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPClient.m +1396 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.h +133 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.m +327 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFImageRequestOperation.h +113 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFImageRequestOperation.m +321 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.h +71 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.m +150 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.h +75 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.m +157 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFNetworking.h +43 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.h +68 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.m +143 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.h +370 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.m +848 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.h +89 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.m +167 -0
- data/vendor/Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.h +78 -0
- data/vendor/Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.m +191 -0
- data/vendor/Pods/AFNetworking/LICENSE +19 -0
- data/vendor/Pods/AFNetworking/README.md +208 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFHTTPClient.h +641 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFHTTPRequestOperation.h +133 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFImageRequestOperation.h +113 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFJSONRequestOperation.h +71 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFNetworkActivityIndicatorManager.h +75 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFNetworking.h +43 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFPropertyListRequestOperation.h +68 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFURLConnectionOperation.h +370 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFXMLRequestOperation.h +89 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/UIImageView+AFNetworking.h +78 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/ContextFilterLogFormatter.h +65 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDASLLogger.h +41 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDAbstractDatabaseLogger.h +102 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDFileLogger.h +334 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDLog.h +601 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDTTYLogger.h +167 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DispatchQueueLogFormatter.h +116 -0
- data/vendor/Pods/BuildHeaders/NSData+MD5Digest/NSData+MD5Digest.h +18 -0
- data/vendor/Pods/BuildHeaders/Reachability/Reachability.h +109 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapCache.h +90 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapCollectionKey.h +20 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabase.h +547 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseConnection.h +447 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseConnectionState.h +29 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseDefaults.h +37 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtension.h +15 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionConnection.h +11 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionPrivate.h +440 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionTransaction.h +11 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredView.h +108 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewConnection.h +12 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewPrivate.h +19 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewTransaction.h +39 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearch.h +89 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchConnection.h +32 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchPrivate.h +69 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchSnippetOptions.h +79 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchTransaction.h +68 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseLogging.h +158 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseManager.h +17 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabasePrivate.h +424 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseQuery.h +42 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndex.h +100 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexConnection.h +33 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexPrivate.h +73 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexSetup.h +33 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexTransaction.h +58 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseStatement.h +13 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseString.h +121 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseTransaction.h +541 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseView.h +186 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewChange.h +272 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewChangePrivate.h +94 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewConnection.h +115 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewMappings.h +825 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewMappingsPrivate.h +72 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewOptions.h +56 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPage.h +36 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPageMetadata.h +27 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPrivate.h +153 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewRangeOptions.h +330 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewRangeOptionsPrivate.h +17 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewTransaction.h +447 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapMemoryTable.h +74 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapNull.h +17 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapSet.h +41 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapTouch.h +15 -0
- data/vendor/Pods/CocoaLumberjack/LICENSE.txt +18 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.h +41 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.m +99 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.h +102 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.m +727 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.h +334 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.m +1353 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.h +601 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.m +1083 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.h +167 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.m +1479 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/ContextFilterLogFormatter.h +65 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/ContextFilterLogFormatter.m +191 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DispatchQueueLogFormatter.h +116 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DispatchQueueLogFormatter.m +251 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/README.txt +7 -0
- data/vendor/Pods/CocoaLumberjack/README.markdown +37 -0
- data/vendor/Pods/Headers/AFNetworking/AFHTTPClient.h +641 -0
- data/vendor/Pods/Headers/AFNetworking/AFHTTPRequestOperation.h +133 -0
- data/vendor/Pods/Headers/AFNetworking/AFImageRequestOperation.h +113 -0
- data/vendor/Pods/Headers/AFNetworking/AFJSONRequestOperation.h +71 -0
- data/vendor/Pods/Headers/AFNetworking/AFNetworkActivityIndicatorManager.h +75 -0
- data/vendor/Pods/Headers/AFNetworking/AFNetworking.h +43 -0
- data/vendor/Pods/Headers/AFNetworking/AFPropertyListRequestOperation.h +68 -0
- data/vendor/Pods/Headers/AFNetworking/AFURLConnectionOperation.h +370 -0
- data/vendor/Pods/Headers/AFNetworking/AFXMLRequestOperation.h +89 -0
- data/vendor/Pods/Headers/AFNetworking/UIImageView+AFNetworking.h +78 -0
- data/vendor/Pods/Headers/CocoaLumberjack/ContextFilterLogFormatter.h +65 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDASLLogger.h +41 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDAbstractDatabaseLogger.h +102 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDFileLogger.h +334 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDLog.h +601 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDTTYLogger.h +167 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DispatchQueueLogFormatter.h +116 -0
- data/vendor/Pods/Headers/NSData+MD5Digest/NSData+MD5Digest.h +18 -0
- data/vendor/Pods/Headers/Reachability/Reachability.h +109 -0
- data/vendor/Pods/Headers/YapDatabase/YapCache.h +90 -0
- data/vendor/Pods/Headers/YapDatabase/YapCollectionKey.h +20 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabase.h +547 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseConnection.h +447 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseConnectionState.h +29 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseDefaults.h +37 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtension.h +15 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionConnection.h +11 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionPrivate.h +440 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionTransaction.h +11 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredView.h +108 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewConnection.h +12 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewPrivate.h +19 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewTransaction.h +39 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearch.h +89 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchConnection.h +32 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchPrivate.h +69 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchSnippetOptions.h +79 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchTransaction.h +68 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseLogging.h +158 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseManager.h +17 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabasePrivate.h +424 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseQuery.h +42 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndex.h +100 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexConnection.h +33 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexPrivate.h +73 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexSetup.h +33 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexTransaction.h +58 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseStatement.h +13 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseString.h +121 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseTransaction.h +541 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseView.h +186 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewChange.h +272 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewChangePrivate.h +94 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewConnection.h +115 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewMappings.h +825 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewMappingsPrivate.h +72 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewOptions.h +56 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPage.h +36 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPageMetadata.h +27 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPrivate.h +153 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewRangeOptions.h +330 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewRangeOptionsPrivate.h +17 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewTransaction.h +447 -0
- data/vendor/Pods/Headers/YapDatabase/YapMemoryTable.h +74 -0
- data/vendor/Pods/Headers/YapDatabase/YapNull.h +17 -0
- data/vendor/Pods/Headers/YapDatabase/YapSet.h +41 -0
- data/vendor/Pods/Headers/YapDatabase/YapTouch.h +15 -0
- data/vendor/Pods/Headers/____Pods-AFNetworking-prefix.h +17 -0
- data/vendor/Pods/Headers/____Pods-CocoaLumberjack-prefix.h +5 -0
- data/vendor/Pods/Headers/____Pods-NSData+MD5Digest-prefix.h +5 -0
- data/vendor/Pods/Headers/____Pods-Reachability-prefix.h +5 -0
- data/vendor/Pods/Headers/____Pods-YapDatabase-prefix.h +5 -0
- data/vendor/Pods/Headers/____Pods-environment.h +38 -0
- data/vendor/Pods/Manifest.lock +24 -0
- data/vendor/Pods/NSData+MD5Digest/NSData+MD5Digest/NSData+MD5Digest.h +18 -0
- data/vendor/Pods/NSData+MD5Digest/NSData+MD5Digest/NSData+MD5Digest.m +39 -0
- data/vendor/Pods/NSData+MD5Digest/README.md +11 -0
- data/vendor/Pods/Pods-AFNetworking-Private.xcconfig +5 -0
- data/vendor/Pods/Pods-AFNetworking-dummy.m +5 -0
- data/vendor/Pods/Pods-AFNetworking-prefix.pch +17 -0
- data/vendor/Pods/Pods-AFNetworking.xcconfig +1 -0
- data/vendor/Pods/Pods-Acknowledgements.markdown +96 -0
- data/vendor/Pods/Pods-Acknowledgements.plist +142 -0
- data/vendor/Pods/Pods-CocoaLumberjack-Private.xcconfig +5 -0
- data/vendor/Pods/Pods-CocoaLumberjack-dummy.m +5 -0
- data/vendor/Pods/Pods-CocoaLumberjack-prefix.pch +5 -0
- data/vendor/Pods/Pods-CocoaLumberjack.xcconfig +0 -0
- data/vendor/Pods/Pods-NSData+MD5Digest-Private.xcconfig +5 -0
- data/vendor/Pods/Pods-NSData+MD5Digest-dummy.m +5 -0
- data/vendor/Pods/Pods-NSData+MD5Digest-prefix.pch +5 -0
- data/vendor/Pods/Pods-NSData+MD5Digest.xcconfig +0 -0
- data/vendor/Pods/Pods-Reachability-Private.xcconfig +5 -0
- data/vendor/Pods/Pods-Reachability-dummy.m +5 -0
- data/vendor/Pods/Pods-Reachability-prefix.pch +5 -0
- data/vendor/Pods/Pods-Reachability.xcconfig +1 -0
- data/vendor/Pods/Pods-YapDatabase-Private.xcconfig +5 -0
- data/vendor/Pods/Pods-YapDatabase-dummy.m +5 -0
- data/vendor/Pods/Pods-YapDatabase-prefix.pch +5 -0
- data/vendor/Pods/Pods-YapDatabase.xcconfig +1 -0
- data/vendor/Pods/Pods-dummy.m +5 -0
- data/vendor/Pods/Pods-environment.h +38 -0
- data/vendor/Pods/Pods-resources.sh +68 -0
- data/vendor/Pods/Pods.bridgesupport +5096 -0
- data/vendor/Pods/Pods.xcconfig +5 -0
- data/vendor/Pods/Pods.xcodeproj/project.pbxproj +5536 -0
- data/vendor/Pods/Reachability/LICENCE.txt +24 -0
- data/vendor/Pods/Reachability/README.md +65 -0
- data/vendor/Pods/Reachability/Reachability.h +109 -0
- data/vendor/Pods/Reachability/Reachability.m +527 -0
- data/vendor/Pods/YapDatabase/LICENSE.txt +18 -0
- data/vendor/Pods/YapDatabase/README.md +30 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/Internal/YapDatabaseFilteredViewPrivate.h +19 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.h +108 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.m +175 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewConnection.h +12 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewConnection.m +41 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.h +39 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.m +966 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/Internal/YapDatabaseFullTextSearchPrivate.h +69 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearch.h +89 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearch.m +146 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchConnection.h +32 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchConnection.m +298 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchSnippetOptions.h +79 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchSnippetOptions.m +95 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchTransaction.h +68 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchTransaction.m +1352 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/Internal/YapDatabaseExtensionPrivate.h +440 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtension.h +15 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtension.m +58 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionConnection.h +11 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionConnection.m +46 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionTransaction.h +11 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionTransaction.m +180 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/Internal/YapDatabaseSecondaryIndexPrivate.h +73 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.h +100 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.m +149 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexConnection.h +33 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexConnection.m +330 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexSetup.h +33 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexSetup.m +184 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexTransaction.h +58 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexTransaction.m +1166 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewChangePrivate.h +94 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewMappingsPrivate.h +72 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPage.h +36 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPage.mm +296 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPageMetadata.h +27 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPageMetadata.m +28 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPrivate.h +153 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewRangeOptionsPrivate.h +17 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.h +272 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.m +2494 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.h +825 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.m +1567 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewRangeOptions.h +330 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewRangeOptions.m +141 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.h +186 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.m +191 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.h +115 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.m +897 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewOptions.h +56 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewOptions.m +27 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.h +447 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.m +4505 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.h +90 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.m +453 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseConnectionState.h +29 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseConnectionState.m +48 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.h +37 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.m +83 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseLogging.h +158 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseLogging.m +73 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseManager.h +17 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseManager.m +56 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabasePrivate.h +424 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseStatement.h +13 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseStatement.m +26 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseString.h +121 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapMemoryTable.h +74 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapMemoryTable.m +603 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapNull.h +17 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapNull.m +31 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapTouch.h +15 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapTouch.m +31 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.h +20 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.m +194 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapDatabaseQuery.h +42 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapDatabaseQuery.m +96 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapSet.h +41 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapSet.m +82 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.h +547 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.m +2022 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.h +447 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.m +3874 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.h +541 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.m +5282 -0
- data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.bridgesupport +16 -0
- data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.h +13 -0
- data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.m +20 -0
- data/yapper.gemspec +24 -0
- metadata +458 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3220185888e67be062af7600cb81346cdb6af641
|
4
|
+
data.tar.gz: 9484efc4e0bc1ac6b2f2da5c271bc7d7bd2849b2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4db43401b1dbe80f9b8700a4f3ac0fbcf48431f6945920bd0e9d67c5b6206409464572af6b8ebbdcfe816fabb8f6479a96a50ec3e643cd1af1e5c5d5cdd79216
|
7
|
+
data.tar.gz: 2f48add1d5a952009a13a6df7e2bd5ee1890a3f0f73a74bfd14b5cdb41b1e6ef141ffc1683751943021a0b471f4b6a90f54165dfdff16a9c5bb6467c11cdcfac
|
data/.gitignore
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#*#
|
2
|
+
*.dat*
|
3
|
+
*.sw[po]
|
4
|
+
*~
|
5
|
+
.DS_Store
|
6
|
+
.eprj
|
7
|
+
.rake_tasks~
|
8
|
+
.redcar
|
9
|
+
.repl_history
|
10
|
+
build
|
11
|
+
nbproject
|
12
|
+
pkg/*
|
13
|
+
resources/*.momd
|
14
|
+
resources/*.nib
|
15
|
+
resources/*.storyboardc
|
16
|
+
tags
|
17
|
+
vendor/*/.build
|
18
|
+
vendor/*/build-*
|
19
|
+
.ruby-version
|
20
|
+
.ruby-gemset
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
motion-yapper (0.0.1)
|
5
|
+
motion-cocoapods (~> 1.4.0)
|
6
|
+
motion-logger (~> 0.1.3)
|
7
|
+
motion-support (~> 0.2.4)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
activesupport (3.2.16)
|
13
|
+
i18n (~> 0.6, >= 0.6.4)
|
14
|
+
multi_json (~> 1.0)
|
15
|
+
claide (0.4.0)
|
16
|
+
cocoapods (0.29.0)
|
17
|
+
activesupport (>= 3.2.15, < 4)
|
18
|
+
claide (~> 0.4.0)
|
19
|
+
cocoapods-core (= 0.29.0)
|
20
|
+
cocoapods-downloader (~> 0.3.0)
|
21
|
+
cocoapods-try-release-fix (~> 0.1.1)
|
22
|
+
colored (~> 1.2)
|
23
|
+
escape (~> 0.0.4)
|
24
|
+
json_pure (~> 1.8)
|
25
|
+
nap (~> 0.5)
|
26
|
+
open4 (~> 1.3)
|
27
|
+
xcodeproj (~> 0.14.1)
|
28
|
+
cocoapods-core (0.29.0)
|
29
|
+
activesupport (>= 3.2.15, < 4)
|
30
|
+
fuzzy_match (~> 2.0.4)
|
31
|
+
json_pure (~> 1.8)
|
32
|
+
nap (~> 0.5)
|
33
|
+
cocoapods-downloader (0.3.0)
|
34
|
+
cocoapods-try-release-fix (0.1.1)
|
35
|
+
colored (1.2)
|
36
|
+
escape (0.0.4)
|
37
|
+
fuzzy_match (2.0.4)
|
38
|
+
i18n (0.6.9)
|
39
|
+
json_pure (1.8.1)
|
40
|
+
motion-cocoapods (1.4.0)
|
41
|
+
cocoapods (>= 0.26.2)
|
42
|
+
motion-logger (0.1.3)
|
43
|
+
motion-cocoapods (>= 1.1.0)
|
44
|
+
motion-redgreen (0.1.0)
|
45
|
+
motion-require (0.0.7)
|
46
|
+
motion-support (0.2.6)
|
47
|
+
motion-require (>= 0.0.6)
|
48
|
+
multi_json (1.8.4)
|
49
|
+
nap (0.6.0)
|
50
|
+
open4 (1.3.0)
|
51
|
+
rake (10.1.1)
|
52
|
+
xcodeproj (0.14.1)
|
53
|
+
activesupport (~> 3.0)
|
54
|
+
colored (~> 1.2)
|
55
|
+
rake
|
56
|
+
|
57
|
+
PLATFORMS
|
58
|
+
ruby
|
59
|
+
|
60
|
+
DEPENDENCIES
|
61
|
+
motion-redgreen
|
62
|
+
motion-yapper!
|
63
|
+
rake
|
data/README.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
yapper [![Build Status](https://travis-ci.org/kareemk/yapper.png?branch=master)](https://travis-ci.org/kareemk/nanoid)
|
2
|
+
======
|
3
|
+
|
4
|
+
RubyMotion ORM for YapDatabase
|
5
|
+
|
6
|
+
**WARNING: Under heavy development. Use with extreme caution. Stable version will be out soon.**
|
7
|
+
|
8
|
+
License
|
9
|
+
-------
|
10
|
+
Copyright (C) 2013 Kareem Kouddous
|
11
|
+
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
$:.unshift("/Library/RubyMotion/lib")
|
3
|
+
require 'motion/project/template/ios'
|
4
|
+
require 'motion-cocoapods'
|
5
|
+
require 'motion-logger'
|
6
|
+
require 'motion-redgreen'
|
7
|
+
require 'webstub'
|
8
|
+
require 'yapper'
|
9
|
+
|
10
|
+
Motion::Project::App.setup do |app|
|
11
|
+
app.name = 'Yapper'
|
12
|
+
app.redgreen_style = :full
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "Build the gem"
|
16
|
+
task :gem do
|
17
|
+
sh "bundle exec gem build nanoid.gemspec"
|
18
|
+
sh "mkdir -p pkg"
|
19
|
+
sh "mv *.gem pkg/"
|
20
|
+
end
|
data/app/app_delegate.rb
ADDED
data/lib/yapper.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
unless defined?(Motion::Project::Config)
|
2
|
+
raise "This file must be required within a RubyMotion project Rakefile."
|
3
|
+
end
|
4
|
+
|
5
|
+
require 'motion-require'
|
6
|
+
require 'motion-support/concern'
|
7
|
+
require 'motion-support/inflector'
|
8
|
+
require 'motion-support/core_ext'
|
9
|
+
|
10
|
+
files = Dir.glob(File.expand_path('../../lib/yapper/**/*.rb', __FILE__))
|
11
|
+
Motion::Require.all(files)
|
12
|
+
|
13
|
+
Motion::Project::App.setup do |app|
|
14
|
+
app.detect_dependencies = false
|
15
|
+
|
16
|
+
app.pods do
|
17
|
+
pod 'YapDatabase' ,'~> 2.3'
|
18
|
+
pod 'AFNetworking' ,'~> 1.3.3'
|
19
|
+
pod 'Reachability' ,'~> 3.1.1'
|
20
|
+
pod 'CocoaLumberjack' ,'~> 1.6.5'
|
21
|
+
pod 'NSData+MD5Digest' ,'~> 1.0.0'
|
22
|
+
end
|
23
|
+
|
24
|
+
yap_patch = File.expand_path(File.join(File.dirname(__FILE__), '../vendor/YapDatabaseRubyMotion'))
|
25
|
+
app.vendor_project(yap_patch,
|
26
|
+
:static,
|
27
|
+
:bridgesupport_cflags => '-I../Pods/Headers -fobjc-arc',
|
28
|
+
:cflags => '-I../Pods/Headers -fobjc-arc')
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
motion_require 'document.rb'
|
2
|
+
motion_require 'sync.rb'
|
3
|
+
|
4
|
+
class Yapper::Attachment
|
5
|
+
include Yapper::Document
|
6
|
+
include Yapper::Sync
|
7
|
+
|
8
|
+
sync
|
9
|
+
|
10
|
+
class_attribute :attachments
|
11
|
+
self.attachments = {}.with_indifferent_access
|
12
|
+
|
13
|
+
field :name
|
14
|
+
field :uid
|
15
|
+
field :additional_fields
|
16
|
+
|
17
|
+
def self.create(name, fields={})
|
18
|
+
name = name.pluralize
|
19
|
+
raise "#{name} attachment not a defined" unless attachments[name]
|
20
|
+
fields.keys.each do |field|
|
21
|
+
raise "Attachment field #{field} not defined for #{name}" unless attachments[name][:with].include?(field)
|
22
|
+
end
|
23
|
+
|
24
|
+
attachment = self.new
|
25
|
+
attachment.name = name
|
26
|
+
attachment.additional_fields = fields
|
27
|
+
attachment.save
|
28
|
+
|
29
|
+
attachment
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.url(uid, size=nil)
|
33
|
+
options = "[[\"f\",\"#{uid}\"]"
|
34
|
+
options << ",[\"p\",\"thumb\", \"#{size}\"]" if size
|
35
|
+
options << "]"
|
36
|
+
path = [options].pack("m").tr("\n=",'')
|
37
|
+
|
38
|
+
NSURL.URLWithString("#{Yapper::Sync.base_url}/#{path}.jpg")
|
39
|
+
end
|
40
|
+
|
41
|
+
def data
|
42
|
+
self.attachments[name][:block].call(self)
|
43
|
+
end
|
44
|
+
|
45
|
+
def metadata
|
46
|
+
self.additional_fields.merge(:id => self.id, :name => self.name).with_indifferent_access
|
47
|
+
end
|
48
|
+
end
|
data/lib/yapper/bson.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
class BSON
|
2
|
+
class ObjectId
|
3
|
+
@@machine_id = NSData.MD5HexDigest(UIDevice.currentDevice.identifierForVendor.UUIDString.dataUsingEncoding(NSUTF8StringEncoding)).unpack("N")[0]
|
4
|
+
|
5
|
+
@@mutex = Mutex.new
|
6
|
+
@@counter = 0
|
7
|
+
|
8
|
+
def self.generate
|
9
|
+
@@mutex.lock
|
10
|
+
begin
|
11
|
+
counter = @@counter = (@@counter + 1) % 0xFFFFFF
|
12
|
+
ensure
|
13
|
+
@@mutex.unlock rescue nil
|
14
|
+
end
|
15
|
+
|
16
|
+
process_thread_id = "#{Process.pid}#{Thread.current.object_id}".hash % 0xFFFF
|
17
|
+
[Time.new.to_i, @@machine_id, process_thread_id, counter << 8].pack("N NX lXX NX").unpack("H*")[0]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Yapper::Config
|
2
|
+
COLLECTION = '_config'
|
3
|
+
extend self
|
4
|
+
|
5
|
+
mattr_accessor :db_version
|
6
|
+
|
7
|
+
def self.get(key)
|
8
|
+
Yapper::DB.instance.execute do |txn|
|
9
|
+
txn.objectForKey(key.to_s, inCollection: '_config')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.set(key, value)
|
14
|
+
Yapper::DB.instance.execute do |txn|
|
15
|
+
txn.setObject(value, forKey: key, inCollection: COLLECTION)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/yapper/db.rb
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
motion_require 'yapper'
|
2
|
+
|
3
|
+
class Yapper::DB
|
4
|
+
@@dbs = {}
|
5
|
+
@@queue = Dispatch::Queue.new("#{NSBundle.mainBundle.bundleIdentifier}.yapper.db#{@name}")
|
6
|
+
|
7
|
+
class_attribute :version
|
8
|
+
|
9
|
+
def self.purge
|
10
|
+
default.purge
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.instance
|
14
|
+
@@db = begin
|
15
|
+
@@queue.sync do
|
16
|
+
@@dbs[name] ||= self.new(:name => name)
|
17
|
+
end
|
18
|
+
@@dbs[name]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
attr_reader :indexes
|
23
|
+
|
24
|
+
def initialize(options)
|
25
|
+
@options = options
|
26
|
+
@name = options[:name]
|
27
|
+
@indexes = {}; @indexes_created = false
|
28
|
+
|
29
|
+
self
|
30
|
+
end
|
31
|
+
|
32
|
+
def configure(&block)
|
33
|
+
block.call(db)
|
34
|
+
end
|
35
|
+
|
36
|
+
def execute(&block)
|
37
|
+
create_indexes!
|
38
|
+
|
39
|
+
exception = nil; result = nil
|
40
|
+
unless self.txn
|
41
|
+
txn_proc = proc do |_txn|
|
42
|
+
self.txn = _txn
|
43
|
+
begin
|
44
|
+
result = block.call(txn)
|
45
|
+
rescue Exception => e
|
46
|
+
self.txn.rollback
|
47
|
+
exception = e
|
48
|
+
ensure
|
49
|
+
self.txn = nil
|
50
|
+
end
|
51
|
+
end
|
52
|
+
connection.readWriteWithBlock(txn_proc)
|
53
|
+
|
54
|
+
else
|
55
|
+
result = block.call(self.txn)
|
56
|
+
end
|
57
|
+
|
58
|
+
raise exception if exception
|
59
|
+
result
|
60
|
+
end
|
61
|
+
|
62
|
+
def purge
|
63
|
+
create_indexes!(true)
|
64
|
+
execute { |txn| txn.removeAllObjectsInAllCollections }
|
65
|
+
end
|
66
|
+
|
67
|
+
def txn=(txn)
|
68
|
+
Thread.current[:yapper_txn] = txn
|
69
|
+
end
|
70
|
+
|
71
|
+
def txn
|
72
|
+
Thread.current[:yapper_txn]
|
73
|
+
end
|
74
|
+
|
75
|
+
def index(collection, field, type)
|
76
|
+
@indexes[collection] ||= {}
|
77
|
+
@indexes[collection][field] = { :type => type }
|
78
|
+
end
|
79
|
+
|
80
|
+
private
|
81
|
+
|
82
|
+
def create_indexes!(force=false)
|
83
|
+
return if @indexes_created && !force
|
84
|
+
|
85
|
+
@@queue.sync do
|
86
|
+
return if @indexes_created && !force
|
87
|
+
|
88
|
+
@indexes.each do |collection, fields|
|
89
|
+
setup = YapDatabaseSecondaryIndexSetup.alloc.init
|
90
|
+
|
91
|
+
fields.each do |field, options|
|
92
|
+
type = case options[:type].to_s
|
93
|
+
when 'String'
|
94
|
+
YapDatabaseSecondaryIndexTypeText
|
95
|
+
when 'Integer'
|
96
|
+
YapDatabaseSecondaryIndexTypeInteger
|
97
|
+
when 'Time'
|
98
|
+
YapDatabaseSecondaryIndexTypeInteger
|
99
|
+
else
|
100
|
+
raise "Invalid type #{type}"
|
101
|
+
end
|
102
|
+
|
103
|
+
setup.addColumn(field, withType: type)
|
104
|
+
end
|
105
|
+
|
106
|
+
block = proc do |_dict, _collection, _key, _attrs|
|
107
|
+
if indexes = @indexes[_collection]
|
108
|
+
indexes.each do |field, options|
|
109
|
+
field = field.to_s
|
110
|
+
if _collection == collection
|
111
|
+
value = case options[:type].to_s
|
112
|
+
when 'Time'
|
113
|
+
_attrs[field].to_i
|
114
|
+
else
|
115
|
+
_attrs[field]
|
116
|
+
end
|
117
|
+
value = NSNull if value.nil?
|
118
|
+
_dict.setObject(value, forKey: field)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
index_block = YapDatabaseSecondaryIndex.alloc.initWithSetup(setup, objectBlock: block)
|
125
|
+
configure do |yap|
|
126
|
+
yap.registerExtension(index_block, withName: "#{collection}_IDX")
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
@indexes_created = true
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def connection
|
135
|
+
Dispatch.once { @connection ||= db.newConnection }
|
136
|
+
@connection
|
137
|
+
end
|
138
|
+
|
139
|
+
def db
|
140
|
+
Dispatch.once { @db ||= YapDatabase.alloc.initWithPath(document_path) }
|
141
|
+
@db
|
142
|
+
end
|
143
|
+
|
144
|
+
def version
|
145
|
+
Yapper::Config.db_version || 0
|
146
|
+
end
|
147
|
+
|
148
|
+
def document_path
|
149
|
+
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, true)[0] + "/yapper.#{version}.db"
|
150
|
+
end
|
151
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
motion_require 'extensions'
|
2
|
+
motion_require 'db'
|
3
|
+
|
4
|
+
module Yapper::Document
|
5
|
+
motion_require 'document/attachment'
|
6
|
+
motion_require 'document/callbacks'
|
7
|
+
motion_require 'document/persistance'
|
8
|
+
motion_require 'document/relation'
|
9
|
+
motion_require 'document/selection'
|
10
|
+
|
11
|
+
extend MotionSupport::Concern
|
12
|
+
|
13
|
+
include Persistance
|
14
|
+
include Selection
|
15
|
+
include Callbacks
|
16
|
+
include Relation
|
17
|
+
include Attachment
|
18
|
+
|
19
|
+
module ClassMethods
|
20
|
+
def db
|
21
|
+
Yapper::DB.instance
|
22
|
+
end
|
23
|
+
|
24
|
+
def _type
|
25
|
+
self.to_s
|
26
|
+
end
|
27
|
+
|
28
|
+
def model_name
|
29
|
+
self.to_s.downcase
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def _type
|
34
|
+
self.class._type
|
35
|
+
end
|
36
|
+
|
37
|
+
def db
|
38
|
+
self.class.db
|
39
|
+
end
|
40
|
+
|
41
|
+
def model_name
|
42
|
+
self.class.model_name
|
43
|
+
end
|
44
|
+
|
45
|
+
# TODO Add specs
|
46
|
+
def ==(other)
|
47
|
+
self.id == other.try(:id)
|
48
|
+
end
|
49
|
+
alias :eql? :==
|
50
|
+
|
51
|
+
def hash
|
52
|
+
self.id.hash
|
53
|
+
end
|
54
|
+
end
|