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
@@ -2,9 +2,8 @@ module ActiveSupport
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 3
4
4
  MINOR = 0
5
- TINY = 0
6
- BUILD = "beta4"
5
+ TINY = "pre"
7
6
 
8
- STRING = [MAJOR, MINOR, TINY, BUILD].join('.')
7
+ STRING = [MAJOR, MINOR, TINY].join('.')
9
8
  end
10
9
  end
@@ -11,7 +11,7 @@
11
11
  # classes in NilClass::WHINERS the error message suggests which could be the
12
12
  # actual intended class:
13
13
  #
14
- # $ rails runner nil.destroy
14
+ # $ script/runner nil.destroy
15
15
  # ...
16
16
  # You might have expected an instance of ActiveRecord::Base.
17
17
  # ...
@@ -25,16 +25,17 @@
25
25
  # By default it is on in development and test modes, and it is off in production
26
26
  # mode.
27
27
  class NilClass
28
+ WHINERS = [::Array]
29
+ WHINERS << ::ActiveRecord::Base if defined? ::ActiveRecord
30
+
28
31
  METHOD_CLASS_MAP = Hash.new
29
32
 
30
- def self.add_whiner(klass)
33
+ WHINERS.each do |klass|
31
34
  methods = klass.public_instance_methods - public_instance_methods
32
35
  class_name = klass.name
33
36
  methods.each { |method| METHOD_CLASS_MAP[method.to_sym] = class_name }
34
37
  end
35
38
 
36
- add_whiner ::Array
37
-
38
39
  # Raises a RuntimeError when you attempt to call +id+ on +nil+.
39
40
  def id
40
41
  raise RuntimeError, "Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id", caller
@@ -42,11 +43,7 @@ class NilClass
42
43
 
43
44
  private
44
45
  def method_missing(method, *args, &block)
45
- if klass = METHOD_CLASS_MAP[method]
46
- raise_nil_warning_for klass, method, caller
47
- else
48
- super
49
- end
46
+ raise_nil_warning_for METHOD_CLASS_MAP[method], method, caller
50
47
  end
51
48
 
52
49
  # Raises a NoMethodError when you attempt to call a method on +nil+.
@@ -58,3 +55,4 @@ class NilClass
58
55
  raise NoMethodError, message, with_caller || caller
59
56
  end
60
57
  end
58
+
@@ -9,71 +9,6 @@ module ActiveSupport
9
9
  module XmlMini
10
10
  extend self
11
11
 
12
- # This module exists to decorate files deserialized using Hash.from_xml with
13
- # the <tt>original_filename</tt> and <tt>content_type</tt> methods.
14
- module FileLike #:nodoc:
15
- attr_writer :original_filename, :content_type
16
-
17
- def original_filename
18
- @original_filename || 'untitled'
19
- end
20
-
21
- def content_type
22
- @content_type || 'application/octet-stream'
23
- end
24
- end
25
-
26
- DEFAULT_ENCODINGS = {
27
- "binary" => "base64"
28
- } unless defined?(TYPE_NAMES)
29
-
30
- TYPE_NAMES = {
31
- "Symbol" => "symbol",
32
- "Fixnum" => "integer",
33
- "Bignum" => "integer",
34
- "BigDecimal" => "decimal",
35
- "Float" => "float",
36
- "TrueClass" => "boolean",
37
- "FalseClass" => "boolean",
38
- "Date" => "date",
39
- "DateTime" => "datetime",
40
- "Time" => "datetime",
41
- "Array" => "array",
42
- "Hash" => "hash"
43
- } unless defined?(TYPE_NAMES)
44
-
45
- FORMATTING = {
46
- "symbol" => Proc.new { |symbol| symbol.to_s },
47
- "date" => Proc.new { |date| date.to_s(:db) },
48
- "datetime" => Proc.new { |time| time.xmlschema },
49
- "binary" => Proc.new { |binary| ActiveSupport::Base64.encode64(binary) },
50
- "yaml" => Proc.new { |yaml| yaml.to_yaml }
51
- } unless defined?(FORMATTING)
52
-
53
- # TODO: use Time.xmlschema instead of Time.parse;
54
- # use regexp instead of Date.parse
55
- unless defined?(PARSING)
56
- PARSING = {
57
- "symbol" => Proc.new { |symbol| symbol.to_sym },
58
- "date" => Proc.new { |date| ::Date.parse(date) },
59
- "datetime" => Proc.new { |time| ::Time.parse(time).utc rescue ::DateTime.parse(time).utc },
60
- "integer" => Proc.new { |integer| integer.to_i },
61
- "float" => Proc.new { |float| float.to_f },
62
- "decimal" => Proc.new { |number| BigDecimal(number) },
63
- "boolean" => Proc.new { |boolean| %w(1 true).include?(boolean.strip) },
64
- "string" => Proc.new { |string| string.to_s },
65
- "yaml" => Proc.new { |yaml| YAML::load(yaml) rescue yaml },
66
- "base64Binary" => Proc.new { |bin| ActiveSupport::Base64.decode64(bin) },
67
- "binary" => Proc.new { |bin, entity| _parse_binary(bin, entity) },
68
- "file" => Proc.new { |file, entity| _parse_file(file, entity) }
69
- }
70
-
71
- PARSING.update(
72
- "double" => PARSING["float"],
73
- "dateTime" => PARSING["datetime"]
74
- )
75
- end
76
-
77
12
  attr_reader :backend
