facets 1.8.49 → 1.8.51

Sign up to get free protection for your applications and to get access to all the features.
Files changed (554) hide show
  1. data/PROJECT +4 -1
  2. data/Rakefile +25 -48
  3. data/VERSION +1 -1
  4. data/doc/AUTHORS +1 -0
  5. data/doc/CHANGES +6 -0
  6. data/lib/facets/core/kernel/tap.rb +33 -3
  7. data/lib/facets/more/command.rb +507 -271
  8. metadata +2 -548
  9. data/test/lib/facets/core/array/test_at_rand.rb +0 -34
  10. data/test/lib/facets/core/array/test_delete_unless.rb +0 -28
  11. data/test/lib/facets/core/array/test_delete_values.rb +0 -28
  12. data/test/lib/facets/core/array/test_delete_values_at.rb +0 -31
  13. data/test/lib/facets/core/array/test_first.rb +0 -46
  14. data/test/lib/facets/core/array/test_head.rb +0 -42
  15. data/test/lib/facets/core/array/test_last_index.rb +0 -26
  16. data/test/lib/facets/core/array/test_merge.rb +0 -35
  17. data/test/lib/facets/core/array/test_mid.rb +0 -33
  18. data/test/lib/facets/core/array/test_middle.rb +0 -29
  19. data/test/lib/facets/core/array/test_op_div.rb +0 -27
  20. data/test/lib/facets/core/array/test_op_fetch.rb +0 -35
  21. data/test/lib/facets/core/array/test_pad.rb +0 -48
  22. data/test/lib/facets/core/array/test_pick.rb +0 -40
  23. data/test/lib/facets/core/array/test_pos.rb +0 -28
  24. data/test/lib/facets/core/array/test_pot.rb +0 -28
  25. data/test/lib/facets/core/array/test_pull.rb +0 -28
  26. data/test/lib/facets/core/array/test_rand_index.rb +0 -29
  27. data/test/lib/facets/core/array/test_rand_subset.rb +0 -29
  28. data/test/lib/facets/core/array/test_range.rb +0 -32
  29. data/test/lib/facets/core/array/test_rotate.rb +0 -36
  30. data/test/lib/facets/core/array/test_select.rb +0 -28
  31. data/test/lib/facets/core/array/test_shuffle.rb +0 -35
  32. data/test/lib/facets/core/array/test_thru.rb +0 -27
  33. data/test/lib/facets/core/array/test_to_b.rb +0 -27
  34. data/test/lib/facets/core/array/test_to_h.rb +0 -33
  35. data/test/lib/facets/core/array/test_to_hash.rb +0 -27
  36. data/test/lib/facets/core/binding/self/test_of_caller.rb +0 -35
  37. data/test/lib/facets/core/binding/test___LINE__.rb +0 -43
  38. data/test/lib/facets/core/binding/test_call_stack.rb +0 -34
  39. data/test/lib/facets/core/binding/test_called.rb +0 -30
  40. data/test/lib/facets/core/binding/test_caller.rb +0 -35
  41. data/test/lib/facets/core/binding/test_defined.rb +0 -34
  42. data/test/lib/facets/core/binding/test_eval.rb +0 -34
  43. data/test/lib/facets/core/binding/test_local_variables.rb +0 -34
  44. data/test/lib/facets/core/binding/test_method_name.rb +0 -34
  45. data/test/lib/facets/core/binding/test_op_fetch.rb +0 -34
  46. data/test/lib/facets/core/binding/test_op_store.rb +0 -35
  47. data/test/lib/facets/core/binding/test_self.rb +0 -34
  48. data/test/lib/facets/core/class/test_cattr.rb +0 -63
  49. data/test/lib/facets/core/class/test_descendents.rb +0 -30
  50. data/test/lib/facets/core/class/test_method_name.rb +0 -26
  51. data/test/lib/facets/core/class/test_remove_descendents.rb +0 -32
  52. data/test/lib/facets/core/class/test_unix_path.rb +0 -26
  53. data/test/lib/facets/core/comparable/test_at_least.rb +0 -34
  54. data/test/lib/facets/core/comparable/test_clip.rb +0 -44
  55. data/test/lib/facets/core/comparable/test_cmp.rb +0 -28
  56. data/test/lib/facets/core/continuation/self/test_create.rb +0 -26
  57. data/test/lib/facets/core/date/test_days_in_month.rb +0 -30
  58. data/test/lib/facets/core/date/test_days_of_month.rb +0 -30
  59. data/test/lib/facets/core/date/test_stamp.rb +0 -38
  60. data/test/lib/facets/core/date/test_to_date.rb +0 -30
  61. data/test/lib/facets/core/date/test_to_s.rb +0 -30
  62. data/test/lib/facets/core/date/test_to_time.rb +0 -30
  63. data/test/lib/facets/core/dir/self/test_ancestor.rb +0 -26
  64. data/test/lib/facets/core/dir/self/test_ascend.rb +0 -41
  65. data/test/lib/facets/core/enumerable/self/test_combinations.rb +0 -46
  66. data/test/lib/facets/core/enumerable/test_cart.rb +0 -49
  67. data/test/lib/facets/core/enumerable/test_collect_with_index.rb +0 -27
  68. data/test/lib/facets/core/enumerable/test_commonality.rb +0 -31
  69. data/test/lib/facets/core/enumerable/test_compact_collect.rb +0 -27
  70. data/test/lib/facets/core/enumerable/test_count.rb +0 -38
  71. data/test/lib/facets/core/enumerable/test_each_by.rb +0 -71
  72. data/test/lib/facets/core/enumerable/test_each_combination.rb +0 -29
  73. data/test/lib/facets/core/enumerable/test_each_pair.rb +0 -29
  74. data/test/lib/facets/core/enumerable/test_each_slice.rb +0 -57
  75. data/test/lib/facets/core/enumerable/test_each_unique_pair.rb +0 -29
  76. data/test/lib/facets/core/enumerable/test_eachn.rb +0 -34
  77. data/test/lib/facets/core/enumerable/test_elementwise.rb +0 -40
  78. data/test/lib/facets/core/enumerable/test_entropy.rb +0 -26
  79. data/test/lib/facets/core/enumerable/test_every.rb +0 -35
  80. data/test/lib/facets/core/enumerable/test_ew.rb +0 -31
  81. data/test/lib/facets/core/enumerable/test_filter_collect.rb +0 -31
  82. data/test/lib/facets/core/enumerable/test_find_collisions.rb +0 -30
  83. data/test/lib/facets/core/enumerable/test_frequency.rb +0 -27
  84. data/test/lib/facets/core/enumerable/test_graph.rb +0 -30
  85. data/test/lib/facets/core/enumerable/test_ideal_entropy.rb +0 -27
  86. data/test/lib/facets/core/enumerable/test_none.rb +0 -33
  87. data/test/lib/facets/core/enumerable/test_occur.rb +0 -30
  88. data/test/lib/facets/core/enumerable/test_one.rb +0 -35
  89. data/test/lib/facets/core/enumerable/test_op_pow.rb +0 -27
  90. data/test/lib/facets/core/enumerable/test_op_tilde_self.rb +0 -40
  91. data/test/lib/facets/core/enumerable/test_partition_by.rb +0 -31
  92. data/test/lib/facets/core/enumerable/test_permutation.rb +0 -29
  93. data/test/lib/facets/core/enumerable/test_probability.rb +0 -27
  94. data/test/lib/facets/core/enumerable/test_to_h.rb +0 -27
  95. data/test/lib/facets/core/enumerable/test_uniq_by.rb +0 -28
  96. data/test/lib/facets/core/file/self/test_create.rb +0 -44
  97. data/test/lib/facets/core/file/self/test_open_as_string.rb +0 -50
  98. data/test/lib/facets/core/file/self/test_read_list.rb +0 -40
  99. data/test/lib/facets/core/file/self/test_sanitize.rb +0 -46
  100. data/test/lib/facets/core/file/self/test_split_all.rb +0 -27
  101. data/test/lib/facets/core/float/test_round_at.rb +0 -46
  102. data/test/lib/facets/core/float/test_round_to.rb +0 -46
  103. data/test/lib/facets/core/hash/self/test_zipnew.rb +0 -28
  104. data/test/lib/facets/core/hash/test_alias.rb +0 -31
  105. data/test/lib/facets/core/hash/test_assert_has_keys.rb +0 -27
  106. data/test/lib/facets/core/hash/test_assert_has_only_keys.rb +0 -27
  107. data/test/lib/facets/core/hash/test_at.rb +0 -28
  108. data/test/lib/facets/core/hash/test_collate.rb +0 -35
  109. data/test/lib/facets/core/hash/test_each_with_index.rb +0 -29
  110. data/test/lib/facets/core/hash/test_each_with_key.rb +0 -29
  111. data/test/lib/facets/core/hash/test_graph.rb +0 -28
  112. data/test/lib/facets/core/hash/test_has_keys.rb +0 -27
  113. data/test/lib/facets/core/hash/test_has_only_keys.rb +0 -27
  114. data/test/lib/facets/core/hash/test_inverse.rb +0 -30
  115. data/test/lib/facets/core/hash/test_normalize_keys.rb +0 -34
  116. data/test/lib/facets/core/hash/test_op_fetch.rb +0 -111
  117. data/test/lib/facets/core/hash/test_op_lshift.rb +0 -29
  118. data/test/lib/facets/core/hash/test_rand_key.rb +0 -27
  119. data/test/lib/facets/core/hash/test_rand_pair.rb +0 -27
  120. data/test/lib/facets/core/hash/test_rand_value.rb +0 -27
  121. data/test/lib/facets/core/hash/test_rekey.rb +0 -52
  122. data/test/lib/facets/core/hash/test_replace_each.rb +0 -29
  123. data/test/lib/facets/core/hash/test_shuffle.rb +0 -32
  124. data/test/lib/facets/core/hash/test_slice.rb +0 -27
  125. data/test/lib/facets/core/hash/test_stringify_keys.rb +0 -34
  126. data/test/lib/facets/core/hash/test_swap.rb +0 -27
  127. data/test/lib/facets/core/hash/test_swapkey.rb +0 -29
  128. data/test/lib/facets/core/hash/test_symbolize_keys.rb +0 -34
  129. data/test/lib/facets/core/hash/test_to_h.rb +0 -27
  130. data/test/lib/facets/core/hash/test_to_ostruct.rb +0 -30
  131. data/test/lib/facets/core/hash/test_to_ostruct_recurse.rb +0 -44
  132. data/test/lib/facets/core/hash/test_traverse.rb +0 -37
  133. data/test/lib/facets/core/hash/test_update_each.rb +0 -29
  134. data/test/lib/facets/core/hash/test_update_keys.rb +0 -28
  135. data/test/lib/facets/core/hash/test_update_values.rb +0 -28
  136. data/test/lib/facets/core/hash/test_weave.rb +0 -29
  137. data/test/lib/facets/core/integer/test_factorial.rb +0 -30
  138. data/test/lib/facets/core/integer/test_multiple.rb +0 -43
  139. data/test/lib/facets/core/integer/test_of.rb +0 -28
  140. data/test/lib/facets/core/integer/test_ordinal.rb +0 -29
  141. data/test/lib/facets/core/integer/test_times_collect.rb +0 -28
  142. data/test/lib/facets/core/kernel/test___class__.rb +0 -26
  143. data/test/lib/facets/core/kernel/test_as.rb +0 -42
  144. data/test/lib/facets/core/kernel/test_assign_from.rb +0 -31
  145. data/test/lib/facets/core/kernel/test_assign_with.rb +0 -31
  146. data/test/lib/facets/core/kernel/test_bool.rb +0 -41
  147. data/test/lib/facets/core/kernel/test_bug.rb +0 -26
  148. data/test/lib/facets/core/kernel/test_call_stack.rb +0 -26
  149. data/test/lib/facets/core/kernel/test_called.rb +0 -26
  150. data/test/lib/facets/core/kernel/test_callee.rb +0 -26
  151. data/test/lib/facets/core/kernel/test_constant.rb +0 -33
  152. data/test/lib/facets/core/kernel/test_copy.rb +0 -40
  153. data/test/lib/facets/core/kernel/test_deep_copy.rb +0 -40
  154. data/test/lib/facets/core/kernel/test_demo.rb +0 -28
  155. data/test/lib/facets/core/kernel/test_fn.rb +0 -26
  156. data/test/lib/facets/core/kernel/test_get_by_id.rb +0 -28
  157. data/test/lib/facets/core/kernel/test_here.rb +0 -26
  158. data/test/lib/facets/core/kernel/test_in.rb +0 -27
  159. data/test/lib/facets/core/kernel/test_instance_class.rb +0 -27
  160. data/test/lib/facets/core/kernel/test_instance_exec.rb +0 -58
  161. data/test/lib/facets/core/kernel/test_maybe.rb +0 -26
  162. data/test/lib/facets/core/kernel/test_meta_class.rb +0 -27
  163. data/test/lib/facets/core/kernel/test_metaclass.rb +0 -27
  164. data/test/lib/facets/core/kernel/test_method.rb +0 -32
  165. data/test/lib/facets/core/kernel/test_methods.rb +0 -50
  166. data/test/lib/facets/core/kernel/test_new.rb +0 -30
  167. data/test/lib/facets/core/kernel/test_object_class.rb +0 -26
  168. data/test/lib/facets/core/kernel/test_object_hexid.rb +0 -27
  169. data/test/lib/facets/core/kernel/test_qua_class.rb +0 -27
  170. data/test/lib/facets/core/kernel/test_require_all.rb +0 -26
  171. data/test/lib/facets/core/kernel/test_require_esc.rb +0 -27
  172. data/test/lib/facets/core/kernel/test_resc.rb +0 -27
  173. data/test/lib/facets/core/kernel/test_send_as.rb +0 -26
  174. data/test/lib/facets/core/kernel/test_set_from.rb +0 -33
  175. data/test/lib/facets/core/kernel/test_set_with.rb +0 -42
  176. data/test/lib/facets/core/kernel/test_silently.rb +0 -28
  177. data/test/lib/facets/core/kernel/test_singleton.rb +0 -40
  178. data/test/lib/facets/core/kernel/test_singleton_class.rb +0 -27
  179. data/test/lib/facets/core/kernel/test_super_at.rb +0 -30
  180. data/test/lib/facets/core/kernel/test_supermethod.rb +0 -33
  181. data/test/lib/facets/core/kernel/test_this.rb +0 -26
  182. data/test/lib/facets/core/kernel/test_to_b.rb +0 -28
  183. data/test/lib/facets/core/kernel/test_to_bool.rb +0 -28
  184. data/test/lib/facets/core/kernel/test_to_data.rb +0 -61
  185. data/test/lib/facets/core/kernel/test_uri.rb +0 -30
  186. data/test/lib/facets/core/kernel/test_val.rb +0 -43
  187. data/test/lib/facets/core/kernel/test_with.rb +0 -30
  188. data/test/lib/facets/core/kernel/test_with_accessor.rb +0 -51
  189. data/test/lib/facets/core/matchdata/test_match.rb +0 -29
  190. data/test/lib/facets/core/matchdata/test_matchtree.rb +0 -37
  191. data/test/lib/facets/core/module/self/test_op_add.rb +0 -50
  192. data/test/lib/facets/core/module/test_abstract.rb +0 -36
  193. data/test/lib/facets/core/module/test_alias_method_chain.rb +0 -46
  194. data/test/lib/facets/core/module/test_alias_module_function.rb +0 -34
  195. data/test/lib/facets/core/module/test_ancestor.rb +0 -26
  196. data/test/lib/facets/core/module/test_attr_tester.rb +0 -39
  197. data/test/lib/facets/core/module/test_basename.rb +0 -26
  198. data/test/lib/facets/core/module/test_by_name.rb +0 -29
  199. data/test/lib/facets/core/module/test_class_extension.rb +0 -70
  200. data/test/lib/facets/core/module/test_clone_using.rb +0 -55
  201. data/test/lib/facets/core/module/test_dirname.rb +0 -26
  202. data/test/lib/facets/core/module/test_equate_on.rb +0 -37
  203. data/test/lib/facets/core/module/test_include_as.rb +0 -45
  204. data/test/lib/facets/core/module/test_initializer.rb +0 -32
  205. data/test/lib/facets/core/module/test_instance_methods.rb +0 -59
  206. data/test/lib/facets/core/module/test_integrate.rb +0 -35
  207. data/test/lib/facets/core/module/test_memoize.rb +0 -50
  208. data/test/lib/facets/core/module/test_modspace.rb +0 -27
  209. data/test/lib/facets/core/module/test_namespace.rb +0 -66
  210. data/test/lib/facets/core/module/test_nesting.rb +0 -36
  211. data/test/lib/facets/core/module/test_new.rb +0 -34
  212. data/test/lib/facets/core/module/test_nodef.rb +0 -30
  213. data/test/lib/facets/core/module/test_on_included.rb +0 -36
  214. data/test/lib/facets/core/module/test_redef.rb +0 -30
  215. data/test/lib/facets/core/module/test_redefine_method.rb +0 -30
  216. data/test/lib/facets/core/module/test_redirect.rb +0 -30
  217. data/test/lib/facets/core/module/test_redirect_method.rb +0 -30
  218. data/test/lib/facets/core/module/test_remove.rb +0 -30
  219. data/test/lib/facets/core/module/test_rename.rb +0 -31
  220. data/test/lib/facets/core/module/test_rename_method.rb +0 -31
  221. data/test/lib/facets/core/module/test_revisal.rb +0 -35
  222. data/test/lib/facets/core/module/test_shadow_method.rb +0 -30
  223. data/test/lib/facets/core/module/test_sort_on.rb +0 -42
  224. data/test/lib/facets/core/module/test_this.rb +0 -31
  225. data/test/lib/facets/core/module/test_wrap.rb +0 -30
  226. data/test/lib/facets/core/module/test_wrap_method.rb +0 -30
  227. data/test/lib/facets/core/nilclass/test_blank.rb +0 -26
  228. data/test/lib/facets/core/nilclass/test_empty.rb +0 -26
  229. data/test/lib/facets/core/nilclass/test_include.rb +0 -26
  230. data/test/lib/facets/core/nilclass/test_op_fetch.rb +0 -28
  231. data/test/lib/facets/core/nilclass/test_size.rb +0 -30
  232. data/test/lib/facets/core/nilclass/test_to_h.rb +0 -26
  233. data/test/lib/facets/core/numeric/test_approx.rb +0 -29
  234. data/test/lib/facets/core/numeric/test_ceil_multiple.rb +0 -31
  235. data/test/lib/facets/core/numeric/test_distance.rb +0 -28
  236. data/test/lib/facets/core/numeric/test_succ.rb +0 -40
  237. data/test/lib/facets/core/numeric/test_to_b.rb +0 -27
  238. data/test/lib/facets/core/ostruct/test___update__.rb +0 -45
  239. data/test/lib/facets/core/ostruct/test_instance_delegate.rb +0 -36
  240. data/test/lib/facets/core/ostruct/test_op_fetch.rb +0 -33
  241. data/test/lib/facets/core/proc/test_compose.rb +0 -29
  242. data/test/lib/facets/core/proc/test_op_mul.rb +0 -34
  243. data/test/lib/facets/core/proc/test_to_method.rb +0 -44
  244. data/test/lib/facets/core/range/test_to_r.rb +0 -27
  245. data/test/lib/facets/core/range/test_to_range.rb +0 -27
  246. data/test/lib/facets/core/range/test_umbrella.rb +0 -34
  247. data/test/lib/facets/core/range/test_within.rb +0 -29
  248. data/test/lib/facets/core/regexp/test_arity.rb +0 -33
  249. data/test/lib/facets/core/regexp/test_to_re.rb +0 -27
  250. data/test/lib/facets/core/regexp/test_to_regexp.rb +0 -27
  251. data/test/lib/facets/core/string/self/test_interpolate.rb +0 -27
  252. data/test/lib/facets/core/string/self/test_patterns.rb +0 -28
  253. data/test/lib/facets/core/string/self/test_rand_letter.rb +0 -26
  254. data/test/lib/facets/core/string/test_align_center.rb +0 -34
  255. data/test/lib/facets/core/string/test_at_rand.rb +0 -35
  256. data/test/lib/facets/core/string/test_basename.rb +0 -41
  257. data/test/lib/facets/core/string/test_blank.rb +0 -27
  258. data/test/lib/facets/core/string/test_bracket.rb +0 -49
  259. data/test/lib/facets/core/string/test_bytes.rb +0 -25
  260. data/test/lib/facets/core/string/test_camelcase.rb +0 -39
  261. data/test/lib/facets/core/string/test_camelize.rb +0 -26
  262. data/test/lib/facets/core/string/test_capitalize_all.rb +0 -26
  263. data/test/lib/facets/core/string/test_capitalized.rb +0 -26
  264. data/test/lib/facets/core/string/test_chars.rb +0 -27
  265. data/test/lib/facets/core/string/test_cleave.rb +0 -43
  266. data/test/lib/facets/core/string/test_cmp.rb +0 -30
  267. data/test/lib/facets/core/string/test_demodulize.rb +0 -38
  268. data/test/lib/facets/core/string/test_divide.rb +0 -29
  269. data/test/lib/facets/core/string/test_downcase.rb +0 -26
  270. data/test/lib/facets/core/string/test_dresner.rb +0 -32
  271. data/test/lib/facets/core/string/test_each_char.rb +0 -29
  272. data/test/lib/facets/core/string/test_each_word.rb +0 -29
  273. data/test/lib/facets/core/string/test_first.rb +0 -43
  274. data/test/lib/facets/core/string/test_fold.rb +0 -34
  275. data/test/lib/facets/core/string/test_humanize.rb +0 -26
  276. data/test/lib/facets/core/string/test_indent.rb +0 -40
  277. data/test/lib/facets/core/string/test_index_all.rb +0 -26
  278. data/test/lib/facets/core/string/test_last.rb +0 -46
  279. data/test/lib/facets/core/string/test_line_wrap.rb +0 -27
  280. data/test/lib/facets/core/string/test_lines.rb +0 -26
  281. data/test/lib/facets/core/string/test_lowercase.rb +0 -26
  282. data/test/lib/facets/core/string/test_margin.rb +0 -117
  283. data/test/lib/facets/core/string/test_methodize.rb +0 -27
  284. data/test/lib/facets/core/string/test_modulize.rb +0 -29
  285. data/test/lib/facets/core/string/test_mscan.rb +0 -30
  286. data/test/lib/facets/core/string/test_natcmp.rb +0 -30
  287. data/test/lib/facets/core/string/test_nchar.rb +0 -29
  288. data/test/lib/facets/core/string/test_pathize.rb +0 -29
  289. data/test/lib/facets/core/string/test_pop.rb +0 -47
  290. data/test/lib/facets/core/string/test_pot.rb +0 -39
  291. data/test/lib/facets/core/string/test_push.rb +0 -40
  292. data/test/lib/facets/core/string/test_quote.rb +0 -49
  293. data/test/lib/facets/core/string/test_rand_byte.rb +0 -35
  294. data/test/lib/facets/core/string/test_rand_index.rb +0 -26
  295. data/test/lib/facets/core/string/test_range.rb +0 -27
  296. data/test/lib/facets/core/string/test_range_all.rb +0 -27
  297. data/test/lib/facets/core/string/test_range_of_line.rb +0 -28
  298. data/test/lib/facets/core/string/test_regesc.rb +0 -28
  299. data/test/lib/facets/core/string/test_shatter.rb +0 -29
  300. data/test/lib/facets/core/string/test_shift.rb +0 -40
  301. data/test/lib/facets/core/string/test_shuffle.rb +0 -27
  302. data/test/lib/facets/core/string/test_similarity.rb +0 -26
  303. data/test/lib/facets/core/string/test_singular.rb +0 -86
  304. data/test/lib/facets/core/string/test_soundex.rb +0 -41
  305. data/test/lib/facets/core/string/test_succ.rb +0 -29
  306. data/test/lib/facets/core/string/test_to_a.rb +0 -27
  307. data/test/lib/facets/core/string/test_to_b.rb +0 -41
  308. data/test/lib/facets/core/string/test_to_const.rb +0 -28
  309. data/test/lib/facets/core/string/test_to_date.rb +0 -30
  310. data/test/lib/facets/core/string/test_to_proc.rb +0 -33
  311. data/test/lib/facets/core/string/test_to_re.rb +0 -28
  312. data/test/lib/facets/core/string/test_to_time.rb +0 -30
  313. data/test/lib/facets/core/string/test_unix_crypt.rb +0 -30
  314. data/test/lib/facets/core/string/test_unpack.rb +0 -34
  315. data/test/lib/facets/core/string/test_unshift.rb +0 -39
  316. data/test/lib/facets/core/string/test_upcase.rb +0 -30
  317. data/test/lib/facets/core/string/test_whitespace.rb +0 -27
  318. data/test/lib/facets/core/string/test_word_filter.rb +0 -34
  319. data/test/lib/facets/core/string/test_word_wrap.rb +0 -51
  320. data/test/lib/facets/core/string/test_words.rb +0 -37
  321. data/test/lib/facets/core/symbol/test_camelcase.rb +0 -26
  322. data/test/lib/facets/core/symbol/test_camelize.rb +0 -27
  323. data/test/lib/facets/core/symbol/test_capitalize.rb +0 -26
  324. data/test/lib/facets/core/symbol/test_capitalized.rb +0 -27
  325. data/test/lib/facets/core/symbol/test_downcase.rb +0 -27
  326. data/test/lib/facets/core/symbol/test_not.rb +0 -29
  327. data/test/lib/facets/core/symbol/test_pad.rb +0 -27
  328. data/test/lib/facets/core/symbol/test_succ.rb +0 -28
  329. data/test/lib/facets/core/symbol/test_to_const.rb +0 -28
  330. data/test/lib/facets/core/symbol/test_to_proc.rb +0 -33
  331. data/test/lib/facets/core/symbol/test_to_str.rb +0 -28
  332. data/test/lib/facets/core/symbol/test_underscore.rb +0 -26
  333. data/test/lib/facets/core/symbol/test_upcase.rb +0 -27
  334. data/test/lib/facets/core/time/test_change.rb +0 -33
  335. data/test/lib/facets/core/time/test_elapse.rb +0 -27
  336. data/test/lib/facets/core/time/test_stamp.rb +0 -39
  337. data/test/lib/facets/core/time/test_to_date.rb +0 -31
  338. data/test/lib/facets/core/time/test_to_s.rb +0 -31
  339. data/test/lib/facets/core/time/test_to_time.rb +0 -31
  340. data/test/lib/facets/more/test_ann.rb +0 -112
  341. data/test/lib/facets/more/test_ann_attr.rb +0 -39
  342. data/test/lib/facets/more/test_ansicode.rb +0 -36
  343. data/test/lib/facets/more/test_arguments.rb +0 -83
  344. data/test/lib/facets/more/test_association.rb +0 -51
  345. data/test/lib/facets/more/test_autoarray.rb +0 -32
  346. data/test/lib/facets/more/test_basicobject.rb +0 -67
  347. data/test/lib/facets/more/test_bbcode.rb +0 -34
  348. data/test/lib/facets/more/test_binaryreader.rb +0 -64
  349. data/test/lib/facets/more/test_bitmask.rb +0 -47
  350. data/test/lib/facets/more/test_buildingblock.rb +0 -48
  351. data/test/lib/facets/more/test_bytes.rb +0 -84
  352. data/test/lib/facets/more/test_classmethods.rb +0 -69
  353. data/test/lib/facets/more/test_command.rb +0 -69
  354. data/test/lib/facets/more/test_coroutine.rb +0 -60
  355. data/test/lib/facets/more/test_crypt.rb +0 -46
  356. data/test/lib/facets/more/test_cut.rb +0 -198
  357. data/test/lib/facets/more/test_dependency.rb +0 -82
  358. data/test/lib/facets/more/test_dictionary.rb +0 -107
  359. data/test/lib/facets/more/test_elementor.rb +0 -52
  360. data/test/lib/facets/more/test_enumerablepass.rb +0 -86
  361. data/test/lib/facets/more/test_floatstring.rb +0 -36
  362. data/test/lib/facets/more/test_functor.rb +0 -39
  363. data/test/lib/facets/more/test_htmlbuilder.rb +0 -38
  364. data/test/lib/facets/more/test_htmlfilter.rb +0 -86
  365. data/test/lib/facets/more/test_infinity.rb +0 -50
  366. data/test/lib/facets/more/test_inheritor.rb +0 -155
  367. data/test/lib/facets/more/test_instance_intercept.rb +0 -50
  368. data/test/lib/facets/more/test_interval.rb +0 -119
  369. data/test/lib/facets/more/test_json.rb +0 -232
  370. data/test/lib/facets/more/test_linkedlist.rb +0 -53
  371. data/test/lib/facets/more/test_lisp.rb +0 -47
  372. data/test/lib/facets/more/test_lisp_format.rb +0 -37
  373. data/test/lib/facets/more/test_lrucache.rb +0 -25
  374. data/test/lib/facets/more/test_mathconstants.rb +0 -18
  375. data/test/lib/facets/more/test_methodfilter.rb +0 -45
  376. data/test/lib/facets/more/test_methodprobe.rb +0 -53
  377. data/test/lib/facets/more/test_multipliers.rb +0 -114
  378. data/test/lib/facets/more/test_multiton.rb +0 -199
  379. data/test/lib/facets/more/test_nackclass.rb +0 -45
  380. data/test/lib/facets/more/test_nilcomparable.rb +0 -47
  381. data/test/lib/facets/more/test_opencascade.rb +0 -75
  382. data/test/lib/facets/more/test_openobject.rb +0 -126
  383. data/test/lib/facets/more/test_overload.rb +0 -54
  384. data/test/lib/facets/more/test_paramix.rb +0 -100
  385. data/test/lib/facets/more/test_pqueue.rb +0 -39
  386. data/test/lib/facets/more/test_preinitialize.rb +0 -49
  387. data/test/lib/facets/more/test_promoteself.rb +0 -45
  388. data/test/lib/facets/more/test_recorder.rb +0 -44
  389. data/test/lib/facets/more/test_snapshot.rb +0 -34
  390. data/test/lib/facets/more/test_statichash.rb +0 -31
  391. data/test/lib/facets/more/test_syncarray.rb +0 -28
  392. data/test/lib/facets/more/test_synchash.rb +0 -28
  393. data/test/lib/facets/more/test_tagiterator.rb +0 -93
  394. data/test/lib/facets/more/test_timer.rb +0 -66
  395. data/test/lib/facets/more/test_times.rb +0 -103
  396. data/test/lib/facets/more/test_tuple.rb +0 -64
  397. data/test/lib/facets/more/test_typecast.rb +0 -68
  398. data/test/lib/facets/more/test_uninheritable.rb +0 -42
  399. data/test/lib/facets/more/test_units.rb +0 -111
  400. data/test/lib/facets/more/test_xmlbuilder.rb +0 -54
  401. data/test/lib/facets/more/test_xmlhelper.rb +0 -40
  402. data/test/lib/facets/more/test_xoxo.rb +0 -288
  403. data/test/lib/facets/more/test_yamlstruct.rb +0 -37
  404. data/test/lib/facets/yore/enumerable/test_cross.rb +0 -44
  405. data/test/lib/facets/yore/kernel/test_require_facet.rb +0 -27
  406. data/test/lib/facets/yore/module/test_namespace.rb +0 -33
  407. data/test/lib/facets/yore/test_annattr.rb +0 -39
  408. data/test/lib/facets/yore/test_annotation.rb +0 -318
  409. data/work/README +0 -42
  410. data/work/TODO +0 -73
  411. data/work/bin/minitar +0 -3
  412. data/work/bin/minitar.rb +0 -814
  413. data/work/core/array/at_rand.rb +0 -95
  414. data/work/core/array/each_slice.rb +0 -23
  415. data/work/core/array/pick_values.rb +0 -32
  416. data/work/core/array/rand_indexes.rb +0 -33
  417. data/work/core/binding/class.rb +0 -11
  418. data/work/core/binding/delegate-binding.rb +0 -19
  419. data/work/core/binding/delegate.rb +0 -15
  420. data/work/core/binding/proc.rb +0 -6
  421. data/work/core/class/to_module.rb +0 -3
  422. data/work/core/enumerable/op_fetch.rb +0 -30
  423. data/work/core/fileutils/cptouch.rb +0 -20
  424. data/work/core/fileutils/nl_convert.rb +0 -133
  425. data/work/core/io/expect.rb +0 -127
  426. data/work/core/join_with.rb +0 -13
  427. data/work/core/kernel/call_line.rb +0 -15
  428. data/work/core/kernel/does.rb +0 -7
  429. data/work/core/kernel/message.rb +0 -6
  430. data/work/core/kernel/query.rb +0 -15
  431. data/work/core/kernel/taint.rb +0 -10
  432. data/work/core/logger/clean_logger.rb +0 -10
  433. data/work/core/module/attr-old.rb +0 -308
  434. data/work/core/module/attr.rb +0 -98
  435. data/work/core/module/attr_xxx.rb +0 -22
  436. data/work/core/module/by_regexp.rb +0 -21
  437. data/work/core/module/cast.rb +0 -64
  438. data/work/core/module/class_attribute_accessors.rb +0 -57
  439. data/work/core/module/inherit.rb +0 -99
  440. data/work/core/module/inherit0.rb +0 -59
  441. data/work/core/module/let.rb +0 -51
  442. data/work/core/module/meta_attr.rb +0 -60
  443. data/work/core/module/module_attribute_accessors.rb +0 -57
  444. data/work/core/module/permissions.rb +0 -32
  445. data/work/core/module/preserved.rb +0 -108
  446. data/work/core/module/sattr_accessor.rb +0 -1
  447. data/work/core/module/sattr_reader.rb +0 -1
  448. data/work/core/module/sattr_setter.rb +0 -1
  449. data/work/core/module/sattr_tester.rb +0 -1
  450. data/work/core/module/sattr_writer.rb +0 -1
  451. data/work/core/module/tc_attr.rb +0 -107
  452. data/work/core/module/to_module.rb +0 -37
  453. data/work/core/module/version.rb +0 -23
  454. data/work/core/string/frequency.rb +0 -40
  455. data/work/core/string/op_add.rb +0 -24
  456. data/work/core/string/op_div.rb +0 -15
  457. data/work/core/string/pred.rb +0 -217
  458. data/work/core/string/probability.rb +0 -35
  459. data/work/core/string/succ_distance.rb +0 -112
  460. data/work/core/string/to_arr.rb +0 -57
  461. data/work/core/string/to_ary.rb +0 -12
  462. data/work/core/string/word_wrap.rb +0 -62
  463. data/work/hash_open.rb +0 -23
  464. data/work/misc/calibre/ProjectInfo.annotation +0 -46
  465. data/work/misc/calibre/ProjectInfo.ansicode +0 -33
  466. data/work/misc/calibre/ProjectInfo.association +0 -34
  467. data/work/misc/calibre/ProjectInfo.basicobject +0 -36
  468. data/work/misc/calibre/ProjectInfo.bbcode +0 -34
  469. data/work/misc/calibre/ProjectInfo.binaryreader +0 -35
  470. data/work/misc/calibre/ProjectInfo.bitmask +0 -33
  471. data/work/misc/calibre/ProjectInfo.classinherit +0 -36
  472. data/work/misc/calibre/ProjectInfo.classmethods +0 -36
  473. data/work/misc/calibre/ProjectInfo.cloneable +0 -33
  474. data/work/misc/calibre/ProjectInfo.consoleapp +0 -35
  475. data/work/misc/calibre/ProjectInfo.coroutine +0 -37
  476. data/work/misc/calibre/ProjectInfo.crypt +0 -33
  477. data/work/misc/calibre/ProjectInfo.dictionary +0 -40
  478. data/work/misc/calibre/ProjectInfo.downloader +0 -39
  479. data/work/misc/calibre/ProjectInfo.enumerablepass +0 -35
  480. data/work/misc/calibre/ProjectInfo.expirable +0 -37
  481. data/work/misc/calibre/ProjectInfo.floatstring +0 -35
  482. data/work/misc/calibre/ProjectInfo.functor +0 -40
  483. data/work/misc/calibre/ProjectInfo.heap +0 -33
  484. data/work/misc/calibre/ProjectInfo.inheritor +0 -36
  485. data/work/misc/calibre/ProjectInfo.interval +0 -36
  486. data/work/misc/calibre/ProjectInfo.lisp +0 -38
  487. data/work/misc/calibre/ProjectInfo.lrucache +0 -34
  488. data/work/misc/calibre/ProjectInfo.mathconstants +0 -41
  489. data/work/misc/calibre/ProjectInfo.methodprobe +0 -38
  490. data/work/misc/calibre/ProjectInfo.mock +0 -34
  491. data/work/misc/calibre/ProjectInfo.multiton +0 -36
  492. data/work/misc/calibre/ProjectInfo.nackclass +0 -33
  493. data/work/misc/calibre/ProjectInfo.nilcomparable +0 -35
  494. data/work/misc/calibre/ProjectInfo.nullclass +0 -35
  495. data/work/misc/calibre/ProjectInfo.one +0 -37
  496. data/work/misc/calibre/ProjectInfo.openobject +0 -39
  497. data/work/misc/calibre/ProjectInfo.paramix +0 -38
  498. data/work/misc/calibre/ProjectInfo.pool +0 -33
  499. data/work/misc/calibre/ProjectInfo.progressbar +0 -37
  500. data/work/misc/calibre/ProjectInfo.reference +0 -36
  501. data/work/misc/calibre/ProjectInfo.semaphore +0 -36
  502. data/work/misc/calibre/ProjectInfo.stateparser +0 -39
  503. data/work/misc/calibre/ProjectInfo.statichash +0 -33
  504. data/work/misc/calibre/ProjectInfo.system +0 -34
  505. data/work/misc/calibre/ProjectInfo.tagiterator +0 -36
  506. data/work/misc/calibre/ProjectInfo.timer +0 -35
  507. data/work/misc/calibre/ProjectInfo.tracepoint +0 -37
  508. data/work/misc/calibre/ProjectInfo.tuple +0 -36
  509. data/work/misc/calibre/ProjectInfo.uniheritable +0 -34
  510. data/work/misc/calibre/ProjectInfo.units +0 -34
  511. data/work/misc/calibre/ProjectInfo.yamlstruct +0 -34
  512. data/work/more/annotation-rw.rb +0 -217
  513. data/work/more/aobject.rb +0 -132
  514. data/work/more/autohash.rb +0 -67
  515. data/work/more/cache.rb +0 -189
  516. data/work/more/class_inheritable_attributes.rb +0 -120
  517. data/work/more/commandrunner.rb +0 -101
  518. data/work/more/daemon.rb +0 -70
  519. data/work/more/debugger.rb +0 -167
  520. data/work/more/detach.rb +0 -423
  521. data/work/more/enumtype.rb +0 -115
  522. data/work/more/ioreactor.rb +0 -671
  523. data/work/more/logger_sing.rb +0 -207
  524. data/work/more/must.rb +0 -37
  525. data/work/more/old-tkxml.rb +0 -189
  526. data/work/more/pairhash.rb +0 -55
  527. data/work/more/password.rb +0 -80
  528. data/work/more/print_exception.rb +0 -35
  529. data/work/more/rand.rb +0 -412
  530. data/work/more/range.rb +0 -383
  531. data/work/more/sanitize.rb +0 -48
  532. data/work/more/superstruct.rb +0 -735
  533. data/work/more/tag.rb +0 -31
  534. data/work/more/timer.rb +0 -164
  535. data/work/op_rshift.rb +0 -87
  536. data/work/openobject-temp.rb +0 -45
  537. data/work/pore/autorequire.rb +0 -83
  538. data/work/pore/basefactory.rb +0 -40
  539. data/work/pore/hash/each.rb +0 -76
  540. data/work/pore/merge3.rb +0 -765
  541. data/work/pore/superann.rb +0 -134
  542. data/work/pore/sys.rb +0 -186
  543. data/work/pore/utils.rb +0 -518
  544. data/work/yore/HashAquisition.rb +0 -36
  545. data/work/yore/Rakefile.old +0 -181
  546. data/work/yore/Reapfile +0 -63
  547. data/work/yore/annotation.rb +0 -489
  548. data/work/yore/annotation2.rb +0 -466
  549. data/work/yore/commandutils.rb +0 -379
  550. data/work/yore/openobject.rb +0 -298
  551. data/work/yore/reap.rb +0 -184
  552. data/work/yore/reap.yml +0 -47
  553. data/work/yore/taskable-old.rb +0 -519
  554. data/work/yore/taskable.rb +0 -482
