activesupport 3.0.0.beta4 → 3.0.pre

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activesupport might be problematic. Click here for more details.

Files changed (333) hide show
  1. data/CHANGELOG +1 -100
  2. data/lib/active_support.rb +4 -38
  3. data/lib/active_support/autoload.rb +28 -0
  4. data/lib/active_support/backtrace_cleaner.rb +9 -31
  5. data/lib/active_support/benchmarkable.rb +0 -1
  6. data/lib/active_support/buffered_logger.rb +1 -0
  7. data/lib/active_support/cache.rb +81 -436
  8. data/lib/active_support/cache/compressed_mem_cache_store.rb +13 -6
  9. data/lib/active_support/cache/file_store.rb +41 -139
  10. data/lib/active_support/cache/mem_cache_store.rb +75 -120
  11. data/lib/active_support/cache/memory_store.rb +27 -127
  12. data/lib/active_support/cache/strategy/local_cache.rb +58 -111
  13. data/lib/active_support/cache/synchronized_memory_store.rb +38 -2
  14. data/lib/active_support/callbacks.rb +48 -87
  15. data/lib/active_support/configurable.rb +18 -19
  16. data/lib/active_support/core_ext/array.rb +0 -1
  17. data/lib/active_support/core_ext/array/access.rb +1 -1
  18. data/lib/active_support/core_ext/array/conversions.rb +54 -29
  19. data/lib/active_support/core_ext/array/extract_options.rb +1 -16
  20. data/lib/active_support/core_ext/array/random_access.rb +5 -19
  21. data/lib/active_support/core_ext/array/wrap.rb +9 -13
  22. data/lib/active_support/core_ext/benchmark.rb +12 -0
  23. data/lib/active_support/core_ext/boolean.rb +1 -0
  24. data/lib/active_support/core_ext/boolean/conversions.rb +11 -0
  25. data/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb +0 -2
  26. data/lib/active_support/core_ext/class.rb +1 -1
  27. data/lib/active_support/core_ext/class/attribute_accessors.rb +27 -33
  28. data/lib/active_support/core_ext/class/delegating_attributes.rb +41 -35
  29. data/lib/active_support/core_ext/class/inheritable_attributes.rb +13 -22
  30. data/lib/active_support/core_ext/class/removal.rb +53 -0
  31. data/lib/active_support/core_ext/date.rb +7 -0
  32. data/lib/active_support/core_ext/date/calculations.rb +8 -30
  33. data/lib/active_support/core_ext/date/conversions.rb +2 -2
  34. data/lib/active_support/core_ext/date_time.rb +5 -0
  35. data/lib/active_support/core_ext/date_time/calculations.rb +1 -2
  36. data/lib/active_support/core_ext/date_time/conversions.rb +5 -23
  37. data/lib/active_support/core_ext/enumerable.rb +9 -5
  38. data/lib/active_support/core_ext/exception.rb +47 -0
  39. data/lib/active_support/core_ext/file.rb +0 -1
  40. data/lib/active_support/core_ext/file/atomic.rb +2 -3
  41. data/lib/active_support/core_ext/float/rounding.rb +2 -3
  42. data/lib/active_support/core_ext/hash/conversions.rb +145 -65
  43. data/lib/active_support/core_ext/hash/deep_merge.rb +7 -6
  44. data/lib/active_support/core_ext/hash/except.rb +0 -8
  45. data/lib/active_support/core_ext/hash/indifferent_access.rb +0 -5
  46. data/lib/active_support/core_ext/hash/keys.rb +11 -10
  47. data/lib/active_support/core_ext/hash/slice.rb +0 -6
  48. data/lib/active_support/core_ext/integer.rb +1 -1
  49. data/lib/active_support/core_ext/integer/even_odd.rb +16 -0
  50. data/lib/active_support/core_ext/kernel.rb +1 -1
  51. data/lib/active_support/core_ext/kernel/daemonizing.rb +7 -0
  52. data/lib/active_support/core_ext/kernel/debugger.rb +2 -3
  53. data/lib/active_support/core_ext/kernel/reporting.rb +1 -2
  54. data/lib/active_support/core_ext/load_error.rb +30 -17
  55. data/lib/active_support/core_ext/logger.rb +1 -1
  56. data/lib/active_support/core_ext/module.rb +3 -5
  57. data/lib/active_support/core_ext/module/aliasing.rb +1 -1
  58. data/lib/active_support/core_ext/module/attr_accessor_with_default.rb +1 -1
  59. data/lib/active_support/core_ext/module/attr_internal.rb +2 -2
  60. data/lib/active_support/core_ext/module/attribute_accessors.rb +21 -25
  61. data/lib/active_support/core_ext/module/delegation.rb +10 -21
  62. data/lib/active_support/core_ext/module/inclusion.rb +30 -0
  63. data/lib/active_support/core_ext/module/introspection.rb +8 -8
  64. data/lib/active_support/core_ext/module/loading.rb +23 -0
  65. data/lib/active_support/core_ext/module/synchronization.rb +1 -2
  66. data/lib/active_support/core_ext/name_error.rb +1 -3
  67. data/lib/active_support/core_ext/nil.rb +1 -0
  68. data/lib/active_support/core_ext/nil/conversions.rb +5 -0
  69. data/lib/active_support/core_ext/object.rb +2 -6
  70. data/lib/active_support/core_ext/object/blank.rb +2 -20
  71. data/lib/active_support/core_ext/object/conversions.rb +16 -2
  72. data/lib/active_support/core_ext/object/duplicable.rb +1 -23
  73. data/lib/active_support/core_ext/object/extending.rb +77 -8
  74. data/lib/active_support/core_ext/object/instance_variables.rb +7 -0
  75. data/lib/active_support/core_ext/object/metaclass.rb +13 -0
  76. data/lib/active_support/core_ext/object/misc.rb +1 -0
  77. data/lib/active_support/core_ext/object/tap.rb +16 -0
  78. data/lib/active_support/core_ext/object/with_options.rb +0 -2
  79. data/lib/active_support/core_ext/proc.rb +4 -4
  80. data/lib/active_support/core_ext/regexp.rb +22 -0
  81. data/lib/active_support/core_ext/rexml.rb +1 -4
  82. data/lib/active_support/core_ext/string.rb +2 -3
  83. data/lib/active_support/core_ext/string/access.rb +2 -4
  84. data/lib/active_support/core_ext/string/bytesize.rb +5 -0
  85. data/lib/active_support/core_ext/string/conversions.rb +1 -36
  86. data/lib/active_support/core_ext/string/filters.rb +0 -29
  87. data/lib/active_support/core_ext/string/inflections.rb +12 -1
  88. data/lib/active_support/core_ext/string/interpolation.rb +92 -2
  89. data/lib/active_support/core_ext/string/iterators.rb +13 -0
  90. data/lib/active_support/core_ext/string/multibyte.rb +19 -16
  91. data/lib/active_support/core_ext/string/output_safety.rb +35 -101
  92. data/lib/active_support/core_ext/string/starts_ends_with.rb +14 -0
  93. data/lib/active_support/core_ext/string/xchar.rb +1 -1
  94. data/lib/active_support/core_ext/symbol.rb +1 -0
  95. data/lib/active_support/core_ext/symbol/to_proc.rb +14 -0
  96. data/lib/active_support/core_ext/time.rb +10 -0
  97. data/lib/active_support/core_ext/time/calculations.rb +7 -9
  98. data/lib/active_support/core_ext/time/conversions.rb +0 -1
  99. data/lib/active_support/core_ext/time/marshal_with_utc_flag.rb +22 -0
  100. data/lib/active_support/core_ext/uri.rb +4 -10
  101. data/lib/active_support/dependencies.rb +192 -179
  102. data/lib/active_support/deprecated_callbacks.rb +283 -0
  103. data/lib/active_support/deprecation/behaviors.rb +1 -1
  104. data/lib/active_support/deprecation/method_wrappers.rb +9 -10
  105. data/lib/active_support/deprecation/reporting.rb +1 -2
  106. data/lib/active_support/duration.rb +2 -6
  107. data/lib/active_support/hash_with_indifferent_access.rb +1 -9
  108. data/lib/active_support/inflections.rb +1 -1
  109. data/lib/active_support/inflector.rb +407 -4
  110. data/lib/active_support/json/backends/jsongem.rb +9 -12
  111. data/lib/active_support/json/decoding.rb +1 -16
  112. data/lib/active_support/json/encoding.rb +12 -42
  113. data/lib/active_support/locale/en.yml +1 -4
  114. data/lib/active_support/memoizable.rb +1 -1
  115. data/lib/active_support/message_encryptor.rb +0 -1
  116. data/lib/active_support/message_verifier.rb +5 -6
  117. data/lib/active_support/multibyte.rb +22 -7
  118. data/lib/active_support/multibyte/chars.rb +392 -164
  119. data/lib/active_support/multibyte/unicode_database.rb +71 -0
  120. data/lib/active_support/multibyte/utils.rb +7 -6
  121. data/lib/active_support/notifications.rb +113 -23
  122. data/lib/active_support/ordered_hash.rb +11 -35
  123. data/lib/active_support/ordered_options.rb +0 -6
  124. data/lib/active_support/rescuable.rb +4 -7
  125. data/lib/active_support/ruby/shim.rb +6 -4
  126. data/lib/active_support/test_case.rb +7 -2
  127. data/lib/active_support/testing/assertions.rb +0 -15
  128. data/lib/active_support/testing/declarative.rb +1 -1
  129. data/lib/active_support/testing/isolation.rb +19 -63
  130. data/lib/active_support/testing/performance.rb +337 -342
  131. data/lib/active_support/testing/setup_and_teardown.rb +29 -51
  132. data/lib/active_support/time.rb +3 -23
  133. data/lib/active_support/time_with_zone.rb +10 -5
  134. data/lib/active_support/values/time_zone.rb +84 -40
  135. data/lib/active_support/values/unicode_tables.dat +0 -0
  136. data/lib/active_support/vendor.rb +16 -0
  137. data/lib/active_support/vendor/builder-2.1.2/lib/blankslate.rb +113 -0
  138. data/lib/active_support/vendor/builder-2.1.2/lib/builder.rb +13 -0
  139. data/lib/active_support/vendor/builder-2.1.2/lib/builder/blankslate.rb +20 -0
  140. data/lib/active_support/vendor/builder-2.1.2/lib/builder/css.rb +250 -0
  141. data/lib/active_support/vendor/builder-2.1.2/lib/builder/xchar.rb +115 -0
  142. data/lib/active_support/vendor/builder-2.1.2/lib/builder/xmlbase.rb +139 -0
  143. data/lib/active_support/vendor/builder-2.1.2/lib/builder/xmlevents.rb +63 -0
  144. data/lib/active_support/vendor/builder-2.1.2/lib/builder/xmlmarkup.rb +328 -0
  145. data/lib/active_support/vendor/i18n-0.1.3/MIT-LICENSE +20 -0
  146. data/lib/active_support/vendor/i18n-0.1.3/README.textile +20 -0
  147. data/lib/active_support/vendor/i18n-0.1.3/Rakefile +5 -0
  148. data/lib/active_support/vendor/i18n-0.1.3/i18n.gemspec +27 -0
  149. data/lib/active_support/vendor/i18n-0.1.3/lib/i18n.rb +204 -0
  150. data/lib/active_support/vendor/i18n-0.1.3/lib/i18n/backend/simple.rb +215 -0
  151. data/lib/active_support/vendor/i18n-0.1.3/lib/i18n/exceptions.rb +53 -0
  152. data/lib/active_support/vendor/i18n-0.1.3/test/all.rb +5 -0
  153. data/lib/active_support/vendor/i18n-0.1.3/test/i18n_exceptions_test.rb +99 -0
  154. data/lib/active_support/vendor/i18n-0.1.3/test/i18n_test.rb +124 -0
  155. data/lib/active_support/vendor/i18n-0.1.3/test/locale/en.rb +1 -0
  156. data/lib/active_support/vendor/i18n-0.1.3/test/locale/en.yml +3 -0
  157. data/lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb +567 -0
  158. data/lib/active_support/vendor/memcache-client-1.7.5/lib/memcache.rb +1133 -0
  159. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo.rb +33 -0
  160. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/data_timezone.rb +47 -0
  161. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/data_timezone_info.rb +228 -0
  162. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Algiers.rb +55 -0
  163. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Cairo.rb +219 -0
  164. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Casablanca.rb +42 -0
  165. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Harare.rb +18 -0
  166. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Johannesburg.rb +25 -0
  167. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Monrovia.rb +22 -0
  168. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Nairobi.rb +23 -0
  169. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Argentina/Buenos_Aires.rb +166 -0
  170. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Argentina/San_Juan.rb +86 -0
  171. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Bogota.rb +23 -0
  172. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Caracas.rb +23 -0
  173. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Chicago.rb +283 -0
  174. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Chihuahua.rb +136 -0
  175. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Denver.rb +204 -0
  176. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Godthab.rb +161 -0
  177. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Guatemala.rb +27 -0
  178. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Halifax.rb +274 -0
  179. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Indiana/Indianapolis.rb +149 -0
  180. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Juneau.rb +194 -0
  181. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/La_Paz.rb +22 -0
  182. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Lima.rb +35 -0
  183. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Los_Angeles.rb +232 -0
  184. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Mazatlan.rb +139 -0
  185. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Mexico_City.rb +144 -0
  186. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Monterrey.rb +131 -0
  187. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/New_York.rb +282 -0
  188. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Phoenix.rb +30 -0
  189. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Regina.rb +74 -0
  190. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Santiago.rb +205 -0
  191. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Sao_Paulo.rb +171 -0
  192. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/St_Johns.rb +288 -0
  193. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Tijuana.rb +196 -0
  194. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Almaty.rb +67 -0
  195. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Baghdad.rb +73 -0
  196. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Baku.rb +161 -0
  197. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Bangkok.rb +20 -0
  198. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Chongqing.rb +33 -0
  199. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Colombo.rb +30 -0
  200. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Dhaka.rb +27 -0
  201. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Hong_Kong.rb +87 -0
  202. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Irkutsk.rb +165 -0
  203. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Jakarta.rb +30 -0
  204. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Jerusalem.rb +163 -0
  205. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kabul.rb +20 -0
  206. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kamchatka.rb +163 -0
  207. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Karachi.rb +32 -0
  208. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kathmandu.rb +20 -0
  209. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kolkata.rb +25 -0
  210. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Krasnoyarsk.rb +163 -0
  211. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kuala_Lumpur.rb +31 -0
  212. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kuwait.rb +18 -0
  213. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Magadan.rb +163 -0
  214. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Muscat.rb +18 -0
  215. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Novosibirsk.rb +164 -0
  216. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Rangoon.rb +24 -0
  217. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Riyadh.rb +18 -0
  218. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Seoul.rb +34 -0
  219. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Shanghai.rb +35 -0
  220. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Singapore.rb +33 -0
  221. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Taipei.rb +59 -0
  222. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tashkent.rb +47 -0
  223. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tbilisi.rb +78 -0
  224. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tehran.rb +121 -0
  225. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tokyo.rb +30 -0
  226. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Ulaanbaatar.rb +65 -0
  227. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Urumqi.rb +33 -0
  228. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Vladivostok.rb +164 -0
  229. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Yakutsk.rb +163 -0
  230. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Yekaterinburg.rb +165 -0
  231. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Yerevan.rb +165 -0
  232. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Atlantic/Azores.rb +270 -0
  233. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Atlantic/Cape_Verde.rb +23 -0
  234. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Atlantic/South_Georgia.rb +18 -0
  235. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Adelaide.rb +187 -0
  236. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Brisbane.rb +35 -0
  237. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Darwin.rb +29 -0
  238. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Hobart.rb +193 -0
  239. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Melbourne.rb +185 -0
  240. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Perth.rb +37 -0
  241. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Sydney.rb +185 -0
  242. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Etc/UTC.rb +16 -0
  243. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Amsterdam.rb +228 -0
  244. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Athens.rb +185 -0
  245. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Belgrade.rb +163 -0
  246. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Berlin.rb +188 -0
  247. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Bratislava.rb +13 -0
  248. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Brussels.rb +232 -0
  249. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Bucharest.rb +181 -0
  250. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Budapest.rb +197 -0
  251. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Copenhagen.rb +179 -0
  252. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Dublin.rb +276 -0
  253. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Helsinki.rb +163 -0
  254. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Istanbul.rb +218 -0
  255. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Kiev.rb +168 -0
  256. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Lisbon.rb +268 -0
  257. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Ljubljana.rb +13 -0
  258. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/London.rb +288 -0
  259. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Madrid.rb +211 -0
  260. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Minsk.rb +170 -0
  261. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Moscow.rb +181 -0
  262. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Paris.rb +232 -0
  263. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Prague.rb +187 -0
  264. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Riga.rb +176 -0
  265. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Rome.rb +215 -0
  266. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Sarajevo.rb +13 -0
  267. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Skopje.rb +13 -0
  268. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Sofia.rb +173 -0
  269. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Stockholm.rb +165 -0
  270. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Tallinn.rb +172 -0
  271. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Vienna.rb +183 -0
  272. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Vilnius.rb +170 -0
  273. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Warsaw.rb +212 -0
  274. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Zagreb.rb +13 -0
  275. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Auckland.rb +202 -0
  276. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Fiji.rb +23 -0
  277. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Guam.rb +22 -0
  278. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Honolulu.rb +28 -0
  279. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Majuro.rb +20 -0
  280. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Midway.rb +25 -0
  281. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Noumea.rb +25 -0
  282. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Pago_Pago.rb +26 -0
  283. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Port_Moresby.rb +20 -0
  284. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Tongatapu.rb +27 -0
  285. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/info_timezone.rb +52 -0
  286. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/linked_timezone.rb +51 -0
  287. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/linked_timezone_info.rb +44 -0
  288. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/offset_rationals.rb +98 -0
  289. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/ruby_core_support.rb +56 -0
  290. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/time_or_datetime.rb +292 -0
  291. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone.rb +508 -0
  292. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_definition.rb +56 -0
  293. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_info.rb +40 -0
  294. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_offset_info.rb +94 -0
  295. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_period.rb +198 -0
  296. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_transition_info.rb +129 -0
  297. data/lib/active_support/version.rb +2 -3
  298. data/lib/active_support/whiny_nil.rb +7 -9
  299. data/lib/active_support/xml_mini.rb +1 -126
  300. data/lib/active_support/xml_mini/jdom.rb +0 -2
  301. data/lib/active_support/xml_mini/libxml.rb +86 -24
  302. data/lib/active_support/xml_mini/nokogiri.rb +24 -27
  303. data/lib/active_support/xml_mini/rexml.rb +1 -7
  304. metadata +191 -49
  305. data/lib/active_support/builder.rb +0 -6
  306. data/lib/active_support/core_ext/array/uniq_by.rb +0 -17
  307. data/lib/active_support/core_ext/class/attribute.rb +0 -67
  308. data/lib/active_support/core_ext/class/subclasses.rb +0 -55
  309. data/lib/active_support/core_ext/file/path.rb +0 -5
  310. data/lib/active_support/core_ext/integer/multiple.rb +0 -6
  311. data/lib/active_support/core_ext/kernel/singleton_class.rb +0 -13
  312. data/lib/active_support/core_ext/module/anonymous.rb +0 -24
  313. data/lib/active_support/core_ext/module/method_names.rb +0 -14
  314. data/lib/active_support/core_ext/module/reachable.rb +0 -10
  315. data/lib/active_support/core_ext/module/remove_method.rb +0 -6
  316. data/lib/active_support/core_ext/object/to_param.rb +0 -49
  317. data/lib/active_support/core_ext/object/to_query.rb +0 -27
  318. data/lib/active_support/core_ext/string/encoding.rb +0 -11
  319. data/lib/active_support/core_ext/string/exclude.rb +0 -6
  320. data/lib/active_support/core_ext/time/marshal.rb +0 -56
  321. data/lib/active_support/dependencies/autoload.rb +0 -50
  322. data/lib/active_support/i18n.rb +0 -8
  323. data/lib/active_support/inflector/inflections.rb +0 -211
  324. data/lib/active_support/inflector/methods.rb +0 -141
  325. data/lib/active_support/inflector/transliterate.rb +0 -97
  326. data/lib/active_support/json/backends/yajl.rb +0 -40
  327. data/lib/active_support/lazy_load_hooks.rb +0 -27
  328. data/lib/active_support/multibyte/unicode.rb +0 -393
  329. data/lib/active_support/notifications/fanout.rb +0 -93
  330. data/lib/active_support/notifications/instrumenter.rb +0 -56
  331. data/lib/active_support/railtie.rb +0 -100
  332. data/lib/active_support/xml_mini/libxmlsax.rb +0 -85
  333. data/lib/active_support/xml_mini/nokogirisax.rb +0 -83
