motion-yapper 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (296) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -2
  3. data/.travis.yml +2 -0
  4. data/Gemfile +1 -0
  5. data/README.md +1 -1
  6. data/Rakefile +1 -1
  7. data/lib/motion-yapper.rb +1 -0
  8. data/lib/yapper.rb +3 -5
  9. data/lib/yapper/config.rb +2 -0
  10. data/lib/yapper/db.rb +105 -40
  11. data/lib/yapper/document.rb +7 -4
  12. data/lib/yapper/document/callbacks.rb +0 -7
  13. data/lib/yapper/document/{persistance.rb → persistence.rb} +27 -21
  14. data/lib/yapper/document/relation.rb +29 -22
  15. data/lib/yapper/document/selection.rb +122 -54
  16. data/lib/yapper/extensions.rb +12 -24
  17. data/lib/yapper/settings.rb +43 -0
  18. data/lib/yapper/timestamps.rb +2 -0
  19. data/lib/yapper/version.rb +1 -1
  20. data/{yapper.gemspec → motion-yapper.gemspec} +0 -0
  21. data/spec/integration/{where_spec.rb → criteria_spec.rb} +78 -10
  22. data/spec/integration/db_spec.rb +70 -0
  23. data/spec/integration/defaults_spec.rb +37 -0
  24. data/spec/integration/extensions_spec.rb +14 -0
  25. data/spec/integration/{persistance_spec.rb → persistence_spec.rb} +0 -0
  26. data/spec/integration/relation_spec.rb +4 -4
  27. data/vendor/Podfile.lock +9 -11
  28. data/vendor/Pods/.build/libPods-CocoaLumberjack.a +0 -0
  29. data/vendor/Pods/.build/libPods-NSData+MD5Digest.a +0 -0
  30. data/vendor/Pods/.build/libPods-YapDatabase.a +0 -0
  31. data/vendor/Pods/.build/libPods.a +0 -0
  32. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDASLLogger.h +4 -4
  33. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDAbstractDatabaseLogger.h +14 -14
  34. data/vendor/Pods/{CocoaLumberjack/Lumberjack/Extensions/ContextFilterLogFormatter.h → BuildHeaders/CocoaLumberjack/DDContextFilterLogFormatter.h} +6 -8
  35. data/vendor/Pods/BuildHeaders/CocoaLumberjack/{DispatchQueueLogFormatter.h → DDDispatchQueueLogFormatter.h} +18 -6
  36. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDFileLogger.h +67 -32
  37. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDLog+LOGV.h +99 -0
  38. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDLog.h +98 -65
  39. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDMultiFormatter.h +30 -0
  40. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDTTYLogger.h +39 -25
  41. data/vendor/Pods/BuildHeaders/YapDatabase/NSDictionary+YapDatabase.h +8 -0
  42. data/vendor/Pods/BuildHeaders/YapDatabase/YapCache.h +1 -0
  43. data/vendor/Pods/BuildHeaders/YapDatabase/YapCollectionKey.h +3 -0
  44. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabase.h +4 -4
  45. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseConnection.h +21 -19
  46. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseDefaults.h +1 -1
  47. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionPrivate.h +35 -31
  48. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredView.h +8 -35
  49. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewPrivate.h +0 -2
  50. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewTransaction.h +17 -17
  51. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewTypes.h +32 -0
  52. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchPrivate.h +8 -0
  53. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabasePrivate.h +43 -21
  54. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationship.h +35 -0
  55. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipConnection.h +29 -0
  56. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipEdge.h +163 -0
  57. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipEdgePrivate.h +79 -0
  58. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipNode.h +99 -0
  59. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipOptions.h +59 -0
  60. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipPrivate.h +125 -0
  61. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipTransaction.h +384 -0
  62. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndex.h +49 -0
  63. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexPrivate.h +10 -0
  64. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexSetupPrivate.h +18 -0
  65. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseTransaction.h +131 -21
  66. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseView.h +48 -107
  67. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewChange.h +2 -2
  68. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewConnection.h +1 -0
  69. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewMappings.h +17 -0
  70. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewOptions.h +10 -3
  71. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPrivate.h +18 -1
  72. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewTransaction.h +75 -24
  73. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewTypes.h +99 -0
  74. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.h +4 -4
  75. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.m +51 -50
  76. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.h +14 -14
  77. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.m +546 -546
  78. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.h +67 -32
  79. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.m +1093 -907
  80. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog+LOGV.h +99 -0
  81. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.h +98 -65
  82. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.m +873 -748
  83. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.h +39 -25
  84. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.m +1284 -1243
  85. data/vendor/Pods/{BuildHeaders/CocoaLumberjack/ContextFilterLogFormatter.h → CocoaLumberjack/Lumberjack/Extensions/DDContextFilterLogFormatter.h} +6 -8
  86. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/{ContextFilterLogFormatter.m → DDContextFilterLogFormatter.m} +70 -70
  87. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/{DispatchQueueLogFormatter.h → DDDispatchQueueLogFormatter.h} +18 -6
  88. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDDispatchQueueLogFormatter.m +253 -0
  89. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDMultiFormatter.h +30 -0
  90. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDMultiFormatter.m +127 -0
  91. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/README.txt +1 -1
  92. data/vendor/Pods/CocoaLumberjack/README.markdown +52 -15
  93. data/vendor/Pods/Headers/CocoaLumberjack/DDASLLogger.h +4 -4
  94. data/vendor/Pods/Headers/CocoaLumberjack/DDAbstractDatabaseLogger.h +14 -14
  95. data/vendor/Pods/Headers/CocoaLumberjack/{ContextFilterLogFormatter.h → DDContextFilterLogFormatter.h} +6 -8
  96. data/vendor/Pods/Headers/CocoaLumberjack/{DispatchQueueLogFormatter.h → DDDispatchQueueLogFormatter.h} +18 -6
  97. data/vendor/Pods/Headers/CocoaLumberjack/DDFileLogger.h +67 -32
  98. data/vendor/Pods/Headers/CocoaLumberjack/DDLog+LOGV.h +99 -0
  99. data/vendor/Pods/Headers/CocoaLumberjack/DDLog.h +98 -65
  100. data/vendor/Pods/Headers/CocoaLumberjack/DDMultiFormatter.h +30 -0
  101. data/vendor/Pods/Headers/CocoaLumberjack/DDTTYLogger.h +39 -25
  102. data/vendor/Pods/Headers/YapDatabase/YapCollectionKey.h +3 -0
  103. data/vendor/Pods/Headers/YapDatabase/YapDatabase.h +4 -4
  104. data/vendor/Pods/Headers/YapDatabase/YapDatabaseConnection.h +21 -19
  105. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredView.h +8 -35
  106. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewTransaction.h +17 -17
  107. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewTypes.h +32 -0
  108. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationship.h +35 -0
  109. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipConnection.h +29 -0
  110. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipEdge.h +163 -0
  111. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipNode.h +99 -0
  112. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipOptions.h +59 -0
  113. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipTransaction.h +384 -0
  114. data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndex.h +49 -0
  115. data/vendor/Pods/Headers/YapDatabase/YapDatabaseTransaction.h +131 -21
  116. data/vendor/Pods/Headers/YapDatabase/YapDatabaseView.h +48 -107
  117. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewChange.h +2 -2
  118. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewConnection.h +1 -0
  119. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewMappings.h +17 -0
  120. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewOptions.h +10 -3
  121. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewTransaction.h +75 -24
  122. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewTypes.h +99 -0
  123. data/vendor/Pods/Headers/____Pods-CocoaLumberjack-prefix.h +2 -0
  124. data/vendor/Pods/Headers/____Pods-environment.h +15 -15
  125. data/vendor/Pods/Manifest.lock +9 -11
  126. data/vendor/Pods/Pods-CocoaLumberjack-Private.xcconfig +1 -1
  127. data/vendor/Pods/Pods-CocoaLumberjack-prefix.pch +2 -0
  128. data/vendor/Pods/Pods-NSData+MD5Digest-Private.xcconfig +1 -1
  129. data/vendor/Pods/Pods-YapDatabase-Private.xcconfig +1 -1
  130. data/vendor/Pods/{Pods-Acknowledgements.markdown → Pods-acknowledgements.markdown} +0 -37
  131. data/vendor/Pods/{Pods-Acknowledgements.plist → Pods-acknowledgements.plist} +0 -45
  132. data/vendor/Pods/Pods-environment.h +15 -15
  133. data/vendor/Pods/Pods.xcconfig +3 -3
  134. data/vendor/Pods/Pods.xcodeproj/project.pbxproj +2426 -3155
  135. data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods-CocoaLumberjack.xcscheme +59 -0
  136. data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods-NSData+MD5Digest.xcscheme +59 -0
  137. data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods-YapDatabase.xcscheme +59 -0
  138. data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods.xcscheme +59 -0
  139. data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/xcschememanagement.plist +31 -0
  140. data/vendor/Pods/YapDatabase/README.md +3 -1
  141. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/Internal/YapDatabaseFilteredViewPrivate.h +0 -2
  142. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.h +8 -35
  143. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.m +25 -41
  144. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.h +17 -17
  145. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.m +403 -134
  146. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTypes.h +32 -0
  147. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/Internal/YapDatabaseFullTextSearchPrivate.h +8 -0
  148. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchConnection.m +8 -8
  149. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchTransaction.m +113 -62
  150. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/Internal/YapDatabaseExtensionPrivate.h +35 -31
  151. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtension.m +25 -0
  152. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionConnection.m +1 -1
  153. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionTransaction.m +25 -1
  154. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/Internal/YapDatabaseRelationshipEdgePrivate.h +79 -0
  155. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/Internal/YapDatabaseRelationshipPrivate.h +125 -0
  156. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationship.h +35 -0
  157. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationship.m +129 -0
  158. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipConnection.h +29 -0
  159. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipConnection.m +802 -0
  160. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipEdge.h +163 -0
  161. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipEdge.m +408 -0
  162. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipNode.h +99 -0
  163. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipOptions.h +59 -0
  164. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipOptions.m +29 -0
  165. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipTransaction.h +384 -0
  166. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipTransaction.m +5254 -0
  167. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/Internal/YapDatabaseSecondaryIndexPrivate.h +10 -0
  168. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/Internal/YapDatabaseSecondaryIndexSetupPrivate.h +18 -0
  169. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.h +49 -0
  170. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.m +12 -0
  171. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexConnection.m +9 -8
  172. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexSetup.m +62 -1
  173. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexTransaction.m +148 -45
  174. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPrivate.h +18 -1
  175. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.h +2 -2
  176. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.m +15 -9
  177. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.h +17 -0
  178. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.m +211 -64
  179. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.h +48 -107
  180. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.m +10 -7
  181. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.h +1 -0
  182. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.m +13 -22
  183. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewOptions.h +10 -3
  184. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.h +75 -24
  185. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.m +725 -244
  186. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTypes.h +99 -0
  187. data/vendor/Pods/YapDatabase/YapDatabase/Internal/NSDictionary+YapDatabase.h +8 -0
  188. data/vendor/Pods/YapDatabase/YapDatabase/Internal/NSDictionary+YapDatabase.m +19 -0
  189. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.h +1 -0
  190. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.m +12 -0
  191. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.h +1 -1
  192. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.m +3 -3
  193. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabasePrivate.h +43 -21
  194. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapNull.m +4 -0
  195. data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.h +3 -0
  196. data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.m +5 -0
  197. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.h +4 -4
  198. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.m +84 -93
  199. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.h +21 -19
  200. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.m +381 -209
  201. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.h +131 -21
  202. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.m +587 -267
  203. data/vendor/Pods/{Pods.bridgesupport → build-iPhoneSimulator/Pods.bridgesupport} +633 -2557
  204. data/vendor/Pods/build-iPhoneSimulator/libPods.a +0 -0
  205. data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.bridgesupport +2 -1
  206. data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.h +2 -1
  207. data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.m +4 -2
  208. metadata +80 -108
  209. data/Gemfile.lock +0 -63
  210. data/lib/yapper/attachment.rb +0 -48
  211. data/lib/yapper/document/attachment.rb +0 -26
  212. data/lib/yapper/sync.rb +0 -134
  213. data/lib/yapper/sync/data.rb +0 -12
  214. data/lib/yapper/sync/event.rb +0 -194
  215. data/lib/yapper/sync/queue.rb +0 -164
  216. data/spec/integration/all_spec.rb +0 -40
  217. data/spec/integration/sync_spec.rb +0 -42
  218. data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPClient.h +0 -641
  219. data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPClient.m +0 -1396
  220. data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.h +0 -133
  221. data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.m +0 -327
  222. data/vendor/Pods/AFNetworking/AFNetworking/AFImageRequestOperation.h +0 -113
  223. data/vendor/Pods/AFNetworking/AFNetworking/AFImageRequestOperation.m +0 -321
  224. data/vendor/Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.h +0 -71
  225. data/vendor/Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.m +0 -150
  226. data/vendor/Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.h +0 -75
  227. data/vendor/Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.m +0 -157
  228. data/vendor/Pods/AFNetworking/AFNetworking/AFNetworking.h +0 -43
  229. data/vendor/Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.h +0 -68
  230. data/vendor/Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.m +0 -143
  231. data/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.h +0 -370
  232. data/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.m +0 -848
  233. data/vendor/Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.h +0 -89
  234. data/vendor/Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.m +0 -167
  235. data/vendor/Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.h +0 -78
  236. data/vendor/Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.m +0 -191
  237. data/vendor/Pods/AFNetworking/LICENSE +0 -19
  238. data/vendor/Pods/AFNetworking/README.md +0 -208
  239. data/vendor/Pods/BuildHeaders/AFNetworking/AFHTTPClient.h +0 -641
  240. data/vendor/Pods/BuildHeaders/AFNetworking/AFHTTPRequestOperation.h +0 -133
  241. data/vendor/Pods/BuildHeaders/AFNetworking/AFImageRequestOperation.h +0 -113
  242. data/vendor/Pods/BuildHeaders/AFNetworking/AFJSONRequestOperation.h +0 -71
  243. data/vendor/Pods/BuildHeaders/AFNetworking/AFNetworkActivityIndicatorManager.h +0 -75
  244. data/vendor/Pods/BuildHeaders/AFNetworking/AFNetworking.h +0 -43
  245. data/vendor/Pods/BuildHeaders/AFNetworking/AFPropertyListRequestOperation.h +0 -68
  246. data/vendor/Pods/BuildHeaders/AFNetworking/AFURLConnectionOperation.h +0 -370
  247. data/vendor/Pods/BuildHeaders/AFNetworking/AFXMLRequestOperation.h +0 -89
  248. data/vendor/Pods/BuildHeaders/AFNetworking/UIImageView+AFNetworking.h +0 -78
  249. data/vendor/Pods/BuildHeaders/Reachability/Reachability.h +0 -109
  250. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DispatchQueueLogFormatter.m +0 -251
  251. data/vendor/Pods/Headers/AFNetworking/AFHTTPClient.h +0 -641
  252. data/vendor/Pods/Headers/AFNetworking/AFHTTPRequestOperation.h +0 -133
  253. data/vendor/Pods/Headers/AFNetworking/AFImageRequestOperation.h +0 -113
  254. data/vendor/Pods/Headers/AFNetworking/AFJSONRequestOperation.h +0 -71
  255. data/vendor/Pods/Headers/AFNetworking/AFNetworkActivityIndicatorManager.h +0 -75
  256. data/vendor/Pods/Headers/AFNetworking/AFNetworking.h +0 -43
  257. data/vendor/Pods/Headers/AFNetworking/AFPropertyListRequestOperation.h +0 -68
  258. data/vendor/Pods/Headers/AFNetworking/AFURLConnectionOperation.h +0 -370
  259. data/vendor/Pods/Headers/AFNetworking/AFXMLRequestOperation.h +0 -89
  260. data/vendor/Pods/Headers/AFNetworking/UIImageView+AFNetworking.h +0 -78
  261. data/vendor/Pods/Headers/Reachability/Reachability.h +0 -109
  262. data/vendor/Pods/Headers/YapDatabase/YapCache.h +0 -90
  263. data/vendor/Pods/Headers/YapDatabase/YapDatabaseConnectionState.h +0 -29
  264. data/vendor/Pods/Headers/YapDatabase/YapDatabaseDefaults.h +0 -37
  265. data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionPrivate.h +0 -440
  266. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewPrivate.h +0 -19
  267. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchPrivate.h +0 -69
  268. data/vendor/Pods/Headers/YapDatabase/YapDatabaseLogging.h +0 -158
  269. data/vendor/Pods/Headers/YapDatabase/YapDatabaseManager.h +0 -17
  270. data/vendor/Pods/Headers/YapDatabase/YapDatabasePrivate.h +0 -424
  271. data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexPrivate.h +0 -73
  272. data/vendor/Pods/Headers/YapDatabase/YapDatabaseStatement.h +0 -13
  273. data/vendor/Pods/Headers/YapDatabase/YapDatabaseString.h +0 -121
  274. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewChangePrivate.h +0 -94
  275. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewMappingsPrivate.h +0 -72
  276. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPage.h +0 -36
  277. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPageMetadata.h +0 -27
  278. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPrivate.h +0 -153
  279. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewRangeOptionsPrivate.h +0 -17
  280. data/vendor/Pods/Headers/YapDatabase/YapMemoryTable.h +0 -74
  281. data/vendor/Pods/Headers/YapDatabase/YapNull.h +0 -17
  282. data/vendor/Pods/Headers/YapDatabase/YapTouch.h +0 -15
  283. data/vendor/Pods/Headers/____Pods-AFNetworking-prefix.h +0 -17
  284. data/vendor/Pods/Headers/____Pods-Reachability-prefix.h +0 -5
  285. data/vendor/Pods/Pods-AFNetworking-Private.xcconfig +0 -5
  286. data/vendor/Pods/Pods-AFNetworking-dummy.m +0 -5
  287. data/vendor/Pods/Pods-AFNetworking-prefix.pch +0 -17
  288. data/vendor/Pods/Pods-AFNetworking.xcconfig +0 -1
  289. data/vendor/Pods/Pods-Reachability-Private.xcconfig +0 -5
  290. data/vendor/Pods/Pods-Reachability-dummy.m +0 -5
  291. data/vendor/Pods/Pods-Reachability-prefix.pch +0 -5
  292. data/vendor/Pods/Pods-Reachability.xcconfig +0 -1
  293. data/vendor/Pods/Reachability/LICENCE.txt +0 -24
  294. data/vendor/Pods/Reachability/README.md +0 -65
  295. data/vendor/Pods/Reachability/Reachability.h +0 -109
  296. data/vendor/Pods/Reachability/Reachability.m +0 -527
