motion-yapper 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (348) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +20 -0
  3. data/.travis.yml +6 -0
  4. data/Gemfile +5 -0
  5. data/Gemfile.lock +63 -0
  6. data/README.md +16 -0
  7. data/Rakefile +20 -0
  8. data/app/app_delegate.rb +5 -0
  9. data/lib/yapper.rb +30 -0
  10. data/lib/yapper/attachment.rb +48 -0
  11. data/lib/yapper/bson.rb +20 -0
  12. data/lib/yapper/config.rb +18 -0
  13. data/lib/yapper/db.rb +151 -0
  14. data/lib/yapper/document.rb +54 -0
  15. data/lib/yapper/document/attachment.rb +26 -0
  16. data/lib/yapper/document/callbacks.rb +86 -0
  17. data/lib/yapper/document/persistance.rb +171 -0
  18. data/lib/yapper/document/relation.rb +84 -0
  19. data/lib/yapper/document/selection.rb +100 -0
  20. data/lib/yapper/extensions.rb +80 -0
  21. data/lib/yapper/log.rb +5 -0
  22. data/lib/yapper/sync.rb +134 -0
  23. data/lib/yapper/sync/data.rb +12 -0
  24. data/lib/yapper/sync/event.rb +194 -0
  25. data/lib/yapper/sync/queue.rb +164 -0
  26. data/lib/yapper/timestamps.rb +16 -0
  27. data/lib/yapper/version.rb +3 -0
  28. data/lib/yapper/yapper.rb +2 -0
  29. data/spec/helpers/time_helper.rb +3 -0
  30. data/spec/integration/all_spec.rb +40 -0
  31. data/spec/integration/callback_spec.rb +87 -0
  32. data/spec/integration/db_spec.rb +40 -0
  33. data/spec/integration/find_spec.rb +51 -0
  34. data/spec/integration/persistance_spec.rb +118 -0
  35. data/spec/integration/relation_spec.rb +174 -0
  36. data/spec/integration/sync_spec.rb +42 -0
  37. data/spec/integration/timestamps_spec.rb +34 -0
  38. data/spec/integration/types_spec.rb +23 -0
  39. data/spec/integration/when_spec.rb +29 -0
  40. data/spec/integration/where_spec.rb +132 -0
  41. data/vendor/Podfile.lock +24 -0
  42. data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPClient.h +641 -0
  43. data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPClient.m +1396 -0
  44. data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.h +133 -0
  45. data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.m +327 -0
  46. data/vendor/Pods/AFNetworking/AFNetworking/AFImageRequestOperation.h +113 -0
  47. data/vendor/Pods/AFNetworking/AFNetworking/AFImageRequestOperation.m +321 -0
  48. data/vendor/Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.h +71 -0
  49. data/vendor/Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.m +150 -0
  50. data/vendor/Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.h +75 -0
  51. data/vendor/Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.m +157 -0
  52. data/vendor/Pods/AFNetworking/AFNetworking/AFNetworking.h +43 -0
  53. data/vendor/Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.h +68 -0
  54. data/vendor/Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.m +143 -0
  55. data/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.h +370 -0
  56. data/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.m +848 -0
  57. data/vendor/Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.h +89 -0
  58. data/vendor/Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.m +167 -0
  59. data/vendor/Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.h +78 -0
  60. data/vendor/Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.m +191 -0
  61. data/vendor/Pods/AFNetworking/LICENSE +19 -0
  62. data/vendor/Pods/AFNetworking/README.md +208 -0
  63. data/vendor/Pods/BuildHeaders/AFNetworking/AFHTTPClient.h +641 -0
  64. data/vendor/Pods/BuildHeaders/AFNetworking/AFHTTPRequestOperation.h +133 -0
  65. data/vendor/Pods/BuildHeaders/AFNetworking/AFImageRequestOperation.h +113 -0
  66. data/vendor/Pods/BuildHeaders/AFNetworking/AFJSONRequestOperation.h +71 -0
  67. data/vendor/Pods/BuildHeaders/AFNetworking/AFNetworkActivityIndicatorManager.h +75 -0
  68. data/vendor/Pods/BuildHeaders/AFNetworking/AFNetworking.h +43 -0
  69. data/vendor/Pods/BuildHeaders/AFNetworking/AFPropertyListRequestOperation.h +68 -0
  70. data/vendor/Pods/BuildHeaders/AFNetworking/AFURLConnectionOperation.h +370 -0
  71. data/vendor/Pods/BuildHeaders/AFNetworking/AFXMLRequestOperation.h +89 -0
  72. data/vendor/Pods/BuildHeaders/AFNetworking/UIImageView+AFNetworking.h +78 -0
  73. data/vendor/Pods/BuildHeaders/CocoaLumberjack/ContextFilterLogFormatter.h +65 -0
  74. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDASLLogger.h +41 -0
  75. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDAbstractDatabaseLogger.h +102 -0
  76. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDFileLogger.h +334 -0
  77. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDLog.h +601 -0
  78. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDTTYLogger.h +167 -0
  79. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DispatchQueueLogFormatter.h +116 -0
  80. data/vendor/Pods/BuildHeaders/NSData+MD5Digest/NSData+MD5Digest.h +18 -0
  81. data/vendor/Pods/BuildHeaders/Reachability/Reachability.h +109 -0
  82. data/vendor/Pods/BuildHeaders/YapDatabase/YapCache.h +90 -0
  83. data/vendor/Pods/BuildHeaders/YapDatabase/YapCollectionKey.h +20 -0
  84. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabase.h +547 -0
  85. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseConnection.h +447 -0
  86. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseConnectionState.h +29 -0
  87. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseDefaults.h +37 -0
  88. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtension.h +15 -0
  89. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionConnection.h +11 -0
  90. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionPrivate.h +440 -0
  91. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionTransaction.h +11 -0
  92. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredView.h +108 -0
  93. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewConnection.h +12 -0
  94. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewPrivate.h +19 -0
  95. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewTransaction.h +39 -0
  96. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearch.h +89 -0
  97. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchConnection.h +32 -0
  98. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchPrivate.h +69 -0
  99. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchSnippetOptions.h +79 -0
  100. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchTransaction.h +68 -0
  101. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseLogging.h +158 -0
  102. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseManager.h +17 -0
  103. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabasePrivate.h +424 -0
  104. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseQuery.h +42 -0
  105. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndex.h +100 -0
  106. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexConnection.h +33 -0
  107. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexPrivate.h +73 -0
  108. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexSetup.h +33 -0
  109. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexTransaction.h +58 -0
  110. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseStatement.h +13 -0
  111. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseString.h +121 -0
  112. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseTransaction.h +541 -0
  113. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseView.h +186 -0
  114. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewChange.h +272 -0
  115. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewChangePrivate.h +94 -0
  116. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewConnection.h +115 -0
  117. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewMappings.h +825 -0
  118. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewMappingsPrivate.h +72 -0
  119. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewOptions.h +56 -0
  120. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPage.h +36 -0
  121. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPageMetadata.h +27 -0
  122. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPrivate.h +153 -0
  123. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewRangeOptions.h +330 -0
  124. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewRangeOptionsPrivate.h +17 -0
  125. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewTransaction.h +447 -0
  126. data/vendor/Pods/BuildHeaders/YapDatabase/YapMemoryTable.h +74 -0
  127. data/vendor/Pods/BuildHeaders/YapDatabase/YapNull.h +17 -0
  128. data/vendor/Pods/BuildHeaders/YapDatabase/YapSet.h +41 -0
  129. data/vendor/Pods/BuildHeaders/YapDatabase/YapTouch.h +15 -0
  130. data/vendor/Pods/CocoaLumberjack/LICENSE.txt +18 -0
  131. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.h +41 -0
  132. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.m +99 -0
  133. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.h +102 -0
  134. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.m +727 -0
  135. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.h +334 -0
  136. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.m +1353 -0
  137. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.h +601 -0
  138. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.m +1083 -0
  139. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.h +167 -0
  140. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.m +1479 -0
  141. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/ContextFilterLogFormatter.h +65 -0
  142. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/ContextFilterLogFormatter.m +191 -0
  143. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DispatchQueueLogFormatter.h +116 -0
  144. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DispatchQueueLogFormatter.m +251 -0
  145. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/README.txt +7 -0
  146. data/vendor/Pods/CocoaLumberjack/README.markdown +37 -0
  147. data/vendor/Pods/Headers/AFNetworking/AFHTTPClient.h +641 -0
  148. data/vendor/Pods/Headers/AFNetworking/AFHTTPRequestOperation.h +133 -0
  149. data/vendor/Pods/Headers/AFNetworking/AFImageRequestOperation.h +113 -0
  150. data/vendor/Pods/Headers/AFNetworking/AFJSONRequestOperation.h +71 -0
  151. data/vendor/Pods/Headers/AFNetworking/AFNetworkActivityIndicatorManager.h +75 -0
  152. data/vendor/Pods/Headers/AFNetworking/AFNetworking.h +43 -0
  153. data/vendor/Pods/Headers/AFNetworking/AFPropertyListRequestOperation.h +68 -0
  154. data/vendor/Pods/Headers/AFNetworking/AFURLConnectionOperation.h +370 -0
  155. data/vendor/Pods/Headers/AFNetworking/AFXMLRequestOperation.h +89 -0
  156. data/vendor/Pods/Headers/AFNetworking/UIImageView+AFNetworking.h +78 -0
  157. data/vendor/Pods/Headers/CocoaLumberjack/ContextFilterLogFormatter.h +65 -0
  158. data/vendor/Pods/Headers/CocoaLumberjack/DDASLLogger.h +41 -0
  159. data/vendor/Pods/Headers/CocoaLumberjack/DDAbstractDatabaseLogger.h +102 -0
  160. data/vendor/Pods/Headers/CocoaLumberjack/DDFileLogger.h +334 -0
  161. data/vendor/Pods/Headers/CocoaLumberjack/DDLog.h +601 -0
  162. data/vendor/Pods/Headers/CocoaLumberjack/DDTTYLogger.h +167 -0
  163. data/vendor/Pods/Headers/CocoaLumberjack/DispatchQueueLogFormatter.h +116 -0
  164. data/vendor/Pods/Headers/NSData+MD5Digest/NSData+MD5Digest.h +18 -0
  165. data/vendor/Pods/Headers/Reachability/Reachability.h +109 -0
  166. data/vendor/Pods/Headers/YapDatabase/YapCache.h +90 -0
  167. data/vendor/Pods/Headers/YapDatabase/YapCollectionKey.h +20 -0
  168. data/vendor/Pods/Headers/YapDatabase/YapDatabase.h +547 -0
  169. data/vendor/Pods/Headers/YapDatabase/YapDatabaseConnection.h +447 -0
  170. data/vendor/Pods/Headers/YapDatabase/YapDatabaseConnectionState.h +29 -0
  171. data/vendor/Pods/Headers/YapDatabase/YapDatabaseDefaults.h +37 -0
  172. data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtension.h +15 -0
  173. data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionConnection.h +11 -0
  174. data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionPrivate.h +440 -0
  175. data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionTransaction.h +11 -0
  176. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredView.h +108 -0
  177. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewConnection.h +12 -0
  178. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewPrivate.h +19 -0
  179. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewTransaction.h +39 -0
  180. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearch.h +89 -0
  181. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchConnection.h +32 -0
  182. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchPrivate.h +69 -0
  183. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchSnippetOptions.h +79 -0
  184. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchTransaction.h +68 -0
  185. data/vendor/Pods/Headers/YapDatabase/YapDatabaseLogging.h +158 -0
  186. data/vendor/Pods/Headers/YapDatabase/YapDatabaseManager.h +17 -0
  187. data/vendor/Pods/Headers/YapDatabase/YapDatabasePrivate.h +424 -0
  188. data/vendor/Pods/Headers/YapDatabase/YapDatabaseQuery.h +42 -0
  189. data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndex.h +100 -0
  190. data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexConnection.h +33 -0
  191. data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexPrivate.h +73 -0
  192. data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexSetup.h +33 -0
  193. data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexTransaction.h +58 -0
  194. data/vendor/Pods/Headers/YapDatabase/YapDatabaseStatement.h +13 -0
  195. data/vendor/Pods/Headers/YapDatabase/YapDatabaseString.h +121 -0
  196. data/vendor/Pods/Headers/YapDatabase/YapDatabaseTransaction.h +541 -0
  197. data/vendor/Pods/Headers/YapDatabase/YapDatabaseView.h +186 -0
  198. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewChange.h +272 -0
  199. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewChangePrivate.h +94 -0
  200. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewConnection.h +115 -0
  201. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewMappings.h +825 -0
  202. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewMappingsPrivate.h +72 -0
  203. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewOptions.h +56 -0
  204. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPage.h +36 -0
  205. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPageMetadata.h +27 -0
  206. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPrivate.h +153 -0
  207. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewRangeOptions.h +330 -0
  208. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewRangeOptionsPrivate.h +17 -0
  209. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewTransaction.h +447 -0
  210. data/vendor/Pods/Headers/YapDatabase/YapMemoryTable.h +74 -0
  211. data/vendor/Pods/Headers/YapDatabase/YapNull.h +17 -0
  212. data/vendor/Pods/Headers/YapDatabase/YapSet.h +41 -0
  213. data/vendor/Pods/Headers/YapDatabase/YapTouch.h +15 -0
  214. data/vendor/Pods/Headers/____Pods-AFNetworking-prefix.h +17 -0
  215. data/vendor/Pods/Headers/____Pods-CocoaLumberjack-prefix.h +5 -0
  216. data/vendor/Pods/Headers/____Pods-NSData+MD5Digest-prefix.h +5 -0
  217. data/vendor/Pods/Headers/____Pods-Reachability-prefix.h +5 -0
  218. data/vendor/Pods/Headers/____Pods-YapDatabase-prefix.h +5 -0
  219. data/vendor/Pods/Headers/____Pods-environment.h +38 -0
  220. data/vendor/Pods/Manifest.lock +24 -0
  221. data/vendor/Pods/NSData+MD5Digest/NSData+MD5Digest/NSData+MD5Digest.h +18 -0
  222. data/vendor/Pods/NSData+MD5Digest/NSData+MD5Digest/NSData+MD5Digest.m +39 -0
  223. data/vendor/Pods/NSData+MD5Digest/README.md +11 -0
  224. data/vendor/Pods/Pods-AFNetworking-Private.xcconfig +5 -0
  225. data/vendor/Pods/Pods-AFNetworking-dummy.m +5 -0
  226. data/vendor/Pods/Pods-AFNetworking-prefix.pch +17 -0
  227. data/vendor/Pods/Pods-AFNetworking.xcconfig +1 -0
  228. data/vendor/Pods/Pods-Acknowledgements.markdown +96 -0
  229. data/vendor/Pods/Pods-Acknowledgements.plist +142 -0
  230. data/vendor/Pods/Pods-CocoaLumberjack-Private.xcconfig +5 -0
  231. data/vendor/Pods/Pods-CocoaLumberjack-dummy.m +5 -0
  232. data/vendor/Pods/Pods-CocoaLumberjack-prefix.pch +5 -0
  233. data/vendor/Pods/Pods-CocoaLumberjack.xcconfig +0 -0
  234. data/vendor/Pods/Pods-NSData+MD5Digest-Private.xcconfig +5 -0
  235. data/vendor/Pods/Pods-NSData+MD5Digest-dummy.m +5 -0
  236. data/vendor/Pods/Pods-NSData+MD5Digest-prefix.pch +5 -0
  237. data/vendor/Pods/Pods-NSData+MD5Digest.xcconfig +0 -0
  238. data/vendor/Pods/Pods-Reachability-Private.xcconfig +5 -0
  239. data/vendor/Pods/Pods-Reachability-dummy.m +5 -0
  240. data/vendor/Pods/Pods-Reachability-prefix.pch +5 -0
  241. data/vendor/Pods/Pods-Reachability.xcconfig +1 -0
  242. data/vendor/Pods/Pods-YapDatabase-Private.xcconfig +5 -0
  243. data/vendor/Pods/Pods-YapDatabase-dummy.m +5 -0
  244. data/vendor/Pods/Pods-YapDatabase-prefix.pch +5 -0
  245. data/vendor/Pods/Pods-YapDatabase.xcconfig +1 -0
  246. data/vendor/Pods/Pods-dummy.m +5 -0
  247. data/vendor/Pods/Pods-environment.h +38 -0
  248. data/vendor/Pods/Pods-resources.sh +68 -0
  249. data/vendor/Pods/Pods.bridgesupport +5096 -0
  250. data/vendor/Pods/Pods.xcconfig +5 -0
  251. data/vendor/Pods/Pods.xcodeproj/project.pbxproj +5536 -0
  252. data/vendor/Pods/Reachability/LICENCE.txt +24 -0
  253. data/vendor/Pods/Reachability/README.md +65 -0
  254. data/vendor/Pods/Reachability/Reachability.h +109 -0
  255. data/vendor/Pods/Reachability/Reachability.m +527 -0
  256. data/vendor/Pods/YapDatabase/LICENSE.txt +18 -0
  257. data/vendor/Pods/YapDatabase/README.md +30 -0
  258. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/Internal/YapDatabaseFilteredViewPrivate.h +19 -0
  259. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.h +108 -0
  260. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.m +175 -0
  261. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewConnection.h +12 -0
  262. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewConnection.m +41 -0
  263. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.h +39 -0
  264. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.m +966 -0
  265. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/Internal/YapDatabaseFullTextSearchPrivate.h +69 -0
  266. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearch.h +89 -0
  267. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearch.m +146 -0
  268. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchConnection.h +32 -0
  269. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchConnection.m +298 -0
  270. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchSnippetOptions.h +79 -0
  271. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchSnippetOptions.m +95 -0
  272. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchTransaction.h +68 -0
  273. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchTransaction.m +1352 -0
  274. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/Internal/YapDatabaseExtensionPrivate.h +440 -0
  275. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtension.h +15 -0
  276. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtension.m +58 -0
  277. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionConnection.h +11 -0
  278. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionConnection.m +46 -0
  279. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionTransaction.h +11 -0
  280. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionTransaction.m +180 -0
  281. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/Internal/YapDatabaseSecondaryIndexPrivate.h +73 -0
  282. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.h +100 -0
  283. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.m +149 -0
  284. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexConnection.h +33 -0
  285. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexConnection.m +330 -0
  286. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexSetup.h +33 -0
  287. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexSetup.m +184 -0
  288. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexTransaction.h +58 -0
  289. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexTransaction.m +1166 -0
  290. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewChangePrivate.h +94 -0
  291. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewMappingsPrivate.h +72 -0
  292. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPage.h +36 -0
  293. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPage.mm +296 -0
  294. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPageMetadata.h +27 -0
  295. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPageMetadata.m +28 -0
  296. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPrivate.h +153 -0
  297. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewRangeOptionsPrivate.h +17 -0
  298. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.h +272 -0
  299. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.m +2494 -0
  300. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.h +825 -0
  301. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.m +1567 -0
  302. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewRangeOptions.h +330 -0
  303. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewRangeOptions.m +141 -0
  304. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.h +186 -0
  305. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.m +191 -0
  306. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.h +115 -0
  307. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.m +897 -0
  308. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewOptions.h +56 -0
  309. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewOptions.m +27 -0
  310. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.h +447 -0
  311. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.m +4505 -0
  312. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.h +90 -0
  313. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.m +453 -0
  314. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseConnectionState.h +29 -0
  315. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseConnectionState.m +48 -0
  316. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.h +37 -0
  317. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.m +83 -0
  318. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseLogging.h +158 -0
  319. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseLogging.m +73 -0
  320. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseManager.h +17 -0
  321. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseManager.m +56 -0
  322. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabasePrivate.h +424 -0
  323. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseStatement.h +13 -0
  324. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseStatement.m +26 -0
  325. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseString.h +121 -0
  326. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapMemoryTable.h +74 -0
  327. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapMemoryTable.m +603 -0
  328. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapNull.h +17 -0
  329. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapNull.m +31 -0
  330. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapTouch.h +15 -0
  331. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapTouch.m +31 -0
  332. data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.h +20 -0
  333. data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.m +194 -0
  334. data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapDatabaseQuery.h +42 -0
  335. data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapDatabaseQuery.m +96 -0
  336. data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapSet.h +41 -0
  337. data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapSet.m +82 -0
  338. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.h +547 -0
  339. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.m +2022 -0
  340. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.h +447 -0
  341. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.m +3874 -0
  342. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.h +541 -0
  343. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.m +5282 -0
  344. data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.bridgesupport +16 -0
  345. data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.h +13 -0
  346. data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.m +20 -0
  347. data/yapper.gemspec +24 -0
  348. metadata +458 -0
