mack-facets 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (492) hide show
  1. data/lib/gems.rb +25 -0
  2. data/lib/gems/english-0.3.1/VERSION +1 -0
  3. data/lib/gems/english-0.3.1/lib/english/array.rb +48 -0
  4. data/lib/gems/english-0.3.1/lib/english/censor.rb +76 -0
  5. data/lib/gems/english-0.3.1/lib/english/double_metaphone.rb +353 -0
  6. data/lib/gems/english-0.3.1/lib/english/dresner.rb +47 -0
  7. data/lib/gems/english-0.3.1/lib/english/inflect.rb +299 -0
  8. data/lib/gems/english-0.3.1/lib/english/jumble.rb +37 -0
  9. data/lib/gems/english-0.3.1/lib/english/levenshtein.rb +78 -0
  10. data/lib/gems/english-0.3.1/lib/english/metaphone.rb +110 -0
  11. data/lib/gems/english-0.3.1/lib/english/numerals.rb +71 -0
  12. data/lib/gems/english-0.3.1/lib/english/patterns.rb +49 -0
  13. data/lib/gems/english-0.3.1/lib/english/porter_stemming.rb +188 -0
  14. data/lib/gems/english-0.3.1/lib/english/roman.rb +174 -0
  15. data/lib/gems/english-0.3.1/lib/english/similarity.rb +103 -0
  16. data/lib/gems/english-0.3.1/lib/english/soundex.rb +70 -0
  17. data/lib/gems/english-0.3.1/lib/english/string.rb +210 -0
  18. data/lib/gems/english-0.3.1/lib/english/style.rb +294 -0
  19. data/lib/gems/english-0.3.1/lib/english/style_orm.rb +143 -0
  20. data/lib/gems/english-0.3.1/lib/english/textfilter.rb +91 -0
  21. data/lib/gems/extlib-0.9.8/lib/extlib.rb +56 -0
  22. data/lib/gems/extlib-0.9.8/lib/extlib/assertions.rb +8 -0
  23. data/lib/gems/extlib-0.9.8/lib/extlib/blank.rb +59 -0
  24. data/lib/gems/extlib-0.9.8/lib/extlib/boolean.rb +11 -0
  25. data/lib/gems/extlib-0.9.8/lib/extlib/class.rb +175 -0
  26. data/lib/gems/extlib-0.9.8/lib/extlib/datetime.rb +9 -0
  27. data/lib/gems/extlib-0.9.8/lib/extlib/dictionary.rb +433 -0
  28. data/lib/gems/extlib-0.9.8/lib/extlib/hash.rb +419 -0
  29. data/lib/gems/extlib-0.9.8/lib/extlib/hook.rb +366 -0
  30. data/lib/gems/extlib-0.9.8/lib/extlib/inflection.rb +435 -0
  31. data/lib/gems/extlib-0.9.8/lib/extlib/lazy_array.rb +106 -0
  32. data/lib/gems/extlib-0.9.8/lib/extlib/logger.rb +202 -0
  33. data/lib/gems/extlib-0.9.8/lib/extlib/mash.rb +148 -0
  34. data/lib/gems/extlib-0.9.8/lib/extlib/module.rb +41 -0
  35. data/lib/gems/extlib-0.9.8/lib/extlib/nil.rb +5 -0
  36. data/lib/gems/extlib-0.9.8/lib/extlib/numeric.rb +5 -0
  37. data/lib/gems/extlib-0.9.8/lib/extlib/object.rb +175 -0
  38. data/lib/gems/extlib-0.9.8/lib/extlib/object_space.rb +13 -0
  39. data/lib/gems/extlib-0.9.8/lib/extlib/pathname.rb +5 -0
  40. data/lib/gems/extlib-0.9.8/lib/extlib/pooling.rb +239 -0
  41. data/lib/gems/extlib-0.9.8/lib/extlib/rubygems.rb +38 -0
  42. data/lib/gems/extlib-0.9.8/lib/extlib/simple_set.rb +39 -0
  43. data/lib/gems/extlib-0.9.8/lib/extlib/string.rb +132 -0
  44. data/lib/gems/extlib-0.9.8/lib/extlib/struct.rb +8 -0
  45. data/lib/gems/extlib-0.9.8/lib/extlib/symbol.rb +17 -0
  46. data/lib/gems/extlib-0.9.8/lib/extlib/tasks/release.rb +15 -0
  47. data/lib/gems/extlib-0.9.8/lib/extlib/time.rb +19 -0
  48. data/lib/gems/extlib-0.9.8/lib/extlib/version.rb +3 -0
  49. data/lib/gems/extlib-0.9.8/lib/extlib/virtual_file.rb +10 -0
  50. data/lib/gems/facets-2.4.5/VERSION +1 -0
  51. data/lib/gems/facets-2.4.5/lib/core/facets-live.rb +17 -0
  52. data/lib/gems/facets-2.4.5/lib/core/facets-load.rb +12 -0
  53. data/lib/gems/facets-2.4.5/lib/core/facets.rb +11 -0
  54. data/lib/gems/facets-2.4.5/lib/core/facets/array.rb +6 -0
  55. data/lib/gems/facets-2.4.5/lib/core/facets/array/combination.rb +59 -0
  56. data/lib/gems/facets-2.4.5/lib/core/facets/array/conjoin.rb +58 -0
  57. data/lib/gems/facets-2.4.5/lib/core/facets/array/delete.rb +61 -0
  58. data/lib/gems/facets-2.4.5/lib/core/facets/array/index.rb +48 -0
  59. data/lib/gems/facets-2.4.5/lib/core/facets/array/indexable.rb +73 -0
  60. data/lib/gems/facets-2.4.5/lib/core/facets/array/merge.rb +21 -0
  61. data/lib/gems/facets-2.4.5/lib/core/facets/array/not_empty.rb +13 -0
  62. data/lib/gems/facets-2.4.5/lib/core/facets/array/only.rb +21 -0
  63. data/lib/gems/facets-2.4.5/lib/core/facets/array/pad.rb +41 -0
  64. data/lib/gems/facets-2.4.5/lib/core/facets/array/permutation.rb +30 -0
  65. data/lib/gems/facets-2.4.5/lib/core/facets/array/product.rb +57 -0
  66. data/lib/gems/facets-2.4.5/lib/core/facets/array/recursively.rb +30 -0
  67. data/lib/gems/facets-2.4.5/lib/core/facets/array/rotate.rb +42 -0
  68. data/lib/gems/facets-2.4.5/lib/core/facets/array/select.rb +16 -0
  69. data/lib/gems/facets-2.4.5/lib/core/facets/array/splice.rb +30 -0
  70. data/lib/gems/facets-2.4.5/lib/core/facets/array/stackable.rb +33 -0
  71. data/lib/gems/facets-2.4.5/lib/core/facets/array/traverse.rb +22 -0
  72. data/lib/gems/facets-2.4.5/lib/core/facets/binding.rb +6 -0
  73. data/lib/gems/facets-2.4.5/lib/core/facets/binding/caller.rb +54 -0
  74. data/lib/gems/facets-2.4.5/lib/core/facets/binding/defined.rb +13 -0
  75. data/lib/gems/facets-2.4.5/lib/core/facets/binding/eval.rb +18 -0
  76. data/lib/gems/facets-2.4.5/lib/core/facets/binding/local_variables.rb +15 -0
  77. data/lib/gems/facets-2.4.5/lib/core/facets/binding/self.rb +12 -0
  78. data/lib/gems/facets-2.4.5/lib/core/facets/bitmask.rb +104 -0
  79. data/lib/gems/facets-2.4.5/lib/core/facets/blank.rb +60 -0
  80. data/lib/gems/facets-2.4.5/lib/core/facets/boolean.rb +156 -0
  81. data/lib/gems/facets-2.4.5/lib/core/facets/callstack.rb +52 -0
  82. data/lib/gems/facets-2.4.5/lib/core/facets/cattr.rb +2 -0
  83. data/lib/gems/facets-2.4.5/lib/core/facets/class.rb +6 -0
  84. data/lib/gems/facets-2.4.5/lib/core/facets/class/cattr.rb +115 -0
  85. data/lib/gems/facets-2.4.5/lib/core/facets/class/cattr_accessor.rb +1 -0
  86. data/lib/gems/facets-2.4.5/lib/core/facets/class/cattr_reader.rb +1 -0
  87. data/lib/gems/facets-2.4.5/lib/core/facets/class/cattr_writer.rb +1 -0
  88. data/lib/gems/facets-2.4.5/lib/core/facets/class/descendents.rb +36 -0
  89. data/lib/gems/facets-2.4.5/lib/core/facets/class/methodize.rb +14 -0
  90. data/lib/gems/facets-2.4.5/lib/core/facets/class/pathize.rb +14 -0
  91. data/lib/gems/facets-2.4.5/lib/core/facets/class/prepend.rb +50 -0
  92. data/lib/gems/facets-2.4.5/lib/core/facets/class/subclasses.rb +2 -0
  93. data/lib/gems/facets-2.4.5/lib/core/facets/class/to_proc.rb +42 -0
  94. data/lib/gems/facets-2.4.5/lib/core/facets/comparable.rb +6 -0
  95. data/lib/gems/facets-2.4.5/lib/core/facets/comparable/bound.rb +65 -0
  96. data/lib/gems/facets-2.4.5/lib/core/facets/comparable/cmp.rb +38 -0
  97. data/lib/gems/facets-2.4.5/lib/core/facets/comparable/comparable.rb +42 -0
  98. data/lib/gems/facets-2.4.5/lib/core/facets/dir.rb +6 -0
  99. data/lib/gems/facets-2.4.5/lib/core/facets/dir/ascend.rb +59 -0
  100. data/lib/gems/facets-2.4.5/lib/core/facets/dir/descend.rb +1 -0
  101. data/lib/gems/facets-2.4.5/lib/core/facets/dir/multiglob.rb +92 -0
  102. data/lib/gems/facets-2.4.5/lib/core/facets/dir/parent.rb +13 -0
  103. data/lib/gems/facets-2.4.5/lib/core/facets/dir/recurse.rb +29 -0
  104. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable.rb +6 -0
  105. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/accumulate.rb +21 -0
  106. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/cluster_by.rb +21 -0
  107. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/collect.rb +54 -0
  108. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/commonality.rb +33 -0
  109. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/count.rb +26 -0
  110. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/divide.rb +33 -0
  111. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/duplicates.rb +38 -0
  112. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/each_by.rb +33 -0
  113. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/entropy.rb +37 -0
  114. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/frequency.rb +18 -0
  115. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/group_by.rb +27 -0
  116. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/inject.rb +31 -0
  117. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/map_send.rb +12 -0
  118. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/mash.rb +32 -0
  119. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/mode.rb +16 -0
  120. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/modulate.rb +22 -0
  121. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/none.rb +31 -0
  122. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/occur.rb +38 -0
  123. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/one.rb +38 -0
  124. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/probability.rb +36 -0
  125. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/split.rb +27 -0
  126. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/sum.rb +16 -0
  127. data/lib/gems/facets-2.4.5/lib/core/facets/enumerable/uniq_by.rb +18 -0
  128. data/lib/gems/facets-2.4.5/lib/core/facets/exception.rb +6 -0
  129. data/lib/gems/facets-2.4.5/lib/core/facets/exception/detail.rb +19 -0
  130. data/lib/gems/facets-2.4.5/lib/core/facets/exception/suppress.rb +21 -0
  131. data/lib/gems/facets-2.4.5/lib/core/facets/file.rb +6 -0
  132. data/lib/gems/facets-2.4.5/lib/core/facets/file/append.rb +14 -0
  133. data/lib/gems/facets-2.4.5/lib/core/facets/file/create.rb +21 -0
  134. data/lib/gems/facets-2.4.5/lib/core/facets/file/null.rb +21 -0
  135. data/lib/gems/facets-2.4.5/lib/core/facets/file/read.rb +41 -0
  136. data/lib/gems/facets-2.4.5/lib/core/facets/file/rewrite.rb +88 -0
  137. data/lib/gems/facets-2.4.5/lib/core/facets/file/rootname.rb +33 -0
  138. data/lib/gems/facets-2.4.5/lib/core/facets/file/split_root.rb +10 -0
  139. data/lib/gems/facets-2.4.5/lib/core/facets/file/write.rb +22 -0
  140. data/lib/gems/facets-2.4.5/lib/core/facets/file/writelines.rb +24 -0
  141. data/lib/gems/facets-2.4.5/lib/core/facets/filetest.rb +6 -0
  142. data/lib/gems/facets-2.4.5/lib/core/facets/filetest/root.rb +17 -0
  143. data/lib/gems/facets-2.4.5/lib/core/facets/float.rb +6 -0
  144. data/lib/gems/facets-2.4.5/lib/core/facets/float/round.rb +2 -0
  145. data/lib/gems/facets-2.4.5/lib/core/facets/functor.rb +77 -0
  146. data/lib/gems/facets-2.4.5/lib/core/facets/hash.rb +6 -0
  147. data/lib/gems/facets-2.4.5/lib/core/facets/hash/alias.rb +31 -0
  148. data/lib/gems/facets-2.4.5/lib/core/facets/hash/argumentize.rb +22 -0
  149. data/lib/gems/facets-2.4.5/lib/core/facets/hash/at.rb +8 -0
  150. data/lib/gems/facets-2.4.5/lib/core/facets/hash/autonew.rb +42 -0
  151. data/lib/gems/facets-2.4.5/lib/core/facets/hash/collate.rb +45 -0
  152. data/lib/gems/facets-2.4.5/lib/core/facets/hash/delete.rb +47 -0
  153. data/lib/gems/facets-2.4.5/lib/core/facets/hash/diff.rb +11 -0
  154. data/lib/gems/facets-2.4.5/lib/core/facets/hash/except.rb +27 -0
  155. data/lib/gems/facets-2.4.5/lib/core/facets/hash/insert.rb +19 -0
  156. data/lib/gems/facets-2.4.5/lib/core/facets/hash/inverse.rb +27 -0
  157. data/lib/gems/facets-2.4.5/lib/core/facets/hash/join.rb +14 -0
  158. data/lib/gems/facets-2.4.5/lib/core/facets/hash/keys.rb +45 -0
  159. data/lib/gems/facets-2.4.5/lib/core/facets/hash/mash.rb +18 -0
  160. data/lib/gems/facets-2.4.5/lib/core/facets/hash/merge.rb +30 -0
  161. data/lib/gems/facets-2.4.5/lib/core/facets/hash/op.rb +7 -0
  162. data/lib/gems/facets-2.4.5/lib/core/facets/hash/op_add.rb +12 -0
  163. data/lib/gems/facets-2.4.5/lib/core/facets/hash/op_and.rb +33 -0
  164. data/lib/gems/facets-2.4.5/lib/core/facets/hash/op_mul.rb +18 -0
  165. data/lib/gems/facets-2.4.5/lib/core/facets/hash/op_or.rb +12 -0
  166. data/lib/gems/facets-2.4.5/lib/core/facets/hash/op_push.rb +17 -0
  167. data/lib/gems/facets-2.4.5/lib/core/facets/hash/op_sub.rb +26 -0
  168. data/lib/gems/facets-2.4.5/lib/core/facets/hash/recursive_merge.rb +33 -0
  169. data/lib/gems/facets-2.4.5/lib/core/facets/hash/recursively.rb +29 -0
  170. data/lib/gems/facets-2.4.5/lib/core/facets/hash/rekey.rb +59 -0
  171. data/lib/gems/facets-2.4.5/lib/core/facets/hash/select.rb +14 -0
  172. data/lib/gems/facets-2.4.5/lib/core/facets/hash/slice.rb +33 -0
  173. data/lib/gems/facets-2.4.5/lib/core/facets/hash/swap.rb +17 -0
  174. data/lib/gems/facets-2.4.5/lib/core/facets/hash/to_h.rb +1 -0
  175. data/lib/gems/facets-2.4.5/lib/core/facets/hash/to_proc.rb +41 -0
  176. data/lib/gems/facets-2.4.5/lib/core/facets/hash/to_struct.rb +17 -0
  177. data/lib/gems/facets-2.4.5/lib/core/facets/hash/traverse.rb +41 -0
  178. data/lib/gems/facets-2.4.5/lib/core/facets/hash/update.rb +81 -0
  179. data/lib/gems/facets-2.4.5/lib/core/facets/hash/weave.rb +81 -0
  180. data/lib/gems/facets-2.4.5/lib/core/facets/hash/zipnew.rb +2 -0
  181. data/lib/gems/facets-2.4.5/lib/core/facets/indexable.rb +251 -0
  182. data/lib/gems/facets-2.4.5/lib/core/facets/integer.rb +6 -0
  183. data/lib/gems/facets-2.4.5/lib/core/facets/integer/even.rb +1 -0
  184. data/lib/gems/facets-2.4.5/lib/core/facets/integer/factorial.rb +30 -0
  185. data/lib/gems/facets-2.4.5/lib/core/facets/integer/multiple.rb +15 -0
  186. data/lib/gems/facets-2.4.5/lib/core/facets/integer/odd.rb +35 -0
  187. data/lib/gems/facets-2.4.5/lib/core/facets/integer/of.rb +18 -0
  188. data/lib/gems/facets-2.4.5/lib/core/facets/integer/ordinal.rb +24 -0
  189. data/lib/gems/facets-2.4.5/lib/core/facets/kernel.rb +6 -0
  190. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/__callee__.rb +1 -0
  191. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/__class__.rb +9 -0
  192. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/__dir__.rb +12 -0
  193. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/__get__.rb +10 -0
  194. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/__method__.rb +36 -0
  195. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/__set__.rb +1 -0
  196. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/as.rb +100 -0
  197. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/ask.rb +27 -0
  198. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/attr_singleton.rb +62 -0
  199. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/complete.rb +18 -0
  200. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/constant.rb +24 -0
  201. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/d.rb +26 -0
  202. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/deep_copy.rb +13 -0
  203. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/demo.rb +23 -0
  204. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/ergo.rb +42 -0
  205. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/here.rb +12 -0
  206. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/in.rb +13 -0
  207. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/instance.rb +19 -0
  208. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/instance_assign.rb +41 -0
  209. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/instance_class.rb +24 -0
  210. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/instance_exec.rb +40 -0
  211. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/instance_send.rb +7 -0
  212. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/instance_variables.rb +99 -0
  213. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/maybe.rb +18 -0
  214. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/not_nil.rb +17 -0
  215. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/object_class.rb +10 -0
  216. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/object_hexid.rb +12 -0
  217. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/object_send.rb +32 -0
  218. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/p.rb +24 -0
  219. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/populate.rb +73 -0
  220. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/qua_class.rb +19 -0
  221. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/require_all.rb +21 -0
  222. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/require_local.rb +24 -0
  223. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/resc.rb +16 -0
  224. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/respond.rb +23 -0
  225. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/returning.rb +23 -0
  226. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/silence.rb +75 -0
  227. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/singleton_class.rb +19 -0
  228. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/tap.rb +32 -0
  229. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/try.rb +23 -0
  230. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/val.rb +19 -0
  231. data/lib/gems/facets-2.4.5/lib/core/facets/kernel/with.rb +20 -0
  232. data/lib/gems/facets-2.4.5/lib/core/facets/lazy.rb +238 -0
  233. data/lib/gems/facets-2.4.5/lib/core/facets/matchdata.rb +6 -0
  234. data/lib/gems/facets-2.4.5/lib/core/facets/matchdata/match.rb +15 -0
  235. data/lib/gems/facets-2.4.5/lib/core/facets/matchdata/matchset.rb +44 -0
  236. data/lib/gems/facets-2.4.5/lib/core/facets/metaid.rb +94 -0
  237. data/lib/gems/facets-2.4.5/lib/core/facets/module.rb +6 -0
  238. data/lib/gems/facets-2.4.5/lib/core/facets/module/abstract.rb +21 -0
  239. data/lib/gems/facets-2.4.5/lib/core/facets/module/alias_accessor.rb +45 -0
  240. data/lib/gems/facets-2.4.5/lib/core/facets/module/alias_method_chain.rb +50 -0
  241. data/lib/gems/facets-2.4.5/lib/core/facets/module/alias_module_function.rb +30 -0
  242. data/lib/gems/facets-2.4.5/lib/core/facets/module/ancestor.rb +16 -0
  243. data/lib/gems/facets-2.4.5/lib/core/facets/module/basename.rb +31 -0
  244. data/lib/gems/facets-2.4.5/lib/core/facets/module/can.rb +14 -0
  245. data/lib/gems/facets-2.4.5/lib/core/facets/module/class.rb +12 -0
  246. data/lib/gems/facets-2.4.5/lib/core/facets/module/conflict.rb +63 -0
  247. data/lib/gems/facets-2.4.5/lib/core/facets/module/include_function_module.rb +25 -0
  248. data/lib/gems/facets-2.4.5/lib/core/facets/module/instance_methods.rb +40 -0
  249. data/lib/gems/facets-2.4.5/lib/core/facets/module/integrate.rb +2 -0
  250. data/lib/gems/facets-2.4.5/lib/core/facets/module/is.rb +57 -0
  251. data/lib/gems/facets-2.4.5/lib/core/facets/module/methodize.rb +14 -0
  252. data/lib/gems/facets-2.4.5/lib/core/facets/module/modspace.rb +22 -0
  253. data/lib/gems/facets-2.4.5/lib/core/facets/module/module_load.rb +56 -0
  254. data/lib/gems/facets-2.4.5/lib/core/facets/module/nesting.rb +18 -0
  255. data/lib/gems/facets-2.4.5/lib/core/facets/module/op.rb +95 -0
  256. data/lib/gems/facets-2.4.5/lib/core/facets/module/pathize.rb +22 -0
  257. data/lib/gems/facets-2.4.5/lib/core/facets/module/prepend.rb +26 -0
  258. data/lib/gems/facets-2.4.5/lib/core/facets/module/redefine_method.rb +35 -0
  259. data/lib/gems/facets-2.4.5/lib/core/facets/module/redirect_method.rb +45 -0
  260. data/lib/gems/facets-2.4.5/lib/core/facets/module/rename_method.rb +20 -0
  261. data/lib/gems/facets-2.4.5/lib/core/facets/module/revise.rb +62 -0
  262. data/lib/gems/facets-2.4.5/lib/core/facets/module/spacename.rb +25 -0
  263. data/lib/gems/facets-2.4.5/lib/core/facets/module/wrap_method.rb +28 -0
  264. data/lib/gems/facets-2.4.5/lib/core/facets/nilclass.rb +6 -0
  265. data/lib/gems/facets-2.4.5/lib/core/facets/nilclass/ergo.rb +1 -0
  266. data/lib/gems/facets-2.4.5/lib/core/facets/nilclass/to_f.rb +17 -0
  267. data/lib/gems/facets-2.4.5/lib/core/facets/numeric.rb +6 -0
  268. data/lib/gems/facets-2.4.5/lib/core/facets/numeric/approx.rb +15 -0
  269. data/lib/gems/facets-2.4.5/lib/core/facets/numeric/distance.rb +14 -0
  270. data/lib/gems/facets-2.4.5/lib/core/facets/numeric/round.rb +72 -0
  271. data/lib/gems/facets-2.4.5/lib/core/facets/proc.rb +6 -0
  272. data/lib/gems/facets-2.4.5/lib/core/facets/proc/bind.rb +22 -0
  273. data/lib/gems/facets-2.4.5/lib/core/facets/proc/compose.rb +42 -0
  274. data/lib/gems/facets-2.4.5/lib/core/facets/proc/curry.rb +31 -0
  275. data/lib/gems/facets-2.4.5/lib/core/facets/proc/to_method.rb +33 -0
  276. data/lib/gems/facets-2.4.5/lib/core/facets/proc/update.rb +9 -0
  277. data/lib/gems/facets-2.4.5/lib/core/facets/range.rb +6 -0
  278. data/lib/gems/facets-2.4.5/lib/core/facets/range/combine.rb +47 -0
  279. data/lib/gems/facets-2.4.5/lib/core/facets/range/overlap.rb +13 -0
  280. data/lib/gems/facets-2.4.5/lib/core/facets/range/to_r.rb +26 -0
  281. data/lib/gems/facets-2.4.5/lib/core/facets/range/umbrella.rb +1 -0
  282. data/lib/gems/facets-2.4.5/lib/core/facets/range/within.rb +66 -0
  283. data/lib/gems/facets-2.4.5/lib/core/facets/regexp.rb +6 -0
  284. data/lib/gems/facets-2.4.5/lib/core/facets/regexp/arity.rb +17 -0
  285. data/lib/gems/facets-2.4.5/lib/core/facets/regexp/to_re.rb +28 -0
  286. data/lib/gems/facets-2.4.5/lib/core/facets/stackable.rb +86 -0
  287. data/lib/gems/facets-2.4.5/lib/core/facets/string.rb +6 -0
  288. data/lib/gems/facets-2.4.5/lib/core/facets/string/align.rb +106 -0
  289. data/lib/gems/facets-2.4.5/lib/core/facets/string/bracket.rb +105 -0
  290. data/lib/gems/facets-2.4.5/lib/core/facets/string/bytes.rb +15 -0
  291. data/lib/gems/facets-2.4.5/lib/core/facets/string/camelcase.rb +26 -0
  292. data/lib/gems/facets-2.4.5/lib/core/facets/string/capitalized.rb +46 -0
  293. data/lib/gems/facets-2.4.5/lib/core/facets/string/chars.rb +16 -0
  294. data/lib/gems/facets-2.4.5/lib/core/facets/string/chomp.rb +33 -0
  295. data/lib/gems/facets-2.4.5/lib/core/facets/string/cleave.rb +36 -0
  296. data/lib/gems/facets-2.4.5/lib/core/facets/string/divide.rb +21 -0
  297. data/lib/gems/facets-2.4.5/lib/core/facets/string/each_char.rb +29 -0
  298. data/lib/gems/facets-2.4.5/lib/core/facets/string/each_word.rb +13 -0
  299. data/lib/gems/facets-2.4.5/lib/core/facets/string/end_with.rb +1 -0
  300. data/lib/gems/facets-2.4.5/lib/core/facets/string/fold.rb +39 -0
  301. data/lib/gems/facets-2.4.5/lib/core/facets/string/interpolate.rb +20 -0
  302. data/lib/gems/facets-2.4.5/lib/core/facets/string/line_wrap.rb +21 -0
  303. data/lib/gems/facets-2.4.5/lib/core/facets/string/lines.rb +16 -0
  304. data/lib/gems/facets-2.4.5/lib/core/facets/string/methodize.rb +17 -0
  305. data/lib/gems/facets-2.4.5/lib/core/facets/string/modulize.rb +21 -0
  306. data/lib/gems/facets-2.4.5/lib/core/facets/string/mscan.rb +19 -0
  307. data/lib/gems/facets-2.4.5/lib/core/facets/string/natcmp.rb +88 -0
  308. data/lib/gems/facets-2.4.5/lib/core/facets/string/nchar.rb +28 -0
  309. data/lib/gems/facets-2.4.5/lib/core/facets/string/op_sub.rb +14 -0
  310. data/lib/gems/facets-2.4.5/lib/core/facets/string/pathize.rb +16 -0
  311. data/lib/gems/facets-2.4.5/lib/core/facets/string/range.rb +77 -0
  312. data/lib/gems/facets-2.4.5/lib/core/facets/string/rewrite.rb +28 -0
  313. data/lib/gems/facets-2.4.5/lib/core/facets/string/shatter.rb +22 -0
  314. data/lib/gems/facets-2.4.5/lib/core/facets/string/snakecase.rb +21 -0
  315. data/lib/gems/facets-2.4.5/lib/core/facets/string/splice.rb +37 -0
  316. data/lib/gems/facets-2.4.5/lib/core/facets/string/start_with.rb +32 -0
  317. data/lib/gems/facets-2.4.5/lib/core/facets/string/subtract.rb +4 -0
  318. data/lib/gems/facets-2.4.5/lib/core/facets/string/tab.rb +103 -0
  319. data/lib/gems/facets-2.4.5/lib/core/facets/string/titlecase.rb +15 -0
  320. data/lib/gems/facets-2.4.5/lib/core/facets/string/to_re.rb +26 -0
  321. data/lib/gems/facets-2.4.5/lib/core/facets/string/variablize.rb +13 -0
  322. data/lib/gems/facets-2.4.5/lib/core/facets/string/word_wrap.rb +34 -0
  323. data/lib/gems/facets-2.4.5/lib/core/facets/string/words.rb +12 -0
  324. data/lib/gems/facets-2.4.5/lib/core/facets/string/xor.rb +22 -0
  325. data/lib/gems/facets-2.4.5/lib/core/facets/symbol.rb +6 -0
  326. data/lib/gems/facets-2.4.5/lib/core/facets/symbol/chomp.rb +24 -0
  327. data/lib/gems/facets-2.4.5/lib/core/facets/symbol/generate.rb +24 -0
  328. data/lib/gems/facets-2.4.5/lib/core/facets/symbol/not.rb +29 -0
  329. data/lib/gems/facets-2.4.5/lib/core/facets/symbol/plain.rb +17 -0
  330. data/lib/gems/facets-2.4.5/lib/core/facets/symbol/query.rb +1 -0
  331. data/lib/gems/facets-2.4.5/lib/core/facets/symbol/re_s.rb +18 -0
  332. data/lib/gems/facets-2.4.5/lib/core/facets/symbol/setter.rb +1 -0
  333. data/lib/gems/facets-2.4.5/lib/core/facets/symbol/succ.rb +19 -0
  334. data/lib/gems/facets-2.4.5/lib/core/facets/symbol/to_proc.rb +38 -0
  335. data/lib/gems/facets-2.4.5/lib/core/facets/symbol/variablize.rb +12 -0
  336. data/lib/gems/facets-2.4.5/lib/core/facets/time.rb +6 -0
  337. data/lib/gems/facets-2.4.5/lib/core/facets/time/advance.rb +17 -0
  338. data/lib/gems/facets-2.4.5/lib/core/facets/time/ago.rb +1 -0
  339. data/lib/gems/facets-2.4.5/lib/core/facets/time/change.rb +41 -0
  340. data/lib/gems/facets-2.4.5/lib/core/facets/time/elapse.rb +16 -0
  341. data/lib/gems/facets-2.4.5/lib/core/facets/time/hence.rb +94 -0
  342. data/lib/gems/facets-2.4.5/lib/core/facets/time/round.rb +17 -0
  343. data/lib/gems/facets-2.4.5/lib/core/facets/time/set.rb +21 -0
  344. data/lib/gems/facets-2.4.5/lib/core/facets/time/stamp.rb +44 -0
  345. data/lib/gems/facets-2.4.5/lib/core/facets/time/to_time.rb +21 -0
  346. data/lib/gems/facets-2.4.5/lib/core/facets/time/trunc.rb +15 -0
  347. data/lib/gems/facets-2.4.5/lib/core/facets/to_hash.rb +87 -0
  348. data/lib/gems/facets-2.4.5/lib/core/facets/unboundmethod.rb +6 -0
  349. data/lib/gems/facets-2.4.5/lib/core/facets/unboundmethod/arguments.rb +44 -0
  350. data/lib/gems/facets-2.4.5/lib/core/facets/unboundmethod/name.rb +25 -0
  351. data/lib/gems/facets-2.4.5/lib/lore/facets/basicobject.rb +14 -0
  352. data/lib/gems/facets-2.4.5/lib/lore/facets/cgi.rb +50 -0
  353. data/lib/gems/facets-2.4.5/lib/lore/facets/continuation.rb +57 -0
  354. data/lib/gems/facets-2.4.5/lib/lore/facets/date.rb +396 -0
  355. data/lib/gems/facets-2.4.5/lib/lore/facets/fileutils.rb +27 -0
  356. data/lib/gems/facets-2.4.5/lib/lore/facets/fileutils/head.rb +1 -0
  357. data/lib/gems/facets-2.4.5/lib/lore/facets/fileutils/safe_ln.rb +28 -0
  358. data/lib/gems/facets-2.4.5/lib/lore/facets/fileutils/slice.rb +141 -0
  359. data/lib/gems/facets-2.4.5/lib/lore/facets/fileutils/tail.rb +1 -0
  360. data/lib/gems/facets-2.4.5/lib/lore/facets/fileutils/wc.rb +114 -0
  361. data/lib/gems/facets-2.4.5/lib/lore/facets/fileutils/whereis.rb +64 -0
  362. data/lib/gems/facets-2.4.5/lib/lore/facets/fileutils/which.rb +101 -0
  363. data/lib/gems/facets-2.4.5/lib/lore/facets/getoptlong.rb +71 -0
  364. data/lib/gems/facets-2.4.5/lib/lore/facets/logger.rb +291 -0
  365. data/lib/gems/facets-2.4.5/lib/lore/facets/ostruct.rb +238 -0
  366. data/lib/gems/facets-2.4.5/lib/lore/facets/pathname.rb +172 -0
  367. data/lib/gems/facets-2.4.5/lib/lore/facets/rbconfig.rb +45 -0
  368. data/lib/gems/facets-2.4.5/lib/lore/facets/set.rb +27 -0
  369. data/lib/gems/facets-2.4.5/lib/lore/facets/shellwords.rb +89 -0
  370. data/lib/gems/facets-2.4.5/lib/lore/facets/uri.rb +249 -0
  371. data/lib/gems/facets-2.4.5/lib/lore/facets/yaml.rb +75 -0
  372. data/lib/gems/facets-2.4.5/lib/lore/facets/zlib.rb +38 -0
  373. data/lib/gems/facets-2.4.5/lib/more/facets/1stclassmethod.rb +140 -0
  374. data/lib/gems/facets-2.4.5/lib/more/facets/advisable.rb +162 -0
  375. data/lib/gems/facets-2.4.5/lib/more/facets/annotations.rb +302 -0
  376. data/lib/gems/facets-2.4.5/lib/more/facets/ansicode.rb +315 -0
  377. data/lib/gems/facets-2.4.5/lib/more/facets/arguments.rb +365 -0
  378. data/lib/gems/facets-2.4.5/lib/more/facets/argvector.rb +353 -0
  379. data/lib/gems/facets-2.4.5/lib/more/facets/association.rb +194 -0
  380. data/lib/gems/facets-2.4.5/lib/more/facets/attr.rb +208 -0
  381. data/lib/gems/facets-2.4.5/lib/more/facets/autoarray.rb +62 -0
  382. data/lib/gems/facets-2.4.5/lib/more/facets/autoreload.rb +150 -0
  383. data/lib/gems/facets-2.4.5/lib/more/facets/basex.rb +37 -0
  384. data/lib/gems/facets-2.4.5/lib/more/facets/bbcode.rb +397 -0
  385. data/lib/gems/facets-2.4.5/lib/more/facets/bicrypt.rb +265 -0
  386. data/lib/gems/facets-2.4.5/lib/more/facets/binding/opvars.rb +24 -0
  387. data/lib/gems/facets-2.4.5/lib/more/facets/binreadable.rb +221 -0
  388. data/lib/gems/facets-2.4.5/lib/more/facets/blankslate.rb +66 -0
  389. data/lib/gems/facets-2.4.5/lib/more/facets/buildable.rb +344 -0
  390. data/lib/gems/facets-2.4.5/lib/more/facets/bytes.rb +175 -0
  391. data/lib/gems/facets-2.4.5/lib/more/facets/cachedecorator.rb +117 -0
  392. data/lib/gems/facets-2.4.5/lib/more/facets/capsule.rb +258 -0
  393. data/lib/gems/facets-2.4.5/lib/more/facets/chain.rb +58 -0
  394. data/lib/gems/facets-2.4.5/lib/more/facets/class_extension.rb +114 -0
  395. data/lib/gems/facets-2.4.5/lib/more/facets/classmethods.rb +199 -0
  396. data/lib/gems/facets-2.4.5/lib/more/facets/cloneable.rb +76 -0
  397. data/lib/gems/facets-2.4.5/lib/more/facets/command.rb +439 -0
  398. data/lib/gems/facets-2.4.5/lib/more/facets/consoleutils.rb +113 -0
  399. data/lib/gems/facets-2.4.5/lib/more/facets/coroutine.rb +159 -0
  400. data/lib/gems/facets-2.4.5/lib/more/facets/crypt.rb +166 -0
  401. data/lib/gems/facets-2.4.5/lib/more/facets/cssfilter.rb +254 -0
  402. data/lib/gems/facets-2.4.5/lib/more/facets/daemonize.rb +44 -0
  403. data/lib/gems/facets-2.4.5/lib/more/facets/dependency.rb +151 -0
  404. data/lib/gems/facets-2.4.5/lib/more/facets/dictionary.rb +478 -0
  405. data/lib/gems/facets-2.4.5/lib/more/facets/dictionarymatcher.rb +136 -0
  406. data/lib/gems/facets-2.4.5/lib/more/facets/downloader.rb +281 -0
  407. data/lib/gems/facets-2.4.5/lib/more/facets/duplicable.rb +43 -0
  408. data/lib/gems/facets-2.4.5/lib/more/facets/duration.rb +540 -0
  409. data/lib/gems/facets-2.4.5/lib/more/facets/elementor.rb +133 -0
  410. data/lib/gems/facets-2.4.5/lib/more/facets/elementwise.rb +61 -0
  411. data/lib/gems/facets-2.4.5/lib/more/facets/enumerablepass.rb +217 -0
  412. data/lib/gems/facets-2.4.5/lib/more/facets/equatable.rb +120 -0
  413. data/lib/gems/facets-2.4.5/lib/more/facets/eventhook.rb +132 -0
  414. data/lib/gems/facets-2.4.5/lib/more/facets/expirable.rb +82 -0
  415. data/lib/gems/facets-2.4.5/lib/more/facets/fileable.rb +162 -0
  416. data/lib/gems/facets-2.4.5/lib/more/facets/filelist.rb +497 -0
  417. data/lib/gems/facets-2.4.5/lib/more/facets/fileshell.rb +202 -0
  418. data/lib/gems/facets-2.4.5/lib/more/facets/hash/stringify_keys.rb +1 -0
  419. data/lib/gems/facets-2.4.5/lib/more/facets/hash/symbolize_keys.rb +94 -0
  420. data/lib/gems/facets-2.4.5/lib/more/facets/heap.rb +22 -0
  421. data/lib/gems/facets-2.4.5/lib/more/facets/htmlfilter.rb +595 -0
  422. data/lib/gems/facets-2.4.5/lib/more/facets/infinity.rb +193 -0
  423. data/lib/gems/facets-2.4.5/lib/more/facets/inheritor.rb +130 -0
  424. data/lib/gems/facets-2.4.5/lib/more/facets/ini.rb +264 -0
  425. data/lib/gems/facets-2.4.5/lib/more/facets/instantiable.rb +47 -0
  426. data/lib/gems/facets-2.4.5/lib/more/facets/instantise.rb +1 -0
  427. data/lib/gems/facets-2.4.5/lib/more/facets/instantize.rb +95 -0
  428. data/lib/gems/facets-2.4.5/lib/more/facets/interval.rb +282 -0
  429. data/lib/gems/facets-2.4.5/lib/more/facets/ioredirect.rb +130 -0
  430. data/lib/gems/facets-2.4.5/lib/more/facets/iteration.rb +65 -0
  431. data/lib/gems/facets-2.4.5/lib/more/facets/kernel/meta.rb +32 -0
  432. data/lib/gems/facets-2.4.5/lib/more/facets/linkedlist.rb +222 -0
  433. data/lib/gems/facets-2.4.5/lib/more/facets/lrucache.rb +157 -0
  434. data/lib/gems/facets-2.4.5/lib/more/facets/main.rb +70 -0
  435. data/lib/gems/facets-2.4.5/lib/more/facets/memoize.rb +116 -0
  436. data/lib/gems/facets-2.4.5/lib/more/facets/methodspace.rb +141 -0
  437. data/lib/gems/facets-2.4.5/lib/more/facets/minitar.rb +1063 -0
  438. data/lib/gems/facets-2.4.5/lib/more/facets/multipliers.rb +109 -0
  439. data/lib/gems/facets-2.4.5/lib/more/facets/multiton.rb +386 -0
  440. data/lib/gems/facets-2.4.5/lib/more/facets/nackclass.rb +41 -0
  441. data/lib/gems/facets-2.4.5/lib/more/facets/net/smtp_tls.rb +131 -0
  442. data/lib/gems/facets-2.4.5/lib/more/facets/nilstatus.rb +47 -0
  443. data/lib/gems/facets-2.4.5/lib/more/facets/nullclass.rb +74 -0
  444. data/lib/gems/facets-2.4.5/lib/more/facets/opencascade.rb +94 -0
  445. data/lib/gems/facets-2.4.5/lib/more/facets/opencollection.rb +43 -0
  446. data/lib/gems/facets-2.4.5/lib/more/facets/openhash.rb +39 -0
  447. data/lib/gems/facets-2.4.5/lib/more/facets/openobject.rb +267 -0
  448. data/lib/gems/facets-2.4.5/lib/more/facets/opesc.rb +60 -0
  449. data/lib/gems/facets-2.4.5/lib/more/facets/orderedhash.rb +37 -0
  450. data/lib/gems/facets-2.4.5/lib/more/facets/overload.rb +94 -0
  451. data/lib/gems/facets-2.4.5/lib/more/facets/paramix.rb +202 -0
  452. data/lib/gems/facets-2.4.5/lib/more/facets/partial.rb +37 -0
  453. data/lib/gems/facets-2.4.5/lib/more/facets/pathlist.rb +112 -0
  454. data/lib/gems/facets-2.4.5/lib/more/facets/platform.rb +192 -0
  455. data/lib/gems/facets-2.4.5/lib/more/facets/pool.rb +91 -0
  456. data/lib/gems/facets-2.4.5/lib/more/facets/pqueue.rb +449 -0
  457. data/lib/gems/facets-2.4.5/lib/more/facets/progressbar.rb +253 -0
  458. data/lib/gems/facets-2.4.5/lib/more/facets/prototype.rb +88 -0
  459. data/lib/gems/facets-2.4.5/lib/more/facets/random.rb +451 -0
  460. data/lib/gems/facets-2.4.5/lib/more/facets/rbsystem.rb +222 -0
  461. data/lib/gems/facets-2.4.5/lib/more/facets/recorder.rb +109 -0
  462. data/lib/gems/facets-2.4.5/lib/more/facets/reference.rb +99 -0
  463. data/lib/gems/facets-2.4.5/lib/more/facets/reflection.rb +145 -0
  464. data/lib/gems/facets-2.4.5/lib/more/facets/registerable.rb +35 -0
  465. data/lib/gems/facets-2.4.5/lib/more/facets/rwdelegator.rb +74 -0
  466. data/lib/gems/facets-2.4.5/lib/more/facets/semaphore.rb +92 -0
  467. data/lib/gems/facets-2.4.5/lib/more/facets/settings.rb +248 -0
  468. data/lib/gems/facets-2.4.5/lib/more/facets/snapshot.rb +209 -0
  469. data/lib/gems/facets-2.4.5/lib/more/facets/string/mask.rb +278 -0
  470. data/lib/gems/facets-2.4.5/lib/more/facets/string/words.rb +173 -0
  471. data/lib/gems/facets-2.4.5/lib/more/facets/succ.rb +44 -0
  472. data/lib/gems/facets-2.4.5/lib/more/facets/syncarray.rb +114 -0
  473. data/lib/gems/facets-2.4.5/lib/more/facets/synchash.rb +157 -0
  474. data/lib/gems/facets-2.4.5/lib/more/facets/tagiter.rb +366 -0
  475. data/lib/gems/facets-2.4.5/lib/more/facets/thread.rb +51 -0
  476. data/lib/gems/facets-2.4.5/lib/more/facets/timer.rb +274 -0
  477. data/lib/gems/facets-2.4.5/lib/more/facets/times.rb +431 -0
  478. data/lib/gems/facets-2.4.5/lib/more/facets/tracepoint.rb +209 -0
  479. data/lib/gems/facets-2.4.5/lib/more/facets/tuple.rb +325 -0
  480. data/lib/gems/facets-2.4.5/lib/more/facets/typecast.rb +261 -0
  481. data/lib/gems/facets-2.4.5/lib/more/facets/uninheritable.rb +50 -0
  482. data/lib/gems/facets-2.4.5/lib/more/facets/uploadutils.rb +464 -0
  483. data/lib/gems/facets-2.4.5/lib/more/facets/version.rb +136 -0
  484. data/lib/gems/facets-2.4.5/lib/more/facets/xmlhash.rb +112 -0
  485. data/lib/gems/facets-2.4.5/lib/more/facets/xoxo.rb +259 -0
  486. data/lib/gems/facets-2.4.5/lib/more/facets/ziputils.rb +349 -0
  487. data/lib/mack-facets.rb +4 -2
  488. data/lib/mack-facets/english_extensions/inflect.rb +50 -50
  489. data/lib/mack-facets/extensions/string.rb +10 -1
  490. data/lib/mack-facets/utils/inflections.rb +50 -47
  491. data/lib/mack-facets/utils/inflector.rb +19 -19
  492. metadata +547 -36
