activesupport 2.1.2 → 2.2.2

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 (240) hide show
  1. data/CHANGELOG +64 -5
  2. data/lib/active_support.rb +6 -6
  3. data/lib/active_support/base64.rb +13 -2
  4. data/lib/active_support/basic_object.rb +1 -1
  5. data/lib/active_support/buffered_logger.rb +15 -14
  6. data/lib/active_support/cache.rb +116 -40
  7. data/lib/active_support/cache/compressed_mem_cache_store.rb +7 -2
  8. data/lib/active_support/cache/file_store.rb +7 -5
  9. data/lib/active_support/cache/mem_cache_store.rb +48 -21
  10. data/lib/active_support/cache/memory_store.rb +16 -2
  11. data/lib/active_support/cache/synchronized_memory_store.rb +47 -0
  12. data/lib/active_support/callbacks.rb +14 -9
  13. data/lib/active_support/core_ext/array/access.rb +27 -0
  14. data/lib/active_support/core_ext/array/conversions.rb +12 -7
  15. data/lib/active_support/core_ext/array/grouping.rb +53 -10
  16. data/lib/active_support/core_ext/base64/encoding.rb +3 -0
  17. data/lib/active_support/core_ext/bigdecimal/conversions.rb +18 -22
  18. data/lib/active_support/core_ext/blank.rb +5 -0
  19. data/lib/active_support/core_ext/class/inheritable_attributes.rb +5 -5
  20. data/lib/active_support/core_ext/date/behavior.rb +3 -0
  21. data/lib/active_support/core_ext/date/calculations.rb +24 -9
  22. data/lib/active_support/core_ext/date_time/calculations.rb +19 -5
  23. data/lib/active_support/core_ext/duplicable.rb +6 -0
  24. data/lib/active_support/core_ext/enumerable.rb +42 -4
  25. data/lib/active_support/core_ext/file.rb +4 -20
  26. data/lib/active_support/core_ext/file/atomic.rb +46 -0
  27. data/lib/active_support/core_ext/float.rb +2 -0
  28. data/lib/active_support/core_ext/float/time.rb +27 -0
  29. data/lib/active_support/core_ext/hash.rb +2 -1
  30. data/lib/active_support/core_ext/hash/conversions.rb +1 -1
  31. data/lib/active_support/core_ext/hash/deep_merge.rb +23 -0
  32. data/lib/active_support/core_ext/hash/except.rb +1 -1
  33. data/lib/active_support/core_ext/hash/reverse_merge.rb +12 -5
  34. data/lib/active_support/core_ext/hash/slice.rb +7 -4
  35. data/lib/active_support/core_ext/integer.rb +2 -0
  36. data/lib/active_support/core_ext/integer/time.rb +45 -0
  37. data/lib/active_support/core_ext/kernel/debugger.rb +4 -4
  38. data/lib/active_support/core_ext/logger.rb +128 -1
  39. data/lib/active_support/core_ext/module.rb +11 -1
  40. data/lib/active_support/core_ext/module/aliasing.rb +71 -67
  41. data/lib/active_support/core_ext/module/delegation.rb +32 -1
  42. data/lib/active_support/core_ext/module/introspection.rb +81 -66
  43. data/lib/active_support/core_ext/module/model_naming.rb +8 -7
  44. data/lib/active_support/core_ext/module/synchronization.rb +39 -0
  45. data/lib/active_support/core_ext/numeric/time.rb +0 -10
  46. data/lib/active_support/core_ext/object.rb +1 -0
  47. data/lib/active_support/core_ext/object/extending.rb +29 -7
  48. data/lib/active_support/core_ext/object/instance_variables.rb +1 -1
  49. data/lib/active_support/core_ext/object/metaclass.rb +13 -0
  50. data/lib/active_support/core_ext/object/misc.rb +36 -21
  51. data/lib/active_support/core_ext/rexml.rb +2 -2
  52. data/lib/active_support/core_ext/string.rb +6 -2
  53. data/lib/active_support/core_ext/string/access.rb +5 -5
  54. data/lib/active_support/core_ext/string/behavior.rb +13 -0
  55. data/lib/active_support/core_ext/string/inflections.rb +21 -2
  56. data/lib/active_support/core_ext/string/multibyte.rb +81 -0
  57. data/lib/active_support/core_ext/time/calculations.rb +39 -12
  58. data/lib/active_support/core_ext/time/conversions.rb +1 -0
  59. data/lib/active_support/core_ext/time/zones.rb +1 -1
  60. data/lib/active_support/dependencies.rb +178 -110
  61. data/lib/active_support/deprecation.rb +24 -4
  62. data/lib/active_support/inflector.rb +122 -38
  63. data/lib/active_support/json.rb +1 -1
  64. data/lib/active_support/json/encoders/date.rb +9 -2
  65. data/lib/active_support/json/encoders/date_time.rb +9 -2
  66. data/lib/active_support/json/encoders/time.rb +10 -3
  67. data/lib/active_support/locale/en.yml +32 -0
  68. data/lib/active_support/memoizable.rb +82 -0
  69. data/lib/active_support/multibyte.rb +31 -7
  70. data/lib/active_support/multibyte/chars.rb +664 -122
  71. data/lib/active_support/multibyte/exceptions.rb +8 -0
  72. data/lib/active_support/multibyte/unicode_database.rb +71 -0
  73. data/lib/active_support/option_merger.rb +2 -10
  74. data/lib/active_support/ordered_hash.rb +15 -0
  75. data/lib/active_support/rescuable.rb +108 -0
  76. data/lib/active_support/secure_random.rb +197 -0
  77. data/lib/active_support/string_inquirer.rb +11 -1
  78. data/lib/active_support/test_case.rb +16 -5
  79. data/lib/active_support/testing/core_ext/test.rb +6 -0
  80. data/lib/active_support/{core_ext → testing/core_ext}/test/unit/assertions.rb +14 -6
  81. data/lib/active_support/testing/performance.rb +452 -0
  82. data/lib/active_support/testing/setup_and_teardown.rb +34 -7
  83. data/lib/active_support/time_with_zone.rb +66 -42
  84. data/lib/active_support/values/time_zone.rb +11 -4
  85. data/lib/active_support/values/unicode_tables.dat +0 -0
  86. data/lib/active_support/vendor.rb +13 -5
  87. data/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb +1 -1
  88. data/lib/active_support/vendor/i18n-0.0.1/i18n.rb +194 -0
  89. data/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb +216 -0
  90. data/lib/active_support/vendor/i18n-0.0.1/i18n/exceptions.rb +53 -0
  91. data/lib/active_support/vendor/{memcache-client-1.5.0 → memcache-client-1.5.1}/memcache.rb +5 -5
  92. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo.rb +0 -0
  93. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/data_timezone.rb +0 -0
  94. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/data_timezone_info.rb +0 -0
  95. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Algiers.rb +0 -0
  96. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Cairo.rb +0 -0
  97. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Casablanca.rb +0 -0
  98. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Harare.rb +0 -0
  99. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Johannesburg.rb +0 -0
  100. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Monrovia.rb +0 -0
  101. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Nairobi.rb +0 -0
  102. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Argentina/Buenos_Aires.rb +0 -0
  103. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Argentina/San_Juan.rb +86 -0
  104. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Bogota.rb +0 -0
  105. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Caracas.rb +0 -0
  106. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Chicago.rb +0 -0
  107. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Chihuahua.rb +0 -0
  108. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Denver.rb +0 -0
  109. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Godthab.rb +0 -0
  110. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Guatemala.rb +0 -0
  111. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Halifax.rb +0 -0
  112. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Indiana/Indianapolis.rb +0 -0
  113. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Juneau.rb +0 -0
  114. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/La_Paz.rb +0 -0
  115. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Lima.rb +0 -0
  116. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Los_Angeles.rb +0 -0
  117. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Mazatlan.rb +0 -0
  118. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Mexico_City.rb +0 -0
  119. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Monterrey.rb +0 -0
  120. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/New_York.rb +0 -0
  121. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Phoenix.rb +0 -0
  122. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Regina.rb +0 -0
  123. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Santiago.rb +0 -0
  124. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Sao_Paulo.rb +0 -0
  125. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/St_Johns.rb +0 -0
  126. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Tijuana.rb +0 -0
  127. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Almaty.rb +0 -0
  128. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Baghdad.rb +0 -0
  129. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Baku.rb +0 -0
  130. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Bangkok.rb +0 -0
  131. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Chongqing.rb +0 -0
  132. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Colombo.rb +30 -0
  133. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Dhaka.rb +0 -0
  134. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Hong_Kong.rb +0 -0
  135. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Irkutsk.rb +0 -0
  136. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Jakarta.rb +0 -0
  137. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Jerusalem.rb +0 -0
  138. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Kabul.rb +0 -0
  139. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Kamchatka.rb +0 -0
  140. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Karachi.rb +0 -0
  141. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Katmandu.rb +0 -0
  142. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Kolkata.rb +0 -0
  143. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Krasnoyarsk.rb +0 -0
  144. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Kuala_Lumpur.rb +0 -0
  145. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Kuwait.rb +0 -0
  146. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Magadan.rb +0 -0
  147. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Muscat.rb +0 -0
  148. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Novosibirsk.rb +0 -0
  149. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Rangoon.rb +0 -0
  150. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Riyadh.rb +0 -0
  151. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Seoul.rb +0 -0
  152. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Shanghai.rb +0 -0
  153. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Singapore.rb +0 -0
  154. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Taipei.rb +0 -0
  155. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Tashkent.rb +0 -0
  156. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Tbilisi.rb +0 -0
  157. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Tehran.rb +0 -0
  158. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Tokyo.rb +0 -0
  159. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Ulaanbaatar.rb +0 -0
  160. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Urumqi.rb +0 -0
  161. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Vladivostok.rb +0 -0
  162. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Yakutsk.rb +0 -0
  163. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Yekaterinburg.rb +0 -0
  164. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Yerevan.rb +0 -0
  165. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Atlantic/Azores.rb +0 -0
  166. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Atlantic/Cape_Verde.rb +0 -0
  167. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Atlantic/South_Georgia.rb +0 -0
  168. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Adelaide.rb +0 -0
  169. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Brisbane.rb +0 -0
  170. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Darwin.rb +0 -0
  171. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Hobart.rb +0 -0
  172. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Melbourne.rb +0 -0
  173. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Perth.rb +0 -0
  174. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Sydney.rb +0 -0
  175. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Etc/UTC.rb +0 -0
  176. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Amsterdam.rb +0 -0
  177. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Athens.rb +0 -0
  178. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Belgrade.rb +0 -0
  179. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Berlin.rb +0 -0
  180. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Bratislava.rb +0 -0
  181. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Brussels.rb +0 -0
  182. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Bucharest.rb +0 -0
  183. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Budapest.rb +0 -0
  184. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Copenhagen.rb +0 -0
  185. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Dublin.rb +0 -0
  186. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Helsinki.rb +0 -0
  187. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Istanbul.rb +0 -0
  188. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Kiev.rb +0 -0
  189. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Lisbon.rb +0 -0
  190. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Ljubljana.rb +0 -0
  191. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/London.rb +0 -0
  192. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Madrid.rb +0 -0
  193. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Minsk.rb +0 -0
  194. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Moscow.rb +0 -0
  195. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Paris.rb +0 -0
  196. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Prague.rb +0 -0
  197. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Riga.rb +0 -0
  198. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Rome.rb +0 -0
  199. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Sarajevo.rb +0 -0
  200. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Skopje.rb +0 -0
  201. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Sofia.rb +0 -0
  202. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Stockholm.rb +0 -0
  203. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Tallinn.rb +0 -0
  204. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Vienna.rb +0 -0
  205. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Vilnius.rb +0 -0
  206. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Warsaw.rb +0 -0
  207. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Zagreb.rb +0 -0
  208. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Auckland.rb +0 -0
  209. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Fiji.rb +0 -0
  210. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Guam.rb +0 -0
  211. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Honolulu.rb +0 -0
  212. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Majuro.rb +0 -0
  213. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Midway.rb +0 -0
  214. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Noumea.rb +0 -0
  215. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Pago_Pago.rb +0 -0
  216. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Port_Moresby.rb +0 -0
  217. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Tongatapu.rb +0 -0
  218. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/info_timezone.rb +0 -0
  219. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/linked_timezone.rb +0 -0
  220. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/linked_timezone_info.rb +0 -0
  221. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/offset_rationals.rb +0 -0
  222. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/ruby_core_support.rb +0 -0
  223. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/time_or_datetime.rb +0 -0
  224. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/timezone.rb +0 -0
  225. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/timezone_definition.rb +0 -0
  226. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/timezone_info.rb +0 -0
  227. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/timezone_offset_info.rb +0 -0
  228. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/timezone_period.rb +0 -0
  229. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/timezone_transition_info.rb +0 -0
  230. data/lib/active_support/vendor/xml-simple-1.0.11/xmlsimple.rb +3 -3
  231. data/lib/active_support/version.rb +1 -1
  232. metadata +185 -167
  233. data/lib/active_support/clean_logger.rb +0 -127
  234. data/lib/active_support/core_ext/string/unicode.rb +0 -66
  235. data/lib/active_support/core_ext/test.rb +0 -1
  236. data/lib/active_support/multibyte/generators/generate_tables.rb +0 -149
  237. data/lib/active_support/multibyte/handlers/passthru_handler.rb +0 -9
  238. data/lib/active_support/multibyte/handlers/utf8_handler.rb +0 -564
  239. data/lib/active_support/multibyte/handlers/utf8_handler_proc.rb +0 -43
  240. data/lib/active_support/vendor/tzinfo-0.3.11/tzinfo/definitions/America/Argentina/San_Juan.rb +0 -170
