activesupport_csi 2.3.5.p6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (349) hide show
  1. data/CHANGELOG +1330 -0
  2. data/README +43 -0
  3. data/lib/active_support/all.rb +8 -0
  4. data/lib/active_support/backtrace_cleaner.rb +72 -0
  5. data/lib/active_support/base64.rb +33 -0
  6. data/lib/active_support/basic_object.rb +24 -0
  7. data/lib/active_support/buffered_logger.rb +127 -0
  8. data/lib/active_support/cache/compressed_mem_cache_store.rb +20 -0
  9. data/lib/active_support/cache/drb_store.rb +14 -0
  10. data/lib/active_support/cache/file_store.rb +72 -0
  11. data/lib/active_support/cache/mem_cache_store.rb +143 -0
  12. data/lib/active_support/cache/memory_store.rb +52 -0
  13. data/lib/active_support/cache/strategy/local_cache.rb +104 -0
  14. data/lib/active_support/cache/synchronized_memory_store.rb +47 -0
  15. data/lib/active_support/cache.rb +248 -0
  16. data/lib/active_support/callbacks.rb +279 -0
  17. data/lib/active_support/core_ext/array/access.rb +53 -0
  18. data/lib/active_support/core_ext/array/conversions.rb +197 -0
  19. data/lib/active_support/core_ext/array/extract_options.rb +20 -0
  20. data/lib/active_support/core_ext/array/grouping.rb +106 -0
  21. data/lib/active_support/core_ext/array/random_access.rb +12 -0
  22. data/lib/active_support/core_ext/array/wrapper.rb +24 -0
  23. data/lib/active_support/core_ext/array.rb +15 -0
  24. data/lib/active_support/core_ext/base64/encoding.rb +16 -0
  25. data/lib/active_support/core_ext/base64.rb +4 -0
  26. data/lib/active_support/core_ext/benchmark.rb +19 -0
  27. data/lib/active_support/core_ext/bigdecimal/conversions.rb +37 -0
  28. data/lib/active_support/core_ext/bigdecimal.rb +6 -0
  29. data/lib/active_support/core_ext/blank.rb +2 -0
  30. data/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb +23 -0
  31. data/lib/active_support/core_ext/cgi.rb +5 -0
  32. data/lib/active_support/core_ext/class/attribute_accessors.rb +54 -0
  33. data/lib/active_support/core_ext/class/delegating_attributes.rb +47 -0
  34. data/lib/active_support/core_ext/class/inheritable_attributes.rb +140 -0
  35. data/lib/active_support/core_ext/class/removal.rb +50 -0
  36. data/lib/active_support/core_ext/class.rb +4 -0
  37. data/lib/active_support/core_ext/date/behavior.rb +42 -0
  38. data/lib/active_support/core_ext/date/calculations.rb +231 -0
  39. data/lib/active_support/core_ext/date/conversions.rb +107 -0
  40. data/lib/active_support/core_ext/date.rb +10 -0
  41. data/lib/active_support/core_ext/date_time/calculations.rb +126 -0
  42. data/lib/active_support/core_ext/date_time/conversions.rb +96 -0
  43. data/lib/active_support/core_ext/date_time.rb +12 -0
  44. data/lib/active_support/core_ext/duplicable.rb +43 -0
  45. data/lib/active_support/core_ext/enumerable.rb +114 -0
  46. data/lib/active_support/core_ext/exception.rb +45 -0
  47. data/lib/active_support/core_ext/file/atomic.rb +46 -0
  48. data/lib/active_support/core_ext/file.rb +5 -0
  49. data/lib/active_support/core_ext/float/rounding.rb +24 -0
  50. data/lib/active_support/core_ext/float/time.rb +27 -0
  51. data/lib/active_support/core_ext/float.rb +7 -0
  52. data/lib/active_support/core_ext/hash/conversions.rb +264 -0
  53. data/lib/active_support/core_ext/hash/deep_merge.rb +23 -0
  54. data/lib/active_support/core_ext/hash/diff.rb +19 -0
  55. data/lib/active_support/core_ext/hash/except.rb +25 -0
  56. data/lib/active_support/core_ext/hash/indifferent_access.rb +143 -0
  57. data/lib/active_support/core_ext/hash/keys.rb +52 -0
  58. data/lib/active_support/core_ext/hash/reverse_merge.rb +35 -0
  59. data/lib/active_support/core_ext/hash/slice.rb +40 -0
  60. data/lib/active_support/core_ext/hash.rb +14 -0
  61. data/lib/active_support/core_ext/integer/even_odd.rb +29 -0
  62. data/lib/active_support/core_ext/integer/inflections.rb +20 -0
  63. data/lib/active_support/core_ext/integer/time.rb +45 -0
  64. data/lib/active_support/core_ext/integer.rb +9 -0
  65. data/lib/active_support/core_ext/kernel/agnostics.rb +11 -0
  66. data/lib/active_support/core_ext/kernel/daemonizing.rb +7 -0
  67. data/lib/active_support/core_ext/kernel/debugger.rb +16 -0
  68. data/lib/active_support/core_ext/kernel/reporting.rb +59 -0
  69. data/lib/active_support/core_ext/kernel/requires.rb +24 -0
  70. data/lib/active_support/core_ext/kernel.rb +5 -0
  71. data/lib/active_support/core_ext/load_error.rb +38 -0
  72. data/lib/active_support/core_ext/logger.rb +145 -0
  73. data/lib/active_support/core_ext/module/aliasing.rb +74 -0
  74. data/lib/active_support/core_ext/module/attr_accessor_with_default.rb +31 -0
  75. data/lib/active_support/core_ext/module/attr_internal.rb +32 -0
  76. data/lib/active_support/core_ext/module/attribute_accessors.rb +60 -0
  77. data/lib/active_support/core_ext/module/delegation.rb +135 -0
  78. data/lib/active_support/core_ext/module/inclusion.rb +30 -0
  79. data/lib/active_support/core_ext/module/introspection.rb +90 -0
  80. data/lib/active_support/core_ext/module/loading.rb +23 -0
  81. data/lib/active_support/core_ext/module/model_naming.rb +25 -0
  82. data/lib/active_support/core_ext/module/synchronization.rb +39 -0
  83. data/lib/active_support/core_ext/module.rb +23 -0
  84. data/lib/active_support/core_ext/name_error.rb +19 -0
  85. data/lib/active_support/core_ext/numeric/bytes.rb +50 -0
  86. data/lib/active_support/core_ext/numeric/conversions.rb +19 -0
  87. data/lib/active_support/core_ext/numeric/time.rb +81 -0
  88. data/lib/active_support/core_ext/numeric.rb +9 -0
  89. data/lib/active_support/core_ext/object/blank.rb +58 -0
  90. data/lib/active_support/core_ext/object/conversions.rb +15 -0
  91. data/lib/active_support/core_ext/object/extending.rb +80 -0
  92. data/lib/active_support/core_ext/object/instance_variables.rb +74 -0
  93. data/lib/active_support/core_ext/object/metaclass.rb +13 -0
  94. data/lib/active_support/core_ext/object/misc.rb +90 -0
  95. data/lib/active_support/core_ext/object.rb +6 -0
  96. data/lib/active_support/core_ext/pathname/clean_within.rb +14 -0
  97. data/lib/active_support/core_ext/pathname.rb +7 -0
  98. data/lib/active_support/core_ext/proc.rb +12 -0
  99. data/lib/active_support/core_ext/process/daemon.rb +25 -0
  100. data/lib/active_support/core_ext/process.rb +1 -0
  101. data/lib/active_support/core_ext/range/blockless_step.rb +32 -0
  102. data/lib/active_support/core_ext/range/conversions.rb +27 -0
  103. data/lib/active_support/core_ext/range/include_range.rb +30 -0
  104. data/lib/active_support/core_ext/range/overlaps.rb +15 -0
  105. data/lib/active_support/core_ext/range.rb +11 -0
  106. data/lib/active_support/core_ext/rexml.rb +41 -0
  107. data/lib/active_support/core_ext/string/access.rb +106 -0
  108. data/lib/active_support/core_ext/string/behavior.rb +13 -0
  109. data/lib/active_support/core_ext/string/bytesize.rb +5 -0
  110. data/lib/active_support/core_ext/string/conversions.rb +28 -0
  111. data/lib/active_support/core_ext/string/filters.rb +26 -0
  112. data/lib/active_support/core_ext/string/inflections.rb +167 -0
  113. data/lib/active_support/core_ext/string/iterators.rb +23 -0
  114. data/lib/active_support/core_ext/string/multibyte.rb +81 -0
  115. data/lib/active_support/core_ext/string/output_safety.rb +48 -0
  116. data/lib/active_support/core_ext/string/starts_ends_with.rb +35 -0
  117. data/lib/active_support/core_ext/string/xchar.rb +11 -0
  118. data/lib/active_support/core_ext/string.rb +25 -0
  119. data/lib/active_support/core_ext/symbol.rb +14 -0
  120. data/lib/active_support/core_ext/time/behavior.rb +13 -0
  121. data/lib/active_support/core_ext/time/calculations.rb +304 -0
  122. data/lib/active_support/core_ext/time/conversions.rb +90 -0
  123. data/lib/active_support/core_ext/time/zones.rb +86 -0
  124. data/lib/active_support/core_ext/time.rb +42 -0
  125. data/lib/active_support/core_ext/try.rb +36 -0
  126. data/lib/active_support/core_ext/uri.rb +16 -0
  127. data/lib/active_support/core_ext.rb +8 -0
  128. data/lib/active_support/dependencies.rb +625 -0
  129. data/lib/active_support/deprecation.rb +196 -0
  130. data/lib/active_support/duration.rb +100 -0
  131. data/lib/active_support/gzip.rb +25 -0
  132. data/lib/active_support/inflections.rb +56 -0
  133. data/lib/active_support/inflector.rb +406 -0
  134. data/lib/active_support/json/backends/jsongem.rb +37 -0
  135. data/lib/active_support/json/backends/okjson.rb +644 -0
  136. data/lib/active_support/json/backends/yaml.rb +20 -0
  137. data/lib/active_support/json/decoding.rb +50 -0
  138. data/lib/active_support/json/encoders/date.rb +22 -0
  139. data/lib/active_support/json/encoders/date_time.rb +22 -0
  140. data/lib/active_support/json/encoders/enumerable.rb +17 -0
  141. data/lib/active_support/json/encoders/false_class.rb +7 -0
  142. data/lib/active_support/json/encoders/hash.rb +56 -0
  143. data/lib/active_support/json/encoders/nil_class.rb +7 -0
  144. data/lib/active_support/json/encoders/numeric.rb +21 -0
  145. data/lib/active_support/json/encoders/object.rb +10 -0
  146. data/lib/active_support/json/encoders/regexp.rb +9 -0
  147. data/lib/active_support/json/encoders/string.rb +9 -0
  148. data/lib/active_support/json/encoders/symbol.rb +5 -0
  149. data/lib/active_support/json/encoders/time.rb +22 -0
  150. data/lib/active_support/json/encoders/true_class.rb +7 -0
  151. data/lib/active_support/json/encoding.rb +102 -0
  152. data/lib/active_support/json/variable.rb +10 -0
  153. data/lib/active_support/json.rb +2 -0
  154. data/lib/active_support/locale/en.yml +33 -0
  155. data/lib/active_support/memoizable.rb +100 -0
  156. data/lib/active_support/message_encryptor.rb +70 -0
  157. data/lib/active_support/message_verifier.rb +79 -0
  158. data/lib/active_support/multibyte/chars.rb +707 -0
  159. data/lib/active_support/multibyte/exceptions.rb +8 -0
  160. data/lib/active_support/multibyte/unicode_database.rb +71 -0
  161. data/lib/active_support/multibyte/utils.rb +61 -0
  162. data/lib/active_support/multibyte.rb +57 -0
  163. data/lib/active_support/option_merger.rb +23 -0
  164. data/lib/active_support/ordered_hash.rb +141 -0
  165. data/lib/active_support/ordered_options.rb +19 -0
  166. data/lib/active_support/rescuable.rb +108 -0
  167. data/lib/active_support/secure_random.rb +199 -0
  168. data/lib/active_support/string_inquirer.rb +21 -0
  169. data/lib/active_support/test_case.rb +40 -0
  170. data/lib/active_support/testing/assertions.rb +65 -0
  171. data/lib/active_support/testing/declarative.rb +21 -0
  172. data/lib/active_support/testing/default.rb +9 -0
  173. data/lib/active_support/testing/deprecation.rb +57 -0
  174. data/lib/active_support/testing/performance.rb +452 -0
  175. data/lib/active_support/testing/setup_and_teardown.rb +91 -0
  176. data/lib/active_support/time_with_zone.rb +335 -0
  177. data/lib/active_support/values/time_zone.rb +404 -0
  178. data/lib/active_support/values/unicode_tables.dat +0 -0
  179. data/lib/active_support/vendor/builder-2.1.2/blankslate.rb +113 -0
  180. data/lib/active_support/vendor/builder-2.1.2/builder/blankslate.rb +20 -0
  181. data/lib/active_support/vendor/builder-2.1.2/builder/css.rb +250 -0
  182. data/lib/active_support/vendor/builder-2.1.2/builder/xchar.rb +115 -0
  183. data/lib/active_support/vendor/builder-2.1.2/builder/xmlbase.rb +139 -0
  184. data/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb +63 -0
  185. data/lib/active_support/vendor/builder-2.1.2/builder/xmlmarkup.rb +328 -0
  186. data/lib/active_support/vendor/builder-2.1.2/builder.rb +13 -0
  187. data/lib/active_support/vendor/i18n-0.1.3/MIT-LICENSE +20 -0
  188. data/lib/active_support/vendor/i18n-0.1.3/README.textile +20 -0
  189. data/lib/active_support/vendor/i18n-0.1.3/Rakefile +5 -0
  190. data/lib/active_support/vendor/i18n-0.1.3/i18n.gemspec +27 -0
  191. data/lib/active_support/vendor/i18n-0.1.3/lib/i18n/backend/simple.rb +214 -0
  192. data/lib/active_support/vendor/i18n-0.1.3/lib/i18n/exceptions.rb +53 -0
  193. data/lib/active_support/vendor/i18n-0.1.3/lib/i18n.rb +199 -0
  194. data/lib/active_support/vendor/i18n-0.1.3/test/all.rb +5 -0
  195. data/lib/active_support/vendor/i18n-0.1.3/test/i18n_exceptions_test.rb +99 -0
  196. data/lib/active_support/vendor/i18n-0.1.3/test/i18n_test.rb +124 -0
  197. data/lib/active_support/vendor/i18n-0.1.3/test/locale/en.rb +1 -0
  198. data/lib/active_support/vendor/i18n-0.1.3/test/locale/en.yml +3 -0
  199. data/lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb +567 -0
  200. data/lib/active_support/vendor/memcache-client-1.7.4/memcache.rb +1107 -0
  201. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/data_timezone.rb +47 -0
  202. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/data_timezone_info.rb +228 -0
  203. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Algiers.rb +55 -0
  204. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Cairo.rb +219 -0
  205. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Casablanca.rb +40 -0
  206. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Harare.rb +18 -0
  207. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Johannesburg.rb +25 -0
  208. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Monrovia.rb +22 -0
  209. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Nairobi.rb +23 -0
  210. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Argentina/Buenos_Aires.rb +166 -0
  211. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Argentina/San_Juan.rb +86 -0
  212. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Bogota.rb +23 -0
  213. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Caracas.rb +23 -0
  214. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Chicago.rb +283 -0
  215. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Chihuahua.rb +136 -0
  216. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Denver.rb +204 -0
  217. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Godthab.rb +161 -0
  218. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Guatemala.rb +27 -0
  219. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Halifax.rb +274 -0
  220. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Indiana/Indianapolis.rb +149 -0
  221. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Juneau.rb +194 -0
  222. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/La_Paz.rb +22 -0
  223. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Lima.rb +35 -0
  224. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Los_Angeles.rb +232 -0
  225. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Mazatlan.rb +139 -0
  226. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Mexico_City.rb +144 -0
  227. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Monterrey.rb +131 -0
  228. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/New_York.rb +282 -0
  229. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Phoenix.rb +30 -0
  230. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Regina.rb +74 -0
  231. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Santiago.rb +205 -0
  232. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Sao_Paulo.rb +171 -0
  233. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/St_Johns.rb +288 -0
  234. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Tijuana.rb +196 -0
  235. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Almaty.rb +67 -0
  236. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Baghdad.rb +73 -0
  237. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Baku.rb +161 -0
  238. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Bangkok.rb +20 -0
  239. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Chongqing.rb +33 -0
  240. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Colombo.rb +30 -0
  241. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Dhaka.rb +27 -0
  242. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Hong_Kong.rb +87 -0
  243. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Irkutsk.rb +165 -0
  244. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Jakarta.rb +30 -0
  245. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Jerusalem.rb +163 -0
  246. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kabul.rb +20 -0
  247. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kamchatka.rb +163 -0
  248. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Karachi.rb +30 -0
  249. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Katmandu.rb +20 -0
  250. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kolkata.rb +25 -0
  251. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Krasnoyarsk.rb +163 -0
  252. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kuala_Lumpur.rb +31 -0
  253. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kuwait.rb +18 -0
  254. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Magadan.rb +163 -0
  255. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Muscat.rb +18 -0
  256. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Novosibirsk.rb +164 -0
  257. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Rangoon.rb +24 -0
  258. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Riyadh.rb +18 -0
  259. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Seoul.rb +34 -0
  260. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Shanghai.rb +35 -0
  261. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Singapore.rb +33 -0
  262. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Taipei.rb +59 -0
  263. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tashkent.rb +47 -0
  264. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tbilisi.rb +78 -0
  265. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tehran.rb +121 -0
  266. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tokyo.rb +30 -0
  267. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Ulaanbaatar.rb +65 -0
  268. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Urumqi.rb +33 -0
  269. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Vladivostok.rb +164 -0
  270. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yakutsk.rb +163 -0
  271. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yekaterinburg.rb +165 -0
  272. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yerevan.rb +165 -0
  273. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/Azores.rb +270 -0
  274. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/Cape_Verde.rb +23 -0
  275. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/South_Georgia.rb +18 -0
  276. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Adelaide.rb +187 -0
  277. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Brisbane.rb +35 -0
  278. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Darwin.rb +29 -0
  279. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Hobart.rb +193 -0
  280. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Melbourne.rb +185 -0
  281. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Perth.rb +37 -0
  282. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Sydney.rb +185 -0
  283. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Etc/UTC.rb +16 -0
  284. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Amsterdam.rb +228 -0
  285. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Athens.rb +185 -0
  286. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Belgrade.rb +163 -0
  287. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Berlin.rb +188 -0
  288. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Bratislava.rb +13 -0
  289. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Brussels.rb +232 -0
  290. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Bucharest.rb +181 -0
  291. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Budapest.rb +197 -0
  292. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Copenhagen.rb +179 -0
  293. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Dublin.rb +276 -0
  294. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Helsinki.rb +163 -0
  295. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Istanbul.rb +218 -0
  296. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Kiev.rb +168 -0
  297. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Lisbon.rb +268 -0
  298. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Ljubljana.rb +13 -0
  299. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/London.rb +288 -0
  300. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Madrid.rb +211 -0
  301. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Minsk.rb +170 -0
  302. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Moscow.rb +181 -0
  303. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Paris.rb +232 -0
  304. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Prague.rb +187 -0
  305. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Riga.rb +176 -0
  306. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Rome.rb +215 -0
  307. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Sarajevo.rb +13 -0
  308. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Skopje.rb +13 -0
  309. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Sofia.rb +173 -0
  310. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Stockholm.rb +165 -0
  311. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Tallinn.rb +172 -0
  312. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Vienna.rb +183 -0
  313. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Vilnius.rb +170 -0
  314. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Warsaw.rb +212 -0
  315. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Zagreb.rb +13 -0
  316. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Auckland.rb +202 -0
  317. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Fiji.rb +23 -0
  318. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Guam.rb +22 -0
  319. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Honolulu.rb +28 -0
  320. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Majuro.rb +20 -0
  321. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Midway.rb +25 -0
  322. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Noumea.rb +25 -0
  323. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Pago_Pago.rb +26 -0
  324. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Port_Moresby.rb +20 -0
  325. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Tongatapu.rb +27 -0
  326. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/info_timezone.rb +52 -0
  327. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/linked_timezone.rb +51 -0
  328. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/linked_timezone_info.rb +44 -0
  329. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/offset_rationals.rb +98 -0
  330. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/ruby_core_support.rb +56 -0
  331. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/time_or_datetime.rb +292 -0
  332. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone.rb +508 -0
  333. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_definition.rb +56 -0
  334. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_info.rb +40 -0
  335. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_offset_info.rb +94 -0
  336. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb +198 -0
  337. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_transition_info.rb +129 -0
  338. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo.rb +33 -0
  339. data/lib/active_support/vendor.rb +28 -0
  340. data/lib/active_support/version.rb +9 -0
  341. data/lib/active_support/whiny_nil.rb +64 -0
  342. data/lib/active_support/xml_mini/jdom.rb +162 -0
  343. data/lib/active_support/xml_mini/libxml.rb +133 -0
  344. data/lib/active_support/xml_mini/nokogiri.rb +69 -0
  345. data/lib/active_support/xml_mini/rexml.rb +108 -0
  346. data/lib/active_support/xml_mini.rb +31 -0
  347. data/lib/active_support.rb +59 -0
  348. data/lib/activesupport.rb +2 -0
  349. metadata +418 -0
