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
@@ -0,0 +1,23 @@
1
+ class Module
2
+ # Returns String#underscore applied to the module name minus trailing classes.
3
+ #
4
+ # ActiveRecord.as_load_path # => "active_record"
5
+ # ActiveRecord::Associations.as_load_path # => "active_record/associations"
6
+ # ActiveRecord::Base.as_load_path # => "active_record" (Base is a class)
7
+ #
8
+ # The Kernel module gives an empty string by definition.
9
+ #
10
+ # Kernel.as_load_path # => ""
11
+ # Math.as_load_path # => "math"
12
+ def as_load_path
13
+ if self == Object || self == Kernel
14
+ ''
15
+ elsif is_a? Class
16
+ parent == self ? '' : parent.as_load_path
17
+ else
18
+ name.split('::').collect do |word|
19
+ word.underscore
20
+ end * '/'
21
+ end
22
+ end
23
+ end
@@ -1,5 +1,4 @@
1
1
  require 'active_support/core_ext/module/aliasing'
2
- require 'active_support/core_ext/array/extract_options'
3
2
 
4
3
  class Module
5
4
  # Synchronize access around a method, delegating synchronization to a
@@ -28,7 +27,7 @@ class Module
28
27
  raise ArgumentError, "#{method} is already synchronized. Double synchronization is not currently supported."
29
28
  end
30
29
 
31
- module_eval(<<-EOS, __FILE__, __LINE__ + 1)
30
+ module_eval(<<-EOS, __FILE__, __LINE__)
32
31
  def #{aliased_method}_with_synchronization#{punctuation}(*args, &block) # def expire_with_synchronization(*args, &block)
33
32
  #{with}.synchronize do # @@lock.synchronize do
34
33
  #{aliased_method}_without_synchronization#{punctuation}(*args, &block) # expire_without_synchronization(*args, &block)
@@ -1,9 +1,7 @@
1
1
  class NameError
2
2
  # Extract the name of the missing constant from the exception message.
3
3
  def missing_name
4
- if /undefined local variable or method/ !~ message
5
- $1 if /((::)?([A-Z]\w*)(::[A-Z]\w*)*)$/ =~ message
6
- end
4
+ $1 if /((::)?([A-Z]\w*)(::[A-Z]\w*)*)$/ =~ message
7
5
  end
8
6
 
9
7
  # Was this exception raised because the given name was missing?
@@ -0,0 +1 @@
1
+ require 'active_support/core_ext/nil/conversions'
@@ -0,0 +1,5 @@
1
+ class NilClass
2
+ def to_param
3
+ self
4
+ end
5
+ end
@@ -4,11 +4,7 @@ require 'active_support/core_ext/object/duplicable'
4
4
  require 'active_support/core_ext/object/try'
5
5
 
6
6
  require 'active_support/core_ext/object/conversions'
7
+ require 'active_support/core_ext/object/extending'
7
8
  require 'active_support/core_ext/object/instance_variables'
9
+ require 'active_support/core_ext/object/metaclass'
8
10
  require 'active_support/core_ext/object/misc'
9
- require 'active_support/core_ext/object/extending'
10
-
11
- require 'active_support/core_ext/object/returning'
12
- require 'active_support/core_ext/object/to_param'
13
- require 'active_support/core_ext/object/to_query'
14
- require 'active_support/core_ext/object/with_options'
@@ -2,11 +2,11 @@ class Object
2
2
  # An object is blank if it's false, empty, or a whitespace string.
3
3
  # For example, "", " ", +nil+, [], and {} are blank.
4
4
  #
5
- # This simplifies:
5
+ # This simplifies
6
6
  #
7
7
  # if !address.nil? && !address.empty?
8
8
  #
9
- # ...to:
9
+ # to
10
10
  #
11
11
  # if !address.blank?
12
12
  def blank?
@@ -17,24 +17,6 @@ class Object
17
17
  def present?
18
18
  !blank?
19
19
  end