@@ -1,6 +1,6 @@
1
- require 'date'
2
1
  require 'active_support/inflector'
3
- require 'active_support/core_ext/time/calculations'
2
+ require 'active_support/core_ext/time/conversions'
3
+ require 'active_support/core_ext/date_time/conversions'
4
4
 
5
5
  class Date
6
6
  DATE_FORMATS = {
@@ -0,0 +1,5 @@
1
+ require 'active_support/core_ext/time'
2
+ require 'active_support/core_ext/date_time/acts_like'
3
+ require 'active_support/core_ext/date_time/calculations'
4
+ require 'active_support/core_ext/date_time/conversions'
5
+ require 'active_support/core_ext/date_time/zones'
@@ -1,5 +1,4 @@
1
- require 'rational' unless RUBY_VERSION >= '1.9.2'
2
- require 'active_support/core_ext/object/acts_like'
1
+ require 'rational'
3
2
 
4
3
  class DateTime
5
4
  class << self
@@ -1,6 +1,4 @@
1
1
  require 'active_support/inflector'
2
- require 'active_support/core_ext/time/conversions'
3
- require 'active_support/core_ext/date_time/calculations'
4
2
 
5
3
  class DateTime
6
4
  # Ruby 1.9 has DateTime#to_time which internally relies on Time. We define our own #to_time which allows
@@ -60,7 +58,7 @@ class DateTime
60
58
  # Converts self to a Ruby Date object; time portion is discarded
61
59
  def to_date
62
60
  ::Date.new(year, month, day)
63
- end unless instance_methods(false).include?(:to_date)
61
+ end unless method_defined?(:to_date)
64
62
 
65
63
  # Attempts to convert self to a Ruby Time object; returns self if out of range of Ruby Time class
66
64
  # If self has an offset other than 0, self will just be returned unaltered, since there's no clean way to map it to a Time
@@ -71,32 +69,16 @@ class DateTime
71
69
  # To be able to keep Times, Dates and DateTimes interchangeable on conversions
72
70
  def to_datetime
73
71
  self
74
- end unless instance_methods(false).include?(:to_datetime)
75
-
76
- def self.civil_from_format(utc_or_local, year, month=1, day=1, hour=0, min=0, sec=0)
77
- offset = utc_or_local.to_sym == :local ? local_offset : 0
78
- civil(year, month, day, hour, min, sec, offset)
79
- end
72
+ end unless method_defined?(:to_datetime)
80
73
 
81
74
  # Converts datetime to an appropriate format for use in XML
82
75
  def xmlschema
83
76
  strftime("%Y-%m-%dT%H:%M:%S%Z")
84
- end unless instance_methods(false).include?(:xmlschema)
77
+ end unless method_defined?(:xmlschema)
85
78
 
86
79
  # Converts self to a floating-point number of seconds since the Unix epoch
87
80
  def to_f
88
- seconds_since_unix_epoch.to_f
89
- end
90
-
91
- # Converts self to an integer number of seconds since the Unix epoch
92
- def to_i
93
- seconds_since_unix_epoch.to_i
94
- end
95
-
96
- private
97
-
98
- def seconds_since_unix_epoch
99
- seconds_per_day = 86_400
100
- (self - ::DateTime.civil(1970)) * seconds_per_day
81
+ days_since_unix_epoch = self - ::DateTime.civil(1970)
82
+ (days_since_unix_epoch * 86_400).to_f
101
83
  end
102
84
  end
@@ -101,11 +101,15 @@ module Enumerable
101
101
  size = block_given? ? select(&block).size : self.size
102
102
  size > 1
103
103
  end
104
-
105
- # The negative of the Enumerable#include?. Returns true if the collection does not include the object.
106
- def exclude?(object)
107
- !include?(object)
108
- end
104
+
105
+ # Returns true if none of the elements match the given block.
106
+ #
107
+ # success = responses.none? {|r| r.status / 100 == 5 }
108
+ #
109
+ # This is a builtin method in Ruby 1.8.7 and later.
110
+ def none?(&block)
111
+ !any?(&block)
112
+ end unless [].respond_to?(:none?)
109
113
  end
110
114
 
111
115
  class Range #:nodoc:
@@ -1,3 +1,50 @@
1
1
  module ActiveSupport
2
2
  FrozenObjectError = RUBY_VERSION < '1.9' ? TypeError : RuntimeError
3
3
  end
4
+
5
+ # TODO: Turn all this into using the BacktraceCleaner.
6
+ class Exception # :nodoc:
7
+ # Clean the paths contained in the message.
8
+ def self.clean_paths(string)
9
+ require 'pathname' unless defined? Pathname
10
+ string.gsub(%r{[\w. ]+(/[\w. ]+)+(\.rb)?(\b|$)}) do |path|
11
+ Pathname.new(path).cleanpath
12
+ end
13
+ end
14
+
15
+ def clean_message
16
+ Exception.clean_paths(message)
17
+ end
18
+
19
+ TraceSubstitutions = []
20
+ FrameworkStart = /action_controller\/dispatcher\.rb/.freeze
21
+ FrameworkRegexp = /generated|vendor|dispatch|ruby|script\/\w+/.freeze
22
+
23
+ def clean_backtrace
24
+ backtrace.collect do |line|
25
+ substituted = TraceSubstitutions.inject(line) do |result, (regexp, sub)|
26
+ result.gsub regexp, sub
27
+ end
28
+ Exception.clean_paths(substituted)
29
+ end
30
+ end
31
+
32
+ def application_backtrace
33
+ before_framework_frame = nil
34
+ before_application_frame = true
35
+
36
+ trace = clean_backtrace.reject do |line|
37
+ before_framework_frame ||= (line =~ FrameworkStart)
38
+ non_app_frame = (line =~ FrameworkRegexp)
39
+ before_application_frame = false unless non_app_frame
40
+ before_framework_frame || (non_app_frame && !before_application_frame)
41
+ end
42
+
43
+ # If we didn't find any application frames, return an empty app trace.
44
+ before_application_frame ? [] : trace
45
+ end
46
+
47
+ def framework_backtrace
48
+ clean_backtrace.grep FrameworkRegexp
49
+ end
50
+ end
@@ -1,2 +1 @@
1
1
  require 'active_support/core_ext/file/atomic'
2
- require 'active_support/core_ext/file/path'
@@ -9,12 +9,11 @@ class File
9
9
  # If your temp directory is not on the same filesystem as the file you're
10
10
  # trying to write, you can provide a different temporary directory.
11
11
  #
12
- # File.atomic_write("/data/something.important", "/data/tmp") do |file|
12
+ # File.atomic_write("/data/something.important", "/data/tmp") do |f|
13
13
  # file.write("hello")
14
14
  # end
15
15
  def self.atomic_write(file_name, temp_dir = Dir.tmpdir)
16
16
  require 'tempfile' unless defined?(Tempfile)
17
- require 'fileutils' unless defined?(FileUtils)
18
17
 
19
18
  temp_file = Tempfile.new(basename(file_name), temp_dir)
20
19
  yield temp_file
@@ -32,7 +31,7 @@ class File
32
31
  end
33
32
 
34
33
  # Overwrite original file with temp file
35
- FileUtils.mv(temp_file.path, file_name)
34
+ rename(temp_file.path, file_name)
36
35
 
37
36
  # Set correct permissions on new file
38
37
  chown(old_stat.uid, old_stat.gid, file_name)
@@ -1,6 +1,5 @@
1
1
  class Float
2
- alias precisionless_round round
3
- private :precisionless_round
2
+ remove_method :round
4
3
 
5
4
  # Rounds the float with the specified precision.
6
5
  #
@@ -13,7 +12,7 @@ class Float
13
12
  magnitude = 10.0 ** precision
14
13
  (self * magnitude).round / magnitude
15
14
  else
16
- precisionless_round
15
+ super()
17
16
  end
18
17
  end
19
18
  end
@@ -1,76 +1,148 @@
1
- require 'active_support/xml_mini'
2
1
  require 'active_support/time'
3
- require 'active_support/core_ext/array/wrap'
2
+ require 'active_support/core_ext/object/conversions'
3
+ require 'active_support/core_ext/array/conversions'
4
4
  require 'active_support/core_ext/hash/reverse_merge'
5
- require 'active_support/core_ext/object/blank'
6
- require 'active_support/core_ext/string/inflections'
7
5
 
8
6
  class Hash
9
- # Returns a string containing an XML representation of its receiver:
10
- #
11
- # {"foo" => 1, "bar" => 2}.to_xml
12
- # # =>
13
- # # <?xml version="1.0" encoding="UTF-8"?>
14
- # # <hash>
15
- # # <foo type="integer">1</foo>
16
- # # <bar type="integer">2</bar>
17
- # # </hash>
18
- #
19
- # To do so, the method loops over the pairs and builds nodes that depend on
20
- # the _values_. Given a pair +key+, +value+:
21
- #
22
- # * If +value+ is a hash there's a recursive call with +key+ as <tt>:root</tt>.
23
- #
24
- # * If +value+ is an array there's a recursive call with +key+ as <tt>:root</tt>,
25
- # and +key+ singularized as <tt>:children</tt>.
26
- #
27
- # * If +value+ is a callable object it must expect one or two arguments. Depending
28
- # on the arity, the callable is invoked with the +options+ hash as first argument
29
- # with +key+ as <tt>:root</tt>, and +key+ singularized as second argument. Its
30
- # return value becomes a new node.
31
- #
32
- # * If +value+ responds to +to_xml+ the method is invoked with +key+ as <tt>:root</tt>.
33
- #
34
- # * Otherwise, a node with +key+ as tag is created with a string representation of
35
- # +value+ as text node. If +value+ is +nil+ an attribute "nil" set to "true" is added.
36
- # Unless the option <tt>:skip_types</tt> exists and is true, an attribute "type" is
37
- # added as well according to the following mapping:
7
+ # This module exists to decorate files deserialized using Hash.from_xml with
8
+ # the <tt>original_filename</tt> and <tt>content_type</tt> methods.
9
+ module FileLike #:nodoc:
10
+ attr_writer :original_filename, :content_type
11
+
12
+ def original_filename
13
+ @original_filename || 'untitled'
14
+ end
15
+
16
+ def content_type
17
+ @content_type || 'application/octet-stream'
18
+ end
19
+ end
20
+
21
+ XML_TYPE_NAMES = {
22
+ "Symbol" => "symbol",
23
+ "Fixnum" => "integer",
24
+ "Bignum" => "integer",
25
+ "BigDecimal" => "decimal",
26
+ "Float" => "float",
27
+ "TrueClass" => "boolean",
28
+ "FalseClass" => "boolean",
29
+ "Date" => "date",
30
+ "DateTime" => "datetime",
31
+ "Time" => "datetime"
32
+ } unless defined?(XML_TYPE_NAMES)
33
+
34
+ XML_FORMATTING = {
35
+ "symbol" => Proc.new { |symbol| symbol.to_s },
36
+ "date" => Proc.new { |date| date.to_s(:db) },
37
+ "datetime" => Proc.new { |time| time.xmlschema },
38
+ "binary" => Proc.new { |binary| ActiveSupport::Base64.encode64(binary) },
39
+ "yaml" => Proc.new { |yaml| yaml.to_yaml }
40
+ } unless defined?(XML_FORMATTING)
41
+
42
+ # TODO: use Time.xmlschema instead of Time.parse;
43
+ # use regexp instead of Date.parse
44
+ unless defined?(XML_PARSING)
45
+ XML_PARSING = {
46
+ "symbol" => Proc.new { |symbol| symbol.to_sym },
47
+ "date" => Proc.new { |date| ::Date.parse(date) },
48
+ "datetime" => Proc.new { |time| ::Time.parse(time).utc rescue ::DateTime.parse(time).utc },
49
+ "integer" => Proc.new { |integer| integer.to_i },
50
+ "float" => Proc.new { |float| float.to_f },
51
+ "decimal" => Proc.new { |number| BigDecimal(number) },
52
+ "boolean" => Proc.new { |boolean| %w(1 true).include?(boolean.strip) },
53
+ "string" => Proc.new { |string| string.to_s },
54
+ "yaml" => Proc.new { |yaml| YAML::load(yaml) rescue yaml },
55
+ "base64Binary" => Proc.new { |bin| ActiveSupport::Base64.decode64(bin) },
56
+ "file" => Proc.new do |file, entity|
57
+ f = StringIO.new(ActiveSupport::Base64.decode64(file))
58
+ f.extend(FileLike)
59
+ f.original_filename = entity['name']
60
+ f.content_type = entity['content_type']
61
+ f
62
+ end
63
+ }
64
+
65
+ XML_PARSING.update(
66
+ "double" => XML_PARSING["float"],
67
+ "dateTime" => XML_PARSING["datetime"]
68
+ )
69
+ end
70
+
71
+ # Converts a hash into a string suitable for use as a URL query string. An optional <tt>namespace</tt> can be
72
+ # passed to enclose the param names (see example below).
38
73
  #
39
- # XML_TYPE_NAMES = {
40
- # "Symbol" => "symbol",
41
- # "Fixnum" => "integer",
42
- # "Bignum" => "integer",
43
- # "BigDecimal" => "decimal",
44
- # "Float" => "float",
45
- # "TrueClass" => "boolean",
46
- # "FalseClass" => "boolean",
47
- # "Date" => "date",
48
- # "DateTime" => "datetime",
49
- # "Time" => "datetime"
50
- # }
51
- #
52
- # By default the root node is "hash", but that's configurable via the <tt>:root</tt> option.
53
- #
54
- # The default XML builder is a fresh instance of <tt>Builder::XmlMarkup</tt>. You can
55
- # configure your own builder with the <tt>:builder</tt> option. The method also accepts
56
- # options like <tt>:dasherize</tt> and friends, they are forwarded to the builder.
74
+ # ==== Examples
75
+ # { :name => 'David', :nationality => 'Danish' }.to_query # => "name=David&nationality=Danish"
76
+ #
77
+ # { :name => 'David', :nationality => 'Danish' }.to_query('user') # => "user%5Bname%5D=David&user%5Bnationality%5D=Danish"
78
+ def to_query(namespace = nil)
79
+ collect do |key, value|
80
+ value.to_query(namespace ? "#{namespace}[#{key}]" : key)
81
+ end.sort * '&'
82
+ end
83
+
84
+ alias_method :to_param, :to_query
85
+
57
86
  def to_xml(options = {})
58
- require 'active_support/builder' unless defined?(Builder)
87
+ require 'builder' unless defined?(Builder)
59
88
 
60
89
  options = options.dup
61
- options[:indent] ||= 2
62
- options[:root] ||= "hash"
63
- options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent])
90
+ options[:indent] ||= 2
91
+ options.reverse_merge!({ :builder => Builder::XmlMarkup.new(:indent => options[:indent]),
92
+ :root => "hash" })
93
+ options[:builder].instruct! unless options.delete(:skip_instruct)
94
+ root = rename_key(options[:root].to_s, options)
64
95
 