@@ -0,0 +1,135 @@
1
+ class Module
2
+ # Provides a delegate class method to easily expose contained objects' methods
3
+ # as your own. Pass one or more methods (specified as symbols or strings)
4
+ # and the name of the target object as the final <tt>:to</tt> option (also a symbol
5
+ # or string). At least one method and the <tt>:to</tt> option are required.
6
+ #
7
+ # Delegation is particularly useful with Active Record associations:
8
+ #
9
+ # class Greeter < ActiveRecord::Base
10
+ # def hello() "hello" end
11
+ # def goodbye() "goodbye" end
12
+ # end
13
+ #
14
+ # class Foo < ActiveRecord::Base
15
+ # belongs_to :greeter
16
+ # delegate :hello, :to => :greeter
17
+ # end
18
+ #
19
+ # Foo.new.hello # => "hello"
20
+ # Foo.new.goodbye # => NoMethodError: undefined method `goodbye' for #<Foo:0x1af30c>
21
+ #
22
+ # Multiple delegates to the same target are allowed:
23
+ #
24
+ # class Foo < ActiveRecord::Base
25
+ # belongs_to :greeter
26
+ # delegate :hello, :goodbye, :to => :greeter
27
+ # end
28
+ #
29
+ # Foo.new.goodbye # => "goodbye"
30
+ #
31
+ # Methods can be delegated to instance variables, class variables, or constants
32
+ # by providing them as a symbols:
33
+ #
34
+ # class Foo
35
+ # CONSTANT_ARRAY = [0,1,2,3]
36
+ # @@class_array = [4,5,6,7]
37
+ #
38
+ # def initialize
39
+ # @instance_array = [8,9,10,11]
40
+ # end
41
+ # delegate :sum, :to => :CONSTANT_ARRAY
42
+ # delegate :min, :to => :@@class_array
43
+ # delegate :max, :to => :@instance_array
44
+ # end
45
+ #
46
+ # Foo.new.sum # => 6
47
+ # Foo.new.min # => 4
48
+ # Foo.new.max # => 11
49
+ #
50
+ # Delegates can optionally be prefixed using the <tt>:prefix</tt> option. If the value
51
+ # is <tt>true</tt>, the delegate methods are prefixed with the name of the object being
52
+ # delegated to.
53
+ #
54
+ # Person = Struct.new(:name, :address)
55
+ #
56
+ # class Invoice < Struct.new(:client)
57
+ # delegate :name, :address, :to => :client, :prefix => true
58
+ # end
59
+ #
60
+ # john_doe = Person.new("John Doe", "Vimmersvej 13")
61
+ # invoice = Invoice.new(john_doe)
62
+ # invoice.client_name # => "John Doe"
63
+ # invoice.client_address # => "Vimmersvej 13"
64
+ #
65
+ # It is also possible to supply a custom prefix.
66
+ #
67
+ # class Invoice < Struct.new(:client)
68
+ # delegate :name, :address, :to => :client, :prefix => :customer
69
+ # end
70
+ #
71
+ # invoice = Invoice.new(john_doe)
72
+ # invoice.customer_name # => "John Doe"
73
+ # invoice.customer_address # => "Vimmersvej 13"
74
+ #
75
+ # If the object to which you delegate can be nil, you may want to use the
76
+ # :allow_nil option. In that case, it returns nil instead of raising a
77
+ # NoMethodError exception:
78
+ #
79
+ # class Foo
80
+ # attr_accessor :bar
81
+ # def initialize(bar = nil)
82
+ # @bar = bar
83
+ # end
84
+ # delegate :zoo, :to => :bar
85
+ # end
86
+ #
87
+ # Foo.new.zoo # raises NoMethodError exception (you called nil.zoo)
88
+ #
89
+ # class Foo
90
+ # attr_accessor :bar
91
+ # def initialize(bar = nil)
92
+ # @bar = bar
93
+ # end
94
+ # delegate :zoo, :to => :bar, :allow_nil => true
95
+ # end
96
+ #
97
+ # Foo.new.zoo # returns nil
98
+ #
99
+ def delegate(*methods)
100
+ options = methods.pop
101
+ unless options.is_a?(Hash) && to = options[:to]
102
+ raise ArgumentError, "Delegation needs a target. Supply an options hash with a :to key as the last argument (e.g. delegate :hello, :to => :greeter)."
103
+ end
104
+
105
+ if options[:prefix] == true && options[:to].to_s =~ /^[^a-z_]/
106
+ raise ArgumentError, "Can only automatically set the delegation prefix when delegating to a method."
107
+ end
108
+
109
+ prefix = options[:prefix] && "#{options[:prefix] == true ? to : options[:prefix]}_"
110
+
111
+ file, line = caller.first.split(':', 2)
112
+ line = line.to_i
113
+
114
+ methods.each do |method|
115
+ on_nil =
116
+ if options[:allow_nil]
117
+ 'return'
118
+ else
119
+ %(raise "#{prefix}#{method} delegated to #{to}.#{method}, but #{to} is nil: \#{self.inspect}")
120
+ end
121
+
122
+ module_eval(<<-EOS, file, line)
123
+ def #{prefix}#{method}(*args, &block) # def customer_name(*args, &block)
124
+ #{to}.__send__(#{method.inspect}, *args, &block) # client.__send__(:name, *args, &block)
125
+ rescue NoMethodError # rescue NoMethodError
126
+ if #{to}.nil? # if client.nil?
127
+ #{on_nil}
128
+ else # else
129
+ raise # raise
130
+ end # end
131
+ end # end
132
+ EOS
133
+ end
134
+ end
135
+ end
@@ -0,0 +1,30 @@
1
+ class Module
2
+ # Returns the classes in the current ObjectSpace where this module has been
3
+ # mixed in according to Module#included_modules.
4
+ #
5
+ # module M
6
+ # end
7
+ #
8
+ # module N
9
+ # include M
10
+ # end
11
+ #
12
+ # class C
13
+ # include M
14
+ # end
15
+ #
16
+ # class D < C
17
+ # end
18
+ #
19
+ # p M.included_in_classes # => [C, D]
20
+ #
21
+ def included_in_classes
22
+ classes = []
23
+ ObjectSpace.each_object(Class) { |k| classes << k if k.included_modules.include?(self) }
24
+
25
+ classes.reverse.inject([]) do |unique_classes, klass|
26
+ unique_classes << klass unless unique_classes.collect { |k| k.to_s }.include?(klass.to_s)
27
+ unique_classes
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,90 @@
1
+ module ActiveSupport
2
+ module CoreExtensions
3
+ module Module
4
+ # Returns the name of the module containing this one.
5
+ #
6
+ # p M::N.parent_name # => "M"
7
+ def parent_name
8
+ unless defined? @parent_name
9
+ @parent_name = name =~ /::[^:]+\Z/ ? $`.freeze : nil
10
+ end
11
+ @parent_name
12
+ end
13
+
14
+ # Returns the module which contains this one according to its name.
15
+ #
16
+ # module M
17
+ # module N
18
+ # end
19
+ # end
20
+ # X = M::N
21
+ #
22
+ # p M::N.parent # => M
23
+ # p X.parent # => M
24
+ #
25
+ # The parent of top-level and anonymous modules is Object.
26
+ #
27
+ # p M.parent # => Object
28
+ # p Module.new.parent # => Object
29
+ #
30
+ def parent
31
+ parent_name ? parent_name.constantize : Object
32
+ end
33
+
34
+ # Returns all the parents of this module according to its name, ordered from
35
+ # nested outwards. The receiver is not contained within the result.
36
+ #
37
+ # module M
38
+ # module N
39
+ # end
40
+ # end
41
+ # X = M::N
42
+ #
43
+ # p M.parents # => [Object]
44
+ # p M::N.parents # => [M, Object]
45
+ # p X.parents # => [M, Object]
46
+ #
47
+ def parents
48
+ parents = []
49
+ if parent_name
50
+ parts = parent_name.split('::')
51
+ until parts.empty?
52
+ parents << (parts * '::').constantize
53
+ parts.pop
54
+ end
55
+ end
56
+ parents << Object unless parents.include? Object
57
+ parents
58
+ end
59
+
60
+ if RUBY_VERSION < '1.9'
61
+ # Returns the constants that have been defined locally by this object and
62
+ # not in an ancestor. This method is exact if running under Ruby 1.9. In
63
+ # previous versions it may miss some constants if their definition in some
64
+ # ancestor is identical to their definition in the receiver.
65
+ def local_constants
66
+ inherited = {}
67
+
68
+ ancestors.each do |anc|
69
+ next if anc == self
70
+ anc.constants.each { |const| inherited[const] = anc.const_get(const) }
71
+ end
72
+
73
+ constants.select do |const|
74
+ !inherited.key?(const) || inherited[const].object_id != const_get(const).object_id
75
+ end
76
+ end
77
+ else
78
+ def local_constants #:nodoc:
79
+ constants(false)
80
+ end
81
+ end
82
+
83
+ # Returns the names of the constants defined locally rather than the
84
+ # constants themselves. See <tt>local_constants</tt>.
85
+ def local_constant_names
86
+ local_constants.map { |c| c.to_s }
87
+ end
88
+ end
89
+ end
90
+ end
@@ -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
@@ -0,0 +1,25 @@
1
+ module ActiveSupport
2
+ class ModelName < String
3
+ attr_reader :singular, :plural, :element, :collection, :partial_path
4
+ alias_method :cache_key, :collection
5
+
6
+ def initialize(name)
7
+ super
8
+ @singular = ActiveSupport::Inflector.underscore(self).tr('/', '_').freeze
9
+ @plural = ActiveSupport::Inflector.pluralize(@singular).freeze
10
+ @element = ActiveSupport::Inflector.underscore(ActiveSupport::Inflector.demodulize(self)).freeze
11
+ @collection = ActiveSupport::Inflector.tableize(self).freeze
12
+ @partial_path = "#{@collection}/#{@element}".freeze
13
+ end
14
+ end
15
+
16
+ module CoreExtensions
17
+ module Module
18
+ # Returns an ActiveSupport::ModelName object for module. It can be
19
+ # used to retrieve all kinds of naming-related information.
20
+ def model_name
21
+ @model_name ||= ::ActiveSupport::ModelName.new(name)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,39 @@
1
+ class Module
2
+ # Synchronize access around a method, delegating synchronization to a
3
+ # particular mutex. A mutex (either a Mutex, or any object that responds to
4
+ # #synchronize and yields to a block) must be provided as a final :with option.
5
+ # The :with option should be a symbol or string, and can represent a method,
6
+ # constant, or instance or class variable.
7
+ # Example:
8
+ # class SharedCache
9
+ # @@lock = Mutex.new
10
+ # def expire
11
+ # ...
12
+ # end
13
+ # synchronize :expire, :with => :@@lock
14
+ # end
15
+ def synchronize(*methods)
16
+ options = methods.extract_options!
17
+ unless options.is_a?(Hash) && with = options[:with]
18
+ raise ArgumentError, "Synchronization needs a mutex. Supply an options hash with a :with key as the last argument (e.g. synchronize :hello, :with => :@mutex)."
19
+ end
20
+
21
+ methods.each do |method|
22
+ aliased_method, punctuation = method.to_s.sub(/([?!=])$/, ''), $1
23
+
24
+ if method_defined?("#{aliased_method}_without_synchronization#{punctuation}")
25
+ raise ArgumentError, "#{method} is already synchronized. Double synchronization is not currently supported."
26
+ end
27
+
28
+ module_eval(<<-EOS, __FILE__, __LINE__)
29
+ def #{aliased_method}_with_synchronization#{punctuation}(*args, &block) # def expire_with_synchronization(*args, &block)
30
+ #{with}.synchronize do # @@lock.synchronize do
31
+ #{aliased_method}_without_synchronization#{punctuation}(*args, &block) # expire_without_synchronization(*args, &block)
32
+ end # end
33
+ end # end
34
+ EOS
35
+
36
+ alias_method_chain method, :synchronization
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,23 @@
1
+ require 'active_support/core_ext/module/inclusion'
2
+ require 'active_support/core_ext/module/attribute_accessors'
3
+ require 'active_support/core_ext/module/attr_internal'
4
+ require 'active_support/core_ext/module/attr_accessor_with_default'
5
+ require 'active_support/core_ext/module/delegation'
6
+ require 'active_support/core_ext/module/introspection'
7
+ require 'active_support/core_ext/module/loading'
8
+ require 'active_support/core_ext/module/aliasing'
9
+ require 'active_support/core_ext/module/model_naming'
10
+ require 'active_support/core_ext/module/synchronization'
11
+
12
+ module ActiveSupport
13
+ module CoreExtensions
14
+ # Various extensions for the Ruby core Module class.
15
+ module Module
16
+ # Nothing here. Only defined for API documentation purposes.
17
+ end
18
+ end
19
+ end
20
+
21
+ class Module
22
+ include ActiveSupport::CoreExtensions::Module
23
+ end
@@ -0,0 +1,19 @@
1
+ # Add a +missing_name+ method to NameError instances.
2
+ class NameError #:nodoc:
3
+ # Add a method to obtain the missing name from a NameError.
4
+ def missing_name
5
+ if /undefined local variable or method/ !~ message
6
+ $1 if /((::)?([A-Z]\w*)(::[A-Z]\w*)*)$/ =~ message
7
+ end
8
+ end
9
+
10
+ # Was this exception raised because the given name was missing?
11
+ def missing_name?(name)
12
+ if name.is_a? Symbol
13
+ last_name = (missing_name || '').split('::').last
14
+ last_name == name.to_s
15
+ else
16
+ missing_name == name.to_s
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,50 @@
1
+ module ActiveSupport #:nodoc:
2
+ module CoreExtensions #:nodoc:
3
+ module Numeric #:nodoc:
4
+ # Enables the use of byte calculations and declarations, like 45.bytes + 2.6.megabytes
5
+ module Bytes
6
+ KILOBYTE = 1024
7
+ MEGABYTE = KILOBYTE * 1024
8
+ GIGABYTE = MEGABYTE * 1024
9
+ TERABYTE = GIGABYTE * 1024
10
+ PETABYTE = TERABYTE * 1024
11
+ EXABYTE = PETABYTE * 1024
12
+
13
+ def bytes
14
+ self
15
+ end
16
+ alias :byte :bytes
17
+
18
+ def kilobytes
19
+ self * KILOBYTE
20
+ end
21
+ alias :kilobyte :kilobytes
22
+
23
+ def megabytes
24
+ self * MEGABYTE
25
+ end
26
+ alias :megabyte :megabytes
27
+
28
+ def gigabytes
29
+ self * GIGABYTE
30
+ end
31
+ alias :gigabyte :gigabytes
32
+
33
+ def terabytes
34
+ self * TERABYTE
35
+ end
36
+ alias :terabyte :terabytes
37
+
38
+ def petabytes
39
+ self * PETABYTE
40
+ end
41
+ alias :petabyte :petabytes
42
+
43
+ def exabytes
44
+ self * EXABYTE
45
+ end
46
+ alias :exabyte :exabytes
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,19 @@
1
+ module ActiveSupport #:nodoc:
2
+ module CoreExtensions #:nodoc:
3
+ module Numeric #:nodoc:
4
+ module Conversions
5
+ # Assumes self represents an offset from UTC in seconds (as returned from Time#utc_offset)
6
+ # and turns this into an +HH:MM formatted string. Example:
7
+ #
8
+ # -21_600.to_utc_offset_s # => "-06:00"
9
+ def to_utc_offset_s(colon=true)
10
+ seconds = self
11
+ sign = (seconds < 0 ? -1 : 1)
12
+ hours = seconds.abs / 3600
13
+ minutes = (seconds.abs % 3600) / 60
14
+ "%+03d%s%02d" % [ hours * sign, colon ? ":" : "", minutes ]
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,81 @@
1
+ module ActiveSupport #:nodoc:
2
+ module CoreExtensions #:nodoc:
3
+ module Numeric #:nodoc:
4
+ # Enables the use of time calculations and declarations, like 45.minutes + 2.hours + 4.years.
5
+ #
6
+ # These methods use Time#advance for precise date calculations when using from_now, ago, etc.
7
+ # as well as adding or subtracting their results from a Time object. For example:
8
+ #
9
+ # # equivalent to Time.now.advance(:months => 1)
10
+ # 1.month.from_now
11
+ #
12
+ # # equivalent to Time.now.advance(:years => 2)
13
+ # 2.years.from_now
14
+ #
15
+ # # equivalent to Time.now.advance(:months => 4, :years => 5)
16
+ # (4.months + 5.years).from_now
17
+ #
18
+ # While these methods provide precise calculation when used as in the examples above, care
19
+ # should be taken to note that this is not true if the result of `months', `years', etc is
20
+ # converted before use:
21
+ #
22
+ # # equivalent to 30.days.to_i.from_now
23
+ # 1.month.to_i.from_now
24
+ #
25
+ # # equivalent to 365.25.days.to_f.from_now
26
+ # 1.year.to_f.from_now
27
+ #
28
+ # In such cases, Ruby's core
29
+ # Date[http://stdlib.rubyonrails.org/libdoc/date/rdoc/index.html] and
30
+ # Time[http://stdlib.rubyonrails.org/libdoc/time/rdoc/index.html] should be used for precision
31
+ # date and time arithmetic
32
+ module Time
33
+ def seconds
34
+ ActiveSupport::Duration.new(self, [[:seconds, self]])
35
+ end
36
+ alias :second :seconds
37
+
38
+ def minutes
39
+ ActiveSupport::Duration.new(self * 60, [[:seconds, self * 60]])
40
+ end
41
+ alias :minute :minutes
42
+
43
+ def hours
44
+ ActiveSupport::Duration.new(self * 3600, [[:seconds, self * 3600]])
45
+ end
46
+ alias :hour :hours
47
+
48
+ def days
49
+ ActiveSupport::Duration.new(self * 24.hours, [[:days, self]])
50
+ end
51
+ alias :day :days
52
+
53
+ def weeks
54
+ ActiveSupport::Duration.new(self * 7.days, [[:days, self * 7]])
55
+ end
56
+ alias :week :weeks
57
+
58
+ def fortnights
59
+ ActiveSupport::Duration.new(self * 2.weeks, [[:days, self * 14]])
60
+ end
61
+ alias :fortnight :fortnights
62
+
63
+ # Reads best without arguments: 10.minutes.ago
64
+ def ago(time = ::Time.now)
65
+ time - self
66
+ end
67
+
68
+ # Reads best with argument: 10.minutes.until(time)
69
+ alias :until :ago
70
+
71
+ # Reads best with argument: 10.minutes.since(time)
72
+ def since(time = ::Time.now)
73
+ time + self
74
+ end
75
+
76
+ # Reads best without arguments: 10.minutes.from_now
77
+ alias :from_now :since
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,9 @@
1
+ require 'active_support/core_ext/numeric/time'
2
+ require 'active_support/core_ext/numeric/bytes'
3
+ require 'active_support/core_ext/numeric/conversions'
4
+
5
+ class Numeric #:nodoc:
6
+ include ActiveSupport::CoreExtensions::Numeric::Time
7
+ include ActiveSupport::CoreExtensions::Numeric::Bytes
8
+ include ActiveSupport::CoreExtensions::Numeric::Conversions
9
+ end
@@ -0,0 +1,58 @@
1
+ class Object
2
+ # An object is blank if it's false, empty, or a whitespace string.
3
+ # For example, "", " ", +nil+, [], and {} are blank.
4
+ #
5
+ # This simplifies
6
+ #
7
+ # if !address.nil? && !address.empty?
8
+ #
9
+ # to
10
+ #
11
+ # if !address.blank?
12
+ def blank?
13
+ respond_to?(:empty?) ? empty? : !self
14
+ end
15
+
16
+ # An object is present if it's not blank.
17
+ def present?
18
+ !blank?
19
+ end
20
+ end
21
+
22
+ class NilClass #:nodoc:
23
+ def blank?
24
+ true
25
+ end
26
+ end
27
+
28
+ class FalseClass #:nodoc:
29
+ def blank?
30
+ true
31
+ end
32
+ end
33
+
34
+ class TrueClass #:nodoc:
35
+ def blank?
36
+ false
37
+ end
38
+ end
39
+
40
+ class Array #:nodoc:
41
+ alias_method :blank?, :empty?
42
+ end
43
+
44
+ class Hash #:nodoc:
45
+ alias_method :blank?, :empty?
46
+ end
47
+
48
+ class String #:nodoc:
49
+ def blank?
50
+ self !~ /\S/
51
+ end
52
+ end
53
+
54
+ class Numeric #:nodoc:
55
+ def blank?
56
+ false
57
+ end
58
+ end
@@ -0,0 +1,15 @@
1
+ class Object
2
+ # Alias of <tt>to_s</tt>.
3
+ def to_param
4
+ to_s
5
+ end
6
+
7
+ # Converts an object into a string suitable for use as a URL query string, using the given <tt>key</tt> as the
8
+ # param name.
9
+ #
10
+ # Note: This method is defined as a default implementation for all Objects for Hash#to_query to work.
11
+ def to_query(key)
12
+ require 'cgi' unless defined?(CGI) && defined?(CGI::escape)
13
+ "#{CGI.escape(key.to_s)}=#{CGI.escape(to_param.to_s)}"
14
+ end
15
+ end