78
13
  delegate :parse, :to => :backend
79
14
 
@@ -81,7 +16,7 @@ module ActiveSupport
81
16
  if name.is_a?(Module)
82
17
  @backend = name
83
18
  else
84
- require "active_support/xml_mini/#{name.to_s.downcase}"
19
+ require "active_support/xml_mini/#{name.to_s.downcase}.rb"
85
20
  @backend = ActiveSupport.const_get("XmlMini_#{name}")
86
21
  end
87
22
  end
@@ -92,66 +27,6 @@ module ActiveSupport
92
27
  ensure
93
28
  self.backend = old_backend
94
29
  end
95
-
96
- def to_tag(key, value, options)
97
- type_name = options.delete(:type)
98
- merged_options = options.merge(:root => key, :skip_instruct => true)
99
-
100
- if value.is_a?(::Method) || value.is_a?(::Proc)
101
- if value.arity == 1
102
- value.call(merged_options)
103
- else
104
- value.call(merged_options, key.to_s.singularize)
105
- end
106
- elsif value.respond_to?(:to_xml)
107
- value.to_xml(merged_options)
108
- else
109
- type_name ||= TYPE_NAMES[value.class.name]
110
- type_name ||= value.class.name if value && !value.respond_to?(:to_str)
111
- type_name = type_name.to_s if type_name
112
-
113
- key = rename_key(key.to_s, options)
114
-
115
- attributes = options[:skip_types] || type_name.nil? ? { } : { :type => type_name }
116
- attributes[:nil] = true if value.nil?
117
-
118
- encoding = options[:encoding] || DEFAULT_ENCODINGS[type_name]
119
- attributes[:encoding] = encoding if encoding
120
-
121
- formatted_value = FORMATTING[type_name] && !value.nil? ?
122
- FORMATTING[type_name].call(value) : value
123
-
124
- options[:builder].tag!(key, formatted_value, attributes)
125
- end
126
- end
127
-
128
- def rename_key(key, options = {})
129
- camelize = options.has_key?(:camelize) && options[:camelize]
130
- dasherize = !options.has_key?(:dasherize) || options[:dasherize]
131
- key = key.camelize if camelize
132
- key = key.dasherize if dasherize
133
- key
134
- end
135
-
136
- protected
137
-
138
- # TODO: Add support for other encodings
139
- def _parse_binary(bin, entity) #:nodoc:
140
- case entity['encoding']
141
- when 'base64'
142
- ActiveSupport::Base64.decode64(bin)
143
- else
144
- bin
145
- end
146
- end
147
-
148
- def _parse_file(file, entity)
149
- f = StringIO.new(ActiveSupport::Base64.decode64(file))
150
- f.extend(FileLike)
151
- f.original_filename = entity['name']
152
- f.content_type = entity['content_type']
153
- f
154
- end
155
30
  end
156
31
 
157
32
  XmlMini.backend = 'REXML'
@@ -3,8 +3,6 @@ raise "JRuby is required to use the JDOM backend for XmlMini" unless RUBY_PLATFO
3
3
  require 'jruby'
4
4
  include Java
5
5
 
6
- require 'active_support/core_ext/object/blank'
7
-
8
6
  import javax.xml.parsers.DocumentBuilder unless defined? DocumentBuilder