20
-
21
- # Returns object if it's #present? otherwise returns nil.
22
- # object.presence is equivalent to object.present? ? object : nil.
23
- #
24
- # This is handy for any representation of objects where blank is the same
25
- # as not present at all. For example, this simplifies a common check for
26
- # HTTP POST/query parameters:
27
- #
28
- # state = params[:state] if params[:state].present?
29
- # country = params[:country] if params[:country].present?
30
- # region = state || country || 'US'
31
- #
32
- # ...becomes:
33
- #
34
- # region = params[:state].presence || params[:country].presence || 'US'
35
- def presence
36
- self if present?
37
- end
38
20
  end
39
21
 
40
22
  class NilClass #:nodoc:
@@ -1,4 +1,18 @@
1
- require 'active_support/core_ext/object/to_param'
2
- require 'active_support/core_ext/object/to_query'
3
1
  require 'active_support/core_ext/array/conversions'
4
2
  require 'active_support/core_ext/hash/conversions'
3
+
4
+ class Object
5
+ # Alias of <tt>to_s</tt>.
6
+ def to_param
7
+ to_s
8
+ end
9
+
10
+ # Converts an object into a string suitable for use as a URL query string, using the given <tt>key</tt> as the
11
+ # param name.
12
+ #
13
+ # Note: This method is defined as a default implementation for all Objects for Hash#to_query to work.
14
+ def to_query(key)
15
+ require 'cgi' unless defined?(CGI) && defined?(CGI::escape)
16
+ "#{CGI.escape(key.to_s)}=#{CGI.escape(to_param.to_s)}"
17
+ end
18
+ end
@@ -1,22 +1,6 @@
1
- # Most objects are cloneable, but not all. For example you can't dup +nil+:
2
- #
3
- # nil.dup # => TypeError: can't dup NilClass
4
- #
5
- # Classes may signal their instances are not duplicable removing +dup+/+clone+
6
- # or raising exceptions from them. So, to dup an arbitrary object you normally
7
- # use an optimistic approach and are ready to catch an exception, say:
8
- #
9
- # arbitrary_object.dup rescue object
10
- #
11
- # Rails dups objects in a few critical spots where they are not that arbitrary.
12
- # That rescue is very expensive (like 40 times slower than a predicate), and it
13
- # is often triggered.
14
- #
15
- # That's why we hardcode the following cases and check duplicable? instead of
16
- # using that rescue idiom.
17
1
  class Object
18
2
  # Can you safely .dup this object?
19
- # False for nil, false, true, symbols, numbers, class and module objects; true otherwise.
3
+ # False for nil, false, true, symbols, numbers, and class objects; true otherwise.
20
4
  def duplicable?
21
5
  true
22
6
  end
@@ -57,9 +41,3 @@ class Class #:nodoc:
57
41
  false
58
42
  end
59
43
  end
60
-
61
- class Module #:nodoc:
62
- def duplicable?
63
- false
64
- end
65
- end
@@ -1,11 +1,80 @@
1
- require 'active_support/core_ext/class/subclasses'
2
-
3
1
  class Object