65
- builder = options[:builder]
66
- builder.instruct! unless options.delete(:skip_instruct)
96
+ options[:builder].__send__(:method_missing, root) do
97
+ each do |key, value|
98
+ case value
99
+ when ::Hash
100
+ value.to_xml(options.merge({ :root => key, :skip_instruct => true }))
101
+ when ::Array
102
+ value.to_xml(options.merge({ :root => key, :children => key.to_s.singularize, :skip_instruct => true}))
103
+ when ::Method, ::Proc
104
+ # If the Method or Proc takes two arguments, then
105
+ # pass the suggested child element name. This is
106
+ # used if the Method or Proc will be operating over
107
+ # multiple records and needs to create an containing
108
+ # element that will contain the objects being
109
+ # serialized.
110
+ if 1 == value.arity
111
+ value.call(options.merge({ :root => key, :skip_instruct => true }))
112
+ else
113
+ value.call(options.merge({ :root => key, :skip_instruct => true }), key.to_s.singularize)
114
+ end
115
+ else
116
+ if value.respond_to?(:to_xml)
117
+ value.to_xml(options.merge({ :root => key, :skip_instruct => true }))
118
+ else
119
+ type_name = XML_TYPE_NAMES[value.class.name]
67
120
 
68
- root = ActiveSupport::XmlMini.rename_key(options[:root].to_s, options)
121
+ key = rename_key(key.to_s, options)
69
122
 