@@ -1,101 +0,0 @@
1
- class CommandRunner
2
-
3
- attr :command
4
- attr :child_pid
5
-
6
- def initialize(*command)
7
- @command = command
8
- @child_pid = nil
9
- @waiting_thread = nil
10
-
11
- @read_pipe = nil
12
- @read_error_pipe = nil
13
- @write_pipe = nil
14
- end
15
-
16
- def closeWrite
17
- @write_pipe.close
18
- end
19
-
20
- def kill
21
- Process.kill("KILL", @child_pid)
22
- end
23
-
24
- def read
25
- return @read_pipe.read
26
- end
27
-
28
- def readError
29
- return @read_error_pipe.read
30
- end
31
-
32
- def run
33
- parent_to_child_read, parent_to_child_write = IO.pipe
34
- child_to_parent_read, child_to_parent_write = IO.pipe
35
- child_to_parent_error_read, child_to_parent_error_write = IO.pipe
36
-
37
- @child_pid = fork do
38
- parent_to_child_write.close
39
- child_to_parent_read.close
40
- child_to_parent_error_read.close
41
-
42
- # Wait until parent is ready before we start doing anything
43
- if parent_to_child_read.readchar.chr != "R"
44
- raise "Unexpected input from parent"
45
- end
46
-
47
- $stdin.reopen(parent_to_child_read)
48
- $stdout.reopen(child_to_parent_write)
49
- $stderr.reopen(child_to_parent_error_write)
50
-
51
- exec(*@command)
52
- end
53
-
54
- @waiting_thread = Thread.new(@child_pid) do |pid|
55
- return_code = -1
56
-
57
- begin
58
- return_code = Process.waitpid2(pid)
59
- rescue SystemError
60
- raise "Process finished running already!"
61
- end
62
- return_code = return_code[1].exitstatus
63
-
64
- return_code
65
- end
66
-
67
- child_to_parent_write.close
68
- child_to_parent_error_write.close
69
- parent_to_child_read.close
70
-
71
- @read_pipe = child_to_parent_read
72
- @read_error_pipe = child_to_parent_error_read
73
- @write_pipe = parent_to_child_write
74
-
75
- @write_pipe.write("R")
76
- @write_pipe.flush
77
- end
78
-
79
- #--------------------------------------------------------------------------
80
- # Waits for command to exit
81
- # Returns: The return code of the program when it exited
82
- #--------------------------------------------------------------------------
83
- def wait
84
- if not @child_pid or not @waiting_thread
85
- raise "Waiting for a process that has not started"
86
- end
87
-
88
- return_value = @waiting_thread.value
89
-
90
- @waiting_thread = nil
91
- @child_pid = nil
92
-
93
- return return_value
94
- end
95
-
96
- def write(string)
97
- @write_pipe.write(string)
98
- end
99
- end
100
-
101
-
@@ -1,70 +0,0 @@
1
- #
2
- # daemon.rb
3
- #
4
- # Copyright (c) 1999-2002 Minero Aoki <aamine@loveruby.net>
5
- #
6
- # This program is free software.
7
- # You can distribute/modify this program under the terms of
8
- # the GNU Lesser General Public License version 2 or later.
9
- #
10
- # $Id: daemon.rb,v 1.2 2002/01/05 06:19:34 aamine Exp $
11
- #
12
-
13
- require 'socket'
14
-
15
-
16
- class Daemon
17
-
18
- def self.exec( port, dir, debug = $DEBUG )
19
- new(debug).exec port, dir
20
- end
21
-
22
- def initialize( debug = $DEBUG )
23
- @debug = $DEBUG
24
- end
25
-
26
- def exec( port, dir )
27
- if @debug then
28
- Dir.chdir dir
29
- wait
30
- return
31
- end
32
-
33
- fork do
34
- Process.setsid
35
- fork do
36
- Dir.chdir dir
37
- $stdin.close
38
- $stdout.close
39
- $stderr.close
40
-
41
- wait
42
- end
43
-
44
- exit!
45
- end
46
- exit!
47
- end
48
-
49
- def wait
50
- s = TCPServer.new( 10070 )
51
-
52
- unless @debug then
53
- trap( 'SIGINT' ) { exit! }
54
- trap( 'SIGHUP' ) { exit! }
55
- trap( 'SIGTERM' ) { exit! }
56
- end
57
-
58
- while true do
59
- @sock = s.accept
60
- begin
61
- session
62
- ensure
63
- @sock.close
64
- end
65
- end
66
- end
67
-
68
- # abstract session
69
-
70
- end
@@ -1,167 +0,0 @@
1
- ###############################
2
- # WARNING! Expiremental code! #
3
- ###############################
4
-
5
- # = debugger.rb
6
- #
7
- # == Copyright (c) 2006 Jan Molic
8
- #
9
- # Ruby License
10
- #
11
- # This module is free software. You may use, modify, and/or redistribute this
12
- # software under the same terms as Ruby.
13
- #
14
- # This program is distributed in the hope that it will be useful, but WITHOUT
15
- # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16
- # FOR A PARTICULAR PURPOSE.
17
- #
18
- # == Authors & Contributors
19
- #
20
- # * Jan Molic
21
- #
22
- # == Developer Notes
23
- #
24
- # TODO Is the name too generic?
25
- #
26
-
27
- # Author:: Jan Molic
28
- # Copyright:: Copyright (c) 2006 Jan Molic
29
- # License:: Ruby License
30
-
31
- require 'yaml'
32
- require 'logger'
33
-
34
- # = Debugger
35
- #
36
- # Debugger is an extension to Ruby's Logger which Adds nesting,
37
- # yaml dumps, backtrace and elapsed time to logs.
38
- #
39
- # $log = Debugger.new( STDERR )
40
- # $log.trace = true
41
- # $log.debug( 'foo' ) { |log|
42
- # log.debug( 'bar happened' )
43
- # }
44
- #
45
- # which produces
46
- #
47
- # D, [2006-06-19T14:39:19.635675 #13814] DEBUG -- : example2:10 > foo: START
48
- # D, [2006-06-19T14:39:19.636447 #13814] DEBUG -- : example2:11 > foo > bar happened
49
- # D, [2006-06-19T14:39:19.637723 #13814] DEBUG -- : example2:12 > foo > object dump
50
- # - 1
51
- # - 2
52
- # - 3
53
- # D, [2006-06-19T14:39:19.638646 #13814] DEBUG -- : example2:13 > foo > baz: START
54
- # D, [2006-06-19T14:39:19.639234 #13814] DEBUG -- : example2:14 > foo > baz > ok
55
- # D, [2006-06-19T14:39:19.639853 #13814] DEBUG -- : example2:13 > foo > baz: END (0.00056 sec)
56
- # D, [2006-06-19T14:39:19.640445 #13814] DEBUG -- : example2:10 > foo: END
57
- # (0.003999 sec)
58
- #
59
-
60
- class Debugger
61
-
62
- DEBUG = 0
63
- INFO = 1
64
- WARN = 2
65
- ERROR = 3
66
- FATAL = 4
67
- UNKNOWN = 5
68
-
69
- METHOD_MAP = {
70
- DEBUG => :debug,
71
- INFO => :info,
72
- WARN => :warn,
73
- ERROR => :error,
74
- FATAL => :fatal,
75
- UNKNOWN => :unknown
76
- }
77
-
78
- attr_accessor :trace, :name, :parent
79
-
80
- def initialize( output )
81
- @parent = nil
82
- @name = ''
83
- @trace = false
84
- @logger = Logger.new( output )
85
- @level = @logger.level
86
- end
87
-
88
- # set level ( choose one of constants )
89
- def level= l
90
- @logger.level = l
91
- end
92
-
93
- # print easily findable "point" in debug
94
- def point( str='---- XXXX ' )
95
- do_debug( DEBUG, (str*5), nil )
96
- end
97
-
98
- def debug( a='', b=nil, &block )
99
- do_debug( DEBUG, a, b, &block )
100
- end
101
-
102
- def info( a='', b=nil, &block )
103
- do_debug( INFO, a, b, &block )
104
- end
105
-
106
- def warn( a='', b=nil, &block )
107
- do_debug( WARN, a, b, &block )
108
- end
109
-
110
- def error( a='', b=nil, &block )
111
- do_debug( ERROR, a, b, &block )
112
- end
113
-
114
- def fatal( a='', b=nil, &block )
115
- do_debug( FATAL, a, b, &block )
116
- end
117
-
118
- # used internally
119
- def get_path
120
- if @parent
121
- @parent.get_path + [ @name ]
122
- else
123
- []
124
- end
125
- end
126
-
127
- private
128
-
129
- def get_trace
130
- ary = caller
131
- 1.upto( 7 ) { |i|
132
- return ary[i] if ary[i] !~ /#{__FILE__}/
133
- }
134
- ''
135
- end
136
-
137
- def output( level, obj, dump_msg )
138
- if level >= @logger.level
139
- if ! obj.is_a?( String )
140
- dump_msg ||= 'object dump'
141
- obj = dump_msg + "\n" + obj.to_yaml
142
- end
143
- ary = []
144
- ary << get_trace if @trace
145
- path = get_path
146
- ary += path if path
147
- ary << obj
148
- @logger.send( METHOD_MAP[level], ary.join(' > ') )
149
- end
150
- end
151
-
152
- def do_debug( level, a, b, &block )
153
- if block
154
- output( level, "#{a}: START", '' )
155
- dbg = self.clone
156
- dbg.parent = self
157
- dbg.name = a
158
- start = Time.now
159
- block.call( dbg )
160
- total = Time.now - start
161
- output( level, "#{a}: END (#{total} sec)", '' )
162
- else
163
- output( level, a, b )
164
- end
165
- end
166
-
167
- end
@@ -1,423 +0,0 @@
1
- =begin rdoc
2
-
3
- = Object#detach
4
-
5
- Written by Evan Webb <evan@fallingsnow.net>
6
-
7
- Detach an object into a seperate process.
8
-
9
- Simplest example expands to all objects.
10
-
11
- require 'detach'
12
-
13
- s = "blah"
14
- s2 = s.detach
15
- s2.size # 4
16
- s2.to_s # blah
17
-
18
-
19
- This basic example is true for all objects. All methods
20
- are passed to the object running in the other process and
21
- the return of #detach can be used in exactly the same way
22
- as the original object.
23
-
24
- Useful in splitting of sections of a application that can
25
- then use their own thread table and will have better performance
26
- then running all parts of a large application under one ruby thread
27
- scheduler.
28
-
29
- =end
30
-
31
- require 'drb'
32
-
33
-
34
- module Dispatch
35
-
36
- # These are created for each background work unit (method call)
37
- # that is created. They keep stats and allow for indexing
38
- # when the value is ready.
39
- class BackgroundUnit
40
- attr_accessor :unit_id, :start, :stop
41
- attr_reader :value, :thread
42
-
43
- def initialize(id)
44
- @unit_id = id
45
- @thread = nil
46
- @start = nil
47
- @stop = nil
48
- end
49
-
50
- # Sets the thread of the unit
51
- def thread=(th)
52
- @thread = th
53
- @start = Time.now
54
- end
55
-
56
- # Sets the value of the unit
57
- def value=(v)
58
- @stop = Time.now
59
- @value = v
60
- end
61
-
62
- # Indicates the elapse time spent on the unit
63
- def elapse
64
- @stop - @start
65
- end
66
-
67
- # Indicates if the unit has finished processing
68
- def ready?
69
- !@thread.alive?
70
- end
71
- end
72
-
73
- # Attached as the front object to a DRb, and given it's own
74
- # front object, method calls on this object spin a new thread
75
- # to handle the method and returns a BackgroundObject right
76
- # away. Future usage of said BackgroundObject causes it to
77
- # request the real object from the Dispatch (via DRb), at
78
- # which time operations may block. This allows for the time
79
- # between object creation and object usage for the real remote
80
- # object to do it's working, not blocking the local objects.
81
- class BackgroundDispatch
82
-
83
- undef :to_s
84
- undef :to_a
85
- undef :respond_to?
86
-
87
- def initialize(front,drb=false)
88
- @front = front
89
- @units = Hash.new
90
- @drb = drb
91
- end
92
-
93
- # This is defined to keep DRb and such from trying
94
- # to move a the Dispatcher, which must remain in the same
95
- # context as the called method. Though, having Thread
96
- # objects referenced with @units makes that true as well.
97
- def _dump(d)
98
- raise TypeError, "can't be moved"
99
- end
100
-
101
- # Someone has requested an operation on
102
- # this front object to be performed. Ok, lets spin
103
- # of the method to do it's working and return a
104
- # BackgroundObject as a stand in.
105
- def method_missing(msg_id, *a, &b)
106
- # puts "Calling #{msg_id}..."
107
- if @drb
108
- obj = BackgroundObject.new(DRbObject.new(self))
109
- else
110
- obj = BackgroundObject.new(self)
111
- end
112
-
113
- unit = BackgroundUnit.new(obj.index)
114
- unit.thread = Thread.new(unit) { |u|
115
- # puts " >> In thread, sending method to real object (#{obj.index})"
116
- u.value = @front.__send__(msg_id, *a, &b)
117
- # puts " >> Finished operation (#{obj.index})"
118
- }
119
- @units[obj.index] = unit
120
- # puts "Returning a BO for #{obj.index}"
121
- return obj
122
- end
123
-
124
- # Used fetch the value of the work unit associated with
125
- # the BackgroundObject at index. This method blocks,
126
- # waiting until the value is ready before returning it.
127
- def _get_obj(index)
128
- # puts "Fetching object #{index} in #{Process.pid}"
129
- # puts "Unit is #{@units[index].inspect}"
130
- if not @units[index].ready?
131
- @units[index].thread.join
132
- end
133
- # puts "Returning value.."
134
- return @units[index].value
135
- end
136
-
137
- # Used to check if the work unit is ready.
138
- def _obj_ready?(uid)
139
- # puts "Checking for readiness in #{Process.pid}"
140
- @units[uid].ready?
141
- end
142
-
143
- # Used for stats transparent back to the caller.
144
- # This is done in seperate struct rather then just
145
- # returning the unit object because it can easily be
146
- # seralized and used on the local side of a DRb session
147
- Stats = Struct.new(:start, :stop, :running)
148
-
149
- # Returns the stats for a work unit.
150
- def _obj_stats(uid)
151
- unit = @units[uid]
152
- if unit.nil?
153
- return Stats.new
154
- end
155
- return Stats.new(unit.start,unit.stop,unit.thread.alive?)
156
- end
157
- end
158
-
159
- # Used to create non-blocking remote method calls. Has an
160
- # index of a work unit and a dispatch object to call on
161
- # to do all the work.
162
- class BackgroundObject
163
-
164
- attr_reader :index
165
-
166
- def initialize(dispatch)
167
- @dispatch = dispatch
168
- @index = self.object_id()
169
- end
170
-
171
- undef :to_s
172
- undef :to_a
173
- undef :respond_to?
174
-
175
- # Passes all unknown method calls back to the
176
- # original object by way of the dispatch.
177
- def method_missing(msg_id, *a, &b)
178
- # puts "in #{Process.pid}, asking for #{msg_id} from a #{@dispatch.class}"
179
- obj = @dispatch._get_obj(@index)
180
- # puts "Ret is a #{obj.class}"
181
- obj.__send__(msg_id,*a,&b)
182
- end
183
-
184
- # Returns true if the real object is ready.
185
- def ready?
186
- # puts "Checking for readiness from #{Process.pid}"
187
- @dispatch._obj_ready?(@index)
188
- end
189
- alias :done? :ready?
190
-
191
- # Returns stats for the backgrouded call.
192
- def stats
193
- @dispatch._obj_stats(@index)
194
- end
195
-
196
- # I added when it choked needing this
197
- def self._load(d)
198
- end
199
- end
200
- end
201
-
202
-
203
-
204
- class Object
205
- # Accepts a hash of options to use when detaching.
206
- #
207
- # :ps - Controls if the title of the new process is changed
208
- # to reflect it being a detached object.
209
- #
210
- # Values:
211
- # * :append - Append information to the current process title
212
- # * :replace - Replace the current process title all together
213
- # * :none - Don't change the process title at all
214
- #
215
- #
216
- # :name - Sets what the name of the process actually is.
217
- #
218
- # Values:
219
- # * :parent - Uses the current process title as the name of the
220
- # detached process (ie, $0 of the parent)
221
- # * String - Any String value is used as the name
222
- #
223
- #
224
- # :id - Sets what the id of the process will be in the new
225
- # process title.
226
- #
227
- # Values:
228
- # * :object Uses a default id, looks like the default Object#to_s
229
- # * String Any String value is used as the id
230
- #
231
- #
232
- # :die - Controls if the child process will be killed if the
233
- # parent exits.
234
- #
235
- # Values:
236
- # * :parent Detached object process follows the course of
237
- # the parent process
238
- # * :none The detached object process will continue running
239
- # inspite of the fate of the parent process
240
- #
241
- # :path - The template of the location of the pipe used for
242
- # communication between the parent and the detached process.
243
- #
244
- # Defaults to: '/tmp/drb_detach.#{pid}'
245
- #
246
- # Use single quotes to embed variables to be filled in later.
247
- #
248
- # Available variables:
249
- # * pid The process id of the detached process
250
- #
251
- #
252
- # :allrefs - Controls how objects are passed to and from the
253
- # detached process. If :allrefs is set to true, all objects
254
- # passed back and forth from the remote object are only
255
- # passed as references, so that the original executing context
256
- # (ie. process) is always used. This option defaults to true
257
- # because it is the expect operating procedure.
258
- #
259
- # The use of this option takes pains to allow objects you would
260
- # always expect to be Marshalled to still be Marshalled, such as
261
- # Symbol, String, Fixnum, Bignum, Array, etc.
262
- #
263
- # NOTE: if you have problems with objects passed to detached
264
- # objects executing there methods in the detached process, and
265
- # you want them executed in the original context, try including
266
- # Drb::Undumped in your object rather then using this.
267
- #
268
- # :background - Controls how methods are dispatch on the detached
269
- # object. If :background is true, then all method calls are done
270
- # non-blocking, and a place holder object is returned. When
271
- # that place holder object has it's methods called, it blocks,
272
- # waiting for the real method operation to finish.
273
- def detach(cfg={})
274
- cfg = {
275
- :ps => :append,
276
- :die => :parent,
277
- :name => :parent,
278
- :id => :object,
279
- :path => '/tmp/drb_detach.#{pid}',
280
- :allref => true,
281
- :background => true
282
- }.merge(cfg)
283
-
284
- if cfg[:name] == :parent
285
- name = $0
286
- else
287
- name = cfg[:name].to_s
288
- end
289
-
290
- if cfg[:id] == :object
291
- id = "#<#{self.class}:0x#{self.object_id.to_s(16)}>"
292
- else
293
- id = cfg[:id]
294
- end
295
-
296
- pid = fork {
297
- # A nice little trick
298
- case cfg[:ps]
299
- when :append
300
- $0 = name + " - #{id}"
301
- when :replace
302
- $0 = id
303
- when :none
304
- break
305
- end
306
-
307
- if cfg[:ps].kind_of? String
308
- $0 = cfg[:ps]
309
- end
310
-
311
- trap("INT") {
312
- exit
313
- }
314
-
315
- pid = Process.pid
316
-
317
- obj = nil
318
- if cfg[:background] == true
319
- obj = Dispatch::BackgroundDispatch.new(self,true)
320
- else
321
- obj = self
322
- end
323
-
324
- DRb.start_service("drbunix://"+eval(%!"#{cfg[:path]}"!),obj)
325
- DRb.thread.join
326
- exit
327
- }
328
-
329
- # Mom always said I should clean up after myself
330
-
331
- if cfg[:die] == :parent
332
- at_exit {
333
- Process.kill("INT", pid)
334
- }
335
- end
336
-
337
- sleep 0.3
338
- DRb.start_service
339
- remote = DRbObject.new(nil,"drbunix://"+eval(%!"#{cfg[:path]}"!))
340
- if cfg[:allref] == true
341
- remote.instance_eval "alias :real_method_missing :method_missing"
342
-
343
- def remote.method_missing(msg_id, *a, &b)
344
- a.each do |i|
345
- allow = true
346
- [Symbol, String, Fixnum, Bignum, Array, Regexp].each do |t|
347
- if i.kind_of? t
348
- allow = false
349
- break
350
- end
351
- end
352
- next if not allow
353
- def i._dump(d)
354
- raise TypeError, 'can\'t dump'
355
- end
356
- end
357
- return real_method_missing(msg_id, *a)
358
- end
359
- end
360
-
361
- return remote
362
- end
363
- end
364
-
365
-
366
-
367
- =begin test
368
-
369
- require 'test/unit'
370
-
371
- # fixture
372
-
373
- class Logger
374
- def log(str)
375
- puts "From #{Process.pid}: #{str.to_s}"
376
- end
377
- end
378
-
379
- class Person
380
- attr_accessor :log
381
- def say(msg)
382
- puts "Detached #{Process.pid}"
383
- @log.log("hello, i said #{msg}")
384
- end
385
- def wait
386
- sleep 10
387
- "hi"
388
- end
389
- end
390
-
391
-
392
- class TC_Detach < Test::Unit::TestCase
393
-
394
- puts "Parent is #{Process.pid}"
395
-
396
- log = Logger.new
397
- p = Person.new
398
- p = p.detach(:allref => true)
399
- puts "p is a #{p.class}"
400
- p.log = log
401
- p.say("I won!")
402
-
403
- s = p.wait
404
-
405
- puts "s is a #{s.class}"
406
-
407
- puts "While i'm here, the other process should be doing it's thing."
408
- puts "It's waiting for 10 seconds, so if i wait for 5, it should only be another 5 after i ask for the method that it returns"
409
- sleep 5
410
-
411
- puts "Lets try something..."
412
- while not s.ready?
413
- puts "Is the method ready? (#{s.ready?})"
414
- sleep 2
415
- end
416
- p s.to_s
417
-
418
- puts "Stats:"
419
- p s.stats
420
-
421
- end
422
-
423
- =end