4
- # Exclude this class unless it's a subclass of our supers and is defined.
5
- # We check defined? in case we find a removed class that has yet to be
6
- # garbage collected. This also fails for anonymous classes -- please
7
- # submit a patch if you have a workaround.
8
- def subclasses_of(*superclasses) #:nodoc:
9
- Class.subclasses_of(*superclasses)
2
+ def remove_subclasses_of(*superclasses) #:nodoc:
3
+ Class.remove_class(*subclasses_of(*superclasses))
4
+ end
5
+
6
+ begin
7
+ ObjectSpace.each_object(Class.new) {}
8
+
9
+ # Exclude this class unless it's a subclass of our supers and is defined.
10
+ # We check defined? in case we find a removed class that has yet to be
11
+ # garbage collected. This also fails for anonymous classes -- please
12
+ # submit a patch if you have a workaround.
13
+ def subclasses_of(*superclasses) #:nodoc:
14
+ subclasses = []
15
+
16
+ superclasses.each do |sup|
17
+ ObjectSpace.each_object(class << sup; self; end) do |k|
18
+ if k != sup && (k.name.blank? || eval("defined?(::#{k}) && ::#{k}.object_id == k.object_id"))
19
+ subclasses << k
20
+ end
21
+ end
22
+ end
23
+
24
+ subclasses
25
+ end
26
+ rescue RuntimeError
27
+ # JRuby and any implementations which cannot handle the objectspace traversal
28
+ # above fall back to this implementation
29
+ def subclasses_of(*superclasses) #:nodoc:
30
+ subclasses = []
31
+
32
+ superclasses.each do |sup|
33
+ ObjectSpace.each_object(Class) do |k|
34
+ if superclasses.any? { |superclass| k < superclass } &&
35
+ (k.name.blank? || eval("defined?(::#{k}) && ::#{k}.object_id == k.object_id"))
36
+ subclasses << k
37
+ end
38
+ end
39
+ subclasses.uniq!
40
+ end
41
+ subclasses
42
+ end
43
+ end
44
+
45
+ def extended_by #:nodoc:
46
+ ancestors = class << self; ancestors end
47
+ ancestors.select { |mod| mod.class == Module } - [ Object, Kernel ]
48
+ end
49
+
50
+ def extend_with_included_modules_from(object) #:nodoc:
51
+ object.extended_by.each { |mod| extend mod }
52
+ end
53
+
54
+ unless defined? instance_exec # 1.9
55
+ module InstanceExecMethods #:nodoc:
56
+ end
57
+ include InstanceExecMethods
58
+
59
+ # Evaluate the block with the given arguments within the context of
60
+ # this object, so self is set to the method receiver.
61
+ #
62
+ # From Mauricio's http://eigenclass.org/hiki/bounded+space+instance_exec
63
+ def instance_exec(*args, &block)
64
+ begin
65
+ old_critical, Thread.critical = Thread.critical, true
66
+ n = 0
67
+ n += 1 while respond_to?(method_name = "__instance_exec#{n}")
68
+ InstanceExecMethods.module_eval { define_method(method_name, &block) }
69
+ ensure
70
+ Thread.critical = old_critical
71
+ end
72
+
73
+ begin
74
+ send(method_name, *args)
75
+ ensure
76
+ InstanceExecMethods.module_eval { remove_method(method_name) } rescue nil
77
+ end
78
+ end
10
79
  end
11
80
  end
@@ -1,4 +1,11 @@
1
1
  class Object
2
+ # Available in 1.8.6 and later.
3
+ unless respond_to?(:instance_variable_defined?)
4
+ def instance_variable_defined?(variable)
5
+ instance_variables.include?(variable.to_s)
6
+ end
7
+ end
8
+
2
9
  # Returns a hash that maps instance variable names without "@" to their
3
10
  # corresponding values. Keys are strings both in Ruby 1.8 and 1.9.
4
11
  #
@@ -0,0 +1,13 @@
1
+ class Object
2
+ # Get object's meta (ghost, eigenclass, singleton) class
3
+ def metaclass
4
+ class << self
5
+ self
6
+ end
7
+ end
8
+
9
+ # If class_eval is called on an object, add those methods to its metaclass
10
+ def class_eval(*args, &block)
11
+ metaclass.class_eval(*args, &block)
12
+ end
13
+ end
@@ -1,2 +1,3 @@
1
1
  require 'active_support/core_ext/object/returning'
2
+ require 'active_support/core_ext/object/tap'
2
3
  require 'active_support/core_ext/object/with_options'
