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
@@ -23,6 +23,9 @@
23
23
  **/
24
24
  #define YAP_DATABASE_VIEW_CLASS_VERSION 3
25
25
 
26
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
27
+ #pragma mark -
28
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
26
29
 
27
30
  @interface YapDatabaseView () {
28
31
  @public
@@ -32,7 +35,7 @@
32
35
  YapDatabaseViewBlockType groupingBlockType;
33
36
  YapDatabaseViewBlockType sortingBlockType;
34
37
 
35
- int version;
38
+ NSString *versionTag;
36
39
 
37
40
  YapDatabaseViewOptions *options;
38
41
  }
@@ -103,6 +106,8 @@
103
106
  YapMemoryTableTransaction *pageTableTransaction;
104
107
  YapMemoryTableTransaction *pageMetadataTableTransaction;
105
108
 
109
+ BOOL isRepopulate;
110
+
106
111
  @protected
107
112
 
108
113
  __unsafe_unretained YapDatabaseViewConnection *viewConnection;
@@ -116,6 +121,7 @@
116
121
 
117
122
  // The following are declared for view subclasses (such as YapDatabaseFilteredView)
118
123
 
124
+ - (void)dropTablesForOldClassVersion:(int)oldClassVersion;
119
125
  - (BOOL)createTables;
120
126
 
121
127
  - (NSString *)registeredName;
@@ -151,3 +157,14 @@
151
157
  usingBlock:(void (^)(int64_t rowid, NSUInteger index, BOOL *stop))block;
152
158
 
153
159
  @end
160
+
161
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
162
+ #pragma mark -
163
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
164
+
165
+ @protocol YapDatabaseViewDependency <NSObject>
166
+ @optional
167
+
168
+ - (void)viewDidRepopulate:(NSString *)registeredName;
169
+
170
+ @end
@@ -86,8 +86,8 @@ typedef enum {
86
86
  *
87
87
  * YapDatabaseViewChangedMetadata means the metadata was changed.
88
88
  * This might have happend implicitly if the user invoked setObject:forKey:inCollection: (implicitly setting
89
- * the meatadata to nil). Or explicitly if the user invoked setObject:forKey:inCollection:withMetadata: or
90
- * setMetadata:forKey:inCollection:.
89
+ * the metadata to nil). Or explicitly if the user invoked setObject:forKey:inCollection:withMetadata: or
90
+ * replaceMetadata:forKey:inCollection:.
91
91
  *
92
92
  * YapDatabaseViewChangedDependency means the row was flagged due to a cell drawing dependency configuration.
93
93
  * See YapDatabaseViewMappings: setCellDrawingDependencyForNeighboringCellWithOffset:forGroup:
@@ -369,8 +369,9 @@
369
369
  NSMutableArray *sectionChanges = [NSMutableArray arrayWithCapacity:1];
370
370
  NSMutableArray *rowChanges = [NSMutableArray arrayWithCapacity:[changes count]];
371
371
 
372
- NSSet *groups = [NSSet setWithArray:[originalMappings allGroups]];
373
-
372
+ NSSet *originalGroups = [NSSet setWithArray:[originalMappings allGroups]];
373
+ NSSet *finalGroups = [NSSet setWithArray:[finalMappings allGroups]];
374
+
374
375
  NSMutableDictionary *counts = [originalMappings counts];
375
376
  NSDictionary *dependencies = [originalMappings dependencies];
376
377
 
@@ -383,7 +384,7 @@
383
384
 
384
385
  if (immutableSectionChange->type == YapDatabaseViewChangeDelete)