@@ -0,0 +1,74 @@
1
+ #import <Foundation/Foundation.h>
2
+
3
+ @class YapMemoryTableTransaction;
4
+
5
+
6
+ /**
7
+ * A "memory table" is a dictionary that supports versioning.
8
+ * There may be multiple values for a single key, with each value associated with a different snapshot.
9
+ *
10
+ * The memory table is accessed via a YapMemoryTableTransaction instance,
11
+ * which is itself associated with a particular timestamp. Thus the transaction is able to properly identify
12
+ * which version is appropriate for itself.
13
+ **/
14
+ @interface YapMemoryTable : NSObject
15
+
16
+ /**
17
+ * Initializes a memory table.
18
+ *
19
+ * The keyClass is used for debugging, to ensure the proper key type is always used when accessing the table.
20
+ * The keyClass is used within NSAssert statements that typically get compiled out for release builds.
21
+ **/
22
+ - (id)initWithKeyClass:(Class)keyClass;
23
+
24
+ /**
25
+ * Creates and returns a new connection associated with the shared cache.
26
+ **/
27
+ - (YapMemoryTableTransaction *)newReadTransactionWithSnapshot:(uint64_t)snapshot;
28
+ - (YapMemoryTableTransaction *)newReadWriteTransactionWithSnapshot:(uint64_t)snapshot;
29
+
30
+ /**
31
+ * Invoked automatically by YapDatabase architecture.
32
+ **/
33
+ - (void)asyncCheckpoint:(int64_t)minSnapshot;
34
+
35
+ @end
36
+
37
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
38
+ #pragma mark -
39
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
40
+
41
+ @interface YapMemoryTableTransaction : NSObject
42
+
43
+ @property (nonatomic, readonly) uint64_t snapshot;
44
+ @property (nonatomic, readonly) BOOL isReadWriteTransaction;
45
+
46
+ - (id)objectForKey:(id)key;
47
+
48
+ - (void)enumerateKeysWithBlock:(void (^)(id key, BOOL *stop))block;
49
+
50
+ - (void)enumerateKeysAndObjectsWithBlock:(void (^)(id key, id obj, BOOL *stop))block;
51
+
52
+ //
53
+ // For ReadWrite transactions:
54
+
55
+ - (void)setObject:(id)object forKey:(id)key;
56
+
57
+ - (void)removeObjectForKey:(id)key;
58
+ - (void)removeObjectsForKeys:(NSArray *)keys;
59
+
60
+ - (void)removeAllObjects;
61
+
62
+ //
63
+ // Batch access / modifications
64
+
65
+ - (void)accessWithBlock:(dispatch_block_t)block;
66
+ - (void)modifyWithBlock:(dispatch_block_t)block;
67
+
68
+ //
69
+ // Transaction state
70
+
71
+ - (void)commit;
72
+ - (void)rollback;
73
+
74
+ @end
@@ -0,0 +1,17 @@
1
+ #import <Foundation/Foundation.h>
2
+
3
+ /**
4
+ * There are various situations in which we need to add a placeholder to signify a nil value.
5
+ * For example, we need to cache the fact that the metadata for a given key is nil.
6
+ *
7
+ * However, we cannot add a nil object to a dictionary.
8
+ * And we cannot use NSNull, or we prevent the user from using NSNull for their own purposes.
9
+ *
10
+ * And thus, we replicate NSNull, and use it instead.
11
+ * And now the user is free to use NSNull if needed.
12
+ **/
13
+ @interface YapNull : NSObject
14
+
15
+ + (id)null;
16
+
17
+ @end
@@ -0,0 +1,41 @@
1
+ #import <Foundation/Foundation.h>
2
+
3
+ /**
4
+ * The YapSet class can be treated more or less like a regular NSSet.
5
+ *
6
+ * It is designed to expose internal mutable objects to the external world.
7
+ * That is, we skip all the overhead associated with making immutable copies,
8
+ * and instead just use this simple wrapper class.
9
+ *
10
+ * In general, the external world won't interact with this class.
11
+ * They are encouraged to instead use the changeset methods exposed in the connection classes.
12
+ *
13
+ * @see YapDatabaseConnection hasChangeForKey:inNotifications:
14
+ * @see YapDatabaseConnection hasChangeForAnyKeys:inNotifications:
15
+ **/
16
+ @interface YapSet : NSObject <NSFastEnumeration>
17
+
18
+ - (id)initWithSet:(NSMutableSet *)set;
19
+ - (id)initWithDictionary:(NSMutableDictionary *)dictionary;
20
+
21
+ // NSSet methods
22
+
23
+ - (BOOL)containsObject:(id)anObject;
24
+ - (BOOL)intersectsSet:(NSSet *)otherSet;
25
+
26
+ - (void)enumerateObjectsUsingBlock:(void (^)(id obj, BOOL *stop))block;
27
+
28
+ // It's open source!
29
+ // You are encouraged to add any methods you may need that are available in the NSSet API.
30
+ //
31
+ // Not every method from NSSet is available here because the author is lazy,
32
+ // and only implemented what was needed at the time.
33
+ //
34
+ // If you add something, keep in mind the spirit of this class.
35
+ // It is designed to expose mutable internals in a safe (immutable) manner.
36
+ // It is designed to expose them in the form of a set.
37
+ //
38
+ // If you make improvements, feel free to submit a patch to the github project and get some good karma for it!
39
+ // https://github.com/yaptv/YapDatabase
40
+
41
+ @end
@@ -0,0 +1,15 @@
1
+ #import <Foundation/Foundation.h>
2
+
3
+ /**
4
+ * Singleton class to represent the "value" for a key that was touched. (i.e. value didn't change)
5
+ *
6
+ * YapDatabase stores changesets in dictionaries, where the object represents the updated value for a key.
7
+ * When an item is touched, we use this singleton as the value to signify internally that the item didn't change.
8
+ * This allows us to act as if the item did change in most all respects,
9
+ * but internally won't cause us to flush the item from the caches.
10
+ **/
11
+ @interface YapTouch : NSObject
12
+
13
+ + (id)touch;
14
+
15
+ @end
@@ -0,0 +1,18 @@
1
+ Software License Agreement (BSD License)
2
+
3
+ Copyright (c) 2010, Deusty, LLC
4
+ All rights reserved.
5
+
6
+ Redistribution and use of this software in source and binary forms,
7
+ with or without modification, are permitted provided that the following conditions are met:
8
+
9
+ * Redistributions of source code must retain the above
10
+ copyright notice, this list of conditions and the
11
+ following disclaimer.
12
+
13
+ * Neither the name of Deusty nor the names of its
14
+ contributors may be used to endorse or promote products
15
+ derived from this software without specific prior
16
+ written permission of Deusty, LLC.
17
+
18
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,41 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import <asl.h>
3
+
4
+ #import "DDLog.h"
5
+
6
+ /**
7
+ * Welcome to Cocoa Lumberjack!
8
+ *
9
+ * The project page has a wealth of documentation if you have any questions.
10
+ * https://github.com/robbiehanson/CocoaLumberjack
11
+ *
12
+ * If you're new to the project you may wish to read the "Getting Started" wiki.
13
+ * https://github.com/robbiehanson/CocoaLumberjack/wiki/GettingStarted
14
+ *
15
+ *
16
+ * This class provides a logger for the Apple System Log facility.
17
+ *
18
+ * As described in the "Getting Started" page,
19
+ * the traditional NSLog() function directs it's output to two places:
20
+ *
21
+ * - Apple System Log
22
+ * - StdErr (if stderr is a TTY) so log statements show up in Xcode console
23
+ *
24
+ * To duplicate NSLog() functionality you can simply add this logger and a tty logger.
25
+ * However, if you instead choose to use file logging (for faster performance),
26
+ * you may choose to use a file logger and a tty logger.
27
+ **/
28
+
29
+ @interface DDASLLogger : DDAbstractLogger <DDLogger>
30
+ {
31
+ aslclient client;
32
+ }
33
+
34
+ + (DDASLLogger *)sharedInstance;
35
+
36
+ // Inherited from DDAbstractLogger
37
+
38
+ // - (id <DDLogFormatter>)logFormatter;
39
+ // - (void)setLogFormatter:(id <DDLogFormatter>)formatter;
40
+
41
+ @end
@@ -0,0 +1,99 @@
1
+ #import "DDASLLogger.h"
2
+
3
+ #import <libkern/OSAtomic.h>
4
+
5
+ /**
6
+ * Welcome to Cocoa Lumberjack!
7
+ *
8
+ * The project page has a wealth of documentation if you have any questions.
9
+ * https://github.com/robbiehanson/CocoaLumberjack
10
+ *
11
+ * If you're new to the project you may wish to read the "Getting Started" wiki.
12
+ * https://github.com/robbiehanson/CocoaLumberjack/wiki/GettingStarted
13
+ **/
14
+
15
+ #if ! __has_feature(objc_arc)
16
+ #warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
17
+ #endif
18
+
19
+
20
+ @implementation DDASLLogger
21
+
22
+ static DDASLLogger *sharedInstance;
23
+
24
+ /**
25
+ * The runtime sends initialize to each class in a program exactly one time just before the class,
26
+ * or any class that inherits from it, is sent its first message from within the program. (Thus the
27
+ * method may never be invoked if the class is not used.) The runtime sends the initialize message to
28
+ * classes in a thread-safe manner. Superclasses receive this message before their subclasses.
29
+ *
30
+ * This method may also be called directly (assumably by accident), hence the safety mechanism.
31
+ **/
32
+ + (void)initialize
33
+ {
34
+ static BOOL initialized = NO;
35
+ if (!initialized)
36
+ {
37
+ initialized = YES;
38
+
39
+ sharedInstance = [[DDASLLogger alloc] init];
40
+ }
41
+ }
42
+
43
+ + (DDASLLogger *)sharedInstance
44
+ {
45
+ return sharedInstance;
46
+ }
47
+
48
+ - (id)init
49
+ {
50
+ if (sharedInstance != nil)
51
+ {
52
+ return nil;
53
+ }
54
+
55
+ if ((self = [super init]))
56
+ {
57
+ // A default asl client is provided for the main thread,
58
+ // but background threads need to create their own client.
59
+
60
+ client = asl_open(NULL, "com.apple.console", 0);
61
+ }
62
+ return self;
63
+ }
64
+
65
+ - (void)logMessage:(DDLogMessage *)logMessage
66
+ {
67
+ NSString *logMsg = logMessage->logMsg;
68
+
69
+ if (formatter)
70
+ {
71
+ logMsg = [formatter formatLogMessage:logMessage];
72
+ }
73
+
74
+ if (logMsg)
75
+ {
76
+ const char *msg = [logMsg UTF8String];
77
+
78
+ int aslLogLevel;
79
+ switch (logMessage->logFlag)
80
+ {
81
+ // Note: By default ASL will filter anything above level 5 (Notice).
82
+ // So our mappings shouldn't go above that level.
83
+
84
+ case LOG_FLAG_ERROR : aslLogLevel = ASL_LEVEL_CRIT; break;
85
+ case LOG_FLAG_WARN : aslLogLevel = ASL_LEVEL_ERR; break;
86
+ case LOG_FLAG_INFO : aslLogLevel = ASL_LEVEL_WARNING; break;
87
+ default : aslLogLevel = ASL_LEVEL_NOTICE; break;
88
+ }
89
+
90
+ asl_log(client, NULL, aslLogLevel, "%s", msg);
91
+ }
92
+ }
93
+
94
+ - (NSString *)loggerName
95
+ {
96
+ return @"cocoa.lumberjack.aslLogger";
97
+ }
98
+
99
+ @end
@@ -0,0 +1,102 @@
1
+ #import <Foundation/Foundation.h>
2
+
3
+ #import "DDLog.h"
4
+
5
+ /**
6
+ * Welcome to Cocoa Lumberjack!
7
+ *
8
+ * The project page has a wealth of documentation if you have any questions.
9
+ * https://github.com/robbiehanson/CocoaLumberjack
10
+ *
11
+ * If you're new to the project you may wish to read the "Getting Started" wiki.
12
+ * https://github.com/robbiehanson/CocoaLumberjack/wiki/GettingStarted
13
+ *
14
+ *
15
+ * This class provides an abstract implementation of a database logger.
16
+ *
17
+ * That is, it provides the base implementation for a database logger to build atop of.
18
+ * All that is needed for a concrete database logger is to extend this class
19
+ * and override the methods in the implementation file that are prefixed with "db_".
20
+ **/
21
+
22
+ @interface DDAbstractDatabaseLogger : DDAbstractLogger {
23
+ @protected
24
+ NSUInteger saveThreshold;
25
+ NSTimeInterval saveInterval;
26
+ NSTimeInterval maxAge;
27
+ NSTimeInterval deleteInterval;
28
+ BOOL deleteOnEverySave;
29
+
30
+ BOOL saveTimerSuspended;
31
+ NSUInteger unsavedCount;
32
+ dispatch_time_t unsavedTime;
33
+ dispatch_source_t saveTimer;
34
+ dispatch_time_t lastDeleteTime;
35
+ dispatch_source_t deleteTimer;
36
+ }
37
+
38
+ /**
39
+ * Specifies how often to save the data to disk.
40
+ * Since saving is an expensive operation (disk io) it is not done after every log statement.
41
+ * These properties allow you to configure how/when the logger saves to disk.
42
+ *
43
+ * A save is done when either (whichever happens first):
44
+ *
45
+ * - The number of unsaved log entries reaches saveThreshold
46
+ * - The amount of time since the oldest unsaved log entry was created reaches saveInterval
47
+ *
48
+ * You can optionally disable the saveThreshold by setting it to zero.
49
+ * If you disable the saveThreshold you are entirely dependent on the saveInterval.
50
+ *
51
+ * You can optionally disable the saveInterval by setting it to zero (or a negative value).
52
+ * If you disable the saveInterval you are entirely dependent on the saveThreshold.
53
+ *
54
+ * It's not wise to disable both saveThreshold and saveInterval.
55
+ *
56
+ * The default saveThreshold is 500.
57
+ * The default saveInterval is 60 seconds.
58
+ **/
59
+ @property (assign, readwrite) NSUInteger saveThreshold;
60
+ @property (assign, readwrite) NSTimeInterval saveInterval;
61
+
62
+ /**
63
+ * It is likely you don't want the log entries to persist forever.
64
+ * Doing so would allow the database to grow infinitely large over time.
65
+ *
66
+ * The maxAge property provides a way to specify how old a log statement can get
67
+ * before it should get deleted from the database.
68
+ *
69
+ * The deleteInterval specifies how often to sweep for old log entries.
70
+ * Since deleting is an expensive operation (disk io) is is done on a fixed interval.
71
+ *
72
+ * An alternative to the deleteInterval is the deleteOnEverySave option.
73
+ * This specifies that old log entries should be deleted during every save operation.
74
+ *
75
+ * You can optionally disable the maxAge by setting it to zero (or a negative value).
76
+ * If you disable the maxAge then old log statements are not deleted.
77
+ *
78
+ * You can optionally disable the deleteInterval by setting it to zero (or a negative value).
79
+ *
80
+ * If you disable both deleteInterval and deleteOnEverySave then old log statements are not deleted.
81
+ *
82
+ * It's not wise to enable both deleteInterval and deleteOnEverySave.
83
+ *
84
+ * The default maxAge is 7 days.
85
+ * The default deleteInterval is 5 minutes.
86
+ * The default deleteOnEverySave is NO.
87
+ **/
88
+ @property (assign, readwrite) NSTimeInterval maxAge;
89
+ @property (assign, readwrite) NSTimeInterval deleteInterval;
90
+ @property (assign, readwrite) BOOL deleteOnEverySave;
91
+
92
+ /**
93
+ * Forces a save of any pending log entries (flushes log entries to disk).
94
+ **/
95
+ - (void)savePendingLogEntries;
96
+
97
+ /**
98
+ * Removes any log entries that are older than maxAge.
99
+ **/
100
+ - (void)deleteOldLogEntries;
101
+
102
+ @end
@@ -0,0 +1,727 @@
1
+ #import "DDAbstractDatabaseLogger.h"
2
+ #import <math.h>
3
+
4
+ /**
5
+ * Welcome to Cocoa Lumberjack!
6
+ *
7
+ * The project page has a wealth of documentation if you have any questions.
8
+ * https://github.com/robbiehanson/CocoaLumberjack
9
+ *
10
+ * If you're new to the project you may wish to read the "Getting Started" wiki.
11
+ * https://github.com/robbiehanson/CocoaLumberjack/wiki/GettingStarted
12
+ **/
13
+
14
+ #if ! __has_feature(objc_arc)
15
+ #warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
16
+ #endif
17
+
18
+ @interface DDAbstractDatabaseLogger ()
19
+ - (void)destroySaveTimer;
20
+ - (void)destroyDeleteTimer;
21
+ @end
22
+
23
+ #pragma mark -
24
+
25
+ @implementation DDAbstractDatabaseLogger
26
+
27
+ - (id)init
28
+ {
29
+ if ((self = [super init]))
30
+ {
31
+ saveThreshold = 500;
32
+ saveInterval = 60; // 60 seconds
33
+ maxAge = (60 * 60 * 24 * 7); // 7 days
34
+ deleteInterval = (60 * 5); // 5 minutes
35
+ }
36
+ return self;
37
+ }
38
+
39
+ - (void)dealloc
40
+ {
41
+ [self destroySaveTimer];
42
+ [self destroyDeleteTimer];
43
+
44
+ }
45
+
46
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
47
+ #pragma mark Override Me
48
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
49
+
50
+ - (BOOL)db_log:(DDLogMessage *)logMessage
51
+ {
52
+ // Override me and add your implementation.
53
+ //
54
+ // Return YES if an item was added to the buffer.
55
+ // Return NO if the logMessage was ignored.
56
+
57
+ return NO;
58
+ }
59
+
60
+ - (void)db_save
61
+ {
62
+ // Override me and add your implementation.
63
+ }
64
+
65
+ - (void)db_delete
66
+ {
67
+ // Override me and add your implementation.
68
+ }
69
+
70
+ - (void)db_saveAndDelete
71
+ {
72
+ // Override me and add your implementation.
73
+ }
74
+
75
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
76
+ #pragma mark Private API
77
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
78
+
79
+ - (void)performSaveAndSuspendSaveTimer
80
+ {
81
+ if (unsavedCount > 0)
82
+ {
83
+ if (deleteOnEverySave)
84
+ [self db_saveAndDelete];
85
+ else
86
+ [self db_save];
87
+ }
88
+
89
+ unsavedCount = 0;
90
+ unsavedTime = 0;
91
+
92
+ if (saveTimer && !saveTimerSuspended)
93
+ {
94
+ dispatch_suspend(saveTimer);
95
+ saveTimerSuspended = YES;
96
+ }
97
+ }
98
+
99
+ - (void)performDelete
100
+ {
101
+ if (maxAge > 0.0)
102
+ {
103
+ [self db_delete];
104
+
105
+ lastDeleteTime = dispatch_time(DISPATCH_TIME_NOW, 0);
106
+ }
107
+ }
108
+
109
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
110
+ #pragma mark Timers
111
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
112
+
113
+ - (void)destroySaveTimer
114
+ {
115
+ if (saveTimer)
116
+ {
117
+ dispatch_source_cancel(saveTimer);
118
+ if (saveTimerSuspended)
119
+ {
120
+ // Must resume a timer before releasing it (or it will crash)
121
+ dispatch_resume(saveTimer);
122
+ saveTimerSuspended = NO;
123
+ }
124
+ #if !OS_OBJECT_USE_OBJC
125
+ dispatch_release(saveTimer);
126
+ #endif
127
+ saveTimer = NULL;
128
+ }
129
+ }
130
+
131
+ - (void)updateAndResumeSaveTimer
132
+ {
133
+ if ((saveTimer != NULL) && (saveInterval > 0.0) && (unsavedTime > 0.0))
134
+ {
135
+ uint64_t interval = (uint64_t)(saveInterval * NSEC_PER_SEC);
136
+ dispatch_time_t startTime = dispatch_time(unsavedTime, interval);
137
+
138
+ dispatch_source_set_timer(saveTimer, startTime, interval, 1.0);
139
+
140
+ if (saveTimerSuspended)
141
+ {
142
+ dispatch_resume(saveTimer);
143
+ saveTimerSuspended = NO;
144
+ }
145
+ }
146
+ }
147
+
148
+ - (void)createSuspendedSaveTimer
149
+ {
150
+ if ((saveTimer == NULL) && (saveInterval > 0.0))
151
+ {
152
+ saveTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, loggerQueue);
153
+
154
+ dispatch_source_set_event_handler(saveTimer, ^{ @autoreleasepool {
155
+
156
+ [self performSaveAndSuspendSaveTimer];
157
+
158
+ }});
159
+
160
+ saveTimerSuspended = YES;
161
+ }
162
+ }
163
+
164
+ - (void)destroyDeleteTimer
165
+ {
166
+ if (deleteTimer)
167
+ {
168
+ dispatch_source_cancel(deleteTimer);
169
+ #if !OS_OBJECT_USE_OBJC
170
+ dispatch_release(deleteTimer);
171
+ #endif
172
+ deleteTimer = NULL;
173
+ }
174
+ }
175
+
176
+ - (void)updateDeleteTimer
177
+ {
178
+ if ((deleteTimer != NULL) && (deleteInterval > 0.0) && (maxAge > 0.0))
179
+ {
180
+ uint64_t interval = (uint64_t)(deleteInterval * NSEC_PER_SEC);
181
+ dispatch_time_t startTime;
182
+
183
+ if (lastDeleteTime > 0)
184
+ startTime = dispatch_time(lastDeleteTime, interval);
185
+ else
186
+ startTime = dispatch_time(DISPATCH_TIME_NOW, interval);
187
+
188
+ dispatch_source_set_timer(deleteTimer, startTime, interval, 1.0);
189
+ }
190
+ }
191
+
192
+ - (void)createAndStartDeleteTimer
193
+ {
194
+ if ((deleteTimer == NULL) && (deleteInterval > 0.0) && (maxAge > 0.0))
195
+ {
196
+ deleteTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, loggerQueue);
197
+
198
+ if (deleteTimer != NULL) {
199
+ dispatch_source_set_event_handler(deleteTimer, ^{ @autoreleasepool {
200
+
201
+ [self performDelete];
202
+
203
+ }});
204
+
205
+ [self updateDeleteTimer];
206
+
207
+ dispatch_resume(deleteTimer);
208
+ }
209
+ }
210
+ }
211
+
212
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
213
+ #pragma mark Configuration
214
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
215
+
216
+ - (NSUInteger)saveThreshold
217
+ {
218
+ // The design of this method is taken from the DDAbstractLogger implementation.
219
+ // For extensive documentation please refer to the DDAbstractLogger implementation.
220
+
221
+ // Note: The internal implementation MUST access the colorsEnabled variable directly,
222
+ // This method is designed explicitly for external access.
223
+ //
224
+ // Using "self." syntax to go through this method will cause immediate deadlock.
225
+ // This is the intended result. Fix it by accessing the ivar directly.
226
+ // Great strides have been take to ensure this is safe to do. Plus it's MUCH faster.
227
+
228
+ NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
229
+ NSAssert(![self isOnInternalLoggerQueue], @"MUST access ivar directly, NOT via self.* syntax.");
230
+
231
+ dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
232
+
233
+ __block NSUInteger result;
234
+
235
+ dispatch_sync(globalLoggingQueue, ^{
236
+ dispatch_sync(loggerQueue, ^{
237
+ result = saveThreshold;
238
+ });
239
+ });
240
+
241
+ return result;
242
+ }
243
+
244
+ - (void)setSaveThreshold:(NSUInteger)threshold
245
+ {
246
+ dispatch_block_t block = ^{ @autoreleasepool {
247
+
248
+ if (saveThreshold != threshold)
249
+ {
250
+ saveThreshold = threshold;
251
+
252
+ // Since the saveThreshold has changed,
253
+ // we check to see if the current unsavedCount has surpassed the new threshold.
254
+ //
255
+ // If it has, we immediately save the log.
256
+
257
+ if ((unsavedCount >= saveThreshold) && (saveThreshold > 0))
258
+ {
259
+ [self performSaveAndSuspendSaveTimer];
260
+ }
261
+ }
262
+ }};
263
+
264
+ // The design of the setter logic below is taken from the DDAbstractLogger implementation.
265
+ // For documentation please refer to the DDAbstractLogger implementation.
266
+
267
+ if ([self isOnInternalLoggerQueue])
268
+ {
269
+ block();
270
+ }
271
+ else
272
+ {
273
+ dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
274
+ NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
275
+
276
+ dispatch_async(globalLoggingQueue, ^{
277
+ dispatch_async(loggerQueue, block);
278
+ });
279
+ }
280
+ }
281
+
282
+ - (NSTimeInterval)saveInterval
283
+ {
284
+ // The design of this method is taken from the DDAbstractLogger implementation.
285
+ // For extensive documentation please refer to the DDAbstractLogger implementation.
286
+
287
+ // Note: The internal implementation MUST access the colorsEnabled variable directly,
288
+ // This method is designed explicitly for external access.
289
+ //
290
+ // Using "self." syntax to go through this method will cause immediate deadlock.
291
+ // This is the intended result. Fix it by accessing the ivar directly.
292
+ // Great strides have been take to ensure this is safe to do. Plus it's MUCH faster.
293
+
294
+ NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
295
+ NSAssert(![self isOnInternalLoggerQueue], @"MUST access ivar directly, NOT via self.* syntax.");
296
+
297
+ dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
298
+
299
+ __block NSTimeInterval result;
300
+
301
+ dispatch_sync(globalLoggingQueue, ^{
302
+ dispatch_sync(loggerQueue, ^{
303
+ result = saveInterval;
304
+ });
305
+ });
306
+
307
+ return result;
308
+ }
309
+
310
+ - (void)setSaveInterval:(NSTimeInterval)interval
311
+ {
312
+ dispatch_block_t block = ^{ @autoreleasepool {
313
+
314
+ // C99 recommended floating point comparison macro
315
+ // Read: isLessThanOrGreaterThan(floatA, floatB)
316
+
317
+ if (/* saveInterval != interval */ islessgreater(saveInterval, interval))
318
+ {
319
+ saveInterval = interval;
320
+
321
+ // There are several cases we need to handle here.
322
+ //
323
+ // 1. If the saveInterval was previously enabled and it just got disabled,
324
+ // then we need to stop the saveTimer. (And we might as well release it.)
325
+ //
326
+ // 2. If the saveInterval was previously disabled and it just got enabled,
327
+ // then we need to setup the saveTimer. (Plus we might need to do an immediate save.)
328
+ //
329
+ // 3. If the saveInterval increased, then we need to reset the timer so that it fires at the later date.
330
+ //
331
+ // 4. If the saveInterval decreased, then we need to reset the timer so that it fires at an earlier date.
332
+ // (Plus we might need to do an immediate save.)
333
+
334
+ if (saveInterval > 0.0)
335
+ {
336
+ if (saveTimer == NULL)
337
+ {
338
+ // Handles #2
339
+ //
340
+ // Since the saveTimer uses the unsavedTime to calculate it's first fireDate,
341
+ // if a save is needed the timer will fire immediately.
342
+
343
+ [self createSuspendedSaveTimer];
344
+ [self updateAndResumeSaveTimer];
345
+ }
346
+ else
347
+ {
348
+ // Handles #3
349
+ // Handles #4
350
+ //
351
+ // Since the saveTimer uses the unsavedTime to calculate it's first fireDate,
352
+ // if a save is needed the timer will fire immediately.
353
+
354
+ [self updateAndResumeSaveTimer];
355
+ }
356
+ }
357
+ else if (saveTimer)
358
+ {
359
+ // Handles #1
360
+
361
+ [self destroySaveTimer];
362
+ }
363
+ }
364
+ }};
365
+
366
+ // The design of the setter logic below is taken from the DDAbstractLogger implementation.
367
+ // For documentation please refer to the DDAbstractLogger implementation.
368
+
369
+ if ([self isOnInternalLoggerQueue])
370
+ {
371
+ block();
372
+ }
373
+ else
374
+ {
375
+ dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
376
+ NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
377
+
378
+ dispatch_async(globalLoggingQueue, ^{
379
+ dispatch_async(loggerQueue, block);
380
+ });
381
+ }
382
+ }
383
+
384
+ - (NSTimeInterval)maxAge
385
+ {
386
+ // The design of this method is taken from the DDAbstractLogger implementation.
387
+ // For extensive documentation please refer to the DDAbstractLogger implementation.
388
+
389
+ // Note: The internal implementation MUST access the colorsEnabled variable directly,
390
+ // This method is designed explicitly for external access.
391
+ //
392
+ // Using "self." syntax to go through this method will cause immediate deadlock.
393
+ // This is the intended result. Fix it by accessing the ivar directly.
394
+ // Great strides have been take to ensure this is safe to do. Plus it's MUCH faster.
395
+
396
+ NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
397
+ NSAssert(![self isOnInternalLoggerQueue], @"MUST access ivar directly, NOT via self.* syntax.");
398
+
399
+ dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
400
+
401
+ __block NSTimeInterval result;
402
+
403
+ dispatch_sync(globalLoggingQueue, ^{
404
+ dispatch_sync(loggerQueue, ^{
405
+ result = maxAge;
406
+ });
407
+ });
408
+
409
+ return result;
410
+ }
411
+
412
+ - (void)setMaxAge:(NSTimeInterval)interval
413
+ {
414
+ dispatch_block_t block = ^{ @autoreleasepool {
415
+
416
+ // C99 recommended floating point comparison macro
417
+ // Read: isLessThanOrGreaterThan(floatA, floatB)
418
+
419
+ if (/* maxAge != interval */ islessgreater(maxAge, interval))
420
+ {
421
+ NSTimeInterval oldMaxAge = maxAge;
422
+ NSTimeInterval newMaxAge = interval;
423
+
424
+ maxAge = interval;
425
+
426
+ // There are several cases we need to handle here.
427
+ //
428
+ // 1. If the maxAge was previously enabled and it just got disabled,
429
+ // then we need to stop the deleteTimer. (And we might as well release it.)
430
+ //
431
+ // 2. If the maxAge was previously disabled and it just got enabled,
432
+ // then we need to setup the deleteTimer. (Plus we might need to do an immediate delete.)
433
+ //
434
+ // 3. If the maxAge was increased,
435
+ // then we don't need to do anything.
436
+ //
437
+ // 4. If the maxAge was decreased,
438
+ // then we should do an immediate delete.
439
+
440
+ BOOL shouldDeleteNow = NO;
441
+
442
+ if (oldMaxAge > 0.0)
443
+ {
444
+ if (newMaxAge <= 0.0)
445
+ {
446
+ // Handles #1
447
+
448
+ [self destroyDeleteTimer];
449
+ }
450
+ else if (oldMaxAge > newMaxAge)
451
+ {
452
+ // Handles #4
453
+ shouldDeleteNow = YES;
454
+ }
455
+ }
456
+ else if (newMaxAge > 0.0)
457
+ {
458
+ // Handles #2
459
+ shouldDeleteNow = YES;
460
+ }
461
+
462
+ if (shouldDeleteNow)
463
+ {
464
+ [self performDelete];
465
+
466
+ if (deleteTimer)
467
+ [self updateDeleteTimer];
468
+ else
469
+ [self createAndStartDeleteTimer];
470
+ }
471
+ }
472
+ }};
473
+
474
+ // The design of the setter logic below is taken from the DDAbstractLogger implementation.
475
+ // For documentation please refer to the DDAbstractLogger implementation.
476
+
477
+ if ([self isOnInternalLoggerQueue])
478
+ {
479
+ block();
480
+ }
481
+ else
482
+ {
483
+ dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
484
+ NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
485
+
486
+ dispatch_async(globalLoggingQueue, ^{
487
+ dispatch_async(loggerQueue, block);
488
+ });
489
+ }
490
+ }
491
+
492
+ - (NSTimeInterval)deleteInterval
493
+ {
494
+ // The design of this method is taken from the DDAbstractLogger implementation.
495
+ // For extensive documentation please refer to the DDAbstractLogger implementation.
496
+
497
+ // Note: The internal implementation MUST access the colorsEnabled variable directly,
498
+ // This method is designed explicitly for external access.
499
+ //
500
+ // Using "self." syntax to go through this method will cause immediate deadlock.
501
+ // This is the intended result. Fix it by accessing the ivar directly.
502
+ // Great strides have been take to ensure this is safe to do. Plus it's MUCH faster.
503
+
504
+ NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
505
+ NSAssert(![self isOnInternalLoggerQueue], @"MUST access ivar directly, NOT via self.* syntax.");
506
+
507
+ dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
508
+
509
+ __block NSTimeInterval result;
510
+
511
+ dispatch_sync(globalLoggingQueue, ^{
512
+ dispatch_sync(loggerQueue, ^{
513
+ result = deleteInterval;
514
+ });
515
+ });
516
+
517
+ return result;
518
+ }
519
+
520
+ - (void)setDeleteInterval:(NSTimeInterval)interval
521
+ {
522
+ dispatch_block_t block = ^{ @autoreleasepool {
523
+
524
+ // C99 recommended floating point comparison macro
525
+ // Read: isLessThanOrGreaterThan(floatA, floatB)
526
+
527
+ if (/* deleteInterval != interval */ islessgreater(deleteInterval, interval))
528
+ {
529
+ deleteInterval = interval;
530
+
531
+ // There are several cases we need to handle here.
532
+ //
533
+ // 1. If the deleteInterval was previously enabled and it just got disabled,
534
+ // then we need to stop the deleteTimer. (And we might as well release it.)
535
+ //
536
+ // 2. If the deleteInterval was previously disabled and it just got enabled,
537
+ // then we need to setup the deleteTimer. (Plus we might need to do an immediate delete.)
538
+ //
539
+ // 3. If the deleteInterval increased, then we need to reset the timer so that it fires at the later date.
540
+ //
541
+ // 4. If the deleteInterval decreased, then we need to reset the timer so that it fires at an earlier date.
542
+ // (Plus we might need to do an immediate delete.)
543
+
544
+ if (deleteInterval > 0.0)
545
+ {
546
+ if (deleteTimer == NULL)
547
+ {
548
+ // Handles #2
549
+ //
550
+ // Since the deleteTimer uses the lastDeleteTime to calculate it's first fireDate,
551
+ // if a delete is needed the timer will fire immediately.
552
+
553
+ [self createAndStartDeleteTimer];
554
+ }
555
+ else
556
+ {
557
+ // Handles #3
558
+ // Handles #4
559
+ //
560
+ // Since the deleteTimer uses the lastDeleteTime to calculate it's first fireDate,
561
+ // if a save is needed the timer will fire immediately.
562
+
563
+ [self updateDeleteTimer];
564
+ }
565
+ }
566
+ else if (deleteTimer)
567
+ {
568
+ // Handles #1
569
+
570
+ [self destroyDeleteTimer];
571
+ }
572
+ }
573
+ }};
574
+
575
+ // The design of the setter logic below is taken from the DDAbstractLogger implementation.
576
+ // For documentation please refer to the DDAbstractLogger implementation.
577
+
578
+ if ([self isOnInternalLoggerQueue])
579
+ {
580
+ block();
581
+ }
582
+ else
583
+ {
584
+ dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
585
+ NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
586
+
587
+ dispatch_async(globalLoggingQueue, ^{
588
+ dispatch_async(loggerQueue, block);
589
+ });
590
+ }
591
+ }
592
+
593
+ - (BOOL)deleteOnEverySave
594
+ {
595
+ // The design of this method is taken from the DDAbstractLogger implementation.
596
+ // For extensive documentation please refer to the DDAbstractLogger implementation.
597
+
598
+ // Note: The internal implementation MUST access the colorsEnabled variable directly,
599
+ // This method is designed explicitly for external access.
600
+ //
601
+ // Using "self." syntax to go through this method will cause immediate deadlock.
602
+ // This is the intended result. Fix it by accessing the ivar directly.
603
+ // Great strides have been take to ensure this is safe to do. Plus it's MUCH faster.
604
+
605
+ NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
606
+ NSAssert(![self isOnInternalLoggerQueue], @"MUST access ivar directly, NOT via self.* syntax.");
607
+
608
+ dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
609
+
610
+ __block BOOL result;
611
+
612
+ dispatch_sync(globalLoggingQueue, ^{
613
+ dispatch_sync(loggerQueue, ^{
614
+ result = deleteOnEverySave;
615
+ });
616
+ });
617
+
618
+ return result;
619
+ }
620
+
621
+ - (void)setDeleteOnEverySave:(BOOL)flag
622
+ {
623
+ dispatch_block_t block = ^{
624
+
625
+ deleteOnEverySave = flag;
626
+ };
627
+
628
+ // The design of the setter logic below is taken from the DDAbstractLogger implementation.
629
+ // For documentation please refer to the DDAbstractLogger implementation.
630
+
631
+ if ([self isOnInternalLoggerQueue])
632
+ {
633
+ block();
634
+ }
635
+ else
636
+ {
637
+ dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
638
+ NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
639
+
640
+ dispatch_async(globalLoggingQueue, ^{
641
+ dispatch_async(loggerQueue, block);
642
+ });
643
+ }
644
+ }
645
+
646
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
647
+ #pragma mark Public API
648
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
649
+
650
+ - (void)savePendingLogEntries
651
+ {
652
+ dispatch_block_t block = ^{ @autoreleasepool {
653
+
654
+ [self performSaveAndSuspendSaveTimer];
655
+ }};
656
+
657
+ if ([self isOnInternalLoggerQueue])
658
+ block();
659
+ else
660
+ dispatch_async(loggerQueue, block);
661
+ }
662
+
663
+ - (void)deleteOldLogEntries
664
+ {
665
+ dispatch_block_t block = ^{ @autoreleasepool {
666
+
667
+ [self performDelete];
668
+ }};
669
+
670
+ if ([self isOnInternalLoggerQueue])
671
+ block();
672
+ else
673
+ dispatch_async(loggerQueue, block);
674
+ }
675
+
676
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
677
+ #pragma mark DDLogger
678
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
679
+
680
+ - (void)didAddLogger
681
+ {
682
+ // If you override me be sure to invoke [super didAddLogger];
683
+
684
+ [self createSuspendedSaveTimer];
685
+
686
+ [self createAndStartDeleteTimer];
687
+ }
688
+
689
+ - (void)willRemoveLogger
690
+ {
691
+ // If you override me be sure to invoke [super willRemoveLogger];
692
+
693
+ [self performSaveAndSuspendSaveTimer];
694
+
695
+ [self destroySaveTimer];
696
+ [self destroyDeleteTimer];
697
+ }
698
+
699
+ - (void)logMessage:(DDLogMessage *)logMessage
700
+ {
701
+ if ([self db_log:logMessage])
702
+ {
703
+ BOOL firstUnsavedEntry = (++unsavedCount == 1);
704
+
705
+ if ((unsavedCount >= saveThreshold) && (saveThreshold > 0))
706
+ {
707
+ [self performSaveAndSuspendSaveTimer];
708
+ }
709
+ else if (firstUnsavedEntry)
710
+ {
711
+ unsavedTime = dispatch_time(DISPATCH_TIME_NOW, 0);
712
+ [self updateAndResumeSaveTimer];
713
+ }
714
+ }
715
+ }
716
+
717
+ - (void)flush
718
+ {
719
+ // This method is invoked by DDLog's flushLog method.
720
+ //
721
+ // It is called automatically when the application quits,
722
+ // or if the developer invokes DDLog's flushLog method prior to crashing or something.
723
+
724
+ [self performSaveAndSuspendSaveTimer];
725
+ }
726
+
727
+ @end