@@ -0,0 +1,16 @@
1
+ class Object
2
+ # Yields <code>x</code> to the block, and then returns <code>x</code>.
3
+ # The primary purpose of this method is to "tap into" a method chain,
4
+ # in order to perform operations on intermediate results within the chain.
5
+ #
6
+ # (1..10).tap { |x| puts "original: #{x.inspect}" }.to_a.
7
+ # tap { |x| puts "array: #{x.inspect}" }.
8
+ # select { |x| x%2 == 0 }.
9
+ # tap { |x| puts "evens: #{x.inspect}" }.
10
+ # map { |x| x*x }.
11
+ # tap { |x| puts "squares: #{x.inspect}" }
12
+ def tap
13
+ yield self
14
+ self
15
+ end unless Object.respond_to?(:tap)
16
+ end
@@ -1,5 +1,3 @@
1
- require 'active_support/option_merger'
2
-
3
1
  class Object
4
2
  # An elegant way to factor duplication out of options passed to a series of
5
3
  # method calls. Each method called in the block, with the block variable as
@@ -1,13 +1,13 @@
1
- require "active_support/core_ext/kernel/singleton_class"
1
+ require "active_support/core_ext/object"
2
2
 
3
3
  class Proc #:nodoc:
4
4
  def bind(object)
5
5
  block, time = self, Time.now
6
6
  object.class_eval do
7
7
  method_name = "__bind_#{time.to_i}_#{time.usec}"
8
- define_method(method_name, &block)
9
- method = instance_method(method_name)
10
- remove_method(method_name)
8
+ define_method(method_name, &block) # define_method("__bind_1230458026_720454", &block)
9
+ method = instance_method(method_name) # method = instance_method("__bind_1230458026_720454")
10
+ remove_method(method_name) # remove_method("__bind_1230458026_720454")
11
11
  method
12
12
  end.bind(object)
13
13
  end
@@ -1,5 +1,27 @@
1
1
  class Regexp #:nodoc:
2
+ def number_of_captures
3
+ Regexp.new("|#{source}").match('').captures.length
4
+ end
5
+
2
6
  def multiline?
3
7
  options & MULTILINE == MULTILINE
4
8
  end
9
+
10
+ class << self
11
+ def optionalize(pattern)
12
+ return pattern if pattern == ""
13
+
14
+ case unoptionalize(pattern)
15
+ when /\A(.|\(.*\))\Z/ then "#{pattern}?"
16
+ else "(?:#{pattern})?"
17
+ end
18
+ end
19
+
20
+ def unoptionalize(pattern)
21
+ [/\A\(\?:(.*)\)\?\Z/, /\A(.|\(.*\))\?\Z/].each do |regexp|
22
+ return $1 if regexp =~ pattern
23
+ end
24
+ return pattern
25
+ end
26
+ end
5
27
  end
@@ -2,10 +2,7 @@ require 'active_support/core_ext/kernel/reporting'
2
2
 
3
3
  # Fixes the rexml vulnerability disclosed at:
4
4
  # http://www.ruby-lang.org/en/news/2008/08/23/dos-vulnerability-in-rexml/
5
- # This fix is identical to rexml-expansion-fix version 1.0.1.
6
- #
7
- # We still need to distribute this fix because albeit the REXML
8
- # in recent 1.8.7s is patched, it wasn't in early patchlevels.
5
+ # This fix is identical to rexml-expansion-fix version 1.0.1
9
6
  require 'rexml/rexml'
10
7
 
11
8
  # Earlier versions of rexml defined REXML::Version, newer ones REXML::VERSION
@@ -4,9 +4,8 @@ require 'active_support/core_ext/string/multibyte'
4
4
  require 'active_support/core_ext/string/starts_ends_with'
5
5
  require 'active_support/core_ext/string/inflections'
6
6
  require 'active_support/core_ext/string/access'
7
+ require 'active_support/core_ext/string/iterators'
7
8
  require 'active_support/core_ext/string/xchar'
8
9
  require 'active_support/core_ext/string/behavior'
9
10
  require 'active_support/core_ext/string/interpolation'
10
- require 'active_support/core_ext/string/output_safety'
11
- require 'active_support/core_ext/string/exclude'
12
- require 'active_support/core_ext/string/encoding'
11
+ require 'active_support/core_ext/string/output_safety'
@@ -1,5 +1,3 @@
1
- require "active_support/multibyte"
2
-
3
1
  class String