9
7
  import javax.xml.parsers.DocumentBuilderFactory unless defined? DocumentBuilderFactory
10
8
  import java.io.StringReader unless defined? StringReader
@@ -1,6 +1,4 @@
1
1
  require 'libxml'
2
- require 'active_support/core_ext/object/returning'
3
- require 'active_support/core_ext/object/blank'
4
2
 
5
3
  # = XmlMini LibXML implementation
6
4
  module ActiveSupport
@@ -14,7 +12,7 @@ module ActiveSupport
14
12
  if !data.respond_to?(:read)
15
13
  data = StringIO.new(data || '')
16
14
  end
17
-
15
+
18
16
  char = data.getc
19
17
  if char.nil?
20
18
  {}
@@ -36,42 +34,106 @@ module LibXML #:nodoc:
36
34
  end
37
35
 
38
36
  module Node #:nodoc:
39
- CONTENT_ROOT = '__content__'.freeze
37
+ CONTENT_ROOT = '__content__'
38
+ LIB_XML_LIMIT = 30000000 # Hardcoded LibXML limit
40
39
 
41
40
  # Convert XML document to hash
42
41
  #
43
42
  # hash::
44
43
  # Hash to merge the converted element into.
45
44
  def to_hash(hash={})
46
- node_hash = {}
45
+ if text? || cdata?
46
+ raise LibXML::XML::Error if hash[CONTENT_ROOT].to_s.length + content.length >= LIB_XML_LIMIT
47
+ hash[CONTENT_ROOT] = hash[CONTENT_ROOT].to_s + content
48
+ else
49
+ sub_hash = insert_name_into_hash(hash, name)
50
+ attributes_to_hash(sub_hash)
51
+ if array?
52
+ children_array_to_hash(sub_hash)
53
+ elsif yaml?
54
+ children_yaml_to_hash(sub_hash)
55
+ else
56
+ children_to_hash(sub_hash)
57
+ end
58
+ end
59
+ hash
60
+ end
47
61
 
48
- # Insert node hash into parent hash correctly.
49
- case hash[name]
50
- when Array then hash[name] << node_hash
51
- when Hash then hash[name] = [hash[name], node_hash]
52
- when nil then hash[name] = node_hash
62
+ protected
63
+
64
+ # Insert name into hash
65
+ #
66
+ # hash::
67
+ # Hash to merge the converted element into.
68
+ # name::
69
+ # name to to merge into hash
70
+ def insert_name_into_hash(hash, name)
71
+ sub_hash = {}
72
+ if hash[name]
73
+ if !hash[name].kind_of? Array
74
+ hash[name] = [hash[name]]
75
+ end
76
+ hash[name] << sub_hash
77
+ else
78
+ hash[name] = sub_hash
79
+ end
80
+ sub_hash
53
81
  end
54
82
 
55
- # Handle child elements
56
- each_child do |c|
57
- if c.element?
58
- c.to_hash(node_hash)
59
- elsif c.text? || c.cdata?
60
- node_hash[CONTENT_ROOT] ||= ''
61
- node_hash[CONTENT_ROOT] << c.content
83
+ # Insert children into hash
84
+ #
85
+ # hash::
86
+ # Hash to merge the children into.
87
+ def children_to_hash(hash={})
88
+ each { |child| child.to_hash(hash) }
89
+
90
+ if hash.length > 1 && hash[CONTENT_ROOT].blank?
91
+ hash.delete(CONTENT_ROOT)
62
92
  end
93
+
94
+ attributes_to_hash(hash)
95
+ hash
63
96
  end
64
97
 
65
- # Remove content node if it is blank
66
- if node_hash.length > 1 && node_hash[CONTENT_ROOT].blank?
67
- node_hash.delete(CONTENT_ROOT)
98
+ # Convert xml attributes to hash
99
+ #
100
+ # hash::
101
+ # Hash to merge the attributes into
102
+ def attributes_to_hash(hash={})
103
+ each_attr { |attr| hash[attr.name] = attr.value }
104
+ hash
68
105
  end
69
106
 