@@ -4,6 +4,9 @@ module ActiveSupport #:nodoc:
4
4
  module Encoding
5
5
  # Encodes the value as base64 without the newline breaks. This makes the base64 encoding readily usable as URL parameters
6
6
  # or memcache keys without further processing.
7
+ #
8
+ # ActiveSupport::Base64.encode64s("Original unencoded string")
9
+ # # => "T3JpZ2luYWwgdW5lbmNvZGVkIHN0cmluZw=="
7
10
  def encode64s(value)
8
11
  encode64(value).gsub(/\n/, '')
9
12
  end
@@ -4,35 +4,31 @@ module ActiveSupport #:nodoc:
4
4
  module CoreExtensions #:nodoc:
5
5
  module BigDecimal #:nodoc:
6
6
  module Conversions
7
+ DEFAULT_STRING_FORMAT = 'F'.freeze
8
+ YAML_TAG = 'tag:yaml.org,2002:float'.freeze
9
+ YAML_MAPPING = { 'Infinity' => '.Inf', '-Infinity' => '-.Inf', 'NaN' => '.NaN' }
10
+
7
11
  def self.included(base) #:nodoc:
8
- base.instance_eval do
12
+ base.class_eval do
9
13
  alias_method :_original_to_s, :to_s
10
14
  alias_method :to_s, :to_formatted_s