4
2
  unless '1.9'.respond_to?(:force_encoding)
5
3
  # Returns the character at the +position+ treating the string as an array (where 0 is the first character).
@@ -7,7 +5,7 @@ class String
7
5
  # Examples:
8
6
  # "hello".at(0) # => "h"
9
7
  # "hello".at(4) # => "o"
10
- # "hello".at(10) # => ERROR if < 1.9, nil in 1.9
8
+ # "hello".at(10) # => nil
11
9
  def at(position)
12
10
  mb_chars[position, 1].to_s
13
11
  end
@@ -17,7 +15,7 @@ class String
17
15
  # Examples:
18
16
  # "hello".from(0) # => "hello"
19
17
  # "hello".from(2) # => "llo"
20
- # "hello".from(10) # => "" if < 1.9, nil in 1.9
18
+ # "hello".from(10) # => nil
21
19
  def from(position)
22
20
  mb_chars[position..-1].to_s
23
21
  end
@@ -0,0 +1,5 @@
1
+ unless '1.9'.respond_to?(:bytesize)
2
+ class String
3
+ alias :bytesize :size
4
+ end
5
+ end
@@ -1,61 +1,26 @@
1
1
  require 'date'
2
- require 'active_support/core_ext/time/publicize_conversion_methods'
3
2
  require 'active_support/core_ext/time/calculations'
4
3
 
5
4
  class String
6
- # Returns the codepoint of the first character of the string, assuming a
7
- # single-byte character encoding:
8
- #
9
- # "a".ord # => 97
10
- # "à".ord # => 224, in ISO-8859-1
11
- #
12
- # This method is defined in Ruby 1.8 for Ruby 1.9 forward compatibility on
13
- # these character encodings.
14
- #
15
- # <tt>ActiveSupport::Multibyte::Chars#ord</tt> is forward compatible with
16
- # Ruby 1.9 on UTF8 strings:
17
- #
18
- # "a".mb_chars.ord # => 97
19
- # "à".mb_chars.ord # => 224, in UTF8
20
- #
21
- # Note that the 224 is different in both examples. In ISO-8859-1 "à" is
22
- # represented as a single byte, 224. In UTF8 it is represented with two
23
- # bytes, namely 195 and 160, but its Unicode codepoint is 224. If we
24
- # call +ord+ on the UTF8 string "à" the return value will be 195. That is
25
- # not an error, because UTF8 is unsupported, the call itself would be
26
- # bogus.
5
+ # 'a'.ord == 'a'[0] for Ruby 1.9 forward compatibility.
27
6
  def ord
28
7
  self[0]
29
8
  end unless method_defined?(:ord)
30
9
 
31
10
  # Form can be either :utc (default) or :local.
32
11
  def to_time(form = :utc)
33
- return nil if self.blank?
34
12
  d = ::Date._parse(self, false).values_at(:year, :mon, :mday, :hour, :min, :sec, :sec_fraction).map { |arg| arg || 0 }
35
13
  d[6] *= 1000000
36
14
  ::Time.send("#{form}_time", *d)
37
15
  end
38
16
 
39
17
  def to_date
40
- return nil if self.blank?
41
18
  ::Date.new(*::Date._parse(self, false).values_at(:year, :mon, :mday))
42
19
  end
43
20
 
44
21
  def to_datetime
45
- return nil if self.blank?
46
22
  d = ::Date._parse(self, false).values_at(:year, :mon, :mday, :hour, :min, :sec, :zone, :sec_fraction).map { |arg| arg || 0 }
47
23
  d[5] += d.pop
48
24
  ::DateTime.civil(*d)
49
25
  end
50
-
51
- # +constantize+ tries to find a declared constant with the name specified
52
- # in the string. It raises a NameError when the name is not in CamelCase
53
- # or is not initialized.
54
- #
55
- # Examples
56
- # "Module".constantize # => Module
57
- # "Class".constantize # => Class
58
- def constantize
59
- ActiveSupport::Inflector.constantize(self)
60
- end
61
26
  end