facets 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (1077) hide show
  1. data/AUTHORS +5 -2
  2. data/ProjectInfo +21 -12
  3. data/README +73 -44
  4. data/Rakefile +11 -11
  5. data/data/facets/index.yml +1 -0
  6. data/lib/facet/annotation.rb +1 -0
  7. data/lib/facet/ansicode.rb +1 -0
  8. data/lib/facet/array.rb +1 -34
  9. data/lib/facet/array/at_rand.rb +1 -52
  10. data/lib/facet/array/body.rb +1 -2
  11. data/lib/facet/array/delete_unless.rb +1 -35
  12. data/lib/facet/array/delete_values.rb +1 -38
  13. data/lib/facet/array/delete_values_at.rb +1 -57
  14. data/lib/facet/array/each_with_key.rb +1 -9
  15. data/lib/facet/array/first.rb +1 -84
  16. data/lib/facet/array/foot.rb +1 -2
  17. data/lib/facet/array/head.rb +1 -80
  18. data/lib/facet/array/last.rb +1 -2
  19. data/lib/facet/array/last_index.rb +1 -35
  20. data/lib/facet/array/merge.rb +1 -40
  21. data/lib/facet/array/mid.rb +1 -50
  22. data/lib/facet/array/middle.rb +1 -45
  23. data/lib/facet/array/op_fetch.rb +1 -40
  24. data/lib/facet/array/op_mod.rb +1 -16
  25. data/lib/facet/array/op_store.rb +1 -47
  26. data/lib/facet/array/pick.rb +1 -68
  27. data/lib/facet/array/pos.rb +1 -39
  28. data/lib/facet/array/pull.rb +1 -37
  29. data/lib/facet/array/rand_index.rb +1 -30
  30. data/lib/facet/array/rand_subset.rb +1 -56
  31. data/lib/facet/array/range.rb +1 -47
  32. data/lib/facet/array/rotate.rb +1 -67
  33. data/lib/facet/array/select.rb +1 -37
  34. data/lib/facet/array/shuffle.rb +1 -66
  35. data/lib/facet/array/slap.rb +1 -37
  36. data/lib/facet/array/store.rb +1 -7
  37. data/lib/facet/array/tail.rb +1 -2
  38. data/lib/facet/array/thru.rb +1 -38
  39. data/lib/facet/array/to_b.rb +1 -31
  40. data/lib/facet/array/to_h.rb +1 -57
  41. data/lib/facet/array/to_hash.rb +1 -46
  42. data/lib/facet/array/unzip.rb +1 -20
  43. data/lib/facet/association.rb +1 -0
  44. data/lib/facet/basicobject.rb +1 -0
  45. data/lib/facet/bbcode.rb +1 -0
  46. data/lib/facet/binaryreader.rb +1 -0
  47. data/lib/facet/binding.rb +1 -14
  48. data/lib/facet/binding/__DIR__.rb +1 -2
  49. data/lib/facet/binding/__FILE__.rb +1 -2
  50. data/lib/facet/binding/__LINE__.rb +1 -58
  51. data/lib/facet/binding/call_stack.rb +1 -42
  52. data/lib/facet/binding/called.rb +1 -41
  53. data/lib/facet/binding/caller.rb +1 -42
  54. data/lib/facet/binding/defined.rb +1 -41
  55. data/lib/facet/binding/eval.rb +1 -42
  56. data/lib/facet/binding/local_variables.rb +1 -45
  57. data/lib/facet/binding/method_name.rb +1 -48
  58. data/lib/facet/binding/op_fetch.rb +1 -45
  59. data/lib/facet/binding/op_store.rb +1 -46
  60. data/lib/facet/binding/self.rb +1 -41
  61. data/lib/facet/binding/self/of_caller.rb +1 -122
  62. data/lib/facet/bitmask.rb +1 -0
  63. data/lib/facet/blankslate.rb +1 -0
  64. data/lib/facet/bytes.rb +1 -0
  65. data/lib/facet/class.rb +1 -7
  66. data/lib/facet/class/by_name.rb +1 -1
  67. data/lib/facet/class/descendents.rb +1 -44
  68. data/lib/facet/class/method_name.rb +1 -33
  69. data/lib/facet/class/remove_descendents.rb +1 -46
  70. data/lib/facet/class/remove_subclasses.rb +1 -2
  71. data/lib/facet/class/subclasses.rb +1 -2
  72. data/lib/facet/class/unix_path.rb +1 -34
  73. data/lib/facet/classinherit.rb +1 -0
  74. data/lib/facet/classmethods.rb +1 -0
  75. data/lib/facet/cloneable.rb +1 -0
  76. data/lib/facet/comparable.rb +1 -5
  77. data/lib/facet/comparable/at_least.rb +1 -53
  78. data/lib/facet/comparable/at_most.rb +1 -2
  79. data/lib/facet/comparable/cap.rb +1 -2
  80. data/lib/facet/comparable/clip.rb +1 -72
  81. data/lib/facet/comparable/cmp.rb +1 -38
  82. data/lib/facet/consoleapp.rb +1 -0
  83. data/lib/facet/continuation.rb +1 -1
  84. data/lib/facet/continuation/self/create.rb +1 -71
  85. data/lib/facet/coroutine.rb +1 -0
  86. data/lib/facet/crypt.rb +1 -0
  87. data/lib/facet/date.rb +1 -0
  88. data/lib/facet/date/days_in_month.rb +1 -42
  89. data/lib/facet/date/days_of_month.rb +1 -34
  90. data/lib/facet/date/stamp.rb +1 -52
  91. data/lib/facet/date/to_date.rb +1 -36
  92. data/lib/facet/date/to_s.rb +1 -33
  93. data/lib/facet/date/to_time.rb +1 -36
  94. data/lib/facet/dictionary.rb +1 -0
  95. data/lib/facet/dir.rb +1 -4
  96. data/lib/facet/dir/self/ancestor.rb +1 -33
  97. data/lib/facet/dir/self/ascend.rb +1 -56
  98. data/lib/facet/dir/self/ls_r.rb +1 -76
  99. data/lib/facet/dir/self/recurse.rb +1 -2
  100. data/lib/facet/downloader.rb +1 -0
  101. data/lib/facet/enumerable.rb +1 -39
  102. data/lib/facet/enumerable/collect_with_counter.rb +1 -2
  103. data/lib/facet/enumerable/collect_with_index.rb +1 -51
  104. data/lib/facet/enumerable/commonality.rb +1 -63
  105. data/lib/facet/enumerable/compact_collect.rb +1 -50
  106. data/lib/facet/enumerable/compact_map.rb +1 -2
  107. data/lib/facet/enumerable/cross.rb +1 -44
  108. data/lib/facet/enumerable/each_by.rb +1 -2
  109. data/lib/facet/enumerable/each_combination.rb +1 -59
  110. data/lib/facet/enumerable/each_pair.rb +1 -50
  111. data/lib/facet/enumerable/each_permutation.rb +1 -2
  112. data/lib/facet/enumerable/each_slice.rb +1 -131
  113. data/lib/facet/enumerable/each_unique_pair.rb +1 -66
  114. data/lib/facet/enumerable/each_with_counter.rb +1 -8
  115. data/lib/facet/enumerable/elementwise.rb +1 -2
  116. data/lib/facet/enumerable/entropy.rb +1 -52
  117. data/lib/facet/enumerable/every.rb +1 -65
  118. data/lib/facet/enumerable/ew.rb +1 -64
  119. data/lib/facet/enumerable/filter_collect.rb +1 -58
  120. data/lib/facet/enumerable/filter_map.rb +1 -2
  121. data/lib/facet/enumerable/find_collisions.rb +1 -41
  122. data/lib/facet/enumerable/frequency.rb +1 -39
  123. data/lib/facet/enumerable/graph.rb +1 -59
  124. data/lib/facet/enumerable/ideal_entropy.rb +1 -49
  125. data/lib/facet/enumerable/map_with_counter.rb +1 -2
  126. data/lib/facet/enumerable/map_with_index.rb +1 -2
  127. data/lib/facet/enumerable/none.rb +1 -56
  128. data/lib/facet/enumerable/nonuniq.rb +1 -39
  129. data/lib/facet/enumerable/occur.rb +1 -62
  130. data/lib/facet/enumerable/one.rb +1 -65
  131. data/lib/facet/enumerable/op_pow.rb +1 -38
  132. data/lib/facet/enumerable/partition_by.rb +1 -55
  133. data/lib/facet/enumerable/permute.rb +1 -135
  134. data/lib/facet/enumerable/probability.rb +1 -59
  135. data/lib/facet/enumerable/project.rb +1 -11
  136. data/lib/facet/enumerable/self/combinations.rb +1 -68
  137. data/lib/facet/enumerable/self/cross.rb +1 -79
  138. data/lib/facet/enumerable/to_h.rb +1 -50
  139. data/lib/facet/enumerable/uniq_by.rb +1 -39
  140. data/lib/facet/enumerable/where.rb +1 -12
  141. data/lib/facet/enumerablepass.rb +1 -0
  142. data/lib/facet/expirable.rb +1 -0
  143. data/lib/facet/file.rb +1 -5
  144. data/lib/facet/file/self/create.rb +1 -52
  145. data/lib/facet/file/self/open_as_string.rb +1 -81
  146. data/lib/facet/file/self/read_list.rb +1 -47
  147. data/lib/facet/file/self/sanitize.rb +1 -50
  148. data/lib/facet/file/self/split_all.rb +1 -36
  149. data/lib/facet/filelist.rb +1 -0
  150. data/lib/facet/fileutils.rb +1 -0
  151. data/lib/facet/fileutils/head.rb +1 -2
  152. data/lib/facet/fileutils/safe_ln.rb +1 -38
  153. data/lib/facet/fileutils/slice.rb +1 -152
  154. data/lib/facet/fileutils/split_all.rb +1 -29
  155. data/lib/facet/fileutils/tail.rb +1 -2
  156. data/lib/facet/fileutils/wc.rb +1 -128
  157. data/lib/facet/fileutils/whereis.rb +1 -76
  158. data/lib/facet/fileutils/which.rb +1 -117
  159. data/lib/facet/float.rb +1 -3
  160. data/lib/facet/float/approx.rb +1 -42
  161. data/lib/facet/float/round_at.rb +1 -72
  162. data/lib/facet/float/round_to.rb +1 -73
  163. data/lib/facet/floatstring.rb +1 -0
  164. data/lib/facet/functor.rb +1 -41
  165. data/lib/facet/gem.rb +1 -3
  166. data/lib/facet/gem/self/active.rb +1 -9
  167. data/lib/facet/gem/self/gempath.rb +1 -10
  168. data/lib/facet/gem/self/gemspec.rb +1 -10
  169. data/lib/facet/hash.rb +1 -40
  170. data/lib/facet/hash/alias.rb +1 -54
  171. data/lib/facet/hash/assert_has_keys.rb +1 -38
  172. data/lib/facet/hash/assert_has_only_keys.rb +1 -38
  173. data/lib/facet/hash/at.rb +1 -26
  174. data/lib/facet/hash/collate.rb +1 -53
  175. data/lib/facet/hash/delete_unless.rb +1 -15
  176. data/lib/facet/hash/each.rb +1 -61
  177. data/lib/facet/hash/each_with_index.rb +1 -35
  178. data/lib/facet/hash/each_with_key.rb +1 -32
  179. data/lib/facet/hash/graph.rb +1 -31
  180. data/lib/facet/hash/has_keys.rb +1 -37
  181. data/lib/facet/hash/has_only_keys.rb +1 -37
  182. data/lib/facet/hash/inverse.rb +1 -51
  183. data/lib/facet/hash/join.rb +1 -19
  184. data/lib/facet/hash/keys_to_iv.rb +1 -60
  185. data/lib/facet/hash/keys_to_s.rb +1 -80
  186. data/lib/facet/hash/keys_to_sym.rb +1 -91
  187. data/lib/facet/hash/op_fetch.rb +1 -146
  188. data/lib/facet/hash/op_lshift.rb +1 -28
  189. data/lib/facet/hash/op_store.rb +1 -2
  190. data/lib/facet/hash/rand_key.rb +1 -47
  191. data/lib/facet/hash/rand_pair.rb +1 -50
  192. data/lib/facet/hash/rand_value.rb +1 -60
  193. data/lib/facet/hash/replace_each.rb +1 -33
  194. data/lib/facet/hash/self/zipnew.rb +1 -37
  195. data/lib/facet/hash/shuffle.rb +1 -53
  196. data/lib/facet/hash/slice.rb +1 -33
  197. data/lib/facet/hash/stringify_keys.rb +1 -2
  198. data/lib/facet/hash/swap.rb +1 -36
  199. data/lib/facet/hash/swapkey.rb +1 -44
  200. data/lib/facet/hash/symoblize_keys.rb +1 -2
  201. data/lib/facet/hash/to_h.rb +1 -35
  202. data/lib/facet/hash/to_ostruct.rb +1 -40
  203. data/lib/facet/hash/to_ostruct_recurse.rb +1 -45
  204. data/lib/facet/hash/traverse.rb +1 -63
  205. data/lib/facet/hash/update_each.rb +1 -43
  206. data/lib/facet/hash/update_keys.rb +1 -31
  207. data/lib/facet/hash/update_values.rb +1 -32
  208. data/lib/facet/hash/variablize_keys.rb +1 -2
  209. data/lib/facet/hash/weave.rb +1 -88
  210. data/lib/facet/heap.rb +1 -0
  211. data/lib/facet/inflect.rb +1 -70
  212. data/lib/facet/inheritor.rb +1 -0
  213. data/lib/facet/integer.rb +1 -9
  214. data/lib/facet/integer/even.rb +1 -2
  215. data/lib/facet/integer/fac.rb +1 -2
  216. data/lib/facet/integer/fact.rb +1 -2
  217. data/lib/facet/integer/factorial.rb +1 -61
  218. data/lib/facet/integer/multiple.rb +1 -69
  219. data/lib/facet/integer/odd.rb +1 -2
  220. data/lib/facet/integer/ordinal.rb +1 -41
  221. data/lib/facet/integer/times_collect.rb +1 -39
  222. data/lib/facet/integer/times_map.rb +1 -2
  223. data/lib/facet/interval.rb +1 -0
  224. data/lib/facet/ioredirect.rb +1 -0
  225. data/lib/facet/kernel.rb +1 -68
  226. data/lib/facet/kernel/__DIR__.rb +1 -11
  227. data/lib/facet/kernel/__class__.rb +1 -31
  228. data/lib/facet/kernel/__meta__.rb +1 -28
  229. data/lib/facet/kernel/adhoc.rb +1 -11
  230. data/lib/facet/kernel/as.rb +1 -91
  231. data/lib/facet/kernel/assign_from.rb +1 -82
  232. data/lib/facet/kernel/assign_with.rb +1 -75
  233. data/lib/facet/kernel/autoreload.rb +1 -124
  234. data/lib/facet/kernel/autoreload_files.rb +1 -2
  235. data/lib/facet/kernel/autoreload_glob.rb +1 -3
  236. data/lib/facet/kernel/bool.rb +1 -77
  237. data/lib/facet/kernel/bug.rb +1 -39
  238. data/lib/facet/kernel/call_stack.rb +1 -59
  239. data/lib/facet/kernel/called.rb +1 -40
  240. data/lib/facet/kernel/complete.rb +1 -6
  241. data/lib/facet/kernel/constant.rb +1 -52
  242. data/lib/facet/kernel/copy.rb +1 -48
  243. data/lib/facet/kernel/deep_copy.rb +1 -49
  244. data/lib/facet/kernel/demo.rb +1 -46
  245. data/lib/facet/kernel/eigenclass.rb +1 -17
  246. data/lib/facet/kernel/false.rb +1 -2
  247. data/lib/facet/kernel/fn.rb +1 -33
  248. data/lib/facet/kernel/generate_method_name.rb +1 -39
  249. data/lib/facet/kernel/get_by_id.rb +1 -33
  250. data/lib/facet/kernel/here.rb +1 -34
  251. data/lib/facet/kernel/in.rb +1 -35
  252. data/lib/facet/kernel/instance_assign.rb +1 -25
  253. data/lib/facet/kernel/instvar.rb +1 -13
  254. data/lib/facet/kernel/is.rb +1 -5
  255. data/lib/facet/kernel/maybe.rb +1 -41
  256. data/lib/facet/kernel/me.rb +1 -17
  257. data/lib/facet/kernel/meta.rb +1 -2
  258. data/lib/facet/kernel/metaclass.rb +1 -42
  259. data/lib/facet/kernel/method.rb +1 -76
  260. data/lib/facet/kernel/method_name.rb +1 -49
  261. data/lib/facet/kernel/methods.rb +1 -79
  262. data/lib/facet/kernel/nack.rb +1 -12
  263. data/lib/facet/kernel/new.rb +1 -40
  264. data/lib/facet/kernel/object_class.rb +1 -31
  265. data/lib/facet/kernel/object_hexid.rb +1 -35
  266. data/lib/facet/kernel/op_esc.rb +1 -37
  267. data/lib/facet/kernel/own.rb +1 -17
  268. data/lib/facet/kernel/p.rb +1 -12
  269. data/lib/facet/kernel/require_all.rb +1 -44
  270. data/lib/facet/kernel/require_esc.rb +1 -42
  271. data/lib/facet/kernel/require_facet.rb +1 -41
  272. data/lib/facet/kernel/require_local.rb +1 -25
  273. data/lib/facet/kernel/resc.rb +1 -32
  274. data/lib/facet/kernel/returning.rb +1 -49
  275. data/lib/facet/kernel/send_as.rb +1 -34
  276. data/lib/facet/kernel/set_from.rb +1 -69
  277. data/lib/facet/kernel/set_with.rb +1 -74
  278. data/lib/facet/kernel/silence_warnings.rb +1 -2
  279. data/lib/facet/kernel/silently.rb +1 -41
  280. data/lib/facet/kernel/singleton.rb +1 -47
  281. data/lib/facet/kernel/superior.rb +1 -53
  282. data/lib/facet/kernel/supermethod.rb +1 -44
  283. data/lib/facet/kernel/this.rb +1 -33
  284. data/lib/facet/kernel/to_b.rb +1 -41
  285. data/lib/facet/kernel/to_bool.rb +1 -47
  286. data/lib/facet/kernel/true.rb +1 -2
  287. data/lib/facet/kernel/unuri.rb +1 -2
  288. data/lib/facet/kernel/uri.rb +1 -38
  289. data/lib/facet/kernel/val.rb +1 -52
  290. data/lib/facet/kernel/warn_with_line.rb +1 -30
  291. data/lib/facet/kernel/with_accessor.rb +1 -94
  292. data/lib/facet/kernel/with_reader.rb +1 -2
  293. data/lib/facet/kernel/with_writer.rb +1 -2
  294. data/lib/facet/lisp.rb +1 -0
  295. data/lib/facet/lisp_format.rb +1 -0
  296. data/lib/facet/logger.rb +1 -0
  297. data/lib/facet/logger/format.rb +1 -28
  298. data/lib/facet/logger/format_message.rb +1 -1
  299. data/lib/facet/lrucache.rb +1 -0
  300. data/lib/facet/matchdata.rb +1 -3
  301. data/lib/facet/matchdata/match.rb +1 -37
  302. data/lib/facet/matchdata/matchset.rb +1 -2
  303. data/lib/facet/matchdata/matchtree.rb +1 -62
  304. data/lib/facet/mathconstants.rb +1 -0
  305. data/lib/facet/methodprobe.rb +1 -0
  306. data/lib/facet/mock.rb +1 -0
  307. data/lib/facet/module.rb +1 -40
  308. data/lib/facet/module/abstract.rb +1 -50
  309. data/lib/facet/module/alias_module_function.rb +1 -57
  310. data/lib/facet/module/ancestor.rb +1 -38
  311. data/lib/facet/module/attr.rb +1 -23
  312. data/lib/facet/module/attr_setter.rb +1 -48
  313. data/lib/facet/module/attr_tester.rb +1 -56
  314. data/lib/facet/module/basename.rb +1 -39
  315. data/lib/facet/module/by_name.rb +1 -68
  316. data/lib/facet/module/cattr_accessor.rb +1 -141
  317. data/lib/facet/module/cattr_reader.rb +1 -2
  318. data/lib/facet/module/cattr_writer.rb +1 -2
  319. data/lib/facet/module/clone_removing.rb +1 -2
  320. data/lib/facet/module/clone_renaming.rb +1 -2
  321. data/lib/facet/module/clone_using.rb +1 -87
  322. data/lib/facet/module/dirname.rb +1 -42
  323. data/lib/facet/module/equate_on.rb +1 -70
  324. data/lib/facet/module/generate_instance_method_name.rb +1 -47
  325. data/lib/facet/module/include_as.rb +1 -102
  326. data/lib/facet/module/initializer.rb +1 -65
  327. data/lib/facet/module/instance_methods.rb +1 -186
  328. data/lib/facet/module/integrate.rb +1 -51
  329. data/lib/facet/module/is.rb +1 -34
  330. data/lib/facet/module/memoize.rb +1 -95
  331. data/lib/facet/module/modspace.rb +1 -43
  332. data/lib/facet/module/namespace.rb +1 -61
  333. data/lib/facet/module/nesting.rb +1 -45
  334. data/lib/facet/module/redef.rb +1 -31
  335. data/lib/facet/module/redefine_method.rb +1 -57
  336. data/lib/facet/module/redirect.rb +1 -30
  337. data/lib/facet/module/redirect_method.rb +1 -64
  338. data/lib/facet/module/remove.rb +1 -29
  339. data/lib/facet/module/rename.rb +1 -31
  340. data/lib/facet/module/rename_method.rb +1 -38
  341. data/lib/facet/module/revisal.rb +1 -49
  342. data/lib/facet/module/shadow_all.rb +1 -17
  343. data/lib/facet/module/shadow_method.rb +1 -42
  344. data/lib/facet/module/sort_on.rb +1 -73
  345. data/lib/facet/module/undef.rb +1 -29
  346. data/lib/facet/module/wrap.rb +1 -30
  347. data/lib/facet/module/wrap_method.rb +1 -48
  348. data/lib/facet/multipliers.rb +1 -0
  349. data/lib/facet/multiton.rb +1 -0
  350. data/lib/facet/nackclass.rb +1 -0
  351. data/lib/facet/nil_as_emptiness.rb +1 -34
  352. data/lib/facet/nilclass.rb +1 -7
  353. data/lib/facet/nilclass/empty.rb +1 -32
  354. data/lib/facet/nilclass/include.rb +1 -32
  355. data/lib/facet/nilclass/length.rb +1 -2
  356. data/lib/facet/nilclass/op_fetch.rb +1 -37
  357. data/lib/facet/nilclass/size.rb +1 -44
  358. data/lib/facet/nilclass/to_f.rb +1 -32
  359. data/lib/facet/nilclass/to_h.rb +1 -33
  360. data/lib/facet/nilcomparable.rb +1 -0
  361. data/lib/facet/nullclass.rb +1 -0
  362. data/lib/facet/numeric.rb +1 -5
  363. data/lib/facet/numeric/ceil_multiple.rb +1 -40
  364. data/lib/facet/numeric/pred.rb +1 -2
  365. data/lib/facet/numeric/succ.rb +1 -69
  366. data/lib/facet/numeric/to_b.rb +1 -38
  367. data/lib/facet/one.rb +1 -0
  368. data/lib/facet/openobject.rb +1 -0
  369. data/lib/facet/orderedhash.rb +1 -0
  370. data/lib/facet/ormsupport.rb +1 -0
  371. data/lib/facet/ostruct.rb +1 -0
  372. data/lib/facet/ostruct/__merge__.rb +1 -52
  373. data/lib/facet/ostruct/__table__.rb +1 -17
  374. data/lib/facet/ostruct/__update__.rb +1 -45
  375. data/lib/facet/ostruct/op_fetch.rb +1 -40
  376. data/lib/facet/ostruct/op_store.rb +1 -42
  377. data/lib/facet/ostruct/to_h.rb +1 -8
  378. data/lib/facet/overload.rb +1 -0
  379. data/lib/facet/paramix.rb +1 -0
  380. data/lib/facet/pathlist.rb +1 -0
  381. data/lib/facet/pathname.rb +1 -2
  382. data/lib/facet/pathname/ascend.rb +1 -22
  383. data/lib/facet/pathname/descend.rb +1 -20
  384. data/lib/facet/pool.rb +1 -0
  385. data/lib/facet/preinitialize.rb +1 -0
  386. data/lib/facet/proc.rb +1 -3
  387. data/lib/facet/proc/compose.rb +1 -62
  388. data/lib/facet/proc/op_mul.rb +1 -2
  389. data/lib/facet/proc/to_method.rb +1 -74
  390. data/lib/facet/progressbar.rb +1 -0
  391. data/lib/facet/promoteself.rb +1 -0
  392. data/lib/facet/quaternion.rb +1 -0
  393. data/lib/facet/random.rb +1 -21
  394. data/lib/facet/range.rb +1 -4
  395. data/lib/facet/range/to_r.rb +1 -32
  396. data/lib/facet/range/to_range.rb +1 -36
  397. data/lib/facet/range/umbrella.rb +1 -67
  398. data/lib/facet/range/within.rb +1 -44
  399. data/lib/facet/reference.rb +1 -0
  400. data/lib/facet/regexp.rb +1 -3
  401. data/lib/facet/regexp/arity.rb +1 -41
  402. data/lib/facet/regexp/to_re.rb +1 -38
  403. data/lib/facet/regexp/to_regexp.rb +1 -36
  404. data/lib/facet/rtals.rb +1 -0
  405. data/lib/facet/semaphore.rb +1 -0
  406. data/lib/facet/snapshot.rb +1 -0
  407. data/lib/facet/stateparser.rb +1 -0
  408. data/lib/facet/statichash.rb +1 -0
  409. data/lib/facet/string.rb +1 -91
  410. data/lib/facet/string/align_center.rb +1 -87
  411. data/lib/facet/string/align_left.rb +1 -2
  412. data/lib/facet/string/align_right.rb +1 -2
  413. data/lib/facet/string/at.rb +1 -8
  414. data/lib/facet/string/at_rand.rb +1 -65
  415. data/lib/facet/string/basename.rb +1 -48
  416. data/lib/facet/string/blank.rb +1 -36
  417. data/lib/facet/string/bracket.rb +1 -70
  418. data/lib/facet/string/brief.rb +1 -33
  419. data/lib/facet/string/bytes.rb +1 -19
  420. data/lib/facet/string/camelcase.rb +1 -58
  421. data/lib/facet/string/camelize.rb +1 -35
  422. data/lib/facet/string/capitalized.rb +1 -38
  423. data/lib/facet/string/chars.rb +1 -34
  424. data/lib/facet/string/cmp.rb +1 -43
  425. data/lib/facet/string/demodulize.rb +1 -40
  426. data/lib/facet/string/dequote.rb +1 -29
  427. data/lib/facet/string/downcase.rb +1 -37
  428. data/lib/facet/string/dresner.rb +1 -49
  429. data/lib/facet/string/each_char.rb +1 -35
  430. data/lib/facet/string/each_word.rb +1 -50
  431. data/lib/facet/string/ends_with.rb +1 -2
  432. data/lib/facet/string/first.rb +1 -94
  433. data/lib/facet/string/first_char.rb +1 -20
  434. data/lib/facet/string/fold.rb +1 -67
  435. data/lib/facet/string/format.rb +1 -17
  436. data/lib/facet/string/frequency.rb +1 -39
  437. data/lib/facet/string/humanize.rb +1 -31
  438. data/lib/facet/string/indent.rb +1 -68
  439. data/lib/facet/string/index_all.rb +1 -40
  440. data/lib/facet/string/last.rb +1 -94
  441. data/lib/facet/string/last_char.rb +1 -22
  442. data/lib/facet/string/line_wrap.rb +1 -77
  443. data/lib/facet/string/lines.rb +1 -33
  444. data/lib/facet/string/lowercase.rb +1 -32
  445. data/lib/facet/string/margin.rb +1 -138
  446. data/lib/facet/string/methodize.rb +1 -44
  447. data/lib/facet/string/modulize.rb +1 -44
  448. data/lib/facet/string/mscan.rb +1 -42
  449. data/lib/facet/string/natcmp.rb +1 -108
  450. data/lib/facet/string/nchar.rb +1 -45
  451. data/lib/facet/string/ordinal.rb +1 -16
  452. data/lib/facet/string/pathize.rb +1 -46
  453. data/lib/facet/string/plural.rb +1 -2
  454. data/lib/facet/string/pop.rb +1 -54
  455. data/lib/facet/string/probability.rb +1 -34
  456. data/lib/facet/string/pull.rb +1 -17
  457. data/lib/facet/string/push.rb +1 -44
  458. data/lib/facet/string/quote.rb +1 -68
  459. data/lib/facet/string/rand_byte.rb +1 -55
  460. data/lib/facet/string/rand_index.rb +1 -29
  461. data/lib/facet/string/range.rb +1 -37
  462. data/lib/facet/string/range_all.rb +1 -48
  463. data/lib/facet/string/range_of_line.rb +1 -42
  464. data/lib/facet/string/regesc.rb +1 -32
  465. data/lib/facet/string/self/format.rb +1 -17
  466. data/lib/facet/string/self/interpolate.rb +1 -31
  467. data/lib/facet/string/self/patterns.rb +1 -51
  468. data/lib/facet/string/self/rand_letter.rb +1 -34
  469. data/lib/facet/string/self/random.rb +1 -37
  470. data/lib/facet/string/shatter.rb +1 -45
  471. data/lib/facet/string/shell_escape.rb +1 -0
  472. data/lib/facet/string/shift.rb +1 -42
  473. data/lib/facet/string/shuffle.rb +1 -42
  474. data/lib/facet/string/similarity.rb +1 -108
  475. data/lib/facet/string/singular.rb +1 -117
  476. data/lib/facet/string/slap.rb +1 -44
  477. data/lib/facet/string/soundex.rb +1 -102
  478. data/lib/facet/string/starts_with.rb +1 -24
  479. data/lib/facet/string/succ.rb +1 -38
  480. data/lib/facet/string/tab.rb +1 -2
  481. data/lib/facet/string/tabto.rb +1 -2
  482. data/lib/facet/string/to_a.rb +1 -35
  483. data/lib/facet/string/to_arr.rb +1 -55
  484. data/lib/facet/string/to_b.rb +1 -64
  485. data/lib/facet/string/to_const.rb +1 -39
  486. data/lib/facet/string/to_date.rb +1 -35
  487. data/lib/facet/string/to_proc.rb +1 -54
  488. data/lib/facet/string/to_re.rb +1 -46
  489. data/lib/facet/string/to_rx.rb +1 -2
  490. data/lib/facet/string/to_time.rb +1 -34
  491. data/lib/facet/string/unbracket.rb +1 -46
  492. data/lib/facet/string/underscore.rb +1 -18
  493. data/lib/facet/string/unix_crypt.rb +1 -41
  494. data/lib/facet/string/unpack.rb +1 -45
  495. data/lib/facet/string/unshift.rb +1 -42
  496. data/lib/facet/string/upcase.rb +1 -45
  497. data/lib/facet/string/uppercase.rb +1 -2
  498. data/lib/facet/string/whitespace.rb +1 -27
  499. data/lib/facet/string/word_filter.rb +1 -61
  500. data/lib/facet/string/word_wrap.rb +1 -90
  501. data/lib/facet/string/words.rb +1 -45
  502. data/lib/facet/string_as_array.rb +1 -16
  503. data/lib/facet/symbol.rb +1 -13
  504. data/lib/facet/symbol/camelcase.rb +1 -42
  505. data/lib/facet/symbol/camelize.rb +1 -33
  506. data/lib/facet/symbol/capitalize.rb +1 -31
  507. data/lib/facet/symbol/capitalized.rb +1 -33
  508. data/lib/facet/symbol/downcase.rb +1 -36
  509. data/lib/facet/symbol/not.rb +1 -40
  510. data/lib/facet/symbol/pad.rb +1 -43
  511. data/lib/facet/symbol/succ.rb +1 -42
  512. data/lib/facet/symbol/to_const.rb +1 -40
  513. data/lib/facet/symbol/to_proc.rb +1 -45
  514. data/lib/facet/symbol/to_str.rb +1 -39
  515. data/lib/facet/symbol/underscore.rb +1 -32
  516. data/lib/facet/symbol/upcase.rb +1 -37
  517. data/lib/facet/syncarray.rb +1 -0
  518. data/lib/facet/synchash.rb +1 -0
  519. data/lib/facet/system.rb +1 -0
  520. data/lib/facet/tagiterator.rb +1 -0
  521. data/lib/facet/time.rb +1 -8
  522. data/lib/facet/time/change.rb +1 -51
  523. data/lib/facet/time/elapse.rb +1 -41
  524. data/lib/facet/time/self/days_extrema.rb +1 -22
  525. data/lib/facet/time/self/stamp.rb +1 -2
  526. data/lib/facet/time/stamp.rb +1 -51
  527. data/lib/facet/time/to_date.rb +1 -37
  528. data/lib/facet/time/to_s.rb +1 -33
  529. data/lib/facet/time/to_time.rb +1 -36
  530. data/lib/facet/timer.rb +1 -0
  531. data/lib/facet/times.rb +1 -0
  532. data/lib/facet/tracepoint.rb +1 -0
  533. data/lib/facet/tuple.rb +1 -0
  534. data/lib/facet/typecast.rb +1 -0
  535. data/lib/facet/unboundmethod.rb +1 -1
  536. data/lib/facet/unboundmethod/name.rb +1 -8
  537. data/lib/facet/uninheritable.rb +1 -0
  538. data/lib/facet/units.rb +1 -0
  539. data/lib/facet/yamlstruct.rb +1 -0
  540. data/lib/facets.rb +77 -45
  541. data/lib/facets/core/array.rb +34 -0
  542. data/lib/facets/core/array/at_rand.rb +52 -0
  543. data/lib/facets/core/array/body.rb +2 -0
  544. data/lib/facets/core/array/delete_unless.rb +35 -0
  545. data/lib/facets/core/array/delete_values.rb +38 -0
  546. data/lib/facets/core/array/delete_values_at.rb +57 -0
  547. data/lib/facets/core/array/each_with_key.rb +9 -0
  548. data/lib/facets/core/array/first.rb +84 -0
  549. data/lib/facets/core/array/foot.rb +2 -0
  550. data/lib/facets/core/array/head.rb +80 -0
  551. data/lib/facets/core/array/last.rb +2 -0
  552. data/lib/facets/core/array/last_index.rb +35 -0
  553. data/lib/facets/core/array/merge.rb +40 -0
  554. data/lib/facets/core/array/mid.rb +50 -0
  555. data/lib/facets/core/array/middle.rb +45 -0
  556. data/lib/facets/core/array/op_fetch.rb +40 -0
  557. data/lib/facets/core/array/op_mod.rb +16 -0
  558. data/lib/facets/core/array/op_store.rb +47 -0
  559. data/lib/facets/core/array/pick.rb +68 -0
  560. data/lib/facets/core/array/pos.rb +39 -0
  561. data/lib/facets/core/array/pull.rb +37 -0
  562. data/lib/facets/core/array/rand_index.rb +30 -0
  563. data/lib/facets/core/array/rand_subset.rb +56 -0
  564. data/lib/facets/core/array/range.rb +47 -0
  565. data/lib/facets/core/array/rotate.rb +67 -0
  566. data/lib/facets/core/array/select.rb +37 -0
  567. data/lib/facets/core/array/shuffle.rb +66 -0
  568. data/lib/facets/core/array/slap.rb +37 -0
  569. data/lib/facets/core/array/store.rb +7 -0
  570. data/lib/facets/core/array/tail.rb +2 -0
  571. data/lib/facets/core/array/thru.rb +38 -0
  572. data/lib/facets/core/array/to_b.rb +31 -0
  573. data/lib/facets/core/array/to_h.rb +57 -0
  574. data/lib/facets/core/array/to_hash.rb +46 -0
  575. data/lib/facets/core/array/unzip.rb +20 -0
  576. data/lib/facets/core/binding.rb +14 -0
  577. data/lib/facets/core/binding/__DIR__.rb +2 -0
  578. data/lib/facets/core/binding/__FILE__.rb +2 -0
  579. data/lib/facets/core/binding/__LINE__.rb +58 -0
  580. data/lib/facets/core/binding/call_stack.rb +42 -0
  581. data/lib/facets/core/binding/called.rb +42 -0
  582. data/lib/facets/core/binding/caller.rb +42 -0
  583. data/lib/facets/core/binding/defined.rb +41 -0
  584. data/lib/facets/core/binding/eval.rb +42 -0
  585. data/lib/facets/core/binding/local_variables.rb +45 -0
  586. data/lib/facets/core/binding/method_name.rb +48 -0
  587. data/lib/facets/core/binding/op_fetch.rb +45 -0
  588. data/lib/facets/core/binding/op_store.rb +46 -0
  589. data/lib/facets/core/binding/self.rb +41 -0
  590. data/lib/facets/core/binding/self/of_caller.rb +122 -0
  591. data/lib/facets/core/class.rb +7 -0
  592. data/lib/facets/core/class/by_name.rb +1 -0
  593. data/lib/facets/core/class/descendents.rb +44 -0
  594. data/lib/facets/core/class/method_name.rb +33 -0
  595. data/lib/facets/core/class/remove_descendents.rb +46 -0
  596. data/lib/facets/core/class/remove_subclasses.rb +2 -0
  597. data/lib/facets/core/class/subclasses.rb +2 -0
  598. data/lib/facets/core/class/unix_path.rb +34 -0
  599. data/lib/facets/core/comparable.rb +5 -0
  600. data/lib/facets/core/comparable/at_least.rb +53 -0
  601. data/lib/facets/core/comparable/at_most.rb +2 -0
  602. data/lib/facets/core/comparable/cap.rb +2 -0
  603. data/lib/facets/core/comparable/clip.rb +72 -0
  604. data/lib/facets/core/comparable/cmp.rb +38 -0
  605. data/lib/facets/core/continuation.rb +1 -0
  606. data/lib/facets/core/continuation/self/create.rb +71 -0
  607. data/lib/facets/core/date.rb +0 -0
  608. data/lib/facets/core/date/days_in_month.rb +42 -0
  609. data/lib/facets/core/date/days_of_month.rb +34 -0
  610. data/lib/facets/core/date/stamp.rb +52 -0
  611. data/lib/facets/core/date/to_date.rb +36 -0
  612. data/lib/facets/core/date/to_s.rb +33 -0
  613. data/lib/facets/core/date/to_time.rb +36 -0
  614. data/lib/facets/core/dir.rb +4 -0
  615. data/lib/facets/core/dir/self/ancestor.rb +33 -0
  616. data/lib/facets/core/dir/self/ascend.rb +56 -0
  617. data/lib/facets/core/dir/self/ls_r.rb +76 -0
  618. data/lib/facets/core/dir/self/recurse.rb +2 -0
  619. data/lib/facets/core/enumerable.rb +39 -0
  620. data/lib/facets/core/enumerable/collect_with_counter.rb +2 -0
  621. data/lib/facets/core/enumerable/collect_with_index.rb +51 -0
  622. data/lib/facets/core/enumerable/commonality.rb +63 -0
  623. data/lib/facets/core/enumerable/compact_collect.rb +50 -0
  624. data/lib/facets/core/enumerable/compact_map.rb +2 -0
  625. data/lib/facets/core/enumerable/cross.rb +44 -0
  626. data/lib/facets/core/enumerable/each_by.rb +2 -0
  627. data/lib/facets/core/enumerable/each_combination.rb +59 -0
  628. data/lib/facets/core/enumerable/each_pair.rb +50 -0
  629. data/lib/facets/core/enumerable/each_permutation.rb +2 -0
  630. data/lib/facets/core/enumerable/each_slice.rb +131 -0
  631. data/lib/facets/core/enumerable/each_unique_pair.rb +66 -0
  632. data/lib/facets/core/enumerable/each_with_counter.rb +8 -0
  633. data/lib/facets/core/enumerable/elementwise.rb +2 -0
  634. data/lib/facets/core/enumerable/entropy.rb +52 -0
  635. data/lib/facets/core/enumerable/every.rb +65 -0
  636. data/lib/facets/core/enumerable/ew.rb +64 -0
  637. data/lib/facets/core/enumerable/filter_collect.rb +58 -0
  638. data/lib/facets/core/enumerable/filter_map.rb +2 -0
  639. data/lib/facets/core/enumerable/find_collisions.rb +41 -0
  640. data/lib/facets/core/enumerable/frequency.rb +39 -0
  641. data/lib/facets/core/enumerable/graph.rb +59 -0
  642. data/lib/facets/core/enumerable/ideal_entropy.rb +49 -0
  643. data/lib/facets/core/enumerable/map_with_counter.rb +2 -0
  644. data/lib/facets/core/enumerable/map_with_index.rb +2 -0
  645. data/lib/facets/core/enumerable/none.rb +56 -0
  646. data/lib/facets/core/enumerable/nonuniq.rb +39 -0
  647. data/lib/facets/core/enumerable/occur.rb +62 -0
  648. data/lib/facets/core/enumerable/one.rb +65 -0
  649. data/lib/facets/core/enumerable/op_pow.rb +38 -0
  650. data/lib/facets/core/enumerable/partition_by.rb +55 -0
  651. data/lib/facets/core/enumerable/permute.rb +135 -0
  652. data/lib/facets/core/enumerable/probability.rb +59 -0
  653. data/lib/facets/core/enumerable/project.rb +11 -0
  654. data/lib/facets/core/enumerable/self/combinations.rb +68 -0
  655. data/lib/facets/core/enumerable/self/cross.rb +79 -0
  656. data/lib/facets/core/enumerable/to_h.rb +50 -0
  657. data/lib/facets/core/enumerable/uniq_by.rb +39 -0
  658. data/lib/facets/core/enumerable/where.rb +12 -0
  659. data/lib/facets/core/file.rb +5 -0
  660. data/lib/facets/core/file/self/create.rb +52 -0
  661. data/lib/facets/core/file/self/open_as_string.rb +81 -0
  662. data/lib/facets/core/file/self/read_list.rb +47 -0
  663. data/lib/facets/core/file/self/sanitize.rb +50 -0
  664. data/lib/facets/core/file/self/split_all.rb +36 -0
  665. data/lib/facets/core/fileutils.rb +0 -0
  666. data/lib/facets/core/fileutils/head.rb +2 -0
  667. data/lib/facets/core/fileutils/safe_ln.rb +38 -0
  668. data/lib/facets/core/fileutils/slice.rb +152 -0
  669. data/lib/facets/core/fileutils/split_all.rb +29 -0
  670. data/lib/facets/core/fileutils/tail.rb +2 -0
  671. data/lib/facets/core/fileutils/wc.rb +128 -0
  672. data/lib/facets/core/fileutils/whereis.rb +76 -0
  673. data/lib/facets/core/fileutils/which.rb +117 -0
  674. data/lib/facets/core/float.rb +3 -0
  675. data/lib/facets/core/float/approx.rb +42 -0
  676. data/lib/facets/core/float/round_at.rb +72 -0
  677. data/lib/facets/core/float/round_to.rb +73 -0
  678. data/lib/facets/core/gem.rb +3 -0
  679. data/lib/facets/core/gem/self/active.rb +9 -0
  680. data/lib/facets/core/gem/self/gempath.rb +10 -0
  681. data/lib/facets/core/gem/self/gemspec.rb +10 -0
  682. data/lib/facets/core/hash.rb +40 -0
  683. data/lib/facets/core/hash/alias.rb +54 -0
  684. data/lib/facets/core/hash/assert_has_keys.rb +38 -0
  685. data/lib/facets/core/hash/assert_has_only_keys.rb +38 -0
  686. data/lib/facets/core/hash/at.rb +26 -0
  687. data/lib/facets/core/hash/collate.rb +53 -0
  688. data/lib/facets/core/hash/delete_unless.rb +15 -0
  689. data/lib/facets/core/hash/each.rb +61 -0
  690. data/lib/facets/core/hash/each_with_index.rb +35 -0
  691. data/lib/facets/core/hash/each_with_key.rb +32 -0
  692. data/lib/facets/core/hash/graph.rb +31 -0
  693. data/lib/facets/core/hash/has_keys.rb +37 -0
  694. data/lib/facets/core/hash/has_only_keys.rb +37 -0
  695. data/lib/facets/core/hash/inverse.rb +51 -0
  696. data/lib/facets/core/hash/join.rb +19 -0
  697. data/lib/facets/core/hash/keys_to_iv.rb +60 -0
  698. data/lib/facets/core/hash/keys_to_s.rb +80 -0
  699. data/lib/facets/core/hash/keys_to_sym.rb +91 -0
  700. data/lib/facets/core/hash/op_fetch.rb +146 -0
  701. data/lib/facets/core/hash/op_lshift.rb +28 -0
  702. data/lib/facets/core/hash/op_store.rb +2 -0
  703. data/lib/facets/core/hash/rand_key.rb +47 -0
  704. data/lib/facets/core/hash/rand_pair.rb +50 -0
  705. data/lib/facets/core/hash/rand_value.rb +60 -0
  706. data/lib/facets/core/hash/replace_each.rb +33 -0
  707. data/lib/facets/core/hash/self/zipnew.rb +37 -0
  708. data/lib/facets/core/hash/shuffle.rb +53 -0
  709. data/lib/facets/core/hash/slice.rb +33 -0
  710. data/lib/facets/core/hash/stringify_keys.rb +2 -0
  711. data/lib/facets/core/hash/swap.rb +36 -0
  712. data/lib/facets/core/hash/swapkey.rb +44 -0
  713. data/lib/facets/core/hash/symoblize_keys.rb +2 -0
  714. data/lib/facets/core/hash/to_h.rb +35 -0
  715. data/lib/facets/core/hash/to_ostruct.rb +40 -0
  716. data/lib/facets/core/hash/to_ostruct_recurse.rb +45 -0
  717. data/lib/facets/core/hash/traverse.rb +63 -0
  718. data/lib/facets/core/hash/update_each.rb +43 -0
  719. data/lib/facets/core/hash/update_keys.rb +31 -0
  720. data/lib/facets/core/hash/update_values.rb +32 -0
  721. data/lib/facets/core/hash/variablize_keys.rb +2 -0
  722. data/lib/facets/core/hash/weave.rb +88 -0
  723. data/lib/facets/core/inflect.rb +70 -0
  724. data/lib/facets/core/integer.rb +9 -0
  725. data/lib/facets/core/integer/even.rb +2 -0
  726. data/lib/facets/core/integer/fac.rb +2 -0
  727. data/lib/facets/core/integer/fact.rb +2 -0
  728. data/lib/facets/core/integer/factorial.rb +61 -0
  729. data/lib/facets/core/integer/multiple.rb +69 -0
  730. data/lib/facets/core/integer/odd.rb +2 -0
  731. data/lib/facets/core/integer/ordinal.rb +41 -0
  732. data/lib/facets/core/integer/times_collect.rb +39 -0
  733. data/lib/facets/core/integer/times_map.rb +2 -0
  734. data/lib/facets/core/kernel.rb +68 -0
  735. data/lib/facets/core/kernel/__DIR__.rb +11 -0
  736. data/lib/facets/core/kernel/__class__.rb +31 -0
  737. data/lib/facets/core/kernel/__meta__.rb +28 -0
  738. data/lib/facets/core/kernel/adhoc.rb +11 -0
  739. data/lib/facets/core/kernel/as.rb +87 -0
  740. data/lib/facets/core/kernel/assign_from.rb +82 -0
  741. data/lib/facets/core/kernel/assign_with.rb +75 -0
  742. data/lib/facets/core/kernel/autoreload.rb +124 -0
  743. data/lib/facets/core/kernel/autoreload_files.rb +2 -0
  744. data/lib/facets/core/kernel/autoreload_glob.rb +3 -0
  745. data/lib/facets/core/kernel/bool.rb +77 -0
  746. data/lib/facets/core/kernel/bug.rb +39 -0
  747. data/lib/facets/core/kernel/call_stack.rb +59 -0
  748. data/lib/facets/core/kernel/called.rb +40 -0
  749. data/lib/facets/core/kernel/complete.rb +6 -0
  750. data/lib/facets/core/kernel/constant.rb +52 -0
  751. data/lib/facets/core/kernel/copy.rb +48 -0
  752. data/lib/facets/core/kernel/deep_copy.rb +49 -0
  753. data/lib/facets/core/kernel/demo.rb +46 -0
  754. data/lib/facets/core/kernel/eigenclass.rb +17 -0
  755. data/lib/facets/core/kernel/false.rb +2 -0
  756. data/lib/facets/core/kernel/fn.rb +33 -0
  757. data/lib/facets/core/kernel/generate_method_name.rb +39 -0
  758. data/lib/facets/core/kernel/get_by_id.rb +33 -0
  759. data/lib/facets/core/kernel/here.rb +34 -0
  760. data/lib/facets/core/kernel/in.rb +35 -0
  761. data/lib/facets/core/kernel/instance_assign.rb +25 -0
  762. data/lib/facets/core/kernel/instvar.rb +13 -0
  763. data/lib/facets/core/kernel/is.rb +7 -0
  764. data/lib/facets/core/kernel/maybe.rb +41 -0
  765. data/lib/facets/core/kernel/me.rb +17 -0
  766. data/lib/facets/core/kernel/meta.rb +2 -0
  767. data/lib/facets/core/kernel/metaclass.rb +42 -0
  768. data/lib/facets/core/kernel/method.rb +76 -0
  769. data/lib/facets/core/kernel/method_name.rb +49 -0
  770. data/lib/facets/core/kernel/methods.rb +79 -0
  771. data/lib/facets/core/kernel/nack.rb +12 -0
  772. data/lib/facets/core/kernel/new.rb +40 -0
  773. data/lib/facets/core/kernel/object_class.rb +31 -0
  774. data/lib/facets/core/kernel/object_hexid.rb +35 -0
  775. data/lib/facets/core/kernel/op_esc.rb +37 -0
  776. data/lib/facets/core/kernel/own.rb +17 -0
  777. data/lib/facets/core/kernel/p.rb +12 -0
  778. data/lib/facets/core/kernel/require_all.rb +44 -0
  779. data/lib/facets/core/kernel/require_esc.rb +42 -0
  780. data/lib/facets/core/kernel/require_facet.rb +41 -0
  781. data/lib/facets/core/kernel/require_local.rb +25 -0
  782. data/lib/facets/core/kernel/resc.rb +32 -0
  783. data/lib/facets/core/kernel/returning.rb +49 -0
  784. data/lib/facets/core/kernel/send_as.rb +34 -0
  785. data/lib/facets/core/kernel/set_from.rb +69 -0
  786. data/lib/facets/core/kernel/set_with.rb +74 -0
  787. data/lib/facets/core/kernel/silence_warnings.rb +2 -0
  788. data/lib/facets/core/kernel/silently.rb +41 -0
  789. data/lib/facets/core/kernel/singleton.rb +47 -0
  790. data/lib/facets/core/kernel/superior.rb +53 -0
  791. data/lib/facets/core/kernel/supermethod.rb +44 -0
  792. data/lib/facets/core/kernel/this.rb +33 -0
  793. data/lib/facets/core/kernel/to_b.rb +41 -0
  794. data/lib/facets/core/kernel/to_bool.rb +47 -0
  795. data/lib/facets/core/kernel/true.rb +2 -0
  796. data/lib/facets/core/kernel/unuri.rb +2 -0
  797. data/lib/facets/core/kernel/uri.rb +38 -0
  798. data/lib/facets/core/kernel/val.rb +52 -0
  799. data/lib/facets/core/kernel/warn_with_line.rb +30 -0
  800. data/lib/facets/core/kernel/with_accessor.rb +94 -0
  801. data/lib/facets/core/kernel/with_reader.rb +2 -0
  802. data/lib/facets/core/kernel/with_writer.rb +2 -0
  803. data/lib/facets/core/logger.rb +0 -0
  804. data/lib/facets/core/logger/format.rb +28 -0
  805. data/lib/facets/core/logger/format_message.rb +1 -0
  806. data/lib/facets/core/matchdata.rb +3 -0
  807. data/lib/facets/core/matchdata/match.rb +37 -0
  808. data/lib/facets/core/matchdata/matchset.rb +2 -0
  809. data/lib/facets/core/matchdata/matchtree.rb +62 -0
  810. data/lib/facets/core/module.rb +40 -0
  811. data/lib/facets/core/module/abstract.rb +50 -0
  812. data/lib/facets/core/module/alias_module_function.rb +57 -0
  813. data/lib/facets/core/module/ancestor.rb +38 -0
  814. data/lib/facets/core/module/attr.rb +23 -0
  815. data/lib/facets/core/module/attr_setter.rb +48 -0
  816. data/lib/facets/core/module/attr_tester.rb +56 -0
  817. data/lib/facets/core/module/basename.rb +39 -0
  818. data/lib/facets/core/module/by_name.rb +68 -0
  819. data/lib/facets/core/module/cattr_accessor.rb +141 -0
  820. data/lib/facets/core/module/cattr_reader.rb +2 -0
  821. data/lib/facets/core/module/cattr_writer.rb +2 -0
  822. data/lib/facets/core/module/clone_removing.rb +2 -0
  823. data/lib/facets/core/module/clone_renaming.rb +2 -0
  824. data/lib/facets/core/module/clone_using.rb +87 -0
  825. data/lib/facets/core/module/dirname.rb +42 -0
  826. data/lib/facets/core/module/equate_on.rb +70 -0
  827. data/lib/facets/core/module/generate_instance_method_name.rb +47 -0
  828. data/lib/facets/core/module/include_as.rb +102 -0
  829. data/lib/facets/core/module/initializer.rb +65 -0
  830. data/lib/facets/core/module/instance_methods.rb +186 -0
  831. data/lib/facets/core/module/integrate.rb +51 -0
  832. data/lib/facets/core/module/is.rb +35 -0
  833. data/lib/facets/core/module/memoize.rb +95 -0
  834. data/lib/facets/core/module/modspace.rb +43 -0
  835. data/lib/facets/core/module/namespace.rb +61 -0
  836. data/lib/facets/core/module/nesting.rb +45 -0
  837. data/lib/facets/core/module/redef.rb +31 -0
  838. data/lib/facets/core/module/redefine_method.rb +57 -0
  839. data/lib/facets/core/module/redirect.rb +30 -0
  840. data/lib/facets/core/module/redirect_method.rb +64 -0
  841. data/lib/facets/core/module/remove.rb +29 -0
  842. data/lib/facets/core/module/rename.rb +31 -0
  843. data/lib/facets/core/module/rename_method.rb +38 -0
  844. data/lib/facets/core/module/revisal.rb +49 -0
  845. data/lib/facets/core/module/shadow_all.rb +17 -0
  846. data/lib/facets/core/module/shadow_method.rb +42 -0
  847. data/lib/facets/core/module/sort_on.rb +73 -0
  848. data/lib/facets/core/module/undef.rb +29 -0
  849. data/lib/facets/core/module/wrap.rb +30 -0
  850. data/lib/facets/core/module/wrap_method.rb +48 -0
  851. data/lib/facets/core/nil_as_emptiness.rb +34 -0
  852. data/lib/facets/core/nilclass.rb +7 -0
  853. data/lib/facets/core/nilclass/empty.rb +32 -0
  854. data/lib/facets/core/nilclass/include.rb +32 -0
  855. data/lib/facets/core/nilclass/length.rb +2 -0
  856. data/lib/facets/core/nilclass/op_fetch.rb +37 -0
  857. data/lib/facets/core/nilclass/size.rb +44 -0
  858. data/lib/facets/core/nilclass/to_f.rb +32 -0
  859. data/lib/facets/core/nilclass/to_h.rb +33 -0
  860. data/lib/facets/core/numeric.rb +5 -0
  861. data/lib/facets/core/numeric/ceil_multiple.rb +40 -0
  862. data/lib/facets/core/numeric/pred.rb +2 -0
  863. data/lib/facets/core/numeric/succ.rb +69 -0
  864. data/lib/facets/core/numeric/to_b.rb +38 -0
  865. data/lib/facets/core/ostruct.rb +0 -0
  866. data/lib/facets/core/ostruct/__merge__.rb +52 -0
  867. data/lib/facets/core/ostruct/__table__.rb +17 -0
  868. data/lib/facets/core/ostruct/__update__.rb +45 -0
  869. data/lib/facets/core/ostruct/op_fetch.rb +40 -0
  870. data/lib/facets/core/ostruct/op_store.rb +42 -0
  871. data/lib/facets/core/ostruct/to_h.rb +8 -0
  872. data/lib/facets/core/pathname.rb +2 -0
  873. data/lib/facets/core/pathname/ascend.rb +22 -0
  874. data/lib/facets/core/pathname/descend.rb +20 -0
  875. data/lib/facets/core/proc.rb +3 -0
  876. data/lib/facets/core/proc/compose.rb +62 -0
  877. data/lib/facets/core/proc/op_mul.rb +2 -0
  878. data/lib/facets/core/proc/to_method.rb +74 -0
  879. data/lib/facets/core/random.rb +21 -0
  880. data/lib/facets/core/range.rb +4 -0
  881. data/lib/facets/core/range/to_r.rb +32 -0
  882. data/lib/facets/core/range/to_range.rb +36 -0
  883. data/lib/facets/core/range/umbrella.rb +67 -0
  884. data/lib/facets/core/range/within.rb +44 -0
  885. data/lib/facets/core/regexp.rb +3 -0
  886. data/lib/facets/core/regexp/arity.rb +41 -0
  887. data/lib/facets/core/regexp/to_re.rb +38 -0
  888. data/lib/facets/core/regexp/to_regexp.rb +36 -0
  889. data/lib/facets/core/string.rb +92 -0
  890. data/lib/facets/core/string/align_center.rb +87 -0
  891. data/lib/facets/core/string/align_left.rb +2 -0
  892. data/lib/facets/core/string/align_right.rb +2 -0
  893. data/lib/facets/core/string/at.rb +8 -0
  894. data/lib/facets/core/string/at_rand.rb +65 -0
  895. data/lib/facets/core/string/basename.rb +48 -0
  896. data/lib/facets/core/string/blank.rb +36 -0
  897. data/lib/facets/core/string/bracket.rb +70 -0
  898. data/lib/facets/core/string/brief.rb +33 -0
  899. data/lib/facets/core/string/bytes.rb +19 -0
  900. data/lib/facets/core/string/camelcase.rb +58 -0
  901. data/lib/facets/core/string/camelize.rb +35 -0
  902. data/lib/facets/core/string/capitalized.rb +38 -0
  903. data/lib/facets/core/string/chars.rb +34 -0
  904. data/lib/facets/core/string/cmp.rb +43 -0
  905. data/lib/facets/core/string/demodulize.rb +40 -0
  906. data/lib/facets/core/string/dequote.rb +29 -0
  907. data/lib/facets/core/string/downcase.rb +37 -0
  908. data/lib/facets/core/string/dresner.rb +49 -0
  909. data/lib/facets/core/string/each_char.rb +35 -0
  910. data/lib/facets/core/string/each_word.rb +50 -0
  911. data/lib/facets/core/string/ends_with.rb +2 -0
  912. data/lib/facets/core/string/first.rb +94 -0
  913. data/lib/facets/core/string/first_char.rb +20 -0
  914. data/lib/facets/core/string/fold.rb +67 -0
  915. data/lib/facets/core/string/format.rb +17 -0
  916. data/lib/facets/core/string/frequency.rb +39 -0
  917. data/lib/facets/core/string/humanize.rb +31 -0
  918. data/lib/facets/core/string/indent.rb +68 -0
  919. data/lib/facets/core/string/index_all.rb +40 -0
  920. data/lib/facets/core/string/last.rb +94 -0
  921. data/lib/facets/core/string/last_char.rb +22 -0
  922. data/lib/facets/core/string/line_wrap.rb +77 -0
  923. data/lib/facets/core/string/lines.rb +33 -0
  924. data/lib/facets/core/string/lowercase.rb +32 -0
  925. data/lib/facets/core/string/margin.rb +138 -0
  926. data/lib/facets/core/string/methodize.rb +44 -0
  927. data/lib/facets/core/string/modulize.rb +44 -0
  928. data/lib/facets/core/string/mscan.rb +42 -0
  929. data/lib/facets/core/string/natcmp.rb +108 -0
  930. data/lib/facets/core/string/nchar.rb +45 -0
  931. data/lib/facets/core/string/ordinal.rb +16 -0
  932. data/lib/facets/core/string/pathize.rb +46 -0
  933. data/lib/facets/core/string/plural.rb +2 -0
  934. data/lib/facets/core/string/pop.rb +54 -0
  935. data/lib/facets/core/string/probability.rb +34 -0
  936. data/lib/facets/core/string/pull.rb +17 -0
  937. data/lib/facets/core/string/push.rb +44 -0
  938. data/lib/facets/core/string/quote.rb +68 -0
  939. data/lib/facets/core/string/rand_byte.rb +55 -0
  940. data/lib/facets/core/string/rand_index.rb +29 -0
  941. data/lib/facets/core/string/range.rb +37 -0
  942. data/lib/facets/core/string/range_all.rb +48 -0
  943. data/lib/facets/core/string/range_of_line.rb +42 -0
  944. data/lib/facets/core/string/regesc.rb +32 -0
  945. data/lib/facets/core/string/self/format.rb +17 -0
  946. data/lib/facets/core/string/self/interpolate.rb +31 -0
  947. data/lib/facets/core/string/self/patterns.rb +51 -0
  948. data/lib/facets/core/string/self/rand_letter.rb +34 -0
  949. data/lib/facets/core/string/self/random.rb +37 -0
  950. data/lib/facets/core/string/shatter.rb +45 -0
  951. data/lib/facets/core/string/shell_escape.rb +11 -0
  952. data/lib/facets/core/string/shift.rb +42 -0
  953. data/lib/facets/core/string/shuffle.rb +42 -0
  954. data/lib/facets/core/string/similarity.rb +108 -0
  955. data/lib/facets/core/string/singular.rb +117 -0
  956. data/lib/facets/core/string/slap.rb +44 -0
  957. data/lib/facets/core/string/soundex.rb +102 -0
  958. data/lib/facets/core/string/starts_with.rb +24 -0
  959. data/lib/facets/core/string/succ.rb +38 -0
  960. data/lib/facets/core/string/tab.rb +2 -0
  961. data/lib/facets/core/string/tabto.rb +2 -0
  962. data/lib/facets/core/string/to_a.rb +35 -0
  963. data/lib/facets/core/string/to_arr.rb +55 -0
  964. data/lib/facets/core/string/to_b.rb +64 -0
  965. data/lib/facets/core/string/to_const.rb +39 -0
  966. data/lib/facets/core/string/to_date.rb +35 -0
  967. data/lib/facets/core/string/to_proc.rb +54 -0
  968. data/lib/facets/core/string/to_re.rb +46 -0
  969. data/lib/facets/core/string/to_rx.rb +2 -0
  970. data/lib/facets/core/string/to_time.rb +34 -0
  971. data/lib/facets/core/string/unbracket.rb +46 -0
  972. data/lib/facets/core/string/underscore.rb +18 -0
  973. data/lib/facets/core/string/unix_crypt.rb +41 -0
  974. data/lib/facets/core/string/unpack.rb +45 -0
  975. data/lib/facets/core/string/unshift.rb +42 -0
  976. data/lib/facets/core/string/upcase.rb +45 -0
  977. data/lib/facets/core/string/uppercase.rb +2 -0
  978. data/lib/facets/core/string/whitespace.rb +27 -0
  979. data/lib/facets/core/string/word_filter.rb +61 -0
  980. data/lib/facets/core/string/word_wrap.rb +90 -0
  981. data/lib/facets/core/string/words.rb +45 -0
  982. data/lib/facets/core/string_as_array.rb +16 -0
  983. data/lib/facets/core/symbol.rb +13 -0
  984. data/lib/facets/core/symbol/camelcase.rb +42 -0
  985. data/lib/facets/core/symbol/camelize.rb +33 -0
  986. data/lib/facets/core/symbol/capitalize.rb +31 -0
  987. data/lib/facets/core/symbol/capitalized.rb +33 -0
  988. data/lib/facets/core/symbol/downcase.rb +36 -0
  989. data/lib/facets/core/symbol/not.rb +40 -0
  990. data/lib/facets/core/symbol/pad.rb +43 -0
  991. data/lib/facets/core/symbol/succ.rb +42 -0
  992. data/lib/facets/core/symbol/to_const.rb +40 -0
  993. data/lib/facets/core/symbol/to_proc.rb +45 -0
  994. data/lib/facets/core/symbol/to_str.rb +39 -0
  995. data/lib/facets/core/symbol/underscore.rb +32 -0
  996. data/lib/facets/core/symbol/upcase.rb +37 -0
  997. data/lib/facets/core/time.rb +8 -0
  998. data/lib/facets/core/time/change.rb +51 -0
  999. data/lib/facets/core/time/elapse.rb +41 -0
  1000. data/lib/facets/core/time/self/days_extrema.rb +22 -0
  1001. data/lib/facets/core/time/self/stamp.rb +2 -0
  1002. data/lib/facets/core/time/stamp.rb +51 -0
  1003. data/lib/facets/core/time/to_date.rb +37 -0
  1004. data/lib/facets/core/time/to_s.rb +33 -0
  1005. data/lib/facets/core/time/to_time.rb +36 -0
  1006. data/lib/facets/core/unboundmethod.rb +1 -0
  1007. data/lib/facets/core/unboundmethod/name.rb +8 -0
  1008. data/lib/facets/more/annotation.rb +580 -0
  1009. data/lib/facets/more/ansicode.rb +311 -0
  1010. data/lib/facets/more/aspects.rb +230 -0
  1011. data/lib/facets/more/association.rb +156 -0
  1012. data/lib/facets/more/basicobject.rb +135 -0
  1013. data/lib/facets/more/bbcode.rb +388 -0
  1014. data/lib/facets/more/binaryreader.rb +246 -0
  1015. data/lib/facets/more/bitmask.rb +112 -0
  1016. data/lib/facets/more/blankslate.rb +3 -0
  1017. data/lib/facets/more/bytes.rb +212 -0
  1018. data/lib/facets/more/classinherit.rb +216 -0
  1019. data/lib/facets/more/classmethods.rb +219 -0
  1020. data/lib/facets/more/cloneable.rb +55 -0
  1021. data/lib/facets/more/consoleapp.rb +123 -0
  1022. data/lib/facets/more/coroutine.rb +172 -0
  1023. data/lib/facets/more/crypt.rb +180 -0
  1024. data/lib/facets/more/dictionary.rb +436 -0
  1025. data/lib/facets/more/downloader.rb +272 -0
  1026. data/lib/facets/more/enumerablepass.rb +285 -0
  1027. data/lib/facets/more/expirable.rb +87 -0
  1028. data/lib/facets/more/filelist.rb +486 -0
  1029. data/lib/facets/more/floatstring.rb +179 -0
  1030. data/lib/facets/more/functor.rb +105 -0
  1031. data/lib/facets/more/heap.rb +226 -0
  1032. data/lib/facets/more/inheritor.rb +239 -0
  1033. data/lib/facets/more/interval.rb +424 -0
  1034. data/lib/facets/more/ioredirect.rb +130 -0
  1035. data/lib/facets/more/lisp.rb +387 -0
  1036. data/lib/facets/more/lisp_format.rb +1843 -0
  1037. data/lib/facets/more/lrucache.rb +183 -0
  1038. data/lib/facets/more/mathconstants.rb +320 -0
  1039. data/lib/facets/more/methodprobe.rb +215 -0
  1040. data/lib/facets/more/mock.rb +233 -0
  1041. data/lib/facets/more/multipliers.rb +192 -0
  1042. data/lib/facets/more/multiton.rb +359 -0
  1043. data/lib/facets/more/nackclass.rb +162 -0
  1044. data/lib/facets/more/nilcomparable.rb +133 -0
  1045. data/lib/facets/more/nullclass.rb +68 -0
  1046. data/lib/facets/more/one.rb +117 -0
  1047. data/lib/facets/more/openobject.rb +220 -0
  1048. data/lib/facets/more/orderedhash.rb +3 -0
  1049. data/lib/facets/more/ormsupport.rb +235 -0
  1050. data/lib/facets/more/overload.rb +110 -0
  1051. data/lib/facets/more/paramix.rb +243 -0
  1052. data/lib/facets/more/pathlist.rb +105 -0
  1053. data/lib/facets/more/pool.rb +98 -0
  1054. data/lib/facets/more/preinitialize.rb +152 -0
  1055. data/lib/facets/more/progressbar.rb +227 -0
  1056. data/lib/facets/more/promoteself.rb +104 -0
  1057. data/lib/facets/more/quaternion.rb +527 -0
  1058. data/lib/facets/more/reference.rb +83 -0
  1059. data/lib/facets/more/rtals.rb +14 -0
  1060. data/lib/facets/more/semaphore.rb +103 -0
  1061. data/lib/facets/more/snapshot.rb +190 -0
  1062. data/lib/facets/more/stateparser.rb +579 -0
  1063. data/lib/facets/more/statichash.rb +87 -0
  1064. data/lib/facets/more/syncarray.rb +144 -0
  1065. data/lib/facets/more/synchash.rb +173 -0
  1066. data/lib/facets/more/system.rb +169 -0
  1067. data/lib/facets/more/tagiterator.rb +387 -0
  1068. data/lib/facets/more/timer.rb +307 -0
  1069. data/lib/facets/more/times.rb +327 -0
  1070. data/lib/facets/more/tracepoint.rb +183 -0
  1071. data/lib/facets/more/tuple.rb +170 -0
  1072. data/lib/facets/more/typecast.rb +280 -0
  1073. data/lib/facets/more/uninheritable.rb +90 -0
  1074. data/lib/facets/more/units.rb +938 -0
  1075. data/lib/facets/more/yamlstruct.rb +90 -0
  1076. metadata +680 -39
  1077. data/data/facets/methods.yaml +0 -446