@@ -3,6 +3,26 @@ module Yapper::Document
3
3
  extend MotionSupport::Concern
4
4
 
5
5
  module ClassMethods
6
+ def all(options={})
7
+ Criteria.new(self, {}, options)
8
+ end
9
+
10
+ def where(criteria, options={})
11
+ Criteria.new(self, criteria, options)
12
+ end
13
+
14
+ def asc(*fields)
15
+ Criteria.new(self, {}, {}).sort(fields, :asc)
16
+ end
17
+
18
+ def desc(*fields)
19
+ Criteria.new(self, {}, {}).sort(fields, :desc)
20
+ end
21
+
22
+ def count
23
+ all.count
24
+ end
25
+
6
26
  def find(id)
7
27
  return nil if id.nil?
8
28
 
@@ -11,16 +31,6 @@ module Yapper::Document
11
31
  attrs ? object_for_attrs(attrs) : nil
12
32
  end
13
33
 
14
- def all(options={})
15
- results = []
16
- each_result_proc = proc do |key, attrs, stop|
17
- results << object_for_attrs(attrs)
18
- end
19
-
20
- db.execute { |txn| txn.enumerateKeysAndObjectsInCollection(self._type, usingBlock: each_result_proc) }
21
- results
22
- end
23
-
24
34
  def when(id, &block)