385
386
  {
386
- if ([groups containsObject:immutableSectionChange->group])
387
+ if ([originalGroups containsObject:immutableSectionChange->group])
387
388
  {
388
389
  YapDatabaseViewSectionChange *sectionChange = [immutableSectionChange copy];
389
390
  [sectionChanges addObject:sectionChange];
@@ -449,7 +450,7 @@
449
450
  }
450
451
  else if (immutableSectionChange->type == YapDatabaseViewChangeInsert)
451
452
  {
452
- if ([groups containsObject:immutableSectionChange->group])
453
+ if ([finalGroups containsObject:immutableSectionChange->group])
453
454
  {
454
455
  YapDatabaseViewSectionChange *sectionChange = [immutableSectionChange copy];
455
456
  [sectionChanges addObject:sectionChange];
@@ -464,10 +465,10 @@
464
465
  NSUInteger groupCount = 0;
465
466
  NSUInteger groupIndex = 0;
466
467
  BOOL wasDelete = 0;
467
-
468
+
468
469
  if (immutableRowChange->type == YapDatabaseViewChangeDelete)
469
470
  {
470
- if ([groups containsObject:immutableRowChange->originalGroup])
471
+ if ([originalGroups containsObject:immutableRowChange->originalGroup])
471
472
  {
472
473
  YapDatabaseViewRowChange *rowChange = [immutableRowChange copy];
473
474
  [rowChanges addObject:rowChange];
@@ -484,7 +485,7 @@
484
485
  }
485
486
  else if (immutableRowChange->type == YapDatabaseViewChangeInsert)
486
487
  {
487
- if ([groups containsObject:immutableRowChange->finalGroup])
488
+ if ([finalGroups containsObject:immutableRowChange->finalGroup])
488
489
  {
489
490
  YapDatabaseViewRowChange *rowChange = [immutableRowChange copy];
490
491
  [rowChanges addObject:rowChange];
@@ -499,7 +500,7 @@
499
500
  }
500
501
  else if (immutableRowChange->type == YapDatabaseViewChangeUpdate)
501
502
  {
502
- if ([groups containsObject:immutableRowChange->originalGroup])
503
+ if ([finalGroups containsObject:immutableRowChange->originalGroup])
503
504
  {
504
505
  YapDatabaseViewRowChange *rowChange = [immutableRowChange copy];
505
506
  [rowChanges addObject:rowChange];
@@ -813,6 +814,7 @@
813
814
  firstChangeForKey->type = YapDatabaseViewChangeMove;
814
815
  firstChangeForKey->finalIndex = lastChangeForKey->finalIndex;
815
816
  firstChangeForKey->finalGroup = lastChangeForKey->finalGroup;
817
+ firstChangeForKey->opFinalIndex = lastChangeForKey->opFinalIndex; // for postProcessing
816
818
 
817
819
  [changes removeObjectsAtIndexes:indexSet];
818
820
  i++;
@@ -833,6 +835,7 @@
833
835
  firstChangeForKey->type = YapDatabaseViewChangeMove;
834
836
  firstChangeForKey->finalIndex = lastChangeForKey->finalIndex;
835
837
  firstChangeForKey->finalGroup = lastChangeForKey->finalGroup;
838
+ firstChangeForKey->opFinalIndex = lastChangeForKey->opFinalIndex; // for postProcessing
836
839
 
837
840
  [changes removeObjectsAtIndexes:indexSet];
838
841
  i++;
@@ -848,7 +851,6 @@
848
851
 
849
852
  [changes removeObjectsAtIndexes:indexSet];
850
853
  [changes removeObjectAtIndex:i];
851
-
852
854
  }
853
855
  else if (lastChangeForKey->type == YapDatabaseViewChangeInsert)
854
856
  {
@@ -901,10 +903,13 @@
901
903
  // then the tableView/collectionView will offset the update's index
902
904
  // based on insertions & deletions at smaller indexes,
903
905
  // and may ultimately update the wrong cell.
906
+ //
907
+ // The final location comes from the last update
904
908
 
905
909
  firstChangeForKey->type = YapDatabaseViewChangeMove;
906
910
  firstChangeForKey->finalIndex = lastChangeForKey->finalIndex;
907
911
  firstChangeForKey->finalGroup = lastChangeForKey->finalGroup;
912
+ firstChangeForKey->opFinalIndex = lastChangeForKey->opFinalIndex; // for postProcessing
908
913
 
909
914
  [changes removeObjectsAtIndexes:indexSet];
910
915
  i++;
@@ -947,6 +952,7 @@
947
952
  firstChangeForKey->type = YapDatabaseViewChangeMove;
948
953
  firstChangeForKey->finalIndex = lastChangeForKey->finalIndex;
949
954
  firstChangeForKey->finalGroup = lastChangeForKey->finalGroup;
955
+ firstChangeForKey->opFinalIndex = lastChangeForKey->opFinalIndex; // for postProcessing
950
956
 
951
957
  [changes removeObjectsAtIndexes:indexSet];
952
958
  i++;
@@ -173,6 +173,8 @@ struct YapDatabaseViewRangePosition {
173
173
  };
174
174
  typedef struct YapDatabaseViewRangePosition YapDatabaseViewRangePosition;
175
175
 
176
+ typedef BOOL (^YapDatabaseViewMappingGroupFilter)(NSString *group, YapDatabaseReadTransaction *transaction);
177
+ typedef NSComparisonResult (^YapDatabaseViewMappingGroupSort)(NSString *group1, NSString *group2, YapDatabaseReadTransaction *transaction);
176
178
 
177
179
  @interface YapDatabaseViewMappings : NSObject <NSCopying>
178
180
 
@@ -203,6 +205,21 @@ typedef struct YapDatabaseViewRangePosition YapDatabaseViewRangePosition;
203
205
  - (id)initWithGroups:(NSArray *)allGroups
204
206
  view:(NSString *)registeredViewName;
205
207
 
208
+
209
+ /**
210
+ * Initializes a new mappings object that uses a filterBlock and a sortBlock to dynamically construct sections from view.
211
+ * @param filterBlock
212
+ * Block that takes a string and returns a BOOL. returning YES will include the group in the sections of the mapping.
213
+ * @param sortBlock
214
+ * Block used to sort group names for groups that pass the filter.
215
+ * @param registeredViewName
216
+ * This is the name of the view, as you registered it with the database system.
217
+ *
218
+ **/
219
+ - (id)initWithGroupFilterBlock:(YapDatabaseViewMappingGroupFilter)filterBlock
220
+ sortBlock:(YapDatabaseViewMappingGroupSort)sortBlock
221
+ view:(NSString *)registeredViewName;
222
+
206
223
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
207
224
  #pragma mark Accessors
208
225
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -24,15 +24,21 @@
24
24
  @implementation YapDatabaseViewMappings
25
25
  {
26
26
  // Immutable init parameters
27
- NSArray *allGroups;
28
27
  NSString *registeredViewName;
29
-
28
+
29
+ NSArray *allGroups;
30
+
31
+ BOOL viewGroupsAreDynamic;
32
+ YapDatabaseViewMappingGroupFilter groupFilterBlock;
33
+ YapDatabaseViewMappingGroupSort groupSort;
34
+
30
35
  // Mappings and cached counts
31
36
  NSMutableArray *visibleGroups;
32
37
  NSMutableDictionary *counts;
33
38
  BOOL isUsingConsolidatedGroup;
34
39
  BOOL autoConsolidationDisabled;
35
-
40
+ BOOL isDynamicSectionForAllGroups;
41
+
36
42
  // Configuration
37
43
  NSMutableSet *dynamicSections;
38
44
  NSMutableSet *reverse;
@@ -60,38 +66,64 @@
60
66
  {
61
67
  if ((self = [super init]))
62
68
  {
63
- allGroups = [[NSArray alloc] initWithArray:inGroups copyItems:YES];
64
- registeredViewName = [inRegisteredViewName copy];
65
-
69
+ allGroups = [[NSArray alloc] initWithArray:inGroups copyItems:YES];
66
70
  NSUInteger allGroupsCount = [allGroups count];
71
+ viewGroupsAreDynamic = NO;
67
72
 
68
73
  visibleGroups = [[NSMutableArray alloc] initWithCapacity:allGroupsCount];
69
-
70
74
  dynamicSections = [[NSMutableSet alloc] initWithCapacity:allGroupsCount];
71
75
  reverse = [[NSMutableSet alloc] initWithCapacity:allGroupsCount];
72
76
 
73
77
  id sharedKeySet = [NSDictionary sharedKeySetForKeys:allGroups];
74
-
75
78
  counts = [NSMutableDictionary dictionaryWithSharedKeySet:sharedKeySet];
76
- rangeOptions = [NSMutableDictionary dictionaryWithSharedKeySet:sharedKeySet];
77
- dependencies = [NSMutableDictionary dictionaryWithSharedKeySet:sharedKeySet];
79
+ rangeOptions = [NSMutableDictionary dictionaryWithCapacity:allGroupsCount];
80
+ dependencies = [NSMutableDictionary dictionaryWithCapacity:allGroupsCount];
78
81
 
79
- snapshotOfLastUpdate = UINT64_MAX;
82
+ [self _initWithView:inRegisteredViewName];
83
+
80
84
  }
81
85
  return self;
82
86
  }
83
87
 
88
+ - (id)initWithGroupFilterBlock:(YapDatabaseViewMappingGroupFilter)inFilter sortBlock:(YapDatabaseViewMappingGroupSort)inSort view:(NSString *)inRegisteredViewName{
89
+ if (self = [super init]){
90
+ groupFilterBlock = inFilter;
91
+ groupSort = inSort;
92
+ viewGroupsAreDynamic = YES;
93
+
94
+ //we don't know what our capacity is going to be yet.
95
+ visibleGroups = [NSMutableArray new];
96
+ dynamicSections = [NSMutableSet new];
97
+ reverse = [NSMutableSet new];
98
+ rangeOptions = [NSMutableDictionary new];
99
+ dependencies = [NSMutableDictionary new];
100
+
101
+ [self _initWithView:inRegisteredViewName];
102
+ }
103
+ return self;
104
+ }
105
+
106
+ - (void)_initWithView:(NSString *)inRegisteredViewName{
107
+ registeredViewName = [inRegisteredViewName copy];
108
+ snapshotOfLastUpdate = UINT64_MAX;
109
+ }
110
+
84
111
  - (id)copyWithZone:(NSZone *)zone
85
112
  {
86
113
  YapDatabaseViewMappings *copy = [[YapDatabaseViewMappings alloc] init];
87
114
  copy->allGroups = allGroups;
88
115
  copy->registeredViewName = registeredViewName;
116
+
117
+ copy->viewGroupsAreDynamic = viewGroupsAreDynamic;
118
+ copy->groupFilterBlock = groupFilterBlock;
119
+ copy->groupSort = groupSort;
89
120
 
90
121
  copy->visibleGroups = [visibleGroups mutableCopy];
91
122
  copy->counts = [counts mutableCopy];
92
123
  copy->isUsingConsolidatedGroup = isUsingConsolidatedGroup;
93
124
  copy->autoConsolidationDisabled = autoConsolidationDisabled;
94
125
 
126
+ copy->isDynamicSectionForAllGroups = isDynamicSectionForAllGroups;
95
127
  copy->dynamicSections = [dynamicSections mutableCopy];
96
128
  copy->reverse = [reverse mutableCopy];
97
129
  copy->rangeOptions = [rangeOptions mutableCopy];
@@ -110,20 +142,21 @@
110
142
 
111
143
  - (void)setIsDynamicSectionForAllGroups:(BOOL)isDynamic
112
144
  {
113
- if (isDynamic)
114
- [dynamicSections addObjectsFromArray:allGroups];
115
- else
116
- [dynamicSections removeAllObjects];
145
+ isDynamicSectionForAllGroups = isDynamic;
117
146
  }
118
147
 
119
148
  - (BOOL)isDynamicSectionForAllGroups
120
149
  {
121
- return ([dynamicSections count] == [allGroups count]);
150
+ return isDynamicSectionForAllGroups;
151
+ }
152
+
153
+ - (BOOL)isGroupNameValid:(NSString *)group{
154
+ return viewGroupsAreDynamic || [allGroups containsObject:group];
122
155
  }
123
156
 
124
157
  - (void)setIsDynamicSection:(BOOL)isDynamic forGroup:(NSString *)group
125
158
  {
126
- if (![allGroups containsObject:group]) {
159
+ if (![self isGroupNameValid:group]) {
127
160
  YDBLogWarn(@"%@ - mappings doesn't contain group(%@), only: %@", THIS_METHOD, group, allGroups);
128
161
  return;
129
162
  }
@@ -145,8 +178,8 @@
145
178
  [self removeRangeOptionsForGroup:group];
146
179
  return;
147
180
  }
148
-
149
- if (![allGroups containsObject:group]) {
181
+
182
+ if (![self isGroupNameValid:group]){
150
183
  YDBLogWarn(@"%@ - mappings doesn't contain group(%@), only: %@", THIS_METHOD, group, allGroups);
151
184
  return;
152
185
  }
@@ -196,7 +229,8 @@
196
229
 
197
230
  - (void)setCellDrawingDependencyOffsets:(NSSet *)offsets forGroup:(NSString *)group
198
231
  {
199
- if (![allGroups containsObject:group]) {
232
+
233
+ if (![self isGroupNameValid:group]){
200
234
  YDBLogWarn(@"%@ - mappings doesn't contain group(%@), only: %@", THIS_METHOD, group, allGroups);
201
235
  return;
202
236
  }
@@ -249,7 +283,7 @@
249
283
 
250
284
  - (void)setIsReversed:(BOOL)isReversed forGroup:(NSString *)group
251
285
  {
252
- if (![allGroups containsObject:group]) {
286
+ if (![self isGroupNameValid:group]){
253
287
  YDBLogWarn(@"%@ - mappings doesn't contain group(%@), only: %@", THIS_METHOD, group, allGroups);
254
288
  return;
255
289
  }
@@ -267,24 +301,9 @@
267
301
 
268
302
  - (void)setAutoConsolidateGroupsThreshold:(NSUInteger)threshold withName:(NSString *)inConsolidatedGroupName
269
303
  {
270
- if ([allGroups containsObject:inConsolidatedGroupName])
271
- {
272
- YDBLogWarn(@"%@ - consolidatedGroupName cannot match existing groupName", THIS_METHOD);
273
-
274
- autoConsolidateGroupsThreshold = 0;
275
- consolidatedGroupName = nil;
276
- }
277
-
278
- if (inConsolidatedGroupName == nil || threshold == 0)
279
- {
280
- autoConsolidateGroupsThreshold = 0;
281
- consolidatedGroupName = nil;
282
- }
283
- else
284
- {
285
- autoConsolidateGroupsThreshold = threshold;
286
- consolidatedGroupName = [inConsolidatedGroupName copy];
287
- }
304
+ autoConsolidateGroupsThreshold = threshold;
305
+ consolidatedGroupName = [inConsolidatedGroupName copy];
306
+ [self validateAutoConsolidation];
288
307
  }
289
308
 
290
309
  - (NSUInteger)autoConsolidateGroupsThreshold
@@ -343,9 +362,18 @@
343
362
  @throw [NSException exceptionWithName:@"YapDatabaseException" reason:reason userInfo:userInfo];
344
363
  }
345
364
 
365
+ YapDatabaseViewTransaction *viewTransaction = [transaction ext:registeredViewName];
366
+ if (viewGroupsAreDynamic)
367
+ {
368
+ NSArray *newGroups = [self filterAndSortGroups:[viewTransaction allGroups] withTransaction:transaction];
369
+ if ([self shouldUpdateAllGroupsWithNewGroups:newGroups]) {
370
+ [self updateMappingsWithNewGroups:newGroups];
371
+ }
372
+ }
373
+
346
374
  for (NSString *group in allGroups)
347
375
  {
348
- NSUInteger count = [[transaction ext:registeredViewName] numberOfKeysInGroup:group];
376
+ NSUInteger count = [viewTransaction numberOfKeysInGroup:group];
349
377
 
350
378
  [counts setObject:@(count) forKey:group];
351
379
  }
@@ -359,12 +387,66 @@
359
387
  [self updateVisibility];
360
388
  }
361
389
 
390
+ - (void)updateMappingsWithNewGroups:(NSArray *)newAllGroups
391
+ {
392
+ allGroups = [newAllGroups copy];
393
+ [self validateAutoConsolidation];
394
+ id sharedKeySet = [NSDictionary sharedKeySetForKeys:allGroups];
395
+ counts = [NSMutableDictionary dictionaryWithSharedKeySet:sharedKeySet];
396
+ }
397
+
398
+ - (void)validateAutoConsolidation{
399
+ if ([allGroups containsObject:consolidatedGroupName]){
400
+ YDBLogWarn(@"%@ - consolidatedGroupName cannot match existing groupName", THIS_METHOD);
401
+ consolidatedGroupName = nil;
402
+ autoConsolidateGroupsThreshold = 0;
403
+ }
404
+
405
+ if (consolidatedGroupName == nil || autoConsolidateGroupsThreshold == 0){
406
+ consolidatedGroupName = nil;
407
+ autoConsolidateGroupsThreshold = 0;
408
+ }
409
+ }
410
+
411
+ - (NSArray *)filterAndSortGroups:(NSArray *)groups withTransaction:(YapDatabaseReadTransaction *)transaction
412
+ {
413
+ NSMutableArray *newAllGroups = [NSMutableArray arrayWithCapacity:[groups count]];
414
+ for (NSString *group in groups)
415
+ {
416
+ if (groupFilterBlock(group, transaction)) {
417
+ [newAllGroups addObject:group];
418
+ }
419
+ }
420
+
421
+ [newAllGroups sortUsingComparator:^NSComparisonResult(id obj1, id obj2) {
422
+
423
+ return groupSort(obj1, obj2, transaction);
424
+ }];
425
+
426
+ return [newAllGroups copy];
427
+ }
428
+
429
+ - (BOOL)shouldUpdateAllGroupsWithNewGroups:(NSArray *)newGroups{
430
+ return ![allGroups isEqualToArray:newGroups];
431
+ }
432
+
433
+
362
434
  /**
363
435
  * This method is internal.
364
436
  * It is only for use by the unit tests in TestViewChangeLogic.
365
437
  **/
366
438
  - (void)updateWithCounts:(NSDictionary *)newCounts
367
439
  {
440
+ if (viewGroupsAreDynamic)
441
+ {
442
+ // The groups passed in the dictionary represent the new allGroups.
443
+ // This simulates as if we ran the groupFilterBlock & groupSortBlock.
444
+
445
+ NSArray *newGroups = [newCounts allKeys];
446
+ if ([self shouldUpdateAllGroupsWithNewGroups:newGroups]) {
447
+ [self updateMappingsWithNewGroups:newGroups];
448
+ }
449
+ }
368
450
  for (NSString *group in allGroups)
369
451
  {
370
452
  NSUInteger count = [[newCounts objectForKey:group] unsignedIntegerValue];
@@ -441,7 +523,7 @@
441
523
  else
442
524
  count = [[counts objectForKey:group] unsignedIntegerValue];
443
525
 
444
- if (count > 0 || ![dynamicSections containsObject:group]) {
526
+ if (count > 0 || ![self isGroupDynamic:group]) {
445
527
  [visibleGroups addObject:group];
446
528
  }
447
529
 
@@ -454,6 +536,13 @@
454
536
  isUsingConsolidatedGroup = NO;
455
537
  }
456
538
 
539
+ -(BOOL)isGroupDynamic:(NSString *)group{
540
+ if (!isDynamicSectionForAllGroups){
541
+ return [dynamicSections containsObject:group];
542
+ }
543
+ return YES;
544
+ }
545
+
457
546
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
458
547
  #pragma mark Internal
459
548
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -528,8 +617,13 @@
528
617
  * Returns the number of items in the given group.
529
618
  *
530
619
  * This is the cached value from the last time one of the following methods was invoked:
531
- * - updateWithTransaction:
532
- * - changesForNotifications:withMappings:
620
+ * - updateWithTransaction:
621
+ * which should be invoked when the mapping is first created and then will be invoked whenever
622
+ * - (void)getSectionChanges:(NSArray **)sectionChangesPtr
623
+ * rowChanges:(NSArray **)rowChangesPtr
624
+ * forNotifications:(NSArray *)notifications
625
+ * withMappings:(YapDatabaseViewMappings *)mappings
626
+ * is called on the associated registered YapDatabaseView.
533
627
  **/
534
628
  - (NSUInteger)numberOfItemsInGroup:(NSString *)group
535
629
  {
@@ -1124,6 +1218,8 @@
1124
1218
  return NO;
1125
1219
  }
1126
1220
 
1221
+ //- (NSUInteger)groupOffsetForGroup:
1222
+
1127
1223
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1128
1224
  #pragma mark Getters + RangeOptions
1129
1225
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1274,6 +1370,33 @@
1274
1370
  return total;
1275
1371
  }
1276
1372
 
1373
+ /**
1374
+ * When isUsingConsolidatedGroup, this method returns the offset of the given group
1375
+ * within the flattened/consolidated group.
1376
+ **/
1377
+ - (NSUInteger)rowOffsetForGroup:(NSString *)searchGroup
1378
+ {
1379
+ NSUInteger offset = 0;
1380
+
1381
+ for (NSString *group in visibleGroups) // NOT [self visibleGroups]
1382
+ {
1383
+ if ([group isEqualToString:searchGroup])
1384
+ {
1385
+ return offset;
1386
+ }
1387
+ else
1388
+ {
1389
+ YapDatabaseViewRangeOptions *rangeOpts = [rangeOptions objectForKey:group];
1390
+ if (rangeOpts)
1391
+ offset += rangeOpts.length;
1392
+ else
1393
+ offset += [[counts objectForKey:group] unsignedIntegerValue];
1394
+ }
1395
+ }
1396
+
1397
+ return 0;
1398
+ }
1399
+
1277
1400
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1278
1401
  #pragma mark Getters + Utilities
1279
1402
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1390,7 +1513,16 @@
1390
1513
  groupIndex++;
1391
1514
  }
1392
1515
 
1393
- if (!foundGroup) return nil;
1516
+ if (!foundGroup)
1517
+ {
1518
+ // The given group doesn't exist.
1519
+ //
1520
+ // Note: You should NOT be passing the consolidatedGroup to this method.
1521
+ // You need to pass the proper database view group.
1522
+ // If the mappings are consolidated, this method will automatically translate the result for you.
1523
+
1524
+ return nil;
1525
+ }
1394
1526
 
1395
1527
  BOOL isGroupVisible = NO;
1396
1528
  NSUInteger visibleGroupIndex = 0;
@@ -1412,24 +1544,21 @@
1412
1544
  NSUInteger rows = [self numberOfItemsInGroup:searchGroup];
1413
1545
  if (rows > 0)
1414
1546
  {
1415
- if (row < rows)
1416
- {
1417
- #if TARGET_OS_IPHONE
1418
- return [NSIndexPath indexPathForRow:row inSection:visibleGroupIndex];
1419
- #else
1420
- NSUInteger indexes[] = {visibleGroupIndex, row};
1421
- return [NSIndexPath indexPathWithIndexes:indexes length:2];
1422
- #endif
1423
- }
1424
- else
1547
+ NSUInteger _row = (row < rows) ? row : rows-1;
1548
+ NSUInteger _section = visibleGroupIndex;
1549
+
1550
+ if (isUsingConsolidatedGroup)
1425
1551
  {
1426
- #if TARGET_OS_IPHONE
1427
- return [NSIndexPath indexPathForRow:(rows-1) inSection:visibleGroupIndex];
1428
- #else
1429
- NSUInteger indexes[] = {visibleGroupIndex, (rows-1)};
1430
- return [NSIndexPath indexPathWithIndexes:indexes length:2];
1431
- #endif
1552
+ _row += [self rowOffsetForGroup:searchGroup];
1553
+ _section = 0;
1432
1554
  }
1555
+
1556
+ #if TARGET_OS_IPHONE
1557
+ return [NSIndexPath indexPathForRow:_row inSection:_section];
1558
+ #else
1559
+ NSUInteger indexes[] = {_section, _row};
1560
+ return [NSIndexPath indexPathWithIndexes:indexes length:2];
1561
+ #endif
1433
1562
  }
1434
1563
  }
1435
1564
 
@@ -1449,10 +1578,19 @@
1449
1578
  NSUInteger rows = [self numberOfItemsInGroup:nearbyGroup];
1450
1579
  if (rows > 0)
1451
1580
  {
1581
+ NSUInteger _row = rows-1;
1582
+ NSUInteger _section = section;
1583
+
1584
+ if (isUsingConsolidatedGroup)
1585
+ {
1586
+ _row += [self rowOffsetForGroup:nearbyGroup];
1587
+ _section = 0;
1588
+ }
1589
+
1452
1590
  #if TARGET_OS_IPHONE
1453
- return [NSIndexPath indexPathForRow:(rows-1) inSection:section];
1591
+ return [NSIndexPath indexPathForRow:_row inSection:_section];
1454
1592
  #else
1455
- NSUInteger indexes[] = {section, (rows-1)};
1593
+ NSUInteger indexes[] = {_section, _row};
1456
1594
  return [NSIndexPath indexPathWithIndexes:indexes length:2];
1457
1595
  #endif
1458
1596
  }
@@ -1473,10 +1611,19 @@
1473
1611
  NSUInteger rows = [self numberOfItemsInGroup:nearbyGroup];
1474
1612
  if (rows > 0)
1475
1613
  {
1614
+ NSUInteger _row = 0;
1615
+ NSUInteger _section = section;
1616
+
1617
+ if (isUsingConsolidatedGroup)
1618
+ {
1619
+ _row += [self rowOffsetForGroup:nearbyGroup];
1620
+ _section = 0;
1621
+ }
1622
+
1476
1623
  #if TARGET_OS_IPHONE
1477
- return [NSIndexPath indexPathForRow:0 inSection:section];
1624
+ return [NSIndexPath indexPathForRow:_row inSection:_section];
1478
1625
  #else
1479
- NSUInteger indexes[] = {section, 0};
1626
+ NSUInteger indexes[] = {_section, _row};
1480
1627
  return [NSIndexPath indexPathWithIndexes:indexes length:2];
1481
1628
  #endif
1482
1629
  }