facets 2.8.4 → 2.9.0.pre.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (1036) hide show
  1. data/AUTHORS +2 -0
  2. data/HISTORY.rdoc +233 -94
  3. data/NOTICE +27 -0
  4. data/README.rdoc +131 -49
  5. data/Rakefile +190 -97
  6. data/lib/core/facets/applique/file_helpers.rb +33 -0
  7. data/lib/core/facets/array/after.rb +1 -0
  8. data/lib/core/facets/array/before.rb +39 -0
  9. data/lib/core/facets/{enumerable → array}/collapse.rb +0 -0
  10. data/lib/core/facets/array/collisions.rb +1 -0
  11. data/lib/core/facets/array/combination.rb +0 -16
  12. data/lib/core/facets/{enumerable → array}/commonality.rb +8 -6
  13. data/lib/core/facets/array/conjoin.rb +48 -17
  14. data/lib/core/facets/{string → array}/contains.rb +0 -0
  15. data/lib/core/facets/array/delete_unless.rb +1 -1
  16. data/lib/core/facets/array/divide.rb +20 -0
  17. data/lib/core/facets/array/duplicates.rb +1 -0
  18. data/lib/core/facets/{enumerable → array}/entropy.rb +8 -6
  19. data/lib/core/facets/array/extract_options.rb +31 -0
  20. data/lib/core/facets/array/from.rb +33 -0
  21. data/lib/core/facets/array/index.rb +2 -4
  22. data/lib/core/facets/array/indexable.rb +4 -46
  23. data/lib/core/facets/array/merge.rb +3 -2
  24. data/lib/core/facets/array/mode.rb +22 -0
  25. data/lib/core/facets/array/nonuniq.rb +37 -0
  26. data/lib/core/facets/array/only.rb +9 -3
  27. data/lib/core/facets/array/peek.rb +1 -0
  28. data/lib/core/facets/array/permutation.rb +2 -0
  29. data/lib/core/facets/array/poke.rb +1 -0
  30. data/lib/core/facets/{enumerable → array}/probability.rb +9 -6
  31. data/lib/core/facets/array/product.rb +1 -2
  32. data/lib/core/facets/array/pull.rb +30 -0
  33. data/lib/core/facets/array/recurse.rb +29 -0
  34. data/lib/core/facets/array/recursively.rb +39 -22
  35. data/lib/core/facets/array/rotate.rb +40 -32
  36. data/lib/core/facets/array/select.rb +14 -10
  37. data/lib/core/facets/array/splice.rb +2 -5
  38. data/lib/core/facets/{enumerable → array}/split.rb +2 -2
  39. data/lib/core/facets/array/store.rb +12 -0
  40. data/lib/core/facets/array/thru.rb +1 -0
  41. data/lib/core/facets/array/traverse.rb +10 -5
  42. data/lib/core/facets/array/uniq_by.rb +6 -8
  43. data/lib/core/facets/binding/__callee__.rb +1 -0
  44. data/lib/core/facets/binding/__method__.rb +1 -0
  45. data/lib/core/facets/binding/call_stack.rb +1 -0
  46. data/lib/core/facets/binding/caller.rb +6 -5
  47. data/lib/core/facets/binding/callstack.rb +1 -1
  48. data/lib/core/facets/binding/eval.rb +2 -6
  49. data/lib/core/facets/binding/local_variables.rb +5 -3
  50. data/lib/core/facets/binding/{opvars.rb → op.rb} +0 -0
  51. data/lib/core/facets/boolean.rb +27 -59
  52. data/lib/core/facets/class/descendants.rb +21 -34
  53. data/lib/core/facets/class/methodize.rb +6 -1
  54. data/lib/core/facets/class/pathize.rb +6 -1
  55. data/lib/core/facets/class/subclasses.rb +27 -1
  56. data/lib/core/facets/class/to_proc.rb +4 -1
  57. data/lib/core/facets/comparable/bound.rb +1 -1
  58. data/lib/core/facets/comparable/cmp.rb +3 -0
  59. data/lib/core/facets/comparable/op_get.rb +45 -0
  60. data/lib/core/facets/dir/ascend.rb +8 -12
  61. data/lib/core/facets/dir/each_child.rb +16 -0
  62. data/lib/core/facets/dir/multiglob.rb +15 -27
  63. data/lib/core/facets/dir/parent.rb +4 -1
  64. data/lib/core/facets/dir/recurse.rb +6 -3
  65. data/lib/core/facets/enumerable/accumulate.rb +47 -9
  66. data/lib/core/facets/enumerable/cluster_by.rb +1 -4
  67. data/lib/core/facets/enumerable/compact_map.rb +3 -5
  68. data/lib/core/facets/enumerable/count.rb +42 -30
  69. data/lib/core/facets/enumerable/defer.rb +1 -2
  70. data/lib/core/facets/enumerable/each_with_object.rb +2 -2
  71. data/lib/core/facets/enumerable/every.rb +16 -11
  72. data/lib/core/facets/enumerable/ewise.rb +11 -19
  73. data/lib/core/facets/enumerable/exclude.rb +4 -1
  74. data/lib/core/facets/enumerable/expand.rb +15 -0
  75. data/lib/core/facets/enumerable/filter.rb +9 -11
  76. data/lib/core/facets/enumerable/find_yield.rb +14 -9
  77. data/lib/core/facets/enumerable/frequency.rb +12 -6
  78. data/lib/core/facets/enumerable/graph.rb +2 -2
  79. data/lib/core/facets/enumerable/group_by.rb +13 -7
  80. data/lib/core/facets/enumerable/map_by.rb +35 -0
  81. data/lib/core/facets/enumerable/map_send.rb +12 -10
  82. data/lib/core/facets/enumerable/modulate.rb +1 -1
  83. data/lib/core/facets/enumerable/none.rb +5 -5
  84. data/lib/core/facets/enumerable/occur.rb +9 -7
  85. data/lib/core/facets/enumerable/one.rb +6 -6
  86. data/lib/core/facets/enumerable/per.rb +35 -13
  87. data/lib/core/facets/enumerable/recursively.rb +66 -0
  88. data/lib/core/facets/enumerable/take.rb +11 -15
  89. data/lib/core/facets/enumerable/uniq_by.rb +1 -4
  90. data/lib/core/facets/enumerable/visit.rb +4 -4
  91. data/lib/core/facets/enumerator.rb +17 -12
  92. data/lib/core/facets/enumerator/fx.rb +24 -8
  93. data/lib/core/facets/exception/detail.rb +1 -1
  94. data/lib/core/facets/exception/raised.rb +1 -1
  95. data/lib/core/facets/exception/suppress.rb +3 -1
  96. data/lib/core/facets/file/append.rb +2 -2
  97. data/lib/core/facets/file/create.rb +1 -1
  98. data/lib/core/facets/file/ext.rb +7 -7
  99. data/lib/core/facets/file/read_binary.rb +18 -0
  100. data/lib/core/facets/file/read_list.rb +34 -0
  101. data/lib/core/facets/file/rewrite.rb +9 -7
  102. data/lib/core/facets/file/rootname.rb +2 -12
  103. data/lib/core/facets/file/sanitize.rb +18 -0
  104. data/lib/core/facets/file/split_all.rb +1 -1
  105. data/lib/core/facets/file/write.rb +16 -14
  106. data/lib/core/facets/file/writelines.rb +5 -1
  107. data/lib/core/facets/functor.rb +53 -52
  108. data/lib/core/facets/hash/alias.rb +3 -3
  109. data/lib/core/facets/hash/argumentize.rb +10 -4
  110. data/lib/core/facets/hash/autonew.rb +10 -12
  111. data/lib/core/facets/hash/collate.rb +35 -49
  112. data/lib/core/facets/hash/count.rb +0 -2
  113. data/lib/core/facets/hash/data.rb +31 -4
  114. data/lib/core/facets/hash/{recursive_merge.rb → deep_merge.rb} +4 -10
  115. data/lib/core/facets/hash/delete.rb +4 -47
  116. data/lib/core/facets/hash/delete_at.rb +7 -0
  117. data/lib/core/facets/hash/delete_unless.rb +17 -0
  118. data/lib/core/facets/hash/delete_values.rb +32 -0
  119. data/lib/core/facets/hash/diff.rb +7 -1
  120. data/lib/core/facets/hash/except.rb +15 -17
  121. data/lib/core/facets/hash/inverse.rb +7 -4
  122. data/lib/core/facets/hash/join.rb +6 -3
  123. data/lib/core/facets/hash/new_with.rb +1 -1
  124. data/lib/core/facets/hash/op_and.rb +2 -2
  125. data/lib/core/facets/hash/op_mul.rb +4 -4
  126. data/lib/core/facets/hash/recurse.rb +29 -0
  127. data/lib/core/facets/hash/recursively.rb +50 -18
  128. data/lib/core/facets/hash/rekey.rb +50 -34
  129. data/lib/core/facets/hash/{merge.rb → reverse_merge.rb} +0 -0
  130. data/lib/core/facets/hash/select.rb +10 -6
  131. data/lib/core/facets/hash/slice.rb +24 -25
  132. data/lib/core/facets/hash/symbolize_keys.rb +74 -76
  133. data/lib/core/facets/hash/to_mod.rb +33 -0
  134. data/lib/core/facets/hash/to_proc.rb +11 -10
  135. data/lib/core/facets/hash/traverse.rb +4 -4
  136. data/lib/core/facets/hash/update.rb +1 -1
  137. data/lib/core/facets/hash/update_values.rb +2 -2
  138. data/lib/core/facets/hash/weave.rb +2 -7
  139. data/lib/core/facets/indexable.rb +59 -40
  140. data/lib/core/facets/{kernel/instance.rb → instance.rb} +3 -2
  141. data/lib/core/facets/integer/bit.rb +1 -0
  142. data/lib/core/facets/{bitmask.rb → integer/bitmask.rb} +9 -11
  143. data/lib/core/facets/integer/factorial.rb +1 -10
  144. data/lib/core/facets/integer/odd.rb +2 -4
  145. data/lib/core/facets/integer/of.rb +1 -1
  146. data/lib/core/facets/kernel/__dir__.rb +10 -6
  147. data/lib/core/facets/kernel/__get__.rb +8 -3
  148. data/lib/core/facets/kernel/__method__.rb +12 -6
  149. data/lib/core/facets/kernel/as.rb +61 -46
  150. data/lib/core/facets/kernel/ask.rb +11 -11
  151. data/lib/core/facets/kernel/assign.rb +40 -27
  152. data/lib/core/facets/kernel/assign_from.rb +1 -45
  153. data/lib/core/facets/kernel/attr_singleton.rb +22 -25
  154. data/lib/core/facets/kernel/blank.rb +84 -0
  155. data/lib/core/facets/kernel/call_stack.rb +56 -0
  156. data/lib/core/facets/kernel/callstack.rb +1 -52
  157. data/lib/core/facets/kernel/case.rb +8 -0
  158. data/lib/core/facets/kernel/clone.rb +1 -0
  159. data/lib/core/facets/kernel/complete.rb +10 -2
  160. data/lib/core/facets/kernel/constant.rb +4 -8
  161. data/lib/core/facets/kernel/d.rb +12 -8
  162. data/lib/core/facets/kernel/deep_clone.rb +1 -0
  163. data/lib/core/facets/kernel/deep_copy.rb +27 -2
  164. data/lib/core/facets/kernel/disable_warnings.rb +26 -0
  165. data/lib/core/facets/kernel/dup.rb +33 -0
  166. data/lib/core/facets/kernel/enable_warnings.rb +1 -0
  167. data/lib/core/facets/kernel/equate.rb +8 -5
  168. data/lib/core/facets/kernel/ergo.rb +4 -3
  169. data/lib/core/facets/kernel/extend.rb +17 -1
  170. data/lib/core/facets/kernel/extension.rb +3 -0
  171. data/lib/core/facets/kernel/here.rb +1 -2
  172. data/lib/core/facets/kernel/instance_class.rb +2 -1
  173. data/lib/core/facets/kernel/load_all.rb +1 -0
  174. data/lib/core/facets/kernel/load_relative.rb +1 -0
  175. data/lib/core/facets/kernel/maybe.rb +3 -2
  176. data/lib/core/facets/kernel/meta_alias.rb +9 -4
  177. data/lib/core/facets/kernel/meta_class.rb +4 -4
  178. data/lib/core/facets/kernel/meta_def.rb +0 -2
  179. data/lib/core/facets/kernel/meta_eval.rb +7 -5
  180. data/lib/core/facets/kernel/method.rb +5 -4
  181. data/lib/core/facets/kernel/not.rb +37 -0
  182. data/lib/core/facets/kernel/not_nil.rb +3 -2
  183. data/lib/core/facets/kernel/object_hexid.rb +9 -7
  184. data/lib/core/facets/kernel/object_send.rb +11 -10
  185. data/lib/core/facets/kernel/object_state.rb +21 -4
  186. data/lib/core/facets/kernel/p.rb +3 -3
  187. data/lib/core/facets/kernel/presence.rb +1 -0
  188. data/lib/core/facets/kernel/present.rb +1 -0
  189. data/lib/core/facets/kernel/qua_class.rb +15 -3
  190. data/lib/core/facets/kernel/replace.rb +1 -0
  191. data/lib/core/facets/kernel/require_all.rb +33 -17
  192. data/lib/core/facets/kernel/require_relative.rb +10 -10
  193. data/lib/core/facets/kernel/respond.rb +26 -7
  194. data/lib/core/facets/kernel/returning.rb +5 -1
  195. data/lib/core/facets/kernel/silence.rb +39 -41
  196. data/lib/core/facets/kernel/silence_warnings.rb +1 -0
  197. data/lib/core/facets/kernel/singleton_class.rb +2 -13
  198. data/lib/core/facets/kernel/super_method.rb +11 -0
  199. data/lib/core/facets/kernel/tap.rb +16 -7
  200. data/lib/core/facets/kernel/temporarily.rb +23 -0
  201. data/lib/core/facets/kernel/try.rb +43 -10
  202. data/lib/core/facets/kernel/try_dup.rb +19 -9
  203. data/lib/core/facets/kernel/writers.rb +91 -0
  204. data/lib/core/facets/matchdata/matchset.rb +4 -4
  205. data/lib/core/facets/method.rb +6 -0
  206. data/lib/core/facets/module/abstract.rb +10 -7
  207. data/lib/core/facets/module/alias_method_chain.rb +22 -4
  208. data/lib/core/facets/module/alias_module_function.rb +4 -4
  209. data/lib/core/facets/module/all_instance_methods.rb +19 -0
  210. data/lib/core/facets/module/ancestor.rb +1 -1
  211. data/lib/core/facets/module/anonymous.rb +25 -0
  212. data/lib/core/facets/module/attr_setter.rb +8 -13
  213. data/lib/core/facets/module/basename.rb +6 -6
  214. data/lib/core/facets/module/can.rb +8 -2
  215. data/lib/core/facets/module/class_method_defined.rb +1 -0
  216. data/lib/core/facets/module/extend.rb +1 -10
  217. data/lib/core/facets/module/instance_method.rb +3 -2
  218. data/lib/core/facets/module/instance_method_defined.rb +23 -0
  219. data/lib/core/facets/module/integrate.rb +48 -1
  220. data/lib/core/facets/module/is.rb +5 -5
  221. data/lib/core/facets/module/method_clash.rb +58 -0
  222. data/lib/core/facets/module/methodize.rb +7 -1
  223. data/lib/core/facets/module/modname.rb +22 -0
  224. data/lib/core/facets/module/nodef.rb +13 -0
  225. data/lib/core/facets/module/op.rb +37 -22
  226. data/lib/core/facets/module/op_add.rb +1 -0
  227. data/lib/core/facets/module/op_mul.rb +1 -0
  228. data/lib/core/facets/module/op_sub.rb +1 -0
  229. data/lib/core/facets/module/pathize.rb +8 -10
  230. data/lib/core/facets/module/redirect_method.rb +5 -5
  231. data/lib/core/facets/module/remove.rb +1 -0
  232. data/lib/core/facets/module/rename_method.rb +12 -2
  233. data/lib/core/facets/module/revise.rb +20 -41
  234. data/lib/core/facets/module/set.rb +1 -1
  235. data/lib/core/facets/module/singleton_method_defined.rb +1 -0
  236. data/lib/core/facets/module/spacename.rb +4 -4
  237. data/lib/core/facets/module/to_obj.rb +20 -0
  238. data/lib/core/facets/module/wrap_method.rb +16 -9
  239. data/lib/core/facets/na.rb +15 -0
  240. data/lib/core/facets/numeric/round.rb +4 -4
  241. data/lib/core/facets/numeric/round_at.rb +1 -0
  242. data/lib/core/facets/numeric/round_to.rb +1 -0
  243. data/lib/core/facets/object.rb +6 -0
  244. data/lib/core/facets/objectspace/reflect.rb +26 -11
  245. data/lib/core/facets/proc/bind.rb +7 -5
  246. data/lib/core/facets/proc/bind_to.rb +8 -0
  247. data/lib/{more/facets → core/facets/proc}/partial.rb +9 -15
  248. data/lib/core/facets/proc/to_method.rb +10 -5
  249. data/lib/core/facets/process.rb +6 -0
  250. data/lib/core/facets/process/daemon.rb +32 -0
  251. data/lib/core/facets/range/combine.rb +1 -1
  252. data/lib/core/facets/range/within.rb +1 -1
  253. data/lib/core/facets/regexp/multiline.rb +13 -0
  254. data/lib/core/facets/regexp/op_add.rb +18 -0
  255. data/lib/core/facets/regexp/op_or.rb +18 -0
  256. data/lib/core/facets/string/align.rb +24 -6
  257. data/lib/core/facets/string/bracket.rb +9 -50
  258. data/lib/core/facets/string/camelcase.rb +32 -23
  259. data/lib/core/facets/string/capitalized.rb +7 -4
  260. data/lib/core/facets/string/characters.rb +13 -0
  261. data/lib/core/facets/string/cleanlines.rb +3 -13
  262. data/lib/core/facets/string/cmp.rb +1 -0
  263. data/lib/core/facets/string/compress_lines.rb +4 -4
  264. data/lib/core/facets/string/divide.rb +1 -4
  265. data/lib/core/facets/string/each_char.rb +17 -15
  266. data/lib/core/facets/string/each_word.rb +5 -1
  267. data/lib/core/facets/string/edit_distance.rb +64 -2
  268. data/lib/core/facets/string/file.rb +21 -5
  269. data/lib/core/facets/string/indent.rb +46 -4
  270. data/lib/core/facets/string/interpolate.rb +3 -4
  271. data/lib/core/facets/string/{chomp.rb → lchomp.rb} +0 -0
  272. data/lib/core/facets/string/line_wrap.rb +2 -5
  273. data/lib/core/facets/string/lines.rb +1 -1
  274. data/lib/core/facets/string/methodize.rb +3 -2
  275. data/lib/core/facets/string/modulize.rb +3 -1
  276. data/lib/core/facets/string/natcmp.rb +35 -36
  277. data/lib/core/facets/string/nchar.rb +11 -5
  278. data/lib/core/facets/string/newlines.rb +10 -13
  279. data/lib/core/facets/string/op_div.rb +2 -2
  280. data/lib/core/facets/string/op_sub.rb +1 -1
  281. data/lib/core/facets/string/pathize.rb +12 -10
  282. data/lib/core/facets/string/quote.rb +93 -0
  283. data/lib/core/facets/string/range.rb +11 -7
  284. data/lib/core/facets/string/rewrite.rb +6 -10
  285. data/lib/core/facets/string/similarity.rb +24 -27
  286. data/lib/core/facets/string/splice.rb +6 -10
  287. data/lib/core/facets/string/squish.rb +22 -0
  288. data/lib/core/facets/string/start_with.rb +31 -8
  289. data/lib/core/facets/string/store.rb +7 -0
  290. data/lib/core/facets/string/titlecase.rb +1 -1
  291. data/lib/core/facets/string/unbracket.rb +1 -0
  292. data/lib/core/facets/string/underscore.rb +1 -0
  293. data/lib/core/facets/string/unindent.rb +1 -0
  294. data/lib/core/facets/string/unquote.rb +1 -0
  295. data/lib/core/facets/string/word_wrap.rb +2 -2
  296. data/lib/core/facets/string/xor.rb +4 -6
  297. data/lib/core/facets/symbol/as_s.rb +17 -0
  298. data/lib/core/facets/symbol/bang.rb +1 -0
  299. data/lib/core/facets/symbol/generate.rb +3 -3
  300. data/lib/core/facets/symbol/not.rb +1 -1
  301. data/lib/core/facets/symbol/op_div.rb +8 -6
  302. data/lib/core/facets/symbol/plain.rb +27 -1
  303. data/lib/core/facets/symbol/succ.rb +7 -3
  304. data/lib/core/facets/symbol/thrown.rb +2 -4
  305. data/lib/core/facets/symbol/to_proc.rb +8 -13
  306. data/lib/core/facets/symbol/variablize.rb +7 -5
  307. data/lib/core/facets/time/ago.rb +1 -1
  308. data/lib/core/facets/time/change.rb +19 -14
  309. data/lib/core/facets/time/dst_adjustment.rb +24 -0
  310. data/lib/core/facets/time/elapse.rb +3 -1
  311. data/lib/core/facets/time/future.rb +4 -4
  312. data/lib/core/facets/time/hence.rb +1 -97
  313. data/lib/core/facets/time/in.rb +93 -0
  314. data/lib/core/facets/time/round_to.rb +21 -0
  315. data/lib/core/facets/time/set.rb +9 -3
  316. data/lib/core/facets/time/stamp.rb +2 -1
  317. data/lib/core/facets/time/to_time.rb +2 -2
  318. data/lib/core/facets/time/trunc.rb +3 -3
  319. data/lib/core/facets/to_hash.rb +16 -12
  320. data/lib/core/facets/unboundmethod/name.rb +3 -3
  321. data/lib/more/facets/argvector.rb +23 -33
  322. data/lib/more/facets/atomicfile.rb +51 -0
  323. data/lib/more/facets/basicobject.rb +6 -6
  324. data/lib/more/facets/cgi.rb +3 -9
  325. data/lib/more/facets/continuation.rb +2 -2
  326. data/lib/more/facets/date.rb +56 -54
  327. data/lib/more/facets/erb.rb +15 -12
  328. data/lib/more/facets/fileutils.rb +1 -20
  329. data/lib/more/facets/fileutils/cp_rx.rb +1 -1
  330. data/lib/more/facets/fileutils/safe_ln.rb +1 -2
  331. data/lib/more/facets/fileutils/slice.rb +11 -99
  332. data/lib/more/facets/fileutils/wc.rb +5 -56
  333. data/lib/more/facets/fileutils/whereis.rb +8 -6
  334. data/lib/more/facets/fileutils/which.rb +5 -48
  335. data/lib/more/facets/find.rb +16 -0
  336. data/lib/more/facets/getoptlong.rb +11 -23
  337. data/lib/more/facets/main.rb +27 -40
  338. data/lib/more/facets/memoizable.rb +141 -0
  339. data/lib/{core → more}/facets/metaid.rb +2 -2
  340. data/lib/more/facets/multipliers.rb +6 -38
  341. data/lib/more/facets/multiton.rb +14 -13
  342. data/lib/more/facets/nullclass.rb +3 -39
  343. data/lib/more/facets/opesc.rb +42 -23
  344. data/lib/more/facets/ostruct.rb +32 -59
  345. data/lib/more/facets/pathname.rb +53 -43
  346. data/lib/more/facets/platform.rb +87 -100
  347. data/lib/more/facets/random.rb +129 -172
  348. data/lib/more/facets/rbconfig.rb +130 -25
  349. data/lib/more/facets/reference.rb +7 -23
  350. data/lib/more/facets/set.rb +5 -0
  351. data/lib/more/facets/shellwords.rb +22 -4
  352. data/lib/more/facets/thread.rb +48 -25
  353. data/lib/more/facets/timer.rb +50 -117
  354. data/lib/more/facets/tuple.rb +31 -74
  355. data/lib/more/facets/uri.rb +29 -67
  356. data/lib/more/facets/yaml.rb +28 -44
  357. data/lib/more/facets/zlib.rb +3 -3
  358. data/lib/tour/facets/array/median.rb +14 -0
  359. data/lib/tour/facets/array/percentile.rb +29 -0
  360. data/lib/{core/facets/class/prepend.rb → tour/facets/class/preallocate.rb} +10 -10
  361. data/lib/{more/facets → tour/facets/integer}/roman.rb +8 -7
  362. data/lib/{core → tour}/facets/kernel/demo.rb +3 -2
  363. data/lib/{core → tour}/facets/kernel/eigenclass.rb +1 -3
  364. data/lib/{core → tour}/facets/kernel/instance_exec.rb +3 -6
  365. data/lib/tour/facets/kernel/memo.rb +38 -0
  366. data/lib/tour/facets/kernel/trap_chain.rb +20 -0
  367. data/lib/tour/facets/method/memoize.rb +10 -0
  368. data/lib/tour/facets/module/attr_class_accessor.rb +33 -0
  369. data/lib/tour/facets/module/attr_inheritor.rb +13 -0
  370. data/lib/{more → tour}/facets/module/attr_tester.rb +0 -3
  371. data/lib/{more → tour}/facets/module/attr_validator.rb +0 -0
  372. data/lib/tour/facets/module/cattr.rb +240 -0
  373. data/lib/tour/facets/module/class_accessor.rb +27 -0
  374. data/lib/tour/facets/module/class_extend.rb +82 -0
  375. data/lib/{more/facets/inheritor.rb → tour/facets/module/class_inheritor.rb} +12 -38
  376. data/lib/tour/facets/module/copy_inheritor.rb +39 -0
  377. data/lib/tour/facets/module/enclosure.rb +62 -0
  378. data/lib/tour/facets/module/enclosures.rb +1 -0
  379. data/lib/tour/facets/module/include_as.rb +1 -0
  380. data/lib/{more/facets → tour/facets/module}/instance_function.rb +26 -16
  381. data/lib/tour/facets/module/memoize.rb +12 -0
  382. data/lib/tour/facets/module/method_space.rb +94 -0
  383. data/lib/{core → tour}/facets/module/module_load.rb +0 -0
  384. data/lib/{core → tour}/facets/module/prepend.rb +4 -4
  385. data/lib/tour/facets/regexp/op_or.rb +11 -0
  386. data/lib/tour/facets/string/crypt.rb +16 -0
  387. data/lib/tour/facets/string/roman.rb +1 -0
  388. data/meta/data.rb +29 -0
  389. data/meta/gemfile +10 -0
  390. data/meta/profile +24 -0
  391. data/qed/applique/file_helpers.rb +24 -0
  392. data/qed/core/array/combination.rdoc +19 -0
  393. data/qed/core/array/delete.rdoc +23 -0
  394. data/qed/core/array/index.rdoc +14 -0
  395. data/qed/core/array/merge.rdoc +15 -0
  396. data/qed/core/array/only.rdoc +9 -0
  397. data/qed/core/array/pad.rdoc +28 -0
  398. data/qed/core/array/permutation.rdoc +10 -0
  399. data/qed/core/array/product.rdoc +26 -0
  400. data/qed/core/array/recursively.rdoc +16 -0
  401. data/qed/core/array/rotate.rdoc +30 -0
  402. data/qed/core/array/select.rdoc +8 -0
  403. data/qed/core/array/uniq_by.rdoc +9 -0
  404. data/qed/core/binding/caller.rdoc +59 -0
  405. data/qed/core/binding/defined.rdoc +10 -0
  406. data/qed/core/binding/eval.rdoc +8 -0
  407. data/qed/core/binding/local_variables.rdoc +26 -0
  408. data/qed/core/binding/opvars.rdoc +16 -0
  409. data/qed/core/binding/self.rdoc +6 -0
  410. data/qed/core/class/descendants.rdoc +10 -0
  411. data/qed/core/class/to_proc.rdoc +8 -0
  412. data/qed/core/comparable/cap.rdoc +20 -0
  413. data/qed/core/comparable/clip.rdoc +37 -0
  414. data/qed/core/comparable/cmp.rdoc +18 -0
  415. data/qed/core/comparable/op_get.rdoc +29 -0
  416. data/qed/core/dir/ascend.rdoc +24 -0
  417. data/qed/core/dir/descend.rdoc +14 -0
  418. data/qed/core/dir/multiglob.rdoc +41 -0
  419. data/qed/core/dir/parent.rdoc +6 -0
  420. data/qed/core/dir/recurse.rdoc +41 -0
  421. data/qed/core/exception/detail.rdoc +12 -0
  422. data/qed/core/facets.rdoc +6 -0
  423. data/qed/core/filetest/root.rdoc +6 -0
  424. data/qed/core/hash/recursively.rdoc +21 -0
  425. data/qed/core/indexable.rdoc +95 -0
  426. data/qed/core/integer/bitmask.rdoc +46 -0
  427. data/qed/core/integer/even.rdoc +12 -0
  428. data/qed/core/integer/factorial.rdoc +10 -0
  429. data/qed/core/integer/length.rdoc +7 -0
  430. data/qed/core/integer/multiple.rdoc +10 -0
  431. data/qed/core/integer/odd.rdoc +12 -0
  432. data/qed/core/integer/of.rdoc +14 -0
  433. data/qed/core/integer/ordinal.rdoc +9 -0
  434. data/qed/core/matchdata/match.rdoc +7 -0
  435. data/qed/core/matchdata/matchset.rdoc +15 -0
  436. data/qed/core/string/align.rdoc +34 -0
  437. data/qed/core/string/bracket.rdoc +35 -0
  438. data/qed/core/string/bytes.rdoc +8 -0
  439. data/qed/core/string/camelcase.rdoc +67 -0
  440. data/qed/core/string/capitalized.rdoc +27 -0
  441. data/qed/core/string/characters.rdoc +11 -0
  442. data/qed/core/string/cleanlines.rdoc +10 -0
  443. data/qed/core/string/cleave.rdoc +49 -0
  444. data/qed/core/string/divide.rdoc +9 -0
  445. data/qed/core/string/each_char.rdoc +9 -0
  446. data/qed/core/string/each_word.rdoc +9 -0
  447. data/qed/core/string/end_with.rdoc +6 -0
  448. data/qed/core/string/expand_tabs.rdoc +69 -0
  449. data/qed/core/string/fold.rdoc +14 -0
  450. data/qed/core/string/indent.rdoc +65 -0
  451. data/qed/core/string/interpolate.rdoc +7 -0
  452. data/qed/core/string/lchomp.rdoc +14 -0
  453. data/qed/core/string/line_wrap.rdoc +7 -0
  454. data/qed/core/string/lines.rdoc +8 -0
  455. data/qed/core/string/margin.rdoc +92 -0
  456. data/qed/core/string/methodize.rdoc +22 -0
  457. data/qed/core/string/modulize.rdoc +22 -0
  458. data/qed/core/string/mscan.rdoc +10 -0
  459. data/qed/core/string/natcmp.rdoc +10 -0
  460. data/qed/core/string/nchar.rdoc +9 -0
  461. data/qed/core/string/newlines.rdoc +9 -0
  462. data/qed/core/string/op_sub.rdoc +7 -0
  463. data/qed/core/string/pathize.rdoc +22 -0
  464. data/qed/core/string/quote.rdoc +20 -0
  465. data/qed/core/string/range.rdoc +19 -0
  466. data/qed/core/string/rewrite.rdoc +9 -0
  467. data/qed/core/string/shatter.rdoc +9 -0
  468. data/qed/core/string/snakecase.rdoc +9 -0
  469. data/qed/core/string/splice.rdoc +28 -0
  470. data/qed/core/string/start_with.rdoc +7 -0
  471. data/qed/core/string/subtract.rdoc +8 -0
  472. data/qed/core/string/tab.rdoc +16 -0
  473. data/qed/core/string/tabto.rdoc +29 -0
  474. data/qed/core/string/titlecase.rdoc +8 -0
  475. data/qed/core/string/to_re.rdoc +22 -0
  476. data/qed/core/string/unfold.rdoc +9 -0
  477. data/qed/core/string/unindent.rdoc +65 -0
  478. data/qed/core/string/unquote.rdoc +6 -0
  479. data/qed/core/string/variablize.rdoc +7 -0
  480. data/qed/core/string/word_wrap.rdoc +54 -0
  481. data/qed/core/string/words.rdoc +13 -0
  482. data/qed/core/string/xor.rdoc +8 -0
  483. data/qed/more/basic_object.rdoc +22 -0
  484. data/qed/more/memoizable.rdoc +134 -0
  485. data/qed/more/mulititon.rdoc +156 -0
  486. data/qed/tour/module/cattr.rdoc +43 -0
  487. data/qed/tour/module/class_extend.rdoc +64 -0
  488. data/qed/tour/module/class_inheritor.rdoc +126 -0
  489. data/qed/tour/module/copy_inheritor.rdoc +30 -0
  490. data/qed/tour/module/method_space.rdoc +55 -0
  491. data/test/core/array/test_after.rb +17 -0
  492. data/test/core/array/test_before.rb +17 -0
  493. data/test/core/array/test_collapse.rb +10 -0
  494. data/test/core/array/test_combination.rb +9 -17
  495. data/test/core/array/test_commonality.rb +27 -0
  496. data/test/core/array/test_conjoin.rb +46 -0
  497. data/test/core/array/test_contains.rb +10 -0
  498. data/test/core/array/test_delete.rb +12 -15
  499. data/test/core/array/test_divide.rb +10 -0
  500. data/test/core/array/test_duplicates.rb +11 -0
  501. data/test/core/array/test_entropy.rb +15 -0
  502. data/test/core/array/test_extract_options.rb +20 -0
  503. data/test/core/array/test_first.rb +13 -0
  504. data/test/core/array/test_index.rb +6 -7
  505. data/test/core/array/test_last.rb +13 -0
  506. data/test/core/array/test_merge.rb +6 -9
  507. data/test/core/array/test_mode.rb +13 -0
  508. data/test/core/array/test_nonuniq.rb +17 -0
  509. data/test/core/array/test_not_empty.rb +13 -0
  510. data/test/core/array/test_only.rb +7 -15
  511. data/test/core/array/test_pad.rb +10 -11
  512. data/test/core/array/test_peek.rb +24 -0
  513. data/test/core/array/test_permutation.rb +11 -9
  514. data/test/core/array/test_poke.rb +17 -0
  515. data/test/core/array/test_probability.rb +11 -0
  516. data/test/core/array/test_product.rb +25 -12
  517. data/test/core/array/test_pull.rb +11 -0
  518. data/test/core/array/test_recurse.rb +17 -0
  519. data/test/core/array/test_recursively.rb +29 -0
  520. data/test/core/array/test_rotate.rb +17 -10
  521. data/test/core/array/test_select.rb +4 -9
  522. data/test/core/array/test_splice.rb +17 -0
  523. data/test/core/array/test_split.rb +18 -0
  524. data/test/core/array/test_store.rb +20 -0
  525. data/test/core/array/test_traverse.rb +18 -0
  526. data/test/core/array/test_uniq_by.rb +13 -0
  527. data/test/core/binding/test_caller.rb +31 -30
  528. data/test/core/binding/test_defined.rb +9 -11
  529. data/test/core/binding/test_eval.rb +6 -9
  530. data/test/core/binding/test_local_variables.rb +24 -16
  531. data/test/core/binding/test_op.rb +20 -0
  532. data/test/core/binding/test_self.rb +6 -11
  533. data/test/core/class/test_descendents.rb +9 -8
  534. data/test/core/class/test_subclasses.rb +17 -0
  535. data/test/core/class/test_to_proc.rb +7 -8
  536. data/test/core/comparable/test_bound.rb +28 -0
  537. data/test/core/comparable/test_cap.rb +14 -15
  538. data/test/core/comparable/test_clip.rb +22 -17
  539. data/test/core/comparable/test_cmp.rb +6 -29
  540. data/test/core/comparable/{test_comparable.rb → test_op_get.rb} +19 -15
  541. data/test/core/denumerable_tc.rb +154 -0
  542. data/test/core/dir/test_ascend.rb +11 -19
  543. data/test/core/dir/test_descend.rb +7 -12
  544. data/test/core/dir/test_each_child.rb +18 -0
  545. data/test/core/dir/test_multiglob.rb +11 -36
  546. data/test/core/dir/test_parent.rb +4 -5
  547. data/test/core/dir/test_recurse.rb +10 -34
  548. data/test/core/enumerable/test_accumulate.rb +36 -0
  549. data/test/core/enumerable/test_cluster_by.rb +14 -10
  550. data/test/core/enumerable/test_compact_map.rb +19 -15
  551. data/test/core/enumerable/test_count.rb +9 -12
  552. data/test/core/enumerable/test_defer.rb +13 -78
  553. data/test/core/enumerable/test_each_by.rb +29 -39
  554. data/test/core/enumerable/test_each_with_object.rb +14 -0
  555. data/test/core/enumerable/test_every.rb +11 -12
  556. data/test/core/enumerable/test_ewise.rb +15 -16
  557. data/test/core/enumerable/test_exclude.rb +11 -0
  558. data/test/core/enumerable/test_expand.rb +11 -0
  559. data/test/core/enumerable/test_filter.rb +15 -0
  560. data/test/core/enumerable/test_find_yield.rb +43 -29
  561. data/test/core/enumerable/test_frequency.rb +6 -6
  562. data/test/core/enumerable/test_graph.rb +38 -0
  563. data/test/core/enumerable/test_group_by.rb +18 -17
  564. data/test/core/enumerable/test_map_by.rb +23 -0
  565. data/test/core/enumerable/test_map_send.rb +10 -0
  566. data/test/core/enumerable/test_map_with_index.rb +9 -5
  567. data/test/core/enumerable/test_mash.rb +5 -30
  568. data/test/core/enumerable/test_modulate.rb +4 -5
  569. data/test/core/enumerable/test_none.rb +6 -4
  570. data/test/core/enumerable/test_occur.rb +7 -8
  571. data/test/core/enumerable/test_one.rb +7 -4
  572. data/test/core/enumerable/test_per.rb +7 -10
  573. data/test/core/enumerable/test_purge.rb +18 -0
  574. data/test/core/enumerable/test_recursively.rb +29 -0
  575. data/test/core/enumerable/test_sum.rb +9 -0
  576. data/test/core/enumerable/test_take.rb +5 -7
  577. data/test/core/enumerable/test_uniq_by.rb +13 -7
  578. data/test/core/enumerable/test_visit.rb +10 -0
  579. data/test/core/enumerator/test_fx.rb +12 -0
  580. data/test/core/enumerator/test_new.rb +17 -0
  581. data/test/core/enumerator_tc.rb +28 -0
  582. data/test/core/exception/test_detail.rb +16 -0
  583. data/test/core/exception/test_raised.rb +13 -0
  584. data/test/core/exception/test_suppress.rb +14 -0
  585. data/test/core/file/test_append.rb +19 -0
  586. data/test/core/file/test_create.rb +8 -26
  587. data/test/core/file/test_ext.rb +15 -19
  588. data/test/core/file/test_null.rb +4 -6
  589. data/test/core/file/test_read_binary.rb +15 -0
  590. data/test/core/file/test_read_list.rb +12 -0
  591. data/test/core/file/test_rewrite.rb +18 -27
  592. data/test/core/file/test_rootname.rb +9 -0
  593. data/test/core/file/test_sanitize.rb +28 -0
  594. data/test/core/file/test_split_all.rb +5 -27
  595. data/test/core/file/test_write.rb +10 -23
  596. data/test/core/file/test_writelines.rb +10 -15
  597. data/test/core/filetest/test_root.rb +10 -0
  598. data/test/core/functor_tc.rb +29 -0
  599. data/test/core/hash/test_alias.rb +8 -7
  600. data/test/core/hash/test_argumentize.rb +19 -0
  601. data/test/core/hash/test_at.rb +5 -6
  602. data/test/core/hash/test_autonew.rb +12 -5
  603. data/test/core/hash/test_collate.rb +41 -23
  604. data/test/core/hash/test_count.rb +10 -0
  605. data/test/core/hash/test_data.rb +31 -0
  606. data/test/core/hash/test_dearray_values.rb +7 -8
  607. data/test/core/hash/test_deep_merge.rb +23 -0
  608. data/test/core/hash/test_delete_at.rb +14 -0
  609. data/test/core/hash/test_delete_unless.rb +14 -0
  610. data/test/core/hash/test_delete_values.rb +22 -0
  611. data/test/core/hash/test_diff.rb +12 -0
  612. data/test/core/hash/test_expect.rb +16 -0
  613. data/test/core/hash/test_graph.rb +32 -0
  614. data/test/core/hash/test_insert.rb +10 -7
  615. data/test/core/hash/test_inverse.rb +8 -7
  616. data/test/core/hash/test_join.rb +28 -0
  617. data/test/core/hash/test_keys.rb +21 -12
  618. data/test/core/hash/test_new_with.rb +13 -0
  619. data/test/core/hash/test_op_add.rb +5 -6
  620. data/test/core/hash/test_op_and.rb +11 -12
  621. data/test/core/hash/test_op_mul.rb +5 -6
  622. data/test/core/hash/test_op_or.rb +5 -6
  623. data/test/core/hash/test_op_push.rb +18 -18
  624. data/test/core/hash/test_op_sub.rb +8 -9
  625. data/test/core/hash/test_recurse.rb +18 -0
  626. data/test/core/hash/test_recursively.rb +67 -0
  627. data/test/core/hash/test_rekey.rb +46 -48
  628. data/test/core/hash/test_replace_each.rb +5 -6
  629. data/test/core/hash/test_reverse_merge.rb +27 -0
  630. data/test/core/hash/test_select.rb +23 -18
  631. data/test/core/hash/test_slice.rb +7 -10
  632. data/test/core/hash/test_stringify_keys.rb +8 -11
  633. data/test/core/hash/test_swap.rb +5 -5
  634. data/test/core/hash/test_symbolize_keys.rb +9 -11
  635. data/test/core/hash/test_to_mod.rb +20 -0
  636. data/test/core/hash/test_to_proc.rb +19 -0
  637. data/test/core/hash/test_to_struct.rb +18 -0
  638. data/test/core/hash/test_traverse.rb +11 -12
  639. data/test/core/hash/test_update_each.rb +5 -6
  640. data/test/core/hash/test_update_keys.rb +6 -7
  641. data/test/core/hash/test_update_values.rb +6 -6
  642. data/test/core/hash/test_weave.rb +5 -9
  643. data/test/core/hash/test_zipnew.rb +4 -5
  644. data/test/core/indexable_tc.rb +177 -0
  645. data/test/core/integer/test_bitmask.rb +34 -27
  646. data/test/core/integer/test_even.rb +7 -6
  647. data/test/core/integer/test_factorial.rb +16 -9
  648. data/test/core/integer/test_multiple.rb +3 -4
  649. data/test/core/integer/test_odd.rb +7 -6
  650. data/test/core/integer/test_of.rb +12 -7
  651. data/test/core/integer/test_ordinal.rb +14 -8
  652. data/test/core/kernel/test_as.rb +48 -39
  653. data/test/core/kernel/test_ask.rb +8 -0
  654. data/test/core/kernel/test_assign.rb +29 -30
  655. data/test/core/kernel/test_assign_from.rb +31 -11
  656. data/test/core/kernel/test_attr_singleton.rb +16 -18
  657. data/test/core/kernel/test_blank.rb +83 -0
  658. data/test/core/kernel/test_callstack.rb +8 -5
  659. data/test/core/kernel/test_class.rb +10 -0
  660. data/test/core/kernel/test_complete.rb +15 -0
  661. data/test/core/kernel/test_constant.rb +7 -11
  662. data/test/core/kernel/test_d.rb +10 -0
  663. data/test/core/kernel/test_deep_copy.rb +33 -0
  664. data/test/core/kernel/test_dir.rb +16 -0
  665. data/test/core/kernel/test_disable_warnings.rb +26 -0
  666. data/test/core/kernel/test_dup.rb +66 -0
  667. data/test/core/kernel/test_ergo.rb +23 -0
  668. data/test/core/kernel/test_extension.rb +14 -0
  669. data/test/core/kernel/test_get.rb +34 -0
  670. data/test/core/kernel/test_here.rb +4 -10
  671. data/test/core/kernel/test_in.rb +5 -6
  672. data/test/core/kernel/test_instance_assign.rb +7 -8
  673. data/test/core/kernel/test_instance_class.rb +4 -5
  674. data/test/core/kernel/test_instance_send.rb +22 -0
  675. data/test/core/kernel/test_maybe.rb +9 -0
  676. data/test/core/kernel/test_meta_alias.rb +14 -0
  677. data/test/core/kernel/test_meta_class.rb +25 -0
  678. data/test/core/kernel/test_meta_def.rb +11 -0
  679. data/test/core/kernel/test_meta_eval.rb +14 -0
  680. data/test/core/kernel/test_method.rb +10 -10
  681. data/test/core/kernel/test_not.rb +44 -0
  682. data/test/core/kernel/test_not_nil.rb +16 -8
  683. data/test/core/kernel/test_object_class.rb +7 -8
  684. data/test/core/kernel/test_object_hexid.rb +4 -5
  685. data/test/core/kernel/test_object_send.rb +21 -0
  686. data/test/core/kernel/test_object_state.rb +72 -0
  687. data/test/core/kernel/test_presence.rb +29 -0
  688. data/test/core/kernel/test_qua_class.rb +19 -0
  689. data/test/core/kernel/test_replace.rb +64 -0
  690. data/test/core/kernel/test_require_all.rb +11 -0
  691. data/test/core/kernel/test_require_relative.rb +12 -0
  692. data/test/core/kernel/test_respond.rb +32 -0
  693. data/test/core/kernel/test_returning.rb +4 -7
  694. data/test/core/kernel/test_silence.rb +17 -8
  695. data/test/core/kernel/test_singleton_class.rb +11 -0
  696. data/test/core/kernel/test_source_location.rb +18 -0
  697. data/test/core/kernel/test_super_method.rb +20 -0
  698. data/test/core/kernel/test_tap.rb +24 -9
  699. data/test/core/kernel/test_temporarily.rb +21 -0
  700. data/test/core/kernel/test_true.rb +23 -0
  701. data/test/core/kernel/test_try.rb +27 -0
  702. data/test/core/kernel/test_try_dup.rb +46 -0
  703. data/test/core/kernel/test_val.rb +11 -12
  704. data/test/core/kernel/test_with.rb +14 -0
  705. data/test/core/kernel/test_writers.rb +49 -0
  706. data/test/core/matchdata/test_match.rb +4 -8
  707. data/test/core/matchdata/test_matchset.rb +8 -10
  708. data/test/core/module/test_abstract.rb +13 -16
  709. data/test/core/module/test_alias_accessor.rb +14 -13
  710. data/test/core/module/test_alias_method_chain.rb +21 -20
  711. data/test/core/module/test_alias_module_function.rb +14 -12
  712. data/test/core/module/test_all_instance_methods.rb +23 -0
  713. data/test/core/module/test_ancestor.rb +6 -5
  714. data/test/core/module/test_anonymous.rb +14 -0
  715. data/test/core/module/test_attr_setter.rb +24 -0
  716. data/test/core/module/test_basename.rb +4 -5
  717. data/test/core/module/test_can.rb +10 -11
  718. data/test/core/module/test_class.rb +10 -13
  719. data/test/core/module/test_class_def.rb +18 -0
  720. data/test/core/module/test_instance_method.rb +16 -0
  721. data/test/core/module/test_instance_method_defined.rb +26 -0
  722. data/test/core/module/test_integrate.rb +15 -14
  723. data/test/core/module/test_is.rb +34 -10
  724. data/test/core/module/test_method_clash.rb +50 -0
  725. data/test/core/module/test_methodize.rb +12 -5
  726. data/test/core/module/test_modname.rb +9 -0
  727. data/test/core/module/test_module_def.rb +18 -0
  728. data/test/core/module/test_nodef.rb +15 -0
  729. data/test/core/module/test_op.rb +23 -25
  730. data/test/core/module/test_pathize.rb +11 -9
  731. data/test/core/module/test_redefine_method.rb +14 -19
  732. data/test/core/module/test_redirect_method.rb +14 -15
  733. data/test/core/module/test_remove.rb +15 -0
  734. data/test/core/module/test_rename_method.rb +16 -17
  735. data/test/core/module/test_revise.rb +33 -34
  736. data/test/core/module/test_set.rb +26 -0
  737. data/test/core/module/test_spacename.rb +5 -8
  738. data/test/core/module/test_to_obj.rb +16 -0
  739. data/test/core/module/test_wrap_method.rb +15 -15
  740. data/test/core/nilclass/test_to_f.rb +4 -5
  741. data/test/core/numeric/test_approx.rb +4 -4
  742. data/test/core/numeric/test_distance.rb +6 -7
  743. data/test/core/numeric/test_length.rb +12 -0
  744. data/test/core/numeric/test_round.rb +42 -33
  745. data/test/core/numeric/test_spacing.rb +8 -7
  746. data/test/core/proc/test_bind.rb +7 -7
  747. data/test/core/proc/test_bind_to.rb +13 -0
  748. data/test/core/proc/test_compose.rb +8 -9
  749. data/test/core/proc/test_curry.rb +11 -13
  750. data/test/core/proc/test_partial.rb +23 -0
  751. data/test/core/proc/test_to_method.rb +28 -15
  752. data/test/core/proc/test_update.rb +11 -0
  753. data/test/core/range/test_combine.rb +13 -7
  754. data/test/core/range/test_overlap.rb +3 -7
  755. data/test/core/range/test_to_r.rb +6 -7
  756. data/test/core/range/test_umbrella.rb +28 -0
  757. data/test/core/range/test_within.rb +3 -27
  758. data/test/core/regexp/test_arity.rb +11 -8
  759. data/test/core/regexp/test_multiline.rb +15 -0
  760. data/test/core/regexp/test_op_add.rb +11 -0
  761. data/test/core/regexp/test_op_or.rb +12 -0
  762. data/test/core/regexp/test_to_re.rb +6 -7
  763. data/test/core/string/test_align.rb +13 -11
  764. data/test/core/string/test_bracket.rb +21 -52
  765. data/test/core/string/test_bytes.rb +4 -5
  766. data/test/core/string/test_camelcase.rb +43 -35
  767. data/test/core/string/test_capitalized.rb +14 -15
  768. data/test/core/string/test_characters.rb +11 -0
  769. data/test/core/string/test_cleanlines.rb +4 -5
  770. data/test/core/string/test_cleave.rb +17 -26
  771. data/test/core/string/test_cmp.rb +14 -0
  772. data/test/core/string/test_compress_lines.rb +14 -0
  773. data/test/core/string/test_divide.rb +4 -5
  774. data/test/core/string/test_each_char.rb +4 -5
  775. data/test/core/string/test_each_word.rb +4 -5
  776. data/test/core/string/test_edit_distance.rb +16 -0
  777. data/test/core/string/test_end_with.rb +9 -5
  778. data/test/core/string/test_exclude.rb +19 -0
  779. data/test/core/string/test_expand_tabs.rb +39 -26
  780. data/test/core/string/test_file.rb +11 -0
  781. data/test/core/string/test_fold.rb +6 -7
  782. data/test/core/string/test_indent.rb +51 -45
  783. data/test/core/string/test_index_all.rb +10 -0
  784. data/test/core/string/test_interpolate.rb +4 -8
  785. data/test/core/string/test_lchomp.rb +6 -7
  786. data/test/core/string/test_line_wrap.rb +5 -6
  787. data/test/core/string/test_lines.rb +4 -5
  788. data/test/core/string/test_lowercase.rb +14 -0
  789. data/test/core/string/test_margin.rb +17 -18
  790. data/test/core/string/test_methodize.rb +8 -9
  791. data/test/core/string/test_modulize.rb +8 -9
  792. data/test/core/string/test_mscan.rb +6 -7
  793. data/test/core/string/test_natcmp.rb +8 -12
  794. data/test/core/string/test_nchar.rb +7 -8
  795. data/test/core/string/test_newlines.rb +4 -5
  796. data/test/core/string/test_op_div.rb +11 -0
  797. data/test/core/string/test_op_sub.rb +4 -5
  798. data/test/core/string/test_pathize.rb +11 -12
  799. data/test/core/string/test_quote.rb +38 -0
  800. data/test/core/string/test_range.rb +12 -12
  801. data/test/core/string/test_rewrite.rb +5 -6
  802. data/test/core/string/test_shatter.rb +6 -7
  803. data/test/core/string/test_similarity.rb +10 -0
  804. data/test/core/string/test_snakecase.rb +7 -8
  805. data/test/core/string/test_splice.rb +13 -14
  806. data/test/core/string/test_squish.rb +23 -0
  807. data/test/core/string/test_start_with.rb +9 -5
  808. data/test/core/string/test_store.rb +12 -0
  809. data/test/core/string/test_subtract.rb +6 -7
  810. data/test/core/string/test_tab.rb +5 -6
  811. data/test/core/string/test_tabto.rb +5 -6
  812. data/test/core/string/test_titlecase.rb +4 -5
  813. data/test/core/string/test_to_re.rb +15 -15
  814. data/test/core/string/test_unbracket.rb +26 -0
  815. data/test/core/string/test_underscore.rb +17 -0
  816. data/test/core/string/test_unfold.rb +4 -5
  817. data/test/core/string/test_unindent.rb +100 -0
  818. data/test/core/string/test_unquote.rb +9 -0
  819. data/test/core/string/test_uppercase.rb +18 -0
  820. data/test/core/string/test_variablize.rb +4 -5
  821. data/test/core/string/test_word_wrap.rb +50 -27
  822. data/test/core/string/test_words.rb +7 -22
  823. data/test/core/string/test_xor.rb +4 -5
  824. data/test/core/symbol/test_as_s.rb +11 -0
  825. data/test/core/symbol/test_bang.rb +11 -0
  826. data/test/core/symbol/test_chomp.rb +6 -7
  827. data/test/core/symbol/test_generate.rb +8 -12
  828. data/test/core/symbol/test_not.rb +7 -5
  829. data/test/core/symbol/test_op_div.rb +11 -0
  830. data/test/core/symbol/test_plain.rb +4 -5
  831. data/test/core/symbol/test_query.rb +3 -4
  832. data/test/core/symbol/test_setter.rb +3 -4
  833. data/test/core/symbol/test_succ.rb +6 -7
  834. data/test/core/symbol/test_to_proc.rb +13 -13
  835. data/test/core/symbol/test_variablize.rb +10 -0
  836. data/test/core/time/test_ago.rb +127 -0
  837. data/test/core/time/test_change.rb +6 -8
  838. data/test/core/time/test_dst_adjustment.rb +10 -0
  839. data/test/core/time/test_elapse.rb +3 -5
  840. data/test/core/time/test_future.rb +21 -0
  841. data/test/core/time/test_hence.rb +9 -121
  842. data/test/core/time/test_in.rb +126 -0
  843. data/test/core/time/test_past.rb +21 -0
  844. data/test/core/time/test_round_to.rb +28 -0
  845. data/test/core/time/test_set.rb +39 -0
  846. data/test/core/time/test_stamp.rb +19 -14
  847. data/test/core/time/test_to_time.rb +5 -6
  848. data/test/core/time/test_trunc.rb +13 -16
  849. data/test/core/to_hash_tc.rb +163 -0
  850. data/test/core/unboundmethod/test_arguments.rb +8 -8
  851. data/test/core/unboundmethod/test_name.rb +6 -6
  852. data/test/more/test_argvector.rb +27 -27
  853. data/test/more/test_date.rb +28 -32
  854. data/test/more/test_memoizable.rb +38 -0
  855. data/test/more/test_multipliers.rb +45 -48
  856. data/test/more/test_ostruct.rb +91 -93
  857. data/test/more/test_random.rb +97 -90
  858. data/test/more/test_shellwords.rb +46 -11
  859. data/test/more/test_thread.rb +8 -9
  860. data/test/more/test_timer.rb +17 -32
  861. data/test/more/test_tuple.rb +29 -23
  862. data/test/more/test_uri.rb +10 -13
  863. data/test/tour/array/test_median.rb +10 -0
  864. data/test/tour/array/test_percentile.rb +10 -0
  865. data/test/tour/class/test_preallocate.rb +27 -0
  866. data/test/tour/module/test_cattr.rb +45 -0
  867. data/test/tour/module/test_class_extend.rb +66 -0
  868. data/test/tour/module/test_class_inheritor.rb +148 -0
  869. data/test/tour/module/test_copy_inheritor.rb +32 -0
  870. data/test/tour/module/test_enclosure.rb +20 -0
  871. data/test/tour/module/test_instance_function.rb +26 -0
  872. data/test/tour/module/test_memoize.rb +30 -0
  873. data/test/tour/module/test_method_space.rb +64 -0
  874. data/test/tour/module/test_module_load.rb +19 -0
  875. data/test/tour/module/test_prepend.rb +24 -0
  876. metadata +658 -278
  877. data/NOTES +0 -143
  878. data/demo/hook.rdoc +0 -49
  879. data/demo/scenario_require.rdoc +0 -7
  880. data/lib/core/facets-live.rb +0 -19
  881. data/lib/core/facets-load.rb +0 -12
  882. data/lib/core/facets/array/recursive.rb +0 -91
  883. data/lib/core/facets/array/stackable.rb +0 -33
  884. data/lib/core/facets/blank.rb +0 -60
  885. data/lib/core/facets/cattr.rb +0 -2
  886. data/lib/core/facets/class/cattr.rb +0 -112
  887. data/lib/core/facets/class/cattr_accessor.rb +0 -1
  888. data/lib/core/facets/class/cattr_reader.rb +0 -1
  889. data/lib/core/facets/class/cattr_writer.rb +0 -1
  890. data/lib/core/facets/class/descendents.rb +0 -1
  891. data/lib/core/facets/comparable/comparable.rb +0 -42
  892. data/lib/core/facets/duplicable.rb +0 -32
  893. data/lib/core/facets/enumerable/collisions.rb +0 -1
  894. data/lib/core/facets/enumerable/divide.rb +0 -33
  895. data/lib/core/facets/enumerable/duplicates.rb +0 -38
  896. data/lib/core/facets/enumerable/mode.rb +0 -16
  897. data/lib/core/facets/enumerable/recursive.rb +0 -75
  898. data/lib/core/facets/file/read.rb +0 -41
  899. data/lib/core/facets/hash/group_by_value.rb +0 -65
  900. data/lib/core/facets/hash/recursive.rb +0 -180
  901. data/lib/core/facets/hash/to_module.rb +0 -26
  902. data/lib/core/facets/kernel/__here__.rb +0 -14
  903. data/lib/core/facets/kernel/populate.rb +0 -2
  904. data/lib/core/facets/kernel/require_local.rb +0 -31
  905. data/lib/core/facets/kernel/resc.rb +0 -16
  906. data/lib/core/facets/kernel/set_from.rb +0 -2
  907. data/lib/core/facets/module/conflict.rb +0 -62
  908. data/lib/core/facets/module/instance_methods.rb +0 -38
  909. data/lib/core/facets/module/modspace.rb +0 -22
  910. data/lib/core/facets/module/module_require.rb +0 -1
  911. data/lib/core/facets/module/nesting.rb +0 -18
  912. data/lib/core/facets/stackable.rb +0 -86
  913. data/lib/core/facets/string/chars.rb +0 -20
  914. data/lib/core/facets/symbol/re_s.rb +0 -18
  915. data/lib/core/facets/time/advance.rb +0 -18
  916. data/lib/core/facets/time/round.rb +0 -17
  917. data/lib/more/facets/ansicode.rb +0 -306
  918. data/lib/more/facets/autoarray.rb +0 -34
  919. data/lib/more/facets/autoreload.rb +0 -150
  920. data/lib/more/facets/blankslate.rb +0 -10
  921. data/lib/more/facets/casting_hash.rb +0 -172
  922. data/lib/more/facets/class_extend.rb +0 -126
  923. data/lib/more/facets/cloneable.rb +0 -76
  924. data/lib/more/facets/daemonize.rb +0 -44
  925. data/lib/more/facets/dictionary.rb +0 -430
  926. data/lib/more/facets/duration.rb +0 -286
  927. data/lib/more/facets/enumargs.rb +0 -192
  928. data/lib/more/facets/equitable.rb +0 -120
  929. data/lib/more/facets/expirable.rb +0 -54
  930. data/lib/more/facets/filelist.rb +0 -497
  931. data/lib/more/facets/hashbuilder.rb +0 -101
  932. data/lib/more/facets/hook.rb +0 -38
  933. data/lib/more/facets/ini.rb +0 -267
  934. data/lib/more/facets/instantiable.rb +0 -47
  935. data/lib/more/facets/linkedlist.rb +0 -195
  936. data/lib/more/facets/matcher.rb +0 -140
  937. data/lib/more/facets/memoize.rb +0 -1
  938. data/lib/more/facets/memoizer.rb +0 -64
  939. data/lib/more/facets/methodspace.rb +0 -146
  940. data/lib/more/facets/module/attr.rb +0 -83
  941. data/lib/more/facets/module/attr_toggler.rb +0 -59
  942. data/lib/more/facets/module/class_extend.rb +0 -3
  943. data/lib/more/facets/once.rb +0 -59
  944. data/lib/more/facets/opencascade.rb +0 -94
  945. data/lib/more/facets/opencollection.rb +0 -43
  946. data/lib/more/facets/openhash.rb +0 -39
  947. data/lib/more/facets/openmodule.rb +0 -16
  948. data/lib/more/facets/openobject.rb +0 -267
  949. data/lib/more/facets/orderedhash.rb +0 -5
  950. data/lib/more/facets/ostructable.rb +0 -209
  951. data/lib/more/facets/pathlist.rb +0 -105
  952. data/lib/more/facets/preinitialize.rb +0 -157
  953. data/lib/more/facets/prepend.rb +0 -57
  954. data/lib/more/facets/rbsystem.rb +0 -222
  955. data/lib/more/facets/registerable.rb +0 -35
  956. data/lib/more/facets/semaphore.rb +0 -92
  957. data/lib/more/facets/stash.rb +0 -181
  958. data/lib/more/facets/succ.rb +0 -44
  959. data/lib/more/facets/version.rb +0 -136
  960. data/meta/authors +0 -1
  961. data/meta/collection +0 -1
  962. data/meta/contact +0 -1
  963. data/meta/contributors +0 -48
  964. data/meta/created +0 -1
  965. data/meta/description +0 -13
  966. data/meta/homepage +0 -1
  967. data/meta/license +0 -1
  968. data/meta/loadpath +0 -2
  969. data/meta/name +0 -1
  970. data/meta/released +0 -1
  971. data/meta/repository +0 -1
  972. data/meta/sitemap +0 -4
  973. data/meta/slogan +0 -1
  974. data/meta/summary +0 -1
  975. data/meta/version +0 -1
  976. data/script/conflicts +0 -63
  977. data/script/methods +0 -49
  978. data/test/core/array/test_indexable.rb +0 -118
  979. data/test/core/array/test_recursive.rb +0 -18
  980. data/test/core/array/test_stackable.rb +0 -22
  981. data/test/core/binding/test_opvars.rb +0 -24
  982. data/test/core/class/test_cattr.rb +0 -47
  983. data/test/core/class/test_cattr_accessor.rb +0 -2
  984. data/test/core/class/test_cattr_reader.rb +0 -1
  985. data/test/core/class/test_cattr_writer.rb +0 -1
  986. data/test/core/enumerable/test_commonality.rb +0 -15
  987. data/test/core/enumerable/test_entropy.rb +0 -15
  988. data/test/core/enumerable/test_inject.rb +0 -18
  989. data/test/core/enumerable/test_probability.rb +0 -11
  990. data/test/core/enumerable/test_recursive.rb +0 -18
  991. data/test/core/enumerable/test_split.rb +0 -19
  992. data/test/core/exception/test_exception.rb +0 -17
  993. data/test/core/file/test_file.rb +0 -85
  994. data/test/core/filetest/test_filetest.rb +0 -10
  995. data/test/core/hash/test_delete.rb +0 -28
  996. data/test/core/hash/test_mash.rb +0 -20
  997. data/test/core/hash/test_merge.rb +0 -14
  998. data/test/core/hash/test_op.rb +0 -1
  999. data/test/core/hash/test_recursive.rb +0 -23
  1000. data/test/core/hash/test_to_module.rb +0 -21
  1001. data/test/core/integer/test_length.rb +0 -12
  1002. data/test/core/kernel/test_deepcopy.rb +0 -27
  1003. data/test/core/kernel/test_resc.rb +0 -12
  1004. data/test/core/module/test_conflict.rb +0 -24
  1005. data/test/core/module/test_modspace.rb +0 -13
  1006. data/test/core/module/test_nesting.rb +0 -21
  1007. data/test/core/module/test_prepend.rb +0 -29
  1008. data/test/core/string/test_chars.rb +0 -12
  1009. data/test/core/string/test_outdent.rb +0 -65
  1010. data/test/core/test_blank.rb +0 -12
  1011. data/test/core/test_boolean.rb +0 -89
  1012. data/test/core/test_functor.rb +0 -26
  1013. data/test/core/test_metaid.rb +0 -39
  1014. data/test/core/test_to_hash.rb +0 -244
  1015. data/test/core/time/test_round.rb +0 -31
  1016. data/test/more/test_ansicode.rb +0 -20
  1017. data/test/more/test_autoarray.rb +0 -18
  1018. data/test/more/test_basicobject.rb +0 -34
  1019. data/test/more/test_class_extend.rb +0 -64
  1020. data/test/more/test_cloneable.rb +0 -41
  1021. data/test/more/test_continuation.rb +0 -15
  1022. data/test/more/test_dictionary.rb +0 -145
  1023. data/test/more/test_enumargs.rb +0 -70
  1024. data/test/more/test_equitable.rb +0 -42
  1025. data/test/more/test_getoptlong.rb +0 -26
  1026. data/test/more/test_inheritor.rb +0 -148
  1027. data/test/more/test_instance_function.rb +0 -31
  1028. data/test/more/test_instantiable.rb +0 -37
  1029. data/test/more/test_memoize.rb +0 -38
  1030. data/test/more/test_methodspace.rb +0 -78
  1031. data/test/more/test_multiton.rb +0 -184
  1032. data/test/more/test_opencascade.rb +0 -61
  1033. data/test/more/test_openobject.rb +0 -112
  1034. data/test/more/test_partial.rb +0 -27
  1035. data/test/more/test_prepend.rb +0 -28
  1036. data/test/more/test_succ.rb +0 -35