25
35
  observer = nil
26
36
  observer_block = proc do |data|
@@ -42,59 +52,117 @@ module Yapper::Document
42
52
  end
43
53
  end
44
54
 
45
- def where(criteria, options={})
46
- values = []; query_str = ''
47
-
48
- # Sort keys so that query string is always the same and is cached
49
- criteria.sort.each do |field, value|
50
- raise "#{field} is not indexed" if self.indexes[field].nil?
51
-
52
- query_str.blank? ? query_str = "WHERE " : query_str += " AND "
53
- query_str += "#{field} = ?"
54
-
55
- # XXX Casting should only happen if the type of the field allows for it
56
- value = case value.class.to_s
57
- when 'Time'
58
- value.to_i
59
- else
60
- value
61
- end
62
- values << value
63
- end
55
+ private
64
56
 
65
- options.each do |option, params|
66
- case option
67
- when :order
68
- params.each do |sort_field, direction|
69
- if query_str.include?("ORDER by")
70
- query_str += ", "
71
- else
72
- query_str += " ORDER by "
73
- end
74
- query_str += "#{sort_field} #{direction.upcase}"
75
- end
76
- else
77
- raise "#{option} not a valid option on #where"
78
- end
79
- end
57
+ def object_for_attrs(attrs)
58
+ Object.qualified_const_get(self._type).new(attrs.deep_dup, :new => false, :pristine => true)
59
+ end
60
+ end
61
+ end
80
62
 