70
- # Handle attributes
71
- each_attr { |a| node_hash[a.name] = a.value }
107
+ # Convert array into hash
108
+ #
109
+ # hash::
110
+ # Hash to merge the array into
111
+ def children_array_to_hash(hash={})
112
+ hash[child.name] = map do |child|
113
+ returning({}) { |sub_hash| child.children_to_hash(sub_hash) }
114
+ end
115
+ hash
116
+ end
117
+
118
+ # Convert yaml into hash
119
+ #
120
+ # hash::
121
+ # Hash to merge the yaml into
122
+ def children_yaml_to_hash(hash = {})
123
+ hash[CONTENT_ROOT] = content unless content.blank?
124
+ hash
125
+ end
126
+
127
+ # Check if child is of type array
128
+ def array?
129
+ child? && child.next? && child.name == child.next.name
130
+ end
131
+
132
+ # Check if child is of type yaml
133
+ def yaml?
134
+ attributes.collect{|x| x.value}.include?('yaml')
135
+ end
72
136
 
73
- hash
74
- end
75
137
  end
76
138
  end
77
139
  end
@@ -1,5 +1,4 @@
1
1
  require 'nokogiri'
2
- require 'active_support/core_ext/object/blank'
3
2
 
4
3
  # = XmlMini Nokogiri implementation
5
4
  module ActiveSupport
@@ -13,13 +12,13 @@ module ActiveSupport
13
12
  if !data.respond_to?(:read)
14
13
  data = StringIO.new(data || '')
15
14
  end
16
-
15
+
17
16
  char = data.getc
18
17
  if char.nil?
19
18
  {}
20
19
  else
21
20
  data.ungetc(char)
22
- doc = Nokogiri::XML(data)
21
+ doc = Nokogiri::XML(data) { |cfg| cfg.noblanks }
23
22
  raise doc.errors.first if doc.errors.length > 0
24
23
  doc.to_hash
25
24
  end
@@ -33,42 +32,40 @@ module ActiveSupport
33
32
  end
34
33
 
35
34
  module Node #:nodoc:
36
- CONTENT_ROOT = '__content__'.freeze
35
+ CONTENT_ROOT = '__content__'
37
36
 
38
37
  # Convert XML document to hash
39
38
  #
40
39
  # hash::
41
40
  # Hash to merge the converted element into.
42
- def to_hash(hash={})
43
- node_hash = {}
44
-
45
- # Insert node hash into parent hash correctly.
46
- case hash[name]
47
- when Array then hash[name] << node_hash
48
- when Hash then hash[name] = [hash[name], node_hash]
49
- when nil then hash[name] = node_hash
41
+ def to_hash(hash = {})
42
+ attributes = attributes_as_hash
43
+ if hash[name]
44
+ hash[name] = [hash[name]].flatten
45
+ hash[name] << attributes
46
+ else
47
+ hash[name] ||= attributes
50
48
  end
51
49
 
52
- # Handle child elements
53
- children.each do |c|
54
- if c.element?
55
- c.to_hash(node_hash)
56
- elsif c.text? || c.cdata?
57
- node_hash[CONTENT_ROOT] ||= ''
58
- node_hash[CONTENT_ROOT] << c.content
59
- end
60
- end
50
+ children.each { |child|
51
+ next if child.blank? && 'file' != self['type']
61
52
 
62
- # Remove content node if it is blank and there are child tags
63
- if node_hash.length > 1 && node_hash[CONTENT_ROOT].blank?
64
- node_hash.delete(CONTENT_ROOT)
65
- end
53
+ if child.text? || child.cdata?
54
+ (attributes[CONTENT_ROOT] ||= '') << child.content
55
+ next
56
+ end
66
57
 
67
- # Handle attributes
68
- attribute_nodes.each { |a| node_hash[a.node_name] = a.value }
58
+ child.to_hash attributes
59
+ }
69
60
 
70
61
  hash
71
62
  end
63
+
64
+ def attributes_as_hash
65
+ Hash[*(attribute_nodes.map { |node|
66
+ [node.node_name, node.value]
67
+ }.flatten)]
68
+ end
72
69
  end
73
70
  end
74
71
 
@@ -27,13 +27,7 @@ module ActiveSupport
27
27
  data.ungetc(char)
28
28
  silence_warnings { require 'rexml/document' } unless defined?(REXML::Document)
29
29
  doc = REXML::Document.new(data)
30
-
31
- if doc.root
32
- merge_element!({}, doc.root)
33
- else
34
- raise REXML::ParseException,
35
- "The document #{doc.to_s.inspect} does not have a valid root"
36
- end
30
+ merge_element!({}, doc.root)
37
31
  end
38
32
  end
39
33