15
+
16
+ yaml_as YAML_TAG
11
17
  end
12
18
  end
13
-
14
- def to_formatted_s(format="F")
19
+
20
+ def to_formatted_s(format = DEFAULT_STRING_FORMAT)
15
21
  _original_to_s(format)
16
22
  end
17
-
18
- yaml_as "tag:yaml.org,2002:float"
19
- def to_yaml( opts = {} )
20
- YAML::quick_emit( nil, opts ) do |out|
21
- # This emits the number without any scientific notation.
22
- # I prefer it to using self.to_f.to_s, which would lose precision.
23
- #
24
- # Note that YAML allows that when reconsituting floats
25
- # to native types, some precision may get lost.
26
- # There is no full precision real YAML tag that I am aware of.
27
- str = self.to_s
28
- if str == "Infinity"
29
- str = ".Inf"
30
- elsif str == "-Infinity"
31
- str = "-.Inf"
32
- elsif str == "NaN"
33
- str = ".NaN"
34
- end
35
- out.scalar( "tag:yaml.org,2002:float", str, :plain )
23
+
24
+ # This emits the number without any scientific notation.
25
+ # This is better than self.to_f.to_s since it doesn't lose precision.
26
+ #
27
+ # Note that reconstituting YAML floats to native floats may lose precision.
28
+ def to_yaml(opts = {})
29
+ YAML.quick_emit(nil, opts) do |out|
30
+ string = to_s
31
+ out.scalar(YAML_TAG, YAML_MAPPING[string] || string, :plain)
36
32
  end