81
- query = YapDatabaseQuery.alloc.initWithQueryString(query_str, queryParameters: values)
63
+ class Criteria
64
+ def initialize(klass, criteria, options)
65
+ @klass = klass
66
+ @criteria = criteria
67
+ @options = options
68
+ end
82
69
 
83
- results = []
84
- each_result_proc = proc do |collection, key, attrs, stop|
85
- results << object_for_attrs(attrs)
86
- end
70
+ def count
71
+ count_ptr = Pointer.new(:uint)
72
+ @klass.db.execute { |txn| txn.ext("#{@klass._type}_IDX").getNumberOfRows(count_ptr, matchingQuery: query) }
73
+ count_ptr.value
74
+ end
75
+
76
+ def first
77
+ asc(:id).limit(1).to_a.first
78
+ end
79
+
80
+ def last
81
+ desc(:id).limit(1).to_a.first
82
+ end
87
83
 
88
- db.execute { |txn| txn.ext("#{self._type}_IDX").enumerateKeysAndObjectsMatchingQuery(query, usingBlock: each_result_proc) }
84
+ def to_a
85
+ results = []
89
86
 
90
- results
87
+ each_result_proc = proc do |collection, key, attrs, stop|
88
+ results << object_for_attrs(attrs)
91
89
  end