@@ -1,97 +1 @@
1
- require 'facets/time/set'
2
-
3
- class Time
4
-
5
- if defined?(::ActiveSupport) && method_defined?(:since)
6
-
7
- alias_method :in, :since
8
- alias_method :hence, :since
9
-
10
- else
11
-
12
- # Returns a new Time representing the time
13
- # a number of time-units ago.
14
- #
15
- def ago(number, units=:seconds)
16
- return hence(-number, units) if number < 0
17
-
18
- time = (
19
- case units.to_s.downcase.to_sym
20
- when :years
21
- set(:year => (year - number))
22
- when :months
23
- new_month = ((month - number - 1) % 12) + 1
24
- y = (number / 12) + (new_month > month ? 1 : 0)
25
- set(:year => (year - y), :month => new_month)
26
- when :weeks
27
- self - (number * 604800)
28
- when :days
29
- self - (number * 86400)
30
- when :hours
31
- self - (number * 3600)
32
- when :minutes
33
- self - (number * 60)
34
- when :seconds, nil
35
- self - number
36
- else
37
- raise ArgumentError, "unrecognized time units -- #{units}"
38
- end
39
- )
40
- dst_adjustment(time)
41
- end
42
- #
43
- # Returns a new Time representing the time
44
- # a number of time-units hence.
45
-
46
- def hence(number, units=:seconds)
47
- return ago(-number, units) if number < 0
48
-
49
- time = (
50
- case units.to_s.downcase.to_sym
51
- when :years
52
- set( :year=>(year + number) )
53
- when :months
54
- new_month = ((month + number - 1) % 12) + 1
55
- y = (number / 12) + (new_month < month ? 1 : 0)
56
- set(:year => (year + y), :month => new_month)
57
- when :weeks
58
- self + (number * 604800)
59
- when :days
60
- self + (number * 86400)
61
- when :hours
62
- self + (number * 3600)
63
- when :minutes
64
- self + (number * 60)
65
- when :seconds
66
- self + number
67
- else
68
- raise ArgumentError, "unrecognized time units -- #{units}"
69
- end
70
- )
71
- dst_adjustment(time)
72
- end
73
-
74
- alias_method :in, :hence
75
- alias_method :since, :hence
76
-
77
- # Adjust DST
78
- #
79
- # TODO: Can't seem to get this to pass ActiveSupport tests.
80
- # Even though it is essentially identical to the
81
- # ActiveSupport code (see Time#since in time/calculations.rb).
82
- # It handles all but 4 tests.
83
- def dst_adjustment(time)
84
- self_dst = self.dst? ? 1 : 0
85
- time_dst = time.dst? ? 1 : 0
86
- seconds = (self - time).abs
87
- if (seconds >= 86400 && self_dst != time_dst)
88
- time + ((self_dst - time_dst) * 60 * 60)
89
- else
90
- time
91
- end
92
- end
93
-
94
- end
95
-
96
- end
97
-
1
+ require 'facets/time/in'
@@ -0,0 +1,93 @@
1
+ require 'facets/time/set'
2
+ require 'facets/time/dst_adjustment'
3
+
4
+ class Time
5
+
6
+ # Returns a new Time representing the time a number of
7
+ # time-units in the futue.
8
+ #
9
+ # t = Time.utc(2010,10,10,0,0,0)
10
+ #
11
+ # t.in(4, :days) #=> Time.utc(2010,10,14,0,0,0)
12
+ #
13
+ # More than one unit of time can be given.
14
+ #
15
+ # t.in(4, :days, 3, :hours) #=> Time.utc(2010,10,14,3,0,0)
16
+ #
17
+ # The #in method can also take a hash.
18
+ #
19
+ # t.in(:days=>4, :hours=>3) #=> Time.utc(2010,10,14,3,0,0)
20
+ #
21
+ def in(*time_units)
22
+ time_hash = Hash===time_units.last ? time_units.pop : {}
23
+ time_units << :seconds if time_units.size % 2 == 1
24
+ time_hash.each{ |units, number| time_units << [number, units] }
25
+ time = self
26
+ time_units.flatten.each_slice(2) do |number, units|
27
+ next time = time.ago(-number, units) if number < 0
28
+ time = (
29
+ case units.to_s.downcase.to_sym
30
+ when :years, :year
31
+ time.set( :year=>(year + number) )
32
+ when :months, :month
33
+ new_month = ((month + number - 1) % 12) + 1
34
+ y = (number / 12) + (new_month < month ? 1 : 0)
35
+ time.set(:year => (year + y), :month => new_month)
36
+ when :weeks, :week
37
+ time + (number * 604800)
38
+ when :days, :day
39
+ time + (number * 86400)
40
+ when :hours, :hour
41
+ time + (number * 3600)
42
+ when :minutes, :minute, :mins, :min
43
+ time + (number * 60)
44
+ when :seconds, :second, :secs, :sec, nil
45
+ time + number
46
+ else
47
+ raise ArgumentError, "unrecognized time units -- #{units}"
48
+ end
49
+ )
50
+ end
51
+ dst_adjustment(time)
52
+ end
53
+
54
+ # Returns a new Time representing the time
55
+ # a number of time-units ago.
56
+ #
57
+ def ago(*time_units)
58
+ time_hash = Hash===time_units.last ? time_units.pop : {}
59
+ time_units << :seconds if time_units.size % 2 == 1
60
+ time_hash.each{ |units, number| time_units << [number, units] }
61
+ time = self
62
+ time_units.each_slice(2) do |number, units|
63
+ next time = time.in(-number, units) if number < 0
64
+ time = (
65
+ case units.to_s.downcase.to_sym
66
+ when :years, :year
67
+ time.set(:year => (year - number))
68
+ when :months, :month
69
+ new_month = ((month - number - 1) % 12) + 1
70
+ y = (number / 12) + (new_month > month ? 1 : 0)
71
+ time.set(:year => (year - y), :month => new_month)
72
+ when :weeks, :week
73
+ time - (number * 604800)
74
+ when :days, :day
75
+ time - (number * 86400)
76
+ when :hours, :hour
77
+ time - (number * 3600)
78
+ when :minutes, :minute, :mins, :min
79
+ time - (number * 60)
80
+ when :seconds, :second, :secs, :sec, nil
81
+ time - number
82
+ else
83
+ raise ArgumentError, "unrecognized time units -- #{units}"
84
+ end
85
+ )
86
+ end
87
+ dst_adjustment(time)
88
+ end unless method_defined?(:ago)
89
+
90
+ # Alias for #in.
91
+ alias_method :hence, :in unless method_defined?(:hence)
92
+
93
+ end
@@ -0,0 +1,21 @@
1
+ require 'facets/time/trunc'
2
+
3
+ class Time
4
+
5
+ # Round time at the nearest range (in seconds).
6
+ #
7
+ # t1 = Time.now
8
+ # t2 = t1.round_to(60*60)
9
+ # t2.min #=> 0
10
+ # t2.sec #=> 0
11
+ #
12
+ # TODO: What about `round(:minute)`?
13
+ #
14
+ # TODO: Fractional seconds should round the usec.
15
+ #
16
+ def round_to(seconds)
17
+ (self + seconds / 2.0).trunc(seconds)
18
+ end
19
+
20
+ end
21
+
@@ -3,11 +3,17 @@ class Time
3
3
  # Like change but does not reset earlier times.