70
- builder.__send__(:method_missing, root) do
71
- each { |key, value| ActiveSupport::XmlMini.to_tag(key, value, options) }
72
- yield builder if block_given?
123
+ attributes = options[:skip_types] || value.nil? || type_name.nil? ? { } : { :type => type_name }
124
+ if value.nil?
125
+ attributes[:nil] = true
126
+ end
127
+
128
+ options[:builder].tag!(key,
129
+ XML_FORMATTING[type_name] ? XML_FORMATTING[type_name].call(value) : value,
130
+ attributes
131
+ )
132
+ end
133
+ end
134
+ end
135
+
136
+ yield options[:builder] if block_given?
73
137
  end
138
+
139
+ end
140
+
141
+ def rename_key(key, options = {})
142
+ camelize = options.has_key?(:camelize) && options[:camelize]
143
+ dasherize = !options.has_key?(:dasherize) || options[:dasherize]
144
+ key = key.camelize if camelize
145
+ dasherize ? key.dasherize : key
74
146
  end
75
147
 
76
148
  class << self
@@ -83,7 +155,7 @@ class Hash
83
155
  case value.class.to_s
84
156
  when 'Hash'
85
157
  if value['type'] == 'array'
86
- child_key, entries = Array.wrap(value.detect { |k,v| k != 'type' }) # child_key is throwaway
158
+ child_key, entries = value.detect { |k,v| k != 'type' } # child_key is throwaway
87
159
  if entries.nil? || (c = value['__content__'] && c.blank?)