92
90
 
93
- private
91
+ @klass.db.execute { |txn| txn.ext("#{@klass._type}_IDX").enumerateKeysAndObjectsMatchingQuery(query, usingBlock: each_result_proc) }
94
92
 
95
- def object_for_attrs(attrs)
96
- Object.qualified_const_get(self._type).new(attrs.deep_dup, :new => false, :pristine => true)
93
+ results
94
+ end
95
+
96
+ def each(&block)
97
+ to_a.each(&block)
98
+ end
99
+
100
+ def where(criteria)
101
+ self.class.new(@klass, @criteria.merge(criteria), @options)
102
+ end
103
+
104
+ def limit(limit)
105
+ self.class.new(@klass, @criteria, @options.merge(:limit => limit))
106
+ end
107
+
108
+ def sort(fields, direction)
109
+ order = @options[:order].to_a + fields.map { |f| [f,direction] }
110
+ self.class.new(@klass, @criteria, @options.merge(:order => order))
111
+ end
112
+
113
+ def asc(*fields)
114
+ sort(fields, :asc)
115
+ end
116
+
117
+ def desc(*fields)
118
+ sort(fields, :desc)
119
+ end
120
+
121
+ private
122
+
123
+ def query
124
+ values = []; query_str = ''
125
+
126
+ # Sort keys so that query string is always the same and is cached
127
+ @criteria.sort.each do |field, value|
128
+ raise "#{field} is not indexed" if @klass.indexes[field].nil?
129
+
130
+ query_str.blank? ? query_str = "WHERE " : query_str += " AND "
131
+ query_str += "#{field} = ?"
132
+
133
+ # XXX Casting should only happen if the type of the field allows for it
134
+ value = case value.class.to_s
135
+ when 'Time'
136
+ value.to_i
137
+ else
138
+ value
139
+ end
140
+ values << value
97
141
  end