37
33
  end
38
34
  end
@@ -12,6 +12,11 @@ class Object
12
12
  def blank?
13
13
  respond_to?(:empty?) ? empty? : !self
14
14
  end
15
+
16
+ # An object is present if it's not blank.
17
+ def present?
18
+ !blank?
19
+ end
15
20
  end
16
21
 
17
22
  class NilClass #:nodoc:
@@ -91,14 +91,14 @@ class Class # :nodoc:
91
91
  def inheritable_attributes
92
92
  @inheritable_attributes ||= EMPTY_INHERITABLE_ATTRIBUTES
93
93
  end
94
-
94
+
95
95
  def write_inheritable_attribute(key, value)
96
96
  if inheritable_attributes.equal?(EMPTY_INHERITABLE_ATTRIBUTES)
97
97
  @inheritable_attributes = {}
98
98
  end
99
99
  inheritable_attributes[key] = value
100
100
  end
101
-
101
+
102
102
  def write_inheritable_array(key, elements)
103
103
  write_inheritable_attribute(key, []) if read_inheritable_attribute(key).nil?
104
104
  write_inheritable_attribute(key, read_inheritable_attribute(key) + elements)
@@ -112,7 +112,7 @@ class Class # :nodoc:
112
112
  def read_inheritable_attribute(key)