@@ -0,0 +1,215 @@
1
+ #--
2
+ # Method Probe
3
+ #
4
+ # Copyright (c) 2004,2005 Thomas Sawyer
5
+ #
6
+ # Ruby License
7
+ #
8
+ # This module is free software. You may use, modify, and/or redistribute this
9
+ # software under the same terms as Ruby.
10
+ #
11
+ # This program is distributed in the hope that it will be useful, but WITHOUT
12
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
+ # FOR A PARTICULAR PURPOSE.
14
+ #
15
+ #
16
+ # ===========================================================================
17
+ # Revision History ::
18
+ # ---------------------------------------------------------------------------
19
+ # 5.7.21 Trans * Changed name from DuckHunter to Method::Probe.
20
+ # ===========================================================================
21
+ #++
22
+
23
+ #:title: Method Probe
24
+ #
25
+ # Method::Probe (aka DuckHunter) is a decoy object which is dropped into
26
+ # methods which records the calls made against it --hence a method probe.
27
+ # Of course, it is not perfect --an inescapable matter it seems for any
28
+ # internal probe. There are a couple of issues related to conditionals.
29
+ # Since the method test for a certain condition against the decoy, how
30
+ # is the decoy to respond? Thus ceratin paths in the code may never get
31
+ # exceuted and thus go unmapped. If Ruby had better conditional reflection
32
+ # (i.e. if 'if', 'case', 'unless', 'when', etc. were true methods) then
33
+ # this could be fixed by making the Probe reentrant, mapping out variant
34
+ # true/false/nil replies. The likely insurmountable problem though is the
35
+ # Halting problem. A probe can cause some methods to complete execution.
36
+ # It's pretty rare, but it can happen and little can be done about it (I think).
37
+ #
38
+ # Note, the alternative to this kind of probe is a program that examines, rather
39
+ # then executes, the code. This would circumvent the above problems, but run
40
+ # into difficulties with dynamic evals. It would also be more complicated,
41
+ # but might prove a better means in the future.
42
+ #
43
+ # This script is provided for experimetnal purposes. Please inform the author
44
+ # if you find ways to improve it or put to an interesting use.
45
+ #
46
+ # == Synopsis
47
+ #
48
+ # require 'methodprobe'
49
+ #
50
+ # def amethod(x)
51
+ # x + 1
52
+ # end
53
+ #
54
+ # p method(:amethod).signiture
55
+ # p method(:amethod).signiture(:class)
56
+ # p method(:amethod).signiture(:pretty)
57
+ #
58
+ # produces
59
+ #
60
+ # [["+"]]
61
+ # [{"+"=>[["Fixnum"]]}]
62
+ # [["+( Fixnum )"]]
63
+ #
64
+ # == Authors(s)
65
+ #
66
+ # * Thomas Sawyer
67
+ #
68
+
69
+ class Method
70
+
71
+ class Probe
72
+
73
+ def Probe.duckcall
74
+ begin
75
+ yield
76
+ rescue TypeError => e
77
+ self.send(e.message)
78
+ retry
79
+ end
80
+ end
81
+
82
+ attr_reader :ducks, :decoys
83
+
84
+ def initialize
85
+ @ducks, @decoys = {}, {}
86
+ end
87
+
88
+ def initialize_copy(from)
89
+ initialize
90
+ end
91
+
92
+ def method_missing(aSym, *args)
93
+ aSymStr = aSym.to_s
94
+
95
+ # This will happen the first time
96
+ @ducks[aSymStr] ||= [] #unless @ducks[aSymStr]
97
+ @ducks[aSymStr] << args.collect { |a| "#{a.class}" }
98
+
99
+ decoy = self.dup
100
+
101
+ @decoys[aSymStr] ||= [] #unless @decoys[aSymStr]
102
+ @decoys[aSymStr] << decoy
103
+
104
+ # build proxy?
105
+ #begin
106
+ # d = <<-HERE
107
+ # def self.#{aSymStr}(*args)
108
+ # # This will happen the subsequent times
109
+ # @ducks["#{aSymStr}"] << args.collect { |a| #{'"#{a.class}"'} }
110
+ # @ducks["#{aSymStr}"].uniq!
111
+ # decoy = self.dup
112
+ # @decoys["#{aSymStr}"] = [] unless @decoys["#{aSymStr}"]
113
+ # @decoys["#{aSymStr}"] << decoy
114
+ # decoy
115
+ # end
116
+ # HERE
117
+ # instance_eval d
118
+ #rescue SyntaxError
119
+ # puts "This error may be avoidable by returning the failing duck type as the error message."
120
+ # raise
121
+ #end
122
+
123
+ decoy
124
+ end
125
+
126
+ end #class Probe
127
+
128
+
129
+ # Outputs migration information.
130
+ def migration
131
+ parameters = []; argc = self.arity
132
+ if argc > 0
133
+ argc.times { parameters << Probe.new }
134
+ Probe.duckcall { self.call(*parameters) }
135
+ elsif argc < 0
136
+ raise "(NYI) method takes unlimited arguments"
137
+ end
138
+ return parameters
139
+ end
140
+ private :migration
141
+
142
+
143
+ # Outputs signiture information.
144
+ def signature(detail=nil)
145
+ ds = []
146
+ case detail
147
+ when :complete, :all, :full
148
+ ds = migration
149
+ when :class, :with_class
150
+ migration.each { |dh| ds << dh.ducks }
151
+ when :pp, :pretty, :prettyprint, :pretty_print
152
+ migration.each do |dh|
153
+ responders = []
154
+ dh.ducks.each do |responder, argss|
155
+ argss.each { |args| responders << "#{responder}( #{args.join(',')} )" }
156
+ end
157
+ ds << responders
158
+ end
159
+ else
160
+ migration.each { |dh| ds << dh.ducks.keys }
161
+ end
162
+ return ds
163
+ end
164
+
165
+ end #class Method
166
+
167
+
168
+
169
+ # _____ _
170
+ # |_ _|__ ___| |_
171
+ # | |/ _ \/ __| __|
172
+ # | | __/\__ \ |_
173
+ # |_|\___||___/\__|
174
+ #
175
+
176
+ =begin testing
177
+
178
+ require 'test/unit'
179
+
180
+ # " I am a Duck Hunter ! "
181
+
182
+ class TC_MethodProbe < Test::Unit::TestCase
183
+
184
+ # fixture
185
+ def amethod(x)
186
+ x + 1
187
+ end
188
+
189
+ def test_signiture_default
190
+ assert_nothing_raised {
191
+ method(:amethod).signature
192
+ }
193
+ end
194
+
195
+ def test_signiture_with_class
196
+ assert_nothing_raised {
197
+ method(:amethod).signature(:class)
198
+ }
199
+ end
200
+
201
+ def test_signiture_pp
202
+ assert_nothing_raised {
203
+ method(:amethod).signature(:pp)
204
+ }
205
+ end
206
+
207
+ def test_signiture_all
208
+ assert_nothing_raised {
209
+ method(:amethod).signature(:complete)
210
+ }
211
+ end
212
+
213
+ end
214
+
215
+ =end
@@ -0,0 +1,233 @@
1
+ #--
2
+ # Mock
3
+ #
4
+ # Copyright (c) 2005 Thomas Sawyer, Michael Granger and George Moschovitis
5
+ #
6
+ # Ruby License
7
+ #
8
+ # This module is free software. You may use, modify, and/or redistribute this
9
+ # software under the same terms as Ruby.
10
+ #
11
+ # This program is distributed in the hope that it will be useful, but WITHOUT
12
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
+ # FOR A PARTICULAR PURPOSE.
14
+ #
15
+ #
16
+ # ==========================================================================
17
+ # Revision History ::
18
+ # --------------------------------------------------------------------------
19
+ # 0.5.8.24 trans Created, based-off of George's initial Mock idea, and
20
+ # largely influence by Michael Granger's Test::Unit::Mock.
21
+ # ==========================================================================
22
+ #
23
+ #++
24
+
25
+ require 'ostruct'
26
+
27
+ #:title: Mock
28
+ #
29
+ # A straightfoward mocking facility. Typically used in test cases.
30
+ # The Mock class offers a few constructors for quickly building
31
+ # mockups.
32
+ #
33
+ # mock - Returns a static reponse.
34
+ # echo - Returns the arguments passed-in.
35
+ # spin - Returns a rotation of responses.
36
+ # keys - Returns an index of responses.
37
+ #
38
+ # Mock classes can be built from sratch or partially framed
39
+ # against other classes.
40
+ #
41
+ # === Usage
42
+ #
43
+ # class ContextMock < Mock
44
+ # mock :response_headers, {}
45
+ # spin :host_url, ['http://www.nitrohq.com','http://www.rubyforge.com']
46
+ # end
47
+ #
48
+ # ctx = ContextMock.new
49
+ # ctx.response_headers['location'] = url
50
+ # ctx.host_url #=> "http://www.nitrohq.com"
51
+ # ctx.host_url #=> "http://www.rubyforge.com"
52
+ #
53
+ # Or
54
+ #
55
+ # class ContextMock < Mock(Context)
56
+ # ...
57
+ # end
58
+ #
59
+
60
+ class Mock < OpenStruct
61
+
62
+ # include these?
63
+ #include Test::Unit::Assertions
64
+
65
+ # Certain methods are not mocked:
66
+ # inspect (tricky)
67
+ # class (delegated)
68
+ # kind_of? (delegated)
69
+ # is_a? (delegated)
70
+ # instance_of? (delegated)
71
+ # method (works as-is)
72
+ # send (works as-is)
73
+ # respond_to? (works as-is)
74
+ # hash (no way to mock)
75
+ #
76
+ # __id__, __call__, etc. (not meant to be mocked, ever!)
77
+ #
78
+
79
+ UnmockedMethods = %r{^(
80
+ |inspect
81
+ |kind_of\?|is_a\?|instance_of\?|class
82
+ |method|send|respond_to\?
83
+ |hash
84
+ |__
85
+ )}x
86
+
87
+ class << self
88
+
89
+ attr :mocked_class
90
+
91
+ def mocks
92
+ self.methods(false)
93
+ end
94
+
95
+ # Mock a static repsonse.
96
+ def mock( sym, val )
97
+ define_method( sym ) { |*args| val }
98
+ end
99
+
100
+ # Responds with input.
101
+ def echo( sym )
102
+ define_method( sym ) { |*args| args }
103
+ end
104
+
105
+ # Reponds with a rotation of reponses.
106
+ def spin( sym, arr )
107
+ define_method( sym ) { |*args| arr.push(arr.shift) ; arr[-1] }
108
+ end
109
+
110
+ # Responds according to a mapping of input parameters.
111
+ def keys( sym, hsh )
112
+ define_method( sym ) { |*args| hsh[args] }
113
+ end
114
+
115
+ end
116
+
117
+ # Delegate methods: #class, instance_of?, kind_of?, and is_a?
118
+
119
+ alias :__class :class
120
+
121
+ def class # :nodoc:
122
+ return __class.mocked_class
123
+ end
124
+
125
+ def instance_of?( klass ) # :nodoc:
126
+ self.class == klass
127
+ end
128
+
129
+ def kind_of?( klass ) # :nodoc:
130
+ self.class <= klass
131
+ end
132
+
133
+ alias_method :is_a?, :kind_of?
134
+
135
+ end
136
+
137
+
138
+ # Factory method for creating semi-functional mock objects given the
139
+ # class which is to be mocked. It looks like a constant for purposes
140
+ # of syntactic sugar.
141
+ def Mock( realclass )
142
+
143
+ mockclass = Class.new( Mock )
144
+
145
+ mockclass.instance_eval do @mocked_class = realclass end
146
+
147
+ # Provide an accessor to class instance var that holds the class
148
+ # object we're faking
149
+ class << mockclass
150
+ # The actual class being mocked
151
+ attr_reader :mocked_class
152
+
153
+ # Propagate the mocked class ivar to derivatives so it can be
154
+ # called like:
155
+ # class MockFoo < Mock( RealClass )
156
+ def inherited( subclass )
157
+ mc = self.mockedClass
158
+ subclass.instance_eval do @mocked_class = mc end
159
+ end
160
+ end
161
+
162
+ # Build method definitions for all the mocked class's instance
163
+ # methods, as well as those given to it by its superclasses, since
164
+ # we're not really inheriting from it.
165
+ imethods = realclass.instance_methods(true).collect do |name|
166
+ next if name =~ ::Mock::UnmockedMethods
167
+
168
+ # Figure out the argument list
169
+ arity = realclass.instance_method( name ).arity
170
+ optargs = false
171
+
172
+ if arity < 0
173
+ optargs = true
174
+ arity = (arity+1).abs
175
+ end
176
+
177
+ args = []
178
+ arity.times do |n| args << "arg#{n+1}" end
179
+ args << "*optargs" if optargs
180
+
181
+ # Build a method definition. Some methods need special
182
+ # declarations.
183
+ argsj = args.join(',')
184
+ case name.intern
185
+ when :initialize
186
+ "def initialize(#{argsj}) ; super ; end"
187
+ else
188
+ "def #{name}(#{argsj}) ; self.send(#{name},#{argsj}) ; end"
189
+ #"def %s( %s ) ; self.__mockRegisterCall(%s) ; end" %
190
+ # [ name, argstr, [":#{name}", *args].join(',') ]
191
+ end
192
+ end
193
+
194
+ # Now add the instance methods to the mockclass class
195
+ mockclass.class_eval imethods.join( "\n" )
196
+
197
+ return mockclass
198
+ end
199
+
200
+
201
+
202
+ # _____ _
203
+ # |_ _|__ ___| |_
204
+ # | |/ _ \/ __| __|
205
+ # | | __/\__ \ |_
206
+ # |_|\___||___/\__|
207
+ #
208
+
209
+ # TODO
210
+
211
+ =begin #test
212
+
213
+ class MyMock < Mock
214
+ mock :m, 10
215
+ echo :e
216
+ spin :s, [1,2,3]
217
+ keys :i, { [:foo] => 'Hello', [:boo] => 'Frog' }
218
+
219
+ def a(k) k+1 end
220
+ end
221
+
222
+ my = MyMock.new
223
+
224
+ p my.m
225
+ p my.e('hi')
226
+ p my.s
227
+ p my.s
228
+ p my.s
229
+ p my.i(:foo)
230
+ p my.i(:boo)
231
+ p my.a(1)
232
+
233
+ =end
@@ -0,0 +1,192 @@
1
+ #--
2
+ # multipliers.rb
3
+ #
4
+ # Copyright (c) 2005 Thomas Sawyer
5
+ #
6
+ # Ruby License
7
+ #
8
+ # This module is free software. You may use, modify, and/or redistribute this
9
+ # software under the same terms as Ruby.
10
+ #
11
+ # This program is distributed in the hope that it will be useful, but WITHOUT
12
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
+ # FOR A PARTICULAR PURPOSE.
14
+ #
15
+ # ==========================================================================
16
+ # Revision History ::
17
+ # --------------------------------------------------------------------------
18
+ # 2005.08.10 trans * Created, inspired by Rich Kilmer's bytes.rb.
19
+ # ==========================================================================
20
+ #++
21
+
22
+ #:title: Multipliers
23
+ #
24
+ # Adds methods to Numeric to make working with
25
+ # magnitudes (kilo, mega, giga, milli, micro, etc.)
26
+ # as well as bits and bytes easier.
27
+ #
28
+ # 1.kilo #=> 1000
29
+ # 1.milli #=> 0.001
30
+ # 1.kibi #=> 1024
31
+ #
32
+ # To display a value in a certain denomination, simply
33
+ # perform the inverse operation by placing the
34
+ # multiplier called on unit (1) in the denominator.
35
+ #
36
+ # 1000 / 1.kilo #=> 1
37
+ # 1024 / 1.kibi #=> 1
38
+ #
39
+
40
+ class Numeric
41
+
42
+ # SI Multipliers
43
+
44
+ def deka ; self * 10 ; end
45
+ def hecto ; self * 100 ; end
46
+ def kilo ; self * 1000 ; end
47
+ def mega ; self * 1000000 ; end
48
+ def giga ; self * 1000000000 ; end
49
+ def tera ; self * 1000000000000 ; end
50
+ def peta ; self * 1000000000000000 ; end
51
+ def exa ; self * 1000000000000000000 ; end
52
+
53
+ # SI Fractional
54
+
55
+ def deci ; self.to_f / 10 ; end
56
+ def centi ; self.to_f / 100 ; end
57
+ def milli ; self.to_f / 1000 ; end
58
+ def micro ; self.to_f / 1000000 ; end
59
+ def nano ; self.to_f / 1000000000 ; end
60
+ def pico ; self.to_f / 1000000000000 ; end
61
+ def femto ; self.to_f / 1000000000000000 ; end
62
+ def atto ; self.to_f / 1000000000000000000 ; end
63
+
64
+ # SI Binary
65
+
66
+ def kibi ; self * 1024 ; end
67
+ def mebi ; self * 1024**2 ; end
68
+ def gibi ; self * 1024**3 ; end
69
+ def tebi ; self * 1024**4 ; end
70
+ def pebi ; self * 1024**5 ; end
71
+ def exbi ; self * 1024**6 ; end
72
+
73
+ # Bits and Bytes
74
+
75
+ def bit ; self ; end
76
+ def bits ; self ; end
77
+ def byte ; self * 8 ; end
78
+ def bytes ; self * 8 ; end
79
+
80
+ end
81
+
82
+
83
+
84
+ # _____ _
85
+ # |_ _|__ ___| |_
86
+ # | |/ _ \/ __| __|
87
+ # | | __/\__ \ |_
88
+ # |_|\___||___/\__|
89
+ #
90
+
91
+ =begin testing
92
+
93
+ require 'test/unit'
94
+
95
+ class TC_Multipliers < Test::Unit::TestCase
96
+
97
+ def test_deka
98
+ assert_equal( 10, 1.deka )
99
+ end
100
+
101
+ def test_hecto
102
+ assert_equal( 100, 1.hecto )
103
+ end
104
+
105
+ def test_kilo
106
+ assert_equal( 1000, 1.kilo )
107
+ end
108
+
109
+ def test_mega
110
+ assert_equal( 1000000, 1.mega )
111
+ end
112
+
113
+ def test_giga
114
+ assert_equal( 1000000000, 1.giga )
115
+ end
116
+
117
+ def test_tera
118
+ assert_equal( 1000000000000, 1.tera )
119
+ end
120
+
121
+ def test_peta
122
+ assert_equal( 1000000000000000, 1.peta )
123
+ end
124
+
125
+ def test_exa
126
+ assert_equal( 1000000000000000000, 1.exa )
127
+ end
128
+
129
+ # Fractional
130
+
131
+ def test_deci
132
+ assert_equal( 0.1, 1.deci )
133
+ end
134
+
135
+ def test_centi
136
+ assert_equal( 0.01, 1.centi )
137
+ end
138
+
139
+ def test_milli
140
+ assert_equal( 0.001, 1.milli )
141
+ end
142
+
143
+ def test_milli
144
+ assert_equal( 0.000001, 1.micro )
145
+ end
146
+
147
+ def test_nano
148
+ assert_equal( 0.000000001, 1.nano )
149
+ end
150
+
151
+ def test_pico
152
+ assert_equal( 0.000000000001, 1.pico )
153
+ end
154
+
155
+ def test_femto
156
+ assert_equal( 0.000000000000001, 1.femto )
157
+ end
158
+
159
+ def test_atto
160
+ assert_equal( 0.000000000000000001, 1.atto )
161
+ end
162
+
163
+ # SI Binary
164
+
165
+ def test_kibi
166
+ assert_equal( 1024, 1.kibi )
167
+ end
168
+
169
+ def test_mebi
170
+ assert_equal( 1024**2, 1.mebi )
171
+ end
172
+
173
+ def test_gibi
174
+ assert_equal( 1024**3, 1.gibi )
175
+ end
176
+
177
+ def test_tebi
178
+ assert_equal( 1024**4, 1.tebi )
179
+ end
180
+
181
+ def test_pebi
182
+ assert_equal( 1024**5, 1.pebi )
183
+ end
184
+
185
+ def test_exbi
186
+ assert_equal( 1024**6, 1.exbi )
187
+ end
188
+
189
+ end
190
+
191
+ =end
192
+