142
+
143
+ @options.each do |option, params|
144
+ case option
145
+ when :order
146
+ params.each do |sort_field, direction|
147
+ if query_str.include?("ORDER by")
148
+ query_str += ", "
149
+ else
150
+ query_str += " ORDER by "
151
+ end
152
+ query_str += "#{sort_field} #{direction.upcase}"
153
+ end
154
+ when :limit
155
+ query_str += " LIMIT #{params}"
156
+ else
157
+ raise "#{option} not a valid option on #where"
158
+ end
159
+ end
160
+
161
+ YapDatabaseQuery.alloc.initWithQueryString(query_str, queryParameters: values)
162
+ end
163
+
164
+ def object_for_attrs(attrs)
165
+ Object.qualified_const_get(@klass._type).new(attrs.deep_dup, :new => false, :pristine => true)
98
166
  end
99
167
  end
100
168
  end
@@ -41,40 +41,28 @@ class Time
41
41
  end
42
42
  end
43
43
 
44
- class Object
45
- def as_json
46
- self
47
- end
48
- end
49
-
50
44
  class Hash
51
- def as_json
52
- hash = self.class.new
53
- self.each { |k,v| hash[k] = v.as_json }
54
- hash
55
- end
56
- end
57
-
58
- class NSDictionary
59
- def as_json
60
- to_hash.as_json
45
+ def to_canonical
46
+ self.keys.to_canonical + self.values.to_canonical
61
47
  end
62
48
  end
63
49
 
64
50
  class Array
65
- def as_json
66
- self.map { |v| v.as_json }
51
+ def to_canonical
52
+ self.map { |v| v.class.to_s == 'Class' ? v.to_s : v}.map(&:to_canonical).sort.join
67
53
  end
68
54
  end
69
55
 
70
- class NSArray
71
- def as_json
72
- self.map { |v| v.as_json }
56
+ class String
57
+ def to_canonical
58
+ self
73
59
  end
74
60
  end
75
61
 
76
- class Time
77
- def as_json
78
- self.to_iso8601
62
+ class Symbol
63
+ def to_canonical
64
+ to_s
79
65
  end
80
66
  end