113
113
  inheritable_attributes[key]
114
114
  end
115
-
115
+
116
116
  def reset_inheritable_attributes
117
117
  @inheritable_attributes = EMPTY_INHERITABLE_ATTRIBUTES
118
118
  end
@@ -123,7 +123,7 @@ class Class # :nodoc:
123
123
 
124
124
  def inherited_with_inheritable_attributes(child)
125
125
  inherited_without_inheritable_attributes(child) if respond_to?(:inherited_without_inheritable_attributes)
126
-
126
+
127
127
  if inheritable_attributes.equal?(EMPTY_INHERITABLE_ATTRIBUTES)
128
128
  new_inheritable_attributes = EMPTY_INHERITABLE_ATTRIBUTES
129
129
  else
@@ -131,7 +131,7 @@ class Class # :nodoc:
131
131
  memo.update(key => value.duplicable? ? value.dup : value)
132
132
  end
133
133
  end
134
-
134
+
135
135
  child.instance_variable_set('@inheritable_attributes', new_inheritable_attributes)
136
136
  end
137
137
 
@@ -1,3 +1,5 @@
1
+ require 'date'
2
+
1
3
  module ActiveSupport #:nodoc:
2
4
  module CoreExtensions #:nodoc:
3
5
  module Date #:nodoc:
@@ -10,6 +12,7 @@ module ActiveSupport #:nodoc:
10
12
 
11
13
  # Date memoizes some instance methods using metaprogramming to wrap
12
14
  # the methods with one that caches the result in an instance variable.
15
+ #
13
16
  # If a Date is frozen but the memoized method hasn't been called, the
14
17
  # first call will result in a frozen object error since the memo
15
18
  # instance variable is uninitialized.
@@ -20,18 +20,33 @@ module ActiveSupport #:nodoc:
20
20
  def yesterday
21
21
  ::Date.today.yesterday
22
22
  end
23
-
23
+
24
24
  # Returns a new Date representing the date 1 day after today (i.e. tomorrow's date).
25
25
  def tomorrow
26
26
  ::Date.today.tomorrow
27
27
  end
28
-
28
+
29
29
  # Returns Time.zone.today when config.time_zone is set, otherwise just returns Date.today.
30
30
  def current
31
31
  ::Time.zone_default ? ::Time.zone.today : ::Date.today
32
32
  end
33
33
  end