@@ -0,0 +1,17 @@
1
+ require 'facets/time/trunc'
2
+
3
+ class Time
4
+
5
+ # Round time at the nearest range (in seconds).
6
+ #
7
+ # t = Time.now
8
+ # =>
9
+ # t.round(60*60) # 1 hour
10
+ # =>
11
+ #
12
+ def round(amount)
13
+ (self+amount/2.0).trunc(amount)
14
+ end
15
+
16
+ end
17
+
@@ -0,0 +1,21 @@
1
+ class Time
2
+
3
+ # Like change but does not reset earlier times.
4
+ #
5
+ # NOTE: It would be better, probably if this were called "change".
6
+ # and that #change were called "reset".
7
+ #
8
+ def set(options)
9
+ opts={}; options.each_pair{ |k,v| opts[k] = v.to_i }
10
+ self.class.send( self.utc? ? :utc : :local,
11
+ opts[:year] || self.year,
12
+ opts[:month] || self.month,
13
+ opts[:day] || self.day,
14
+ opts[:hour] || self.hour,
15
+ opts[:min] || self.min,
16
+ opts[:sec] || self.sec,
17
+ opts[:usec] || self.usec
18
+ )
19
+ end
20
+
21
+ end
@@ -0,0 +1,44 @@
1
+ class Time
2
+
3
+ unless const_defined?('FORMAT')
4
+ FORMAT = {
5
+ :db => "%Y-%m-%d %H:%M:%S",
6
+ :dbase => "%Y-%m-%d %H:%M:%S",
7
+ :datbase => "%Y-%m-%d %H:%M:%S",
8
+ :utc => "%Y-%m-%d %H:%M:%S",
9
+ :number => "%Y%m%d%H%M%S",
10
+ :short => "%d %b %H:%M",
11
+ :time => "%H:%M",
12
+ :long => "%B %d, %Y %H:%M",
13
+ :day1st => "%d-%m-%Y %H:%M",
14
+ :dmYHM => "%d-%m-%Y %H:%M",
15
+ :rfc822 => "%a, %d %b %Y %H:%M:%S %z",
16
+ nil => "%a %b %d %H:%M:%S %Z %Y"
17
+ }
18
+ end
19
+
20
+ # Produce time stamp for Time.now. See #stamp.
21
+ #
22
+ # CREDIT: Trans
23
+
24
+ def self.stamp(*args)
25
+ now.stamp(*args)
26
+ end
27
+
28
+ # Create a time stamp.
29
+ #
30
+ # Time.now.stamp(:short) #=> "01 Dec 15:15"
31
+ #
32
+ # Supported formats come from the Time::FORMAT constant.
33
+ #
34
+ # CREDIT: Trans
35
+
36
+ def stamp(fmt = nil)
37
+ unless String === fmt
38
+ fmt = FORMAT[fmt]
39
+ end
40
+ strftime(fmt).strip
41
+ end
42
+
43
+ end
44
+
@@ -0,0 +1,21 @@
1
+ class Time
2
+
3
+ unless defined? to_time #1.9
4
+
5
+ # To be able to keep Dates and Times interchangeable
6
+ # on conversions.
7
+
8
+ def to_time
9
+ getlocal
10
+ end
11
+
12
+ # A method to keep Time, Date and DateTime instances interchangeable on conversions.
13
+ # In this case, it simply returns +self+.
14
+ #def to_time
15
+ # self
16
+ #end
17
+
18
+ end
19
+
20
+ end
21
+
@@ -0,0 +1,15 @@
1
+ class Time
2
+
3
+ # Truncate time at give range (in seconds).
4
+ #
5
+ # t = Time.now
6
+ # =>
7
+ # t.trunc(60*60) # 1 hour
8
+ # =>
9
+ #
10
+ def trunc(amount)
11
+ self - (self.to_i % amount)
12
+ end
13
+
14
+ end
15
+
@@ -0,0 +1,87 @@
1
+ class Array
2
+
3
+ # Converts a two-element associative array into a hash.
4
+ #
5
+ # a = [ [:a,1], [:b,2] ]
6
+ # a.to_h #=> { :a=>1, :b=>2 }
7
+ #
8
+ # If +arrayed+ is set it will maintain trailing arrays.
9
+ #
10
+ # a = [ [:a,1,2], [:b,3] ]
11
+ # a.to_h(true) #=> { :a=>[1,2], :b=>[3] }
12
+ #
13
+ # Note that the use of a values parameter has been deprecated
14
+ # because that functionality is as simple as:
15
+ #
16
+ # array1.zip(array2).to_h
17
+ #
18
+ # CREDIT: Trans
19
+
20
+ def to_h(arrayed=nil)
21
+ h = {}
22
+ if arrayed #or (flatten.size % 2 == 1)
23
+ #each{ |e| h[e.first] = e.slice(1..-1) }
24
+ each{ |k,*v| h[k] = v }
25
+ else
26
+ #h = Hash[*flatten(1)] # TODO Use in 1.9 instead.
27
+ ary = []
28
+ each do |a|
29
+ Array===a ? ary.concat(a) : ary << a
30
+ end
31
+ h = Hash[*ary]
32
+ end
33
+ h
34
+ end
35
+
36
+ #def to_hash
37
+ # h = {}
38
+ # each_with_index do |v, i|
39
+ # h[i] = v
40
+ # end
41
+ # h
42
+ #end
43
+
44
+ end
45
+
46
+ class Hash
47
+
48
+ # Return a rehashing of _self_.
49
+ #
50
+ # {"a"=>1,"b"=>2}.to_h #=> {"b"=>2,"a"=>1}
51
+ #
52
+ # CREDIT: Forian Gross
53
+
54
+ def to_h; rehash; end
55
+
56
+ end
57
+
58
+ module Enumerable
59
+
60
+ # Convert an Enumerable object into a hash by first
61
+ # turning it into an array.
62
+ #
63
+ # CREDIT: Trans
64
+
65
+ def to_h(arrayed=nil)
66
+ to_a.to_h(arrayed)
67
+ end
68
+
69
+ #def to_hash
70
+ # to_a.to_hash
71
+ #end
72
+
73
+ end
74
+
75
+ class NilClass
76
+
77
+ # Allows <tt>nil</tt> to create an empty hash,
78
+ # similar to #to_a and #to_s.
79
+ #
80
+ # nil.to_h #=> {}
81
+ #
82
+ # CREDIT: Trans
83
+
84
+ def to_h; {}; end
85
+
86
+ end
87
+
@@ -0,0 +1,6 @@
1
+ dir, base = *File.split(__FILE__)
2
+ base = base.chomp('.rb')
3
+ Dir[File.join(dir, base, '*')].each do |lib|
4
+ require "facets/#{base}/#{File.basename(lib)}"
5
+ end
6
+
@@ -0,0 +1,44 @@
1
+ class UnboundMethod
2
+
3
+ # Resolves the arguments of the method to have an
4
+ # identical signiture --useful for preserving arity.
5
+ #
6
+ # class X
7
+ # def foo(a, b); end
8
+ # def bar(a, b=1); end
9
+ # end
10
+ #
11
+ # foo_method = X.instance_method(:foo)
12
+ # foo_method.arguments #=> "a0, a1"
13
+ #
14
+ # bar_method = X.instance_method(:bar)
15
+ # bar_method.arguments #=> "a0, *args"
16
+ #
17
+ # When defaults are used the arguments must end in "*args".
18
+ #
19
+ # CREDIT: Trans
20
+
21
+ def arguments
22
+ ar = arity
23
+ case ar <=> 0
24
+ when 1
25
+ args = []
26
+ ar.times do |i|
27
+ args << "a#{i}"
28
+ end
29
+ args = args.join(", ")
30
+ when 0
31
+ args = ""
32
+ else
33
+ ar = -ar - 1
34
+ args = []
35
+ ar.times do |i|
36
+ args << "a#{i}"
37
+ end
38
+ args << "*args"
39
+ args = args.join(", ")
40
+ end
41
+ return args
42
+ end
43
+
44
+ end
@@ -0,0 +1,25 @@
1
+ unless (RUBY_VERSION[0,3] == '1.9')
2
+
3
+ class UnboundMethod
4
+
5
+ # Return the name of the method.
6
+ # Is this already in 1.9+ ?
7
+ #
8
+ # class X
9
+ # def foo; end
10
+ # end
11
+ #
12
+ # meth = X.instance_method(:foo)
13
+ #
14
+ # meth.name #=> "foo"
15
+ #
16
+ # CREDIT: Trans
17
+
18
+ def name
19
+ i = to_s.rindex('#')
20
+ to_s.slice(i+1...-1)
21
+ end
22
+
23
+ end
24
+
25
+ end
@@ -0,0 +1,14 @@
1
+ # Facets' old BasicObject has been replaced totally replaced by
2
+ # Jim Weirich's BlankSlate. Since Ruby 1.9 has a BasicObject class
3
+ # this will of course be deprecated when 1.9 goes mainstream.
4
+
5
+ unless defined? ::BasicObject # just in case it already exists!
6
+
7
+ require 'facets/blankslate'
8
+
9
+ # ActiveSupport compatiable version of BasicObject
10
+ # if not Ruby 1.9+ uses Jim Weirich's BlankSlate.
11
+ BasicObject = BlankSlate
12
+
13
+ end
14
+
@@ -0,0 +1,50 @@
1
+ # Title:: CGI Extensions
2
+ # Authors:: Trans
3
+ # Copying:: (c)2005 Trans
4
+ # License:: Ruby Licens
5
+
6
+ require 'cgi'
7
+
8
+ # = CGI Extensions
9
+
10
+ class CGI
11
+
12
+ # Create an hidden input field through which an object can can be marshalled.
13
+ # This makes it very easy to pass from data betwenn requests.
14
+ def marshal_to_cgi(name, iobj)
15
+ data = CGI.escape(Marshal.dump(iobj))
16
+ return %Q{<input type="hidden" name="__#{name}__" value="#{data}"/>\n}
17
+ end
18
+
19
+ # Create an hidden input field through which an object can can be marshalled.
20
+ # This makes it very easy to pass from data between requests.
21
+ def marshal_from_cgi(name)
22
+ if self.params.has_key?("__#{name}__")
23
+ return Marshal.load(CGI.unescape(self["__#{name}__"][0]))
24
+ end
25
+ end
26
+
27
+ # RENAME!!!!
28
+
29
+ # Are these two good enough to replace CGI.escape?
30
+
31
+ # Return an html "safe" version of the string,
32
+ # where every &, < and > are replaced with appropriate entities.
33
+ def esc(str)
34
+ str.gsub(/&/,'&amp;').gsub(/</,'&lt;').gsub(/>/,'&gt;')
35
+ end
36
+
37
+ # Calls #esc, and then further replaces carriage returns and quote characters with entities.
38
+ def escformat(str)
39
+ esc(str).gsub(/[\r\n]+/,'&#13;&#10;').gsub(%r|"|,'&quot;').gsub(%r|'|,'&#39;')
40
+ end
41
+
42
+ class << self
43
+ alias :escape_html :escapeHTML
44
+ alias :unescape_html :unescapeHTML
45
+ alias :escape_element :escapeElement
46
+ alias :unescape_element :unescapeElement
47
+ end
48
+
49
+ end
50
+
@@ -0,0 +1,57 @@
1
+ # = Continuation Extension
2
+ #
3
+ # Creates a continuation in a way that is easier to use than callcc.
4
+ # On the initial call this will return the created Continuation and
5
+ # the arguments you gave to Continuation.create in an Array. If you
6
+ # then issue .call() on the Continuation execution will jump back to
7
+ # the point of time where you initially invoked Continuation.create,
8
+ # but this time it will return the Continuation and the arguments
9
+ # you supplied in an Array.
10
+ #
11
+ # You can supply a block instead of default arguments which will
12
+ # cause that block to be executed once and its result to be returned
13
+ # along side the created Continuation, but this form is confusing
14
+ # and does only rarely make sense.
15
+ #
16
+ # # Count from 0 to 10
17
+ # cc, counter = Continuation.create(0)
18
+ # puts counter
19
+ # cc.call(counter + 1) if counter < 10
20
+ #
21
+ # # Implement something similar to Array#inject using Continuations.
22
+ # # For simplicity's sake, this is not fully compatible with the real
23
+ # # inject. Make sure that you understand Array#inject before you try
24
+ # # to understand this.
25
+ # class Array
26
+ # def cc_inject(value = nil)
27
+ # copy = self.clone
28
+ # cc, result, item = Continuation.create(value, nil)
29
+ # next_item = copy.shift
30
+ # if result and item
31
+ # # Aggregate the result using the block.
32
+ # cc.call(yield(result, item), next_item)
33
+ # elsif next_item
34
+ # # item not yet set and Array is not empty:
35
+ # # This means we did not get a value and thus need to use the
36
+ # # first item from the Array before we can start using the
37
+ # # block to aggregate the result.
38
+ # cc.call(next_item, result)
39
+ # end
40
+ #
41
+ # return result
42
+ # end
43
+ # end
44
+ # [1,2,3,4,5].cc_inject { |acc, n| acc + n } # => 15
45
+ #
46
+
47
+
48
+ # There is no continuation in Ruby 1.9.
49
+
50
+ raise "Ruby 1.9+ does not support continuations." unless Continuation
51
+
52
+ def Continuation.create(*args, &block)
53
+ args = [args] if not args.nil? and not args.is_a? Array # 1.6.8 compatibility
54
+ cc = nil; result = callcc {|c| cc = c; block.call(cc) if block and args.empty?}
55
+ result ||= args
56
+ return *[cc, *result]
57
+ end
@@ -0,0 +1,396 @@
1
+ require 'date'
2
+ require 'facets/time/stamp'
3
+
4
+ # = Date
5
+ #
6
+ # This new version of Date extension has been largely improved by
7
+ # porting some of the methods used by ActiveSupport. The old version
8
+ # already had much in common with the Active Support library, so it
9
+ # was decided to take it a step further in that direction for the
10
+ # sake of interoparability.
11
+ #
12
+ # Hopefully most of these methods will find there way into Ruby's
13
+ # own standard library eventually.
14
+ #
15
+ # The biggest difference with ActiveSupport is the lack of many
16
+ # of the "English-esque" methods, and that we use #stamp with
17
+ # Date::FORMAT, instead of #to_formmated_s with Date::DATE_FORMATS.
18
+ # We do not override the standard #to_s method like ActiveSupport does.
19
+
20
+ class Date
21
+
22
+ FORMAT = {
23
+ :short => "%e %b",
24
+ :long => "%B %e, %Y",
25
+ :db => "%Y-%m-%d",
26
+ :number => "%Y%m%d",
27
+ :rfc822 => "%e %b %Y",
28
+ :default => "%Y-%m-%d",
29
+ nil => "%Y-%m-%d"
30
+ }
31
+
32
+ # Returns a new Date representing the date 1 day ago (i.e. yesterday's date).
33
+ def self.yesterday
34
+ ::Date.today.yesterday
35
+ end
36
+
37
+ # Returns a new Date representing the date 1 day after today (i.e. tomorrow's date).
38
+ def self.tomorrow
39
+ ::Date.today.tomorrow
40
+ end
41
+
42
+ # Returns Time.zone.today when config.time_zone is set, otherwise just returns Date.today.
43
+ def self.current
44
+ ::Time.zone_default ? ::Time.zone.today : ::Date.today
45
+ end
46
+
47
+ # A method to keep Time, Date and DateTime instances interchangeable
48
+ # on conversions. In this case, it simply returns +self+.
49
+ def to_date
50
+ self
51
+ end if RUBY_VERSION < '1.9'
52
+
53
+ # Converts a Date instance to a DateTime, where the time is set to the beginning of the day
54
+ # and UTC offset is set to 0.
55
+ #
56
+ # ==== Example:
57
+ # date = Date.new(2007, 11, 10) # => Sat, 10 Nov 2007
58
+ #
59
+ # date.to_datetime # => Sat, 10 Nov 2007 00:00:00 0000
60
+ def to_datetime
61
+ ::DateTime.civil(year, month, day, 0, 0, 0, 0)
62
+ end if RUBY_VERSION < '1.9'
63
+
64
+ # Converts a Date instance to a Time, where the time is set to the beginning of the day.
65
+ # The timezone can be either :local or :utc (default :local).
66
+ #
67
+ # date = Date.new(2007, 11, 10) # => Sat, 10 Nov 2007
68
+ #
69
+ # date.to_time # => Sat Nov 10 00:00:00 0800 2007
70
+ # date.to_time(:local) # => Sat Nov 10 00:00:00 0800 2007
71
+ #
72
+ # date.to_time(:utc) # => Sat Nov 10 00:00:00 UTC 2007
73
+ #
74
+ def to_time(form=:local)
75
+ ::Time.send(form, year, month, day)
76
+ #::Time.send("#{form}_time", year, month, day)
77
+ end
78
+
79
+ def xmlschema
80
+ to_time.xmlschema
81
+ end
82
+
83
+ # Returns the number of days in the date's month.
84
+ #
85
+ # Date.new(2004,2).days_in_month #=> 28
86
+ #
87
+ # CREDIT: Ken Kunz.
88
+
89
+ def days_in_month
90
+ Date.civil(year, month, -1).day
91
+ end
92
+
93
+ def days_of_month
94
+ (1..days_in_month).to_a
95
+ end
96
+
97
+ # Get the month name for this date object
98
+ #
99
+ # CREDIT Benjamin Oakes
100
+
101
+ def month_name
102
+ MONTHNAMES[self.month]
103
+ end
104
+
105
+ # Convert to a formatted string. See DATE_FORMATS for predefined formats.
106
+ #
107
+ # This method is aliased to <tt>to_s</tt>.
108
+ #
109
+ # ==== Examples:
110
+ # date = Date.new(2007, 11, 10) # => Sat, 10 Nov 2007
111
+ #
112
+ # date.stamp(:db) # => "2007-11-10"
113
+ # date.stamp(:short) # => "10 Nov"
114
+ # date.stamp(:long) # => "November 10, 2007"
115
+ # date.stamp(:rfc822) # => "10 Nov 2007"
116
+ #
117
+ # == Adding your own formats to stamp
118
+ # You can add your own formats to the Date::FORMAT hash.
119
+ # Use the format name as the hash key and a strftime string
120
+ # as the value. Eg.
121
+ #
122
+ # Date::FORMAT[:month_and_year] = "%B %Y"
123
+ #
124
+ def stamp(format=:default)
125
+ if formatter = FORMAT[format]
126
+ strftime(formatter)
127
+ else
128
+ to_s
129
+ end
130
+ end
131
+
132
+ # Overrides the default inspect method with a human readable one, e.g., "Mon, 21 Feb 2005"
133
+ #def inspect
134
+ # strftime("%a, %d %b %Y")
135
+ #end
136
+
137
+ # Provides precise Date calculations for years, months, and days. The +options+ parameter takes a hash with
138
+ # any of these keys: <tt>:years</tt>, <tt>:months</tt>, <tt>:weeks</tt>, <tt>:days</tt>.
139
+ def advance(options)
140
+ d = self
141
+ d = d >> options.delete(:years) * 12 if options[:years]
142
+ d = d >> options.delete(:months) if options[:months]
143
+ d = d + options.delete(:weeks) * 7 if options[:weeks]
144
+ d = d + options.delete(:days) if options[:days]
145
+ d
146
+ end
147
+
148
+ # Returns a new Date where one or more of the elements have been changed according to the +options+ parameter.
149
+ #
150
+ # Examples:
151
+ #
152
+ # Date.new(2007, 5, 12).change(:day => 1) # => Date.new(2007, 5, 1)
153
+ # Date.new(2007, 5, 12).change(:year => 2005, :month => 1) # => Date.new(2005, 1, 12)
154
+ def change(options)
155
+ ::Date.new(
156
+ options[:year] || self.year,
157
+ options[:month] || self.month,
158
+ options[:day] || self.day
159
+ )
160
+ end
161
+
162
+ # Converts Date to a Time (or DateTime if necessary) with the time portion set to the beginning of the day (0:00)
163
+ # and then subtracts the specified number of seconds
164
+ def ago(seconds)
165
+ to_time.since(-seconds)
166
+ end
167
+
168
+ # Converts Date to a Time (or DateTime if necessary) with the time portion set to the beginning of the day (0:00)
169
+ # and then adds the specified number of seconds
170
+ def since(seconds)
171
+ to_time.since(seconds)
172
+ end
173
+ alias :in :since
174
+
175
+ # Converts Date to a Time (or DateTime if necessary) with the time portion set to the beginning of the day (0:00)
176
+ def beginning_of_day
177
+ to_time
178
+ end
179
+ alias :midnight :beginning_of_day
180
+
181
+ # Convenience method which returns a new Date/DateTime representing the time 1 day ago
182
+ def yesterday
183
+ self - 1
184
+ end
185
+
186
+ # Convenience method which returns a new Date/DateTime representing the time 1 day since the instance time
187
+ def tomorrow
188
+ self + 1
189
+ end
190
+
191
+ end
192
+
193
+
194
+ class DateTime
195
+
196
+ #
197
+ def self.local_offset
198
+ ::Time.local(2007).utc_offset.to_r / 86400
199
+ end
200
+
201
+ # Converts self to a Ruby Date object; time portion is discarded
202
+ def to_date
203
+ ::Date.new(year, month, day)
204
+ end
205
+
206
+ # Attempts to convert self to a Ruby Time object; returns self if
207
+ # out of range of Ruby Time class, If self has an offset other than 0,
208
+ # self will just be returned unaltered, since there's no clean way
209
+ # to map it to a Time
210
+ def to_time
211
+ self.offset == 0 ? ::Time.utc_time(year, month, day, hour, min, sec) : self
212
+ end
213
+
214
+ # To be able to keep Times, Dates and DateTimes interchangeable on conversions
215
+ def to_datetime
216
+ self
217
+ end
218
+
219
+ # Convert to a formatted string. See Time::FORMAT for predefined formats.
220
+ #
221
+ # This method is aliased to <tt>to_s</tt>.
222
+ #
223
+ # === Examples:
224
+ # datetime = DateTime.civil(2007, 12, 4, 0, 0, 0, 0) # => Tue, 04 Dec 2007 00:00:00 +0000
225
+ #
226
+ # datetime.stamp(:db) # => "2007-12-04 00:00:00"
227
+ # datetime.stamp(:db) # => "2007-12-04 00:00:00"
228
+ # datetime.stamp(:number) # => "20071204000000"
229
+ # datetime.stamp(:short) # => "04 Dec 00:00"
230
+ # datetime.stamp(:long) # => "December 04, 2007 00:00"
231
+ # datetime.stamp(:rfc822) # => "Tue, 04 Dec 2007 00:00:00 +0000"
232
+ #
233
+ # == Adding your own datetime formats to stamp
234
+ # DateTime formats are shared with Time. You can add your own to the
235
+ # Time::FORMAT hash. Use the format name as the hash key and
236
+ # a strftime string as the value. Eg.
237
+ #
238
+ # Time::FORMAT[:month_and_year] = "%B %Y"
239
+ #
240
+ def stamp(format=:default)
241
+ if formatter = ::Time::FORMAT[format]
242
+ strftime(formatter)
243
+ else
244
+ to_s
245
+ end
246
+ end
247
+
248
+ # Seconds since midnight: DateTime.now.seconds_since_midnight
249
+ def seconds_since_midnight
250
+ self.sec + (self.min * 60) + (self.hour * 3600)
251
+ end
252
+
253
+ # Returns a new DateTime where one or more of the elements have been
254
+ # changed according to the +options+ parameter. The time options
255
+ # (hour, minute, sec) reset cascadingly, so if only the hour is
256
+ # passed, then minute and sec is set to 0. If the hour and
257
+ # minute is passed, then sec is set to 0.
258
+ def change(options)
259
+ ::DateTime.civil(
260
+ options[:year] || self.year,
261
+ options[:month] || self.month,
262
+ options[:day] || self.day,
263
+ options[:hour] || self.hour,
264
+ options[:min] || (options[:hour] ? 0 : self.min),
265
+ options[:sec] || ((options[:hour] || options[:min]) ? 0 : self.sec),
266
+ options[:offset] || self.offset,
267
+ options[:start] || self.start
268
+ )
269
+ end
270
+
271
+ # Uses Date to provide precise Time calculations for years, months, and days.
272
+ # The +options+ parameter takes a hash with any of these keys: <tt>:years</tt>,
273
+ # <tt>:months</tt>, <tt>:weeks</tt>, <tt>:days</tt>, <tt>:hours</tt>,
274
+ # <tt>:minutes</tt>, <tt>:seconds</tt>.
275
+ def advance(options)
276
+ d = to_date.advance(options)
277
+ datetime_advanced_by_date = change(:year => d.year, :month => d.month, :day => d.day)
278
+ seconds_to_advance = (options[:seconds] || 0) + (options[:minutes] || 0) * 60 + (options[:hours] || 0) * 3600
279
+ seconds_to_advance == 0 ? datetime_advanced_by_date : datetime_advanced_by_date.since(seconds_to_advance)
280
+ end
281
+
282
+ # Returns a new DateTime representing the time a number of seconds ago
283
+ # Do not use this method in combination with x.months, use months_ago instead!
284
+ def ago(seconds)
285
+ self.since(-seconds)
286
+ end
287
+
288
+ # Returns a new DateTime representing the time a number of seconds since the instance time
289
+ # Do not use this method in combination with x.months, use months_since instead!
290
+ def since(seconds)
291
+ self + Rational(seconds.round, 86400)
292
+ end
293
+ alias :in :since
294
+
295
+ # Returns a new DateTime representing the start of the day (0:00)
296
+ def beginning_of_day
297
+ change(:hour => 0)
298
+ end
299
+ alias :midnight :beginning_of_day
300
+
301
+ # Returns a new DateTime representing the end of the day (23:59:59)
302
+ def end_of_day
303
+ change(:hour => 23, :min => 59, :sec => 59)
304
+ end
305
+
306
+ # Adjusts DateTime to UTC by adding its offset value; offset is set to 0
307
+ #
308
+ # Example:
309
+ #
310
+ # DateTime.civil(2005, 2, 21, 10, 11, 12, Rational(-6, 24)) # => Mon, 21 Feb 2005 10:11:12 -0600
311
+ # DateTime.civil(2005, 2, 21, 10, 11, 12, Rational(-6, 24)).utc # => Mon, 21 Feb 2005 16:11:12 +0000
312
+ def utc
313
+ new_offset(0)
314
+ end
315
+ alias_method :getutc, :utc
316
+
317
+ # Returns true if offset == 0
318
+ def utc?
319
+ offset == 0
320
+ end
321
+
322
+ # Returns the offset value in seconds
323
+ def utc_offset
324
+ (offset * 86400).to_i
325
+ end
326
+
327
+ # Converts datetime to an appropriate format for use in XML
328
+ def xmlschema
329
+ strftime("%Y-%m-%dT%H:%M:%S%Z")
330
+ end if RUBY_VERSION < '1.9'
331
+
332
+ # Converts self to a floating-point number of seconds since the Unix epoch
333
+ def to_f
334
+ days_since_unix_epoch = self - ::DateTime.civil(1970)
335
+ (days_since_unix_epoch * 86_400).to_f
336
+ end
337
+
338
+ end
339
+
340
+
341
+ class Time
342
+
343
+ public :to_date
344
+ public :to_datetime
345
+
346
+ # Converts a Time object to a Date, dropping hour, minute, and second precision.
347
+ #
348
+ # my_time = Time.now # => Mon Nov 12 22:59:51 -0500 2007
349
+ # my_time.to_date # => Mon, 12 Nov 2007
350
+ #
351
+ # your_time = Time.parse("1/13/2009 1:13:03 P.M.") # => Tue Jan 13 13:13:03 -0500 2009
352
+ # your_time.to_date # => Tue, 13 Jan 2009
353
+ def to_date
354
+ ::Date.new(year, month, day)
355
+ end
356
+
357
+ # # Convert a Time to a Date. Time is a superset of Date.
358
+ # # It is the year, month and day that are carried over.
359
+ #
360
+ # def to_date
361
+ # require 'date' # just in case
362
+ # jd = Date.__send__(:civil_to_jd, year, mon, mday, Date::ITALY)
363
+ # Date.new!(Date.__send__(:jd_to_ajd, jd, 0, 0), 0, Date::ITALY)
364
+ # end
365
+
366
+
367
+ # Converts a Time instance to a Ruby DateTime instance, preserving UTC offset.
368
+ #
369
+ # my_time = Time.now # => Mon Nov 12 23:04:21 -0500 2007
370
+ # my_time.to_datetime # => Mon, 12 Nov 2007 23:04:21 -0500
371
+ #
372
+ # your_time = Time.parse("1/13/2009 1:13:03 P.M.") # => Tue Jan 13 13:13:03 -0500 2009
373
+ # your_time.to_datetime # => Tue, 13 Jan 2009 13:13:03 -0500
374
+ def to_datetime
375
+ ::DateTime.civil(year, month, day, hour, min, sec, Rational(utc_offset, 86400))
376
+ end
377
+
378
+ end
379
+
380
+
381
+ class String
382
+
383
+ # Convert string to DateTime.
384
+ def to_datetime
385
+ date = ::Date._parse(self, false).values_at(:year, :mon, :mday, :hour, :min, :sec).map { |arg| arg || 0 }
386
+ ::DateTime.civil(*date)
387
+ end
388
+
389
+ # Parse data from string.
390
+ def to_date
391
+ #::Date::civil(*ParseDate.parsedate(self)[0..2])
392
+ ::Date.new(*::Date._parse(self, false).values_at(:year, :mon, :mday))
393
+ end
394
+
395
+ end
396
+