67
+
68
+ class Boolean; end
@@ -0,0 +1,43 @@
1
+ motion_require 'yapper'
2
+
3
+ module Yapper::Settings
4
+ PREFIX = 'yapper-'
5
+ extend self
6
+
7
+ mattr_accessor :db_version
8
+
9
+ def get(key)
10
+ value = storage.objectForKey(storage_key(key))
11
+
12
+ # RubyMotion currently has a bug where the strings returned from
13
+ # standardUserDefaults are missing some methods (e.g. to_data).
14
+ # And because the returned object is slightly different than a normal
15
+ # String, we can't just use `value.is_a?(String)`
16
+ value.class.to_s == 'String' ? value.dup : value
17
+ end
18
+
19
+ def set(key, value)
20
+ storage.setObject(value, forKey: storage_key(key))
21
+ storage.synchronize
22
+ end
23
+
24
+ def delete(key)
25
+ storage.removeObjectForKey(storage_key(key))
26
+ storage.synchronize
27
+ end
28
+
29
+ def purge
30
+ storage.dictionaryRepresentation.keys.each { |key| self.delete(key.gsub(/^#{PREFIX}/,'')) if key =~ /^#{PREFIX}/ }
31
+ storage.synchronize
32
+ end
33
+
34
+ private
35
+
36
+ def storage_key(key)
37
+ "#{PREFIX}#{key}"
38
+ end
39
+
40
+ def storage
41
+ NSUserDefaults.standardUserDefaults
42
+ end
43
+ end
@@ -1,3 +1,5 @@
1
+ motion_require 'document.rb'
2
+
1
3
  module Yapper::Timestamps
2
4
  extend MotionSupport::Concern
3
5
 
@@ -1,3 +1,3 @@
1
1
  module Yapper
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
@@ -1,4 +1,4 @@
1
- describe '#where' do
1
+ describe 'Criteria' do
2
2
  before do
3
3
  class WhereDocument
4
4
  include Yapper::Document
@@ -6,8 +6,10 @@ describe '#where' do
6
6
  field :field1, :type => String
7
7
  field :field2, :type => Integer
8
8
  field :field3, :type => Time
9
+ field :field4, :type => String
10
+ field :field5, :type => Boolean
9
11
 
10
- index :field1, :field2, :field3
12
+ index :field1, :field2, :field3, :field5
11
13
  end
12
14
  class AnotherWhereDocument
13
15
  include Yapper::Document
@@ -22,16 +24,32 @@ describe '#where' do
22
24
  after { Object.send(:remove_const, 'WhereDocument') }
23
25
  after { Object.send(:remove_const, 'AnotherWhereDocument') }
24
26
 
27
+ describe 'when changing the index definition' do
28
+ it "reindexes the fields" do
29
+ WhereDocument.create(:field1 => 'field1', :field4 => 'field4')
30
+
31
+ lambda {
32
+ WhereDocument.where(:field4 => 'field4').first
33
+ }.should.raise
34
+
35
+ WhereDocument.class_eval do
36
+ index :field4
37
+ end
38
+
39
+ WhereDocument.where(:field4 => 'field4').count.should == 1
40
+ end
41
+ end
42
+
25
43
  describe 'with no documents created' do
26
44
  it 'returns []' do
27
- WhereDocument.where(:field1 => 'xxx').should == []
45
+ WhereDocument.where(:field1 => 'xxx').to_a.should == []
28
46
  end
29
47
  end
30
48
 
31
49
  describe 'when searching with a non indexed field' do
32
50
  it 'raises' do
33
51
  lambda {
34
- AnotherWhereDocument.where(:field2 => 'xxx')
52
+ AnotherWhereDocument.where(:field2 => 'xxx').first
35
53
  }.should.raise
36
54
  end
37
55
  end
@@ -42,10 +60,54 @@ describe '#where' do
42
60
  WhereDocument.create(:field1 => 'field1_value', :field2 => 2)
43
61
  WhereDocument.create(:field1 => 'field1_value', :field2 => 3)
44
62
  WhereDocument.create(:field1 => 'field1_value', :field2 => 4)
63
+ WhereDocument.create(:field1 => 'field1_other_value', :field2 => 1)
45
64
  WhereDocument.create(:field1 => 'field1_other_value', :field2 => 2, :field3 => @now)
65
+ WhereDocument.create(:field5 => true)
46
66
  AnotherWhereDocument.create(:field1 => 'field1_value', :field2 => 2)
47
67
  end
48
68
 
69
+ describe '#all' do
70
+ it 'returns all documents' do
71
+ WhereDocument.all.to_a.count.should == 6
72
+ end
73
+
74
+ describe 'with a document that has no indexes' do
75
+ before do
76
+ class NoIndexDocument
77
+ include Yapper::Document
78
+
79
+ field :field1
80
+ end
81
+ end
82
+
83
+ it 'still returns' do
84
+ NoIndexDocument.all.count.should == 0
85
+ NoIndexDocument.all.to_a.count.should == 0
86
+ end
87
+ end
88
+ end
89
+
90
+ describe '#count' do
91
+ it 'returns all documents' do
92
+ WhereDocument.count.should == 6
93
+ end
94
+ end
95
+
96
+ describe 'chaining' do
97
+ it 'where, all' do
98
+ WhereDocument.all.where(:field1 => 'field1_value').where(:field2 => 2).count.should == 1
99
+ end
100
+
101
+ it 'where, desc, asc' do
102
+ WhereDocument.where(:field1 => 'field1_value').asc(:field2).first.field2.should == 2
103
+ end
104
+
105
+ it 'desc, asc' do
106
+ WhereDocument.where(:field1 => 'field1_value').desc(:field1).desc(:field2).first.field2.should == 4
107
+ WhereDocument.where(:field1 => 'field1_value').desc(:field1).asc(:field2).first.field2.should == 2
108
+ end
109
+ end
110
+
49
111
  it 'can search by string' do
50
112
  WhereDocument.where(:field1 => 'field1_value').count.should == 3
51
113
  end
@@ -58,12 +120,17 @@ describe '#where' do
58
120
  WhereDocument.where(:field3 => @now).count.should == 1
59
121
  end
60
122
 
123
+ it 'can search by boolean' do
124
+ WhereDocument.where(:field5 => true).count.should == 1
125
+ WhereDocument.where(:field5 => false).count.should == 0
126
+ end
127
+
61
128
  it 'returns [] when looking up a non-existant doc' do
62
- WhereDocument.where(:field1 => 'xxx').should == []
129
+ WhereDocument.where(:field1 => 'xxx').to_a.should == []
63
130
  end
64
131
 
65
132
  it 'can select docments matching on multiple fields' do
66
- WhereDocument.where(:field1 => 'field1_value', :field2 => 2).count.should == 1
133
+ WhereDocument.where(:field1 => 'field1_value', :field2 => 2).to_a.count.should == 1
67
134
  end
68
135
 
69
136
  describe 'when documents are updated' do
@@ -104,13 +171,14 @@ describe '#where' do
104
171
  WhereDocument.create(:field1 => 'apple')
105
172
  WhereDocument.create(:field1 => 'squash')
106
173
  WhereDocument.create(:field1 => 'carrot')
174
+ WhereDocument.create(:field1 => nil)
107
175
  end
108
176
  it 'can sort documents ascending' do
109
- WhereDocument.where({}, :order => { :field1 => :asc }).collect(&:field1).should == ['apple', 'carrot', 'squash']
177
+ WhereDocument.asc(:field1).to_a.collect(&:field1).should == [nil, 'apple', 'carrot', 'squash']
110
178
  end
111
179
 
112
180
  it 'can sort documents descending' do
113
- WhereDocument.where({}, :order => { :field1 => :desc }).collect(&:field1).should == ['squash', 'carrot', 'apple']
181
+ WhereDocument.desc(:field1).to_a.collect(&:field1).should == ['squash', 'carrot', 'apple', nil]
114
182
  end
115
183
  end
116
184
 
@@ -121,11 +189,11 @@ describe '#where' do
121
189
  WhereDocument.create(:field3 => Time.utc(2013,1,1,14,00))
122
190
  end
123
191
  it 'can sort documents ascending' do
124
- WhereDocument.where({}, :order => { :field3 => :asc }).collect(&:field3).should == [Time.utc(2013,1,1,9,00), Time.utc(2013,1,1,10,00), Time.utc(2013,1,1,14,00)]
192
+ WhereDocument.asc(:field3).to_a.collect(&:field3).should == [Time.utc(2013,1,1,9,00), Time.utc(2013,1,1,10,00), Time.utc(2013,1,1,14,00)]
125
193
  end
126
194
 
127
195
  it 'can sort documents descending' do
128
- WhereDocument.where({}, :order => { :field3 => :desc }).collect(&:field3).should == [Time.utc(2013,1,1,14,00), Time.utc(2013,1,1,10,00), Time.utc(2013,1,1,9,00)]
196
+ WhereDocument.desc(:field3).to_a.collect(&:field3).should == [Time.utc(2013,1,1,14,00), Time.utc(2013,1,1,10,00), Time.utc(2013,1,1,9,00)]
129
197
  end
130
198
  end
131
199
  end