34
-
34
+
35
+ # Tells whether the Date object's date lies in the past
36
+ def past?
37
+ self < ::Date.current
38
+ end
39
+
40
+ # Tells whether the Date object's date is today
41
+ def today?
42
+ self.to_date == ::Date.current # we need the to_date because of DateTime
43
+ end
44
+
45
+ # Tells whether the Date object's date lies in the future
46
+ def future?
47
+ self > ::Date.current
48
+ end
49
+
35
50
  # Converts Date to a Time (or DateTime if necessary) with the time portion set to the beginning of the day (0:00)
36
51
  # and then subtracts the specified number of seconds
37
52
  def ago(seconds)
@@ -57,7 +72,7 @@ module ActiveSupport #:nodoc:
57
72
  def end_of_day
58
73
  to_time.end_of_day
59
74
  end
60
-
75
+
61
76
  def plus_with_duration(other) #:nodoc:
62
77
  if ActiveSupport::Duration === other
63
78
  other.since(self)
@@ -65,7 +80,7 @@ module ActiveSupport #:nodoc:
65
80
  plus_without_duration(other)
66
81
  end
67
82
  end
68
-
83
+
69
84
  def minus_with_duration(other) #:nodoc:
70
85
  if ActiveSupport::Duration === other
71
86
  plus_with_duration(-other)
@@ -73,8 +88,8 @@ module ActiveSupport #:nodoc:
73
88
  minus_without_duration(other)
74
89
  end
75
90
  end
76
-
77
- # Provides precise Date calculations for years, months, and days. The +options+ parameter takes a hash with
91
+
92
+ # Provides precise Date calculations for years, months, and days. The +options+ parameter takes a hash with
78
93
  # any of these keys: <tt>:years</tt>, <tt>:months</tt>, <tt>:weeks</tt>, <tt>:days</tt>.
79
94
  def advance(options)
80
95
  d = self
@@ -98,7 +113,7 @@ module ActiveSupport #:nodoc:
98
113
  options[:day] || self.day
99
114
  )
100
115
  end
101
-
116
+
102
117
  # Returns a new Date/DateTime representing the time a number of specified months ago
103
118
  def months_ago(months)
104
119
  advance(:months => -months)
@@ -161,7 +176,7 @@ module ActiveSupport #:nodoc:
161
176
  days_into_week = { :monday => 0, :tuesday => 1, :wednesday => 2, :thursday => 3, :friday => 4, :saturday => 5, :sunday => 6}
162
177
  result = (self + 7).beginning_of_week + days_into_week[day]
163
178
  self.acts_like?(:time) ? result.change(:hour => 0) : result
164
- end
179
+ end
165
180
 
166
181
  # Returns a new ; DateTime objects will have time set to 0:00DateTime representing the start of the month (1st of the month; DateTime objects will have time set to 0:00)
167
182
  def beginning_of_month
@@ -7,7 +7,7 @@ module ActiveSupport #:nodoc:
7
7
  module Calculations
8
8
  def self.included(base) #:nodoc:
9
9
  base.extend ClassMethods
10
-
10
+
11
11
  base.class_eval do
12
12
  alias_method :compare_without_coercion, :<=>
13
13
  alias_method :<=>, :compare_with_coercion
@@ -19,6 +19,20 @@ module ActiveSupport #:nodoc:
19
19
  def local_offset
20
20
  ::Time.local(2007).utc_offset.to_r / 86400
21
21
  end
22
+
23
+ def current
24
+ ::Time.zone_default ? ::Time.zone.now.to_datetime : ::Time.now.to_datetime
25
+ end
26
+ end
27
+
28
+ # Tells whether the DateTime object's datetime lies in the past
29
+ def past?
30
+ self < ::DateTime.current
31
+ end
32
+
33
+ # Tells whether the DateTime object's datetime lies in the future
34
+ def future?
35
+ self > ::DateTime.current
22
36
  end
23
37
 
24
38
  # Seconds since midnight: DateTime.now.seconds_since_midnight
@@ -78,7 +92,7 @@ module ActiveSupport #:nodoc:
78
92
  def end_of_day
79
93
  change(:hour => 23, :min => 59, :sec => 59)
80
94
  end
81
-
95
+
82
96
  # Adjusts DateTime to UTC by adding its offset value; offset is set to 0