4
4
  #
5
5
  # NOTE: It would be better, probably if this were called "change".
6
- # and that #change were called "reset".
6
+ # and that #change were called "reset".
7
7
  #
8
8
  def set(options)
9
- opts={}; options.each_pair{ |k,v| opts[k] = v.to_i }
10
- self.class.send( self.utc? ? :utc : :local,
9
+ opts={}
10
+ options.each_pair do |k,v|
11
+ k = :min if k.to_s =~ /^min/
12
+ k = :sec if k.to_s =~ /^sec/
13
+ opts[k] = v.to_i
14
+ end
15
+ self.class.send(
16
+ self.utc? ? :utc : :local,
11
17
  opts[:year] || self.year,
12
18
  opts[:month] || self.month,
13
19
  opts[:day] || self.day,
@@ -27,7 +27,8 @@ class Time
27
27
 
28
28
  # Create a time stamp.
29
29
  #
30
- # Time.now.stamp(:short) #=> "01 Dec 15:15"
30
+ # t = Time.at(10000)
31
+ # t.stamp(:short) #=> "31 Dec 21:46"
31
32
  #
32
33
  # Supported formats come from the Time::FORMAT constant.
33
34
  #
@@ -9,8 +9,8 @@ class Time
9
9
  getlocal
10
10
  end
11
11
 
12
- # A method to keep Time, Date and DateTime instances interchangeable on conversions.
13
- # In this case, it simply returns +self+.
12
+ # A method to keep Time, Date and DateTime instances interchangeable
13
+ # on conversions. In this case, it simply returns +self+.
14
14
  #def to_time
15
15
  # self
16
16
  #end
@@ -3,9 +3,9 @@ class Time
3
3
  # Truncate time at give range (in seconds).
4
4
  #
5
5
  # t = Time.now
6
- # =>
7
- # t.trunc(60*60) # 1 hour
8
- # =>
6
+ # t = t.trunc(60*60)
7
+ # t.min #=> 0
8
+ # t.sec #=> 0
9
9
  #
10
10
  def trunc(amount)
11
11
  self - (self.to_i % amount)
@@ -36,12 +36,11 @@ class Array
36
36
  # This has been left in for backward compatability.
37
37
  #
38
38
  # NOTE: The use of a +values+ parameter has been deprecated
39
- # because that functionality is as simple as:
39
+ # because that functionality is as simple as ...
40
40
  #
41
41
  # array1.zip(array2).to_h
42
42
  #
43
- # CREDIT: Robert Klemme
44
- # CREDIT: Trans
43
+ # CREDIT: Robert Klemme, Trans
45
44
  #
46
45
  #--
47
46
  # The +True+ option in the case statement provides some
@@ -75,19 +74,19 @@ class Array
75
74
  # #to_h_flat.
76
75
  #
77
76
  # a = [ [:a,1], [:b,2] ]
78
- # a.to_h #=> { :a=>1, :b=>2 }
77
+ # a.to_h_auto #=> { :a=>1, :b=>2 }
79
78
  #
80
79
  # If the array contains only arrays, but are not perfect pairs,
81
80
  # then #to_h_multi is called.
82
81
  #
83
82
  # a = [ [:a,1,2], [:b,2], [:c], [:d] ]
84
- # a.to_h #=> { :a=>[1,2], :b=>[2], :c=>[], :d=>[] }
83
+ # a.to_h_auto #=> { :a=>[1,2], :b=>[2], :c=>[], :d=>[] }
85
84
  #
86
85
  # If the array contians objects other then arrays then
87
86
  # the #to_h_splat method is called.
88
87
  #
89
88
  # a = [ [:a,1,2], 2, :b, [:c,3], 9 ]
90
- # a.to_h #=> { [:a,1,2]=>2, :b=>[:c,3], 9=>nil }
89
+ # a.to_h_auto #=> { [:a,1,2]=>2, :b=>[:c,3], 9=>nil }
91
90
  #
92
91
  def to_h_auto
93
92
  pairs = true
@@ -137,9 +136,11 @@ class Array
137
136
  Hash[*a]
138
137
  end
139
138
 
139
+ #--
140
140
  #def to_h_flat
141
141
  # each_slice(2).inject({}) {|ha,(k,v)| ha[k]=v; ha}
142
142
  #end
143
+ #++
143
144
 
144
145
  # When a mixed or multi-element accociative array
145
146
  # is used, the result is as follows:
@@ -151,7 +152,7 @@ class Array
151
152
  # the value will be set to the last occuring value.
152
153
  #
153
154
  # a = [ :x, [:x], [:x,1,2], [:x,3], [:x,4] ]
154
- # a.to_h_assoc #=> { :x=>4 }
155
+ # a.to_h_assoc #=> { :x=>[4] }
155
156
  #
156
157
  def to_h_assoc
157
158
  h = {}
@@ -182,6 +183,7 @@ class Array
182
183
  h
183
184
  end
184
185
 
186
+ #--
185
187
  #def to_h_multi
186
188
  # inject({}) {|h,a| h[a.first] = a[1..-1]; h}
187
189
  #end
@@ -194,6 +196,7 @@ class Array
194
196
  # end
195
197
  # h
196
198
  #end
199
+ #++
197
200
 
198
201
  end
199
202
 
@@ -207,11 +210,10 @@ class Hash
207
210
 
208
211
  def to_h; rehash; end
209
212
 
210
- # Returns _self_.
211
- #
212
- # CREDIT: Trans
213
-
214
- def to_hash; self; end
213
+ unless method_defined?(:to_hash) # 1.9.?+
214
+ # Returns _self_.
215
+ def to_hash; self; end
216
+ end
215
217
 
216
218
  end
217
219
 
@@ -246,9 +248,11 @@ module Enumerable
246
248
  to_a.to_h_multi
247
249
  end
248
250
 
251
+ #--
249
252
  #def to_hash
250
253
  # to_a.to_hash
251
254
  #end
255
+ #++
252
256
 
253
257
  end
254
258
 
@@ -7,13 +7,13 @@ class UnboundMethod
7
7
  # Be aware that in ruby 1.9 UnboundMethod#name is defined already,
8
8
  # but it returns a Symbol not a String.
9
9
  #
10
- # class X
10
+ # class NameExample
11
11
  # def foo; end
12
12
  # end
13
13
  #
14
- # meth = X.instance_method(:foo)
14
+ # meth = NameExample.instance_method(:foo)
15
15
  #
16
- # meth.name #=> :foo
16
+ # meth.name.to_sym #=> :foo
17
17
  #
18
18
  # CREDIT: Trans
19
19
 
@@ -19,7 +19,7 @@
19
19
  # cargs.flags #=> ['a']
20
20
  # cargs.preoptions #=> {'a'=>true}
21
21
  # cargs.preflags #=> ['a']
22
- # cargs.subcommand #=> ['foo',{'b'=>'2'}]
22
+ # cargs.subcommand #=> ['foo', [], {'b'=>'2'}]
23
23
  #
24
24
  # == Authors
25
25
  #
@@ -60,7 +60,7 @@ require 'shellwords'
60
60
  # cargs.flags #=> ['a']
61
61
  # cargs.preoptions #=> {'a'=>true}
62
62
  # cargs.preflags #=> ['a']
63
- # cargs.subcommand #=> ['foo',{'b'=>'2'}]
63
+ # cargs.subcommand #=> ['foo', [], {'b'=>'2'}]
64
64
  #
65
65
  class Argvector
66
66
 
@@ -71,9 +71,9 @@ class Argvector
71
71
  attr :line
72
72
  attr :argv
73
73
  attr :arity
74
- #attr :opts
74
+ ##attr :opts
75
75
 
76
- #alias :flags :options
76
+ ##alias :flags :options
77
77
 
78
78
  # Takes the command line string (or array) and options.
79
79
  # Options have flags and end with a hash of option arity.
@@ -87,7 +87,6 @@ class Argvector
87
87
  public
88
88
 
89
89
  # Returns operand array.
90
-
91
90
  def operands
92
91
  @operands
93
92
  end
@@ -96,20 +95,17 @@ class Argvector
96
95
  alias arguments operands
97
96
 
98
97
  # Returns options hash.
99
-
100
98
  def options
101
99
  @options
102
100
  end
103
101
 
104
102
  # Returns [operands, options], which is good for plugging
105
103
  # directly into a method.
106
-
107
104
  def parameters
108
105
  return @operands, @options
109
106
  end
110
107
 
111
108
  # Return flags, which are true options.
112
-
113
109
  def flags
114
110
  f = []
115
111
  @options.each do |k, v|
@@ -123,7 +119,6 @@ class Argvector
123
119
  # Assumes the first operand is a "subcommand" and
124
120
  # returns it and the argments following it as
125
121
  # parameters.
126
-
127
122
  def subcommand_with_parameters
128
123
  opts, args = *parse_preoptions(argv)
129
124
  cmd = args.shift
@@ -163,7 +158,7 @@ class Argvector
163
158
  # cargs = Argvector.new(line)
164
159
  # opts = cargs.preoptions
165
160
  # opts #=> {"trace"=>true}
166
-
161
+ #
167
162
  def preoptions
168
163
  preopts, remainder = *parse_preoptions(argv)
169
164
  return preopts
@@ -171,7 +166,6 @@ class Argvector
171
166
 
172
167
  # Same as +flags+ but only returns flags in the
173
168
  # preoptions.
174
-
175
169
  def preflags
176
170
  preopts, remainder = *parse_preoptions(argv)
177
171
  f = []
@@ -184,7 +178,6 @@ class Argvector
184
178
  end
185
179
 
186
180
  # Like parameters but without allowing for duplicate options.
187
-
188
181
  def parameters_without_duplicates
189
182
  opts = {}
190
183
  @options.each do |k,v|
@@ -197,15 +190,16 @@ class Argvector
197
190
  return @operands, opts
198
191
  end
199
192
 
200
- private # ------------------
193
+ #private
201
194
 
202
195
  # Basic parser partitions the command line into options and
203
196
  # operands. Options are converted to a hash and the two
204
197
  # parts are returned.
205
198
  #
206
199
  # line = "--trace stamp --file=VERSION"
200
+ # argv = Argvector.new(line)
207
201
  #
208
- # args, keys = *parse_command(line)
202
+ # args, keys = *argv.parse
209
203
  #
210
204
  # args #=> ["stamp"]
211
205
  # keys #=> {"trace"=>true, "file"=>"VERSION"}
@@ -223,7 +217,6 @@ class Argvector
223
217
 
224
218
  # First pass parser to split the command line into an
225
219
  # array using Shellwords, if not already so divided.
226
-
227
220
  def parse_line(line=nil)
228
221
  if line
229
222
  case line
@@ -240,16 +233,15 @@ class Argvector
240
233
  return line, argv
241
234
  end
242
235
 
243
- # Ensure opts are a uniform.
244
- #
245
- #def clean_opts( opts )
246
- # opts2 = opts.collect{ |o| o.to_sym }
247
- # opts2 = opts2 & [:simple, :repeat] # valid options only
248
- # return opts2
249
- #end
236
+ ## Ensure opts are a uniform.
237
+ ##
238
+ ##def clean_opts( opts )
239
+ ## opts2 = opts.collect{ |o| o.to_sym }
240
+ ## opts2 = opts2 & [:simple, :repeat] # valid options only
241
+ ## return opts2
242
+ ##end
250
243
 
251
244
  # Ensure arity is uniform.
252
-
253
245
  def parse_arity(arity)
254
246
  arity2 = {}
255
247
  arity.each{ |k,v| arity2[k.to_s] = v.to_i }
@@ -258,9 +250,8 @@ class Argvector
258
250
 
259
251
  # Parse preoptions. A "preoption" is one that
260
252
  # occurs before the first operans (if any).
261
-
262
253
  def parse_preoptions(args)
263
- #args = args.dup
254
+ ##args = args.dup
264
255
  args = multi_flag(args) #unless opts.include?(:simple)
265
256
 
266
257
  flags = []
@@ -283,18 +274,18 @@ class Argvector
283
274
  return flags, args
284
275
  end
285
276
 
286
- # Parse flags takes the command line and
287
- # transforms it such that flags (eg. -x and --x)
288
- # are elemental associative arrays.
277
+ # Parse flags takes the command line and transforms it such that
278
+ # flags (eg. -x and --x) are elemental associative arrays.
289
279
  #
290
280
  # line = "--foo hello --try=this"
281
+ # argv = Argvector.new(line)
291
282
  #
292
- # parse_flags(line) #=> [ [foo,true], hello, ["try","this"] ]
283
+ # args = line.split(/\s/)
284
+ # argv.assoc_options(args) #=> [ ["foo",true], "hello", ["try","this"] ]
293
285
  #
294
286
  def assoc_options(args)
295
- #args = args.dup
287
+ ##args = args.dup
296
288
  args = multi_flag(args) #unless opts.include?(:simple)
297
-
298
289
  i = 0
299
290
  while i < args.size
300
291
  arg = args[i]
@@ -322,7 +313,6 @@ class Argvector
322
313
 
323
314
  # Split single letter option groupings into separate options.
324
315
  # ie. -xyz => -x -y -z
325
-
326
316
  def multi_flag(args=nil)
327
317
  args ||= argv
328
318
  args.collect { |arg|
@@ -336,7 +326,6 @@ class Argvector
336
326
 
337
327
  # Format flag options. This converts the associative array of
338
328
  # options/flags into a hash. Repeat options will be placed in arrays.
339
-
340
329
  def format_options(assoc_options)
341
330
  opts = {}
342
331
  assoc_options.each do |k,v|
@@ -351,3 +340,4 @@ class Argvector
351
340
 
352
341
  end
353
342
 
343
+ ArgVector = Argvector