88
160
  []
89
161
  else
@@ -98,8 +170,12 @@ class Hash
98
170
  end
99
171
  elsif value.has_key?("__content__")
100
172
  content = value["__content__"]
101
- if parser = ActiveSupport::XmlMini::PARSING[value["type"]]
102
- parser.arity == 1 ? parser.call(content) : parser.call(content, value)
173
+ if parser = XML_PARSING[value["type"]]
174
+ if parser.arity == 2
175
+ XML_PARSING[value["type"]].call(content, value)
176
+ else
177
+ XML_PARSING[value["type"]].call(content)
178
+ end
103
179
  else
104
180
  content
105
181
  end
@@ -125,7 +201,11 @@ class Hash
125
201
  end
126
202
  when 'Array'
127
203
  value.map! { |i| typecast_xml_value(i) }
128
- value.length > 1 ? value : value.first
204
+ case value.length
205
+ when 0 then nil
206
+ when 1 then value.first
207
+ else value
208
+ end
129
209
  when 'String'
130
210
  value
131
211
  else
@@ -1,16 +1,17 @@
1
1
  class Hash
2
2
  # Returns a new hash with +self+ and +other_hash+ merged recursively.
3
3
  def deep_merge(other_hash)
4
- dup.deep_merge!(other_hash)
4
+ target = dup
5
+ other_hash.each_pair do |k,v|
6
+ tv = target[k]
7
+ target[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? tv.deep_merge(v) : v
8
+ end
9
+ target
5
10
  end
6
11
 
7
12
  # Returns a new hash with +self+ and +other_hash+ merged recursively.
8
13
  # Modifies the receiver in place.
9
14
  def deep_merge!(other_hash)
10
- other_hash.each_pair do |k,v|
11
- tv = self[k]
12
- self[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? tv.deep_merge(v) : v
13
- end
14
- self
15
+ replace(deep_merge(other_hash))
15
16
  end
16
17
  end