83
97
  #
84
98
  # Example:
@@ -89,17 +103,17 @@ module ActiveSupport #:nodoc:
89
103
  new_offset(0)
90
104
  end
91
105
  alias_method :getutc, :utc
92
-
106
+
93
107
  # Returns true if offset == 0
94
108
  def utc?
95
109
  offset == 0
96
110
  end
97
-
111
+
98
112
  # Returns the offset value in seconds
99
113
  def utc_offset
100
114
  (offset * 86400).to_i
101
115
  end
102
-
116
+
103
117
  # Layers additional behavior on DateTime#<=> so that Time and ActiveSupport::TimeWithZone instances can be compared with a DateTime
104
118
  def compare_with_coercion(other)
105
119
  other = other.comparable_time if other.respond_to?(:comparable_time)
@@ -35,3 +35,9 @@ class Numeric #:nodoc:
35
35
  false
36
36
  end
37
37
  end
38
+
39
+ class Class #:nodoc:
40
+ def duplicable?
41
+ false
42
+ end
43
+ end
@@ -1,3 +1,5 @@
1
+ require 'active_support/ordered_hash'
2
+
1
3
  module Enumerable
2
4
  # Ruby 1.8.7 introduces group_by, but the result isn't ordered. Override it.
3
5
  remove_method(:group_by) if [].respond_to?(:group_by) && RUBY_VERSION < '1.9'
@@ -18,10 +20,19 @@ module Enumerable
18
20
  # "2006-02-24 -> Transcript, Transcript"
19
21
  # "2006-02-23 -> Transcript"
20
22
  def group_by
21
- inject ActiveSupport::OrderedHash.new do |grouped, element|
22
- (grouped[yield(element)] ||= []) << element
23
- grouped
23
+ assoc = ActiveSupport::OrderedHash.new
24
+
25
+ each do |element|
26
+ key = yield(element)
27
+
28
+ if assoc.has_key?(key)
29
+ assoc[key] << element
30
+ else
31
+ assoc[key] = [element]
32
+ end
24
33
  end
34
+
35
+ assoc
25
36
  end unless [].respond_to?(:group_by)
26
37
 
27
38
  # Calculates a sum from the elements. Examples:
@@ -53,8 +64,28 @@ module Enumerable
53
64
  end
54
65
  end
55
66
 
67
+ # Iterates over a collection, passing the current element *and* the
68
+ # +memo+ to the block. Handy for building up hashes or
69
+ # reducing collections down to one object. Examples:
70
+ #
71
+ # %w(foo bar).each_with_object({}) { |str, hsh| hsh[str] = str.upcase } #=> {'foo' => 'FOO', 'bar' => 'BAR'}
72
+ #
73
+ # *Note* that you can't use immutable objects like numbers, true or false as
74
+ # the memo. You would think the following returns 120, but since the memo is
75
+ # never changed, it does not.
76
+ #
77
+ # (1..5).each_with_object(1) { |value, memo| memo *= value } # => 1
78
+ #
79
+ def each_with_object(memo, &block)
80
+ returning memo do |m|
81
+ each do |element|
82
+ block.call(element, m)
83
+ end
84
+ end
85
+ end unless [].respond_to?(:each_with_object)
86
+
56
87
  # Convert an enumerable to a hash. Examples:
57
- #
88
+ #
58
89
  # people.index_by(&:login)
59
90
  # => { "nextangle" => <Person ...>, "chade-" => <Person ...>, ...}
60
91
  # people.index_by { |person| "#{person.first_name} #{person.last_name}" }
@@ -66,4 +97,11 @@ module Enumerable
66
97
  accum
67
98
  end
68
99
  end
100
+
101
+ # Returns true if the collection has more than 1 element. Functionally equivalent to collection.size > 1.
102
+ # Works with a block too ala any?, so people.many? { |p| p.age > 26 } # => returns true if more than 1 person is over 26.
103
+ def many?(&block)
104
+ size = block_given? ? select(&block).size : self.size
105
+ size > 1
106
+ end
69
107
  end
@@ -1,21 +1,5 @@
1
- require 'tempfile'
1
+ require 'active_support/core_ext/file/atomic'
2
2
 
3
- # Write to a file atomically. Useful for situations where you don't
4
- # want other processes or threads to see half-written files.
5
- #
6
- # File.atomic_write("important.file") do |file|
7
- # file.write("hello")
8
- # end
9
- #
10
- # If your temp directory is not on the same filesystem as the file you're
11
- # trying to write, you can provide a different temporary directory.
12
- #
13
- # File.atomic_write("/data/something.important", "/data/tmp") do |f|
14
- # file.write("hello")
15
- # end
16
- def File.atomic_write(file_name, temp_dir = Dir.tmpdir)
17
- temp_file = Tempfile.new(File.basename(file_name), temp_dir)
18
- yield temp_file
19
- temp_file.close
20
- File.rename(temp_file.path, file_name)
21
- end
3
+ class File #:nodoc:
4
+ extend ActiveSupport::CoreExtensions::File::Atomic
5
+ end
@@ -0,0 +1,46 @@
1
+ require 'tempfile'
2
+
3
+ module ActiveSupport #:nodoc:
4
+ module CoreExtensions #:nodoc:
5
+ module File #:nodoc:
6
+ module Atomic
7
+ # Write to a file atomically. Useful for situations where you don't
8
+ # want other processes or threads to see half-written files.
9
+ #
10
+ # File.atomic_write("important.file") do |file|
11
+ # file.write("hello")
12
+ # end
13
+ #
14
+ # If your temp directory is not on the same filesystem as the file you're
15
+ # trying to write, you can provide a different temporary directory.
16
+ #
17
+ # File.atomic_write("/data/something.important", "/data/tmp") do |f|
18
+ # file.write("hello")
19
+ # end
20
+ def atomic_write(file_name, temp_dir = Dir.tmpdir)
21
+ temp_file = Tempfile.new(basename(file_name), temp_dir)
22
+ yield temp_file
23
+ temp_file.close
24
+
25
+ begin
26
+ # Get original file permissions
27
+ old_stat = stat(file_name)
28
+ rescue Errno::ENOENT
29
+ # No old permissions, write a temp file to determine the defaults
30
+ check_name = ".permissions_check.#{Thread.current.object_id}.#{Process.pid}.#{rand(1000000)}"
31
+ open(check_name, "w") { }
32
+ old_stat = stat(check_name)
33
+ unlink(check_name)
34
+ end
35
+
36
+ # Overwrite original file with temp file
37
+ rename(temp_file.path, file_name)
38
+
39
+ # Set correct permissions on new file
40
+ chown(old_stat.uid, old_stat.gid, file_name)
41
+ chmod(old_stat.mode, file_name)
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -1,5 +1,7 @@
1
1
  require 'active_support/core_ext/float/rounding'
2
+ require 'active_support/core_ext/float/time'
2
3
 
3
4
  class Float #:nodoc:
4
5
  include ActiveSupport::CoreExtensions::Float::Rounding
6
+ include ActiveSupport::CoreExtensions::Float::Time
5
7
  end
@@ -0,0 +1,27 @@
1
+ module ActiveSupport #:nodoc:
2
+ module CoreExtensions #:nodoc:
3
+ module Float #:nodoc:
4
+ module Time
5
+ # Deprication helper methods not available as core_ext is loaded first.
6
+ def years
7
+ ::ActiveSupport::Deprecation.warn(self.class.deprecated_method_warning(:years, "Fractional years are not respected. Convert value to integer before calling #years."), caller)
8
+ years_without_deprecation
9
+ end
10
+ def months
11
+ ::ActiveSupport::Deprecation.warn(self.class.deprecated_method_warning(:months, "Fractional months are not respected. Convert value to integer before calling #months."), caller)
12
+ months_without_deprecation
13
+ end
14
+
15
+ def months_without_deprecation
16
+ ActiveSupport::Duration.new(self * 30.days, [[:months, self]])
17
+ end
18
+ alias :month :months
19
+
20
+ def years_without_deprecation
21
+ ActiveSupport::Duration.new(self * 365.25.days, [[:years, self]])
22
+ end
23
+ alias :year :years
24
+ end
25
+ end
26
+ end
27
+ end