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,76 +0,0 @@
1
- #--
2
- # Special thanks to Daniel Schierbeck.
3
- #++
4
-
5
- # TODO Deprecate Hash#each
6
- warn "Hash#each is being deprecated"
7
-
8
-
9
- class Hash
10
-
11
- # A "smarter" hash#each which iterates through each
12
- # _value_ if only one block parameter is given.
13
- #
14
- # {:a=>"a", 2=>"b", "x"=>"c"}.each{ |v| puts v }
15
- #
16
- # _produces_
17
- #
18
- # a
19
- # b
20
- # c
21
- #
22
- # WARNING! Use with caution. Methods from other libraries
23
- # may depend on the old behavior, expecting a two element
24
- # array to be passed into a single block argument.
25
-
26
- def each(&block)
27
- if block.arity < 2
28
- each_value(&block)
29
- else
30
- each_pair(&block)
31
- end
32
- end
33
-
34
- # def each(&yld)
35
- # case yld.arity
36
- # when 0
37
- # when 1
38
- # each_value{|v| yield(v)}
39
- # else
40
- # each_pair{|k,v| yld.call(k,v)}
41
- # end
42
- # self
43
- # end
44
-
45
- end
46
-
47
-
48
- # _____ _
49
- # |_ _|__ ___| |_
50
- # | |/ _ \/ __| __|
51
- # | | __/\__ \ |_
52
- # |_|\___||___/\__|
53
- #
54
- =begin test
55
-
56
- require 'test/unit'
57
-
58
- class TCHash < Test::Unit::TestCase
59
-
60
- def test_each_1
61
- h = { :a=>1, :b=>2, :c=>3 }
62
- a = []
63
- h.each { |v| a << v }
64
- assert_equal( [1,2,3], a.sort )
65
- end
66
-
67
- def test_each_2
68
- h = { 'a'=>1, 'b'=>2, 'c'=>3 }
69
- a = []
70
- h.each { |k,v| a << [k,v] }
71
- assert_equal( [['a',1],['b',2],['c',3]], a.sort )
72
- end
73
-
74
- end
75
-
76
- =end
@@ -1,765 +0,0 @@
1
- #
2
- # merge3.rb - a 3 way text merging tool
3
- #
4
- # Copyright 2004 Helsinki Institute for Information Technology (HIIT)
5
- # and the authors. All rights reserved.
6
- #
7
- # Authors: Torsten Rueger <torsten@lightning.nu>
8
- #
9
-
10
- # Permission is hereby granted, free of charge, to any person
11
- # obtaining a copy of this software and associated documentation files
12
- # (the "Software"), to deal in the Software without restriction,
13
- # including without limitation the rights to use, copy, modify, merge,
14
- # publish, distribute, sublicense, and/or sell copies of the Software,
15
- # and to permit persons to whom the Software is furnished to do so,
16
- # subject to the following conditions:
17
- #
18
- # The above copyright notice and this permission notice shall be
19
- # included in all copies or substantial portions of the Software.
20
- #
21
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
25
- # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
26
- # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27
- # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
- # SOFTWARE.
29
- #
30
- # start : last week it was really nice weather
31
- # one (+end) : last weekend it was really nice weather
32
- # two (order) : it was really nice weather last week
33
- #
34
- # merged : it was really nice weather last weekend
35
-
36
- # It's a simple example, but getting that merged result is not.
37
-
38
- # it seems the standard diff/patch does not use move or copy as a command
39
- # as a consequence, simple avoidable conflicts are produced as soon as
40
- # move + edit touch the same data.
41
-
42
- # this is not only surprising as diff/patch have been around for so long
43
- # also the algorithms for detecting moves have been around for long:
44
- # basically there are the two approaches of using add/delete
45
- # or add/copy (or just copy). Diff/Patch just use the first, whereas the second
46
- # would allow better patching.
47
-
48
- # now the really interesting thing is that modern diff algorithms I know
49
- # (xdelta + vcdiff) use copy. As these algorithms are used to work on
50
- # 2 versions, A,B , producing a diff ab that then may be aplied to A and
51
- # A only, the algorithms use copy not because it's better for 3-way merging,
52
- # but because it's more efficient.
53
-
54
- # This algorithm is a 3 way merge on text files.
55
- # It turns out that it merges xml just fine though.
56
-
57
- # A very rough scetch is:
58
- # -- find the common parts of two files . We do this by a hashing technique
59
- # once we have the common (copied) parts we add the added/deleted ones
60
- # -- common parts are sorted according to both original nad edited file order
61
- # -- merge by going through the list of parts. Start at one file and always
62
- # swap to the other when there is a change in the other, a change from
63
- # the original files order
64
-
65
- # Note: While this does not concentrate performance, it is quite reasonable,
66
- # meaning linear in file size and quadrtic in numer of edits.
67
- # Performace may be tested with the speedy.rb file in test directory
68
- #
69
-
70
- DEBUG = false #toggle this to true to get a complete trace of what happens
71
-
72
-
73
- # so here comes the main algorithm. We have the class to carry the original file
74
- # and it's hash codes we need for the matching of the files
75
-
76
- class Merge3
77
-
78
- # make a three way merge, passing in strings and returning a string
79
- # strings are byte arrays (not line arrays as in diff)
80
- def Merge3::three_way( start_file , one_file , two_file , ignore_white_space = false )
81
- # We also create chunks of the whole files, in case whitespace
82
- # handling is on. Chunk::subchunk passed compressed whitespace on
83
- start_chunk = Chunk.new( 0 , start_file.length , start_file )
84
- one_chunk = Chunk.new( 0 , one_file.length , one_file )
85
- two_chunk = Chunk.new( 0 , two_file.length , two_file )
86
- if ignore_white_space
87
- start_chunk.squeeze # all consecutive whitespace is then squeezed
88
- one_chunk.squeeze # into one, and a talbe create to unsqueeze later
89
- two_chunk.squeeze # Yes, this is expensive
90
- end
91
- # only create the macthes hash once for the start file
92
- start_matches = Merge3::all_matches(start_chunk)
93
- # Create the chunks( moves first , then added and deleted)
94
- one_seq = Sequence.new( one_chunk , start_chunk , start_matches )
95
- two_seq = Sequence.new( two_chunk , start_chunk , start_matches )
96
- puts "Diff original 0" , one_seq if DEBUG
97
- puts "Diff original 1" , two_seq if DEBUG
98
- # break all chunks into non overlapping regions (in the original file order)
99
- one_seq.no_overlap( two_seq )
100
- two_seq.no_overlap( one_seq )
101
- puts "Diff non-overlapping 0" , one_seq if DEBUG
102
- puts "Diff non-overlapping 1" , two_seq if DEBUG
103
- # and finally (and most simply) do the merge
104
- Merge3::merge( one_seq , two_seq )
105
- end
106
-
107
- # given the Sequences of both files, attempt merging them.
108
- # the chunks in the sequences are non-overlapping, so we can always work
109
- # on whole chunks.
110
- # In a sentence, the algorithm is now: Follow the line of change
111
- def Merge3::merge( one_seq , two_seq )
112
- # we go along the original file's order and change to the other sequence
113
- # if there has been a change compared to the original file.
114
- out = [] # this is the array of string to be outputted, the result
115
- # this doesn't consider changes at the beginning of the file
116
- # which just goes to prove that we're researchers
117
- one_chunk = one_seq.chunks.first
118
- two_chunk = two_seq.chunks.first
119
- last_choosen = one_chunk
120
- break_flag = nil
121
- while break_flag.nil?
122
- if DEBUG and one_chunk.from != two_chunk.from
123
- #chunks are non overlapping, so they must be the same
124
- raise "CHUNKS differ #{one_chunk}\n#{two_chunk}"
125
- end
126
- # we start with the next in the edited file order and then check where
127
- next_one = one_seq.get_next( one_chunk ) # the change is
128
- next_two = two_seq.get_next( two_chunk )
129
- break_flag = true if next_one.nil? or next_two.nil? #eof
130
- # so if the change is in the first file,
131
- if break_flag.nil? and one_chunk.org_stop != next_one.from
132
- raise "conflict at #{one_chunk.org_stop}" if two_chunk.org_stop != next_two.from
133
- # we find the one in file two that starts where it (one) ends
134
- next_two = two_seq.find_from( next_one.from )
135
- puts "ONE #{one_chunk}\n #{two_chunk} nNEXT #{next_one}\n #{next_two}" if DEBUG
136
- next_choosen = next_one
137
- # otherwise the change must be in file two
138
- elsif break_flag.nil?
139
- # and we look for the chunk in one, that starts where two ends
140
- next_one = one_seq.find_from( next_two.from )
141
- puts "TWO #{two_chunk}\n #{one_chunk}\nNEXT #{next_two}\n #{next_one}" if DEBUG
142
- next_choosen = next_two
143
- else
144
- next_one , next_two = nil ,nil
145
- end
146
- this_del = ( one_chunk.kind_of?(Deleted) or two_chunk.kind_of?(Deleted) )
147
- # Output the associated (real==whitespace expanded) string if not deleted
148
- out << last_choosen.real_string unless this_del
149
- puts "OUT #{Chunk::short_string(one_chunk.real_string)}" if DEBUG and not this_del
150
- # we ignore adds (from one file) that happen to fall in the middle of a deleted in the other
151
- one_del = ( one_chunk.kind_of?( Deleted) and next_one.kind_of?( Deleted) )
152
- two_del = ( two_chunk.kind_of?( Deleted) and next_two.kind_of?( Deleted) )
153
- unless one_del or two_del
154
- # otherwise we output added text from both files
155
- puts "ADD one #{one_chunk.added}" if DEBUG and not one_chunk.added.nil?
156
- out << one_chunk.added.real_string unless one_chunk.added.nil?
157
- # and if both have added text create an asymetric result, hmm
158
- puts "ADD two #{ two_chunk.added}" if DEBUG and not two_chunk.added.nil?
159
- out << two_chunk.added.real_string unless two_chunk.added.nil?
160
- end
161
- one_chunk = next_one
162
- two_chunk = next_two
163
- last_choosen = next_choosen
164
- end
165
- puts "RESULT" , out.join , "END" if DEBUG
166
- return out.join # joins the pieces and returns the merged string
167
- end
168
-
169
- # build a hash of chunks( hash of the chunks string against the chunk).
170
- # This is the backbone of the matching algorithm, so that finding a match
171
- # is basically a hash lookup
172
- # Matches may be of different sizes, we use 16,32,48 and -1 for line matching
173
- def Merge3::matches( chunk , size )
174
- if size == -1 then
175
- return Merge3::match_newlines( chunk )
176
- else
177
- return Merge3::match( chunk , size )
178
- end
179
- end
180
-
181
- # collect all matches (for the start file, so it doesn't have to be done twice)
182
- def Merge3::all_matches( chunk )
183
- # order counts, so large chunks overwrites small for hash collisions
184
- matches = Merge3::match(chunk,16)
185
- matches.update(match(chunk,32))
186
- matches.update(match(chunk,48))
187
- matches.update(match_newlines(chunk))
188
- matches
189
- end
190
-
191
- # find matches according to newline seperation.
192
- def Merge3::match_newlines( chunk )
193
- match = {} # the hash of matches , using the strings as key, chunk as value
194
- index = 0 #count through the string length
195
- if chunk.whitespace.empty? # whitespace compression on or not ?
196
- # because there are only newline if whitespace compression is off
197
- chunk.str.split("\n").each do |line|
198
- # this logic strips the whitespace off both sides of the line, in an
199
- # effort to match things like changed indentation
200
- offset = 0
201
- offset += 1 while line[offset,1] =~ /\s/
202
- index += offset
203
- line.strip!
204
- cop = chunk.subchunk( index , line.length , index )
205
- match[cop.str] = cop # and store in our hash (no collision detection)
206
- #puts "LINE #{index} #{line.length} #{offset}--#{cop.str}--"
207
- index += line.length + 1 # 1 is the newline
208
- end
209
- else #whitespace compression is on, so the whitespace table contains
210
- # the newlines, just have to find them
211
- chunk.whitespace.each do | at , str |
212
- #puts "###{str}##"
213
- next unless str.include?( "\n" )
214
- cop = chunk.subchunk( index + 1 , at - index , index )
215
- index =at
216
- #puts "###{cop.str}##" if cop.str.include?("Four")
217
- match[cop.str] = cop # and store in our hash (no collision detection)
218
- end
219
- end
220
- match
221
- end
222
-
223
- # find matches for around the given length. Exactly the length for binary files,
224
- # but if there is whitespace, we use that to break within 70% of the given
225
- # value
226
- def Merge3::match( chunk , around )
227
- match = {} # the hash of matches , using the strings as key, chunks as value
228
- index = 0 #count through the string length
229
- while index < chunk.length # also possible here to do half from the
230
- left = chunk.length - index #front and half from the back (?)
231
- if left > 0.7*around and left <= 1.5*around # are we at the end
232
- len = chunk.length - index
233
- else
234
- sub = chunk.str[index , 1.5*around] # take the maximum length we want
235
- if (white = sub.index( /\W/ , 0.7 * around )).nil? # and check for non char
236
- len = around # either taking the whole
237
- else #or the "words" we found
238
- len = white #hoping this is better for text, so we have no allignment
239
- end # issues
240
- end #then create a chunk with the indexes and string
241
- cop = chunk.subchunk( index , len , index )
242
- match[cop.str] = cop # and store in our hash (no collision detection)
243
- index += len
244
- end
245
- # now we only take one from the back,because that's often a match and will be
246
- at = (chunk.length - 0.7*around).to_i
247
- cop = chunk.subchunk( at , (0.7*around).to_i , at )
248
- match[cop.str] = cop
249
- match
250
- end
251
- end
252
-
253
- # A Sequence represents a sequence of chunks , in other words the modified file
254
- # broken into the chunks that were found
255
-
256
- # the sequence keeps the chunks as lists, one in edited file order
257
- # and one in original file order
258
- class Sequence
259
- attr :chunks # the list of chunks, sorted in order of the edited file
260
- attr :org_chunks # the list of chunks, sorted in order of the original file
261
-
262
- # output both lists of chunks, edited and original, with chunks and numbers
263
- # but strings only up to 70 chars (for readability)
264
- def to_s
265
- ret = ""
266
- @chunks.each_with_index do | chunk , index |
267
- ret += index.to_s + " - " + chunk.to_s + "\n"
268
- end
269
- @org_chunks.each_with_index do | chunk , index |
270
- ret += index.to_s + " - " + chunk.to_s + "\n"
271
- end
272
- return ret
273
- end
274
-
275
- # find the difference from (file, or byte array) too to start
276
- # (matches are precalculated matches for start ) start.
277
- # Collect the differences as chunks (copies or adds) and mark deletes
278
- # The algorithm is "greedy", meaning if it finds a match (using the
279
- # matches) it tries to extend in both directions
280
- def initialize too_chunk , start_chunk , start_matches
281
- @chunks = []
282
- @org_chunks = []
283
- # run by length to get big (sure) hits first (-1 == newlines)
284
- [ -1 , 48 , 32, 16 ].each do |c_size|
285
- two_matches = Merge3::matches(too_chunk , c_size).each do |key , two|
286
- next if (start = start_matches[two.str]).nil?
287
- raise "Keys collide :#{start}" if start.str != two.str
288
- next if done?( two , start )
289
- # here comes the greedy part, first left then right
290
- two_start , start_start , len = two.start , start.start , two.length
291
- puts two , "MINUS" if len <= 0 and DEBUG
292
- start_rim , edit_rim = find_left_rim( start_start , two_start )
293
- while ( start_chunk.str[start_start - 1] == too_chunk.str[two_start - 1] ) and
294
- ( edit_rim < two_start ) and ( start_rim < start_start )
295
- two_start -= 1
296
- start_start -= 1
297
- len += 1 # to keep the right end where it was
298
- end
299
- start_rim , edit_rim = find_right_rim( start_start + len , two_start + len , start_chunk.length , too_chunk.length )
300
- while ( start_chunk.str[start_start + len ] == too_chunk.str[two_start + len ] ) and
301
- ((len + start_start) < start_rim) and ((two_start + len) < edit_rim)
302
- len += 1
303
- end
304
- chunk = too_chunk.subchunk(two_start,len , start_start )
305
- puts "Matched #{chunk}" if DEBUG
306
- add_chunk( chunk )
307
- end
308
- end
309
- # now find the parts that were deleted
310
- # (gaps in the matching of the original file)
311
- each_org_pair do | org , next_org |
312
- if org.org_stop < next_org.from
313
- del_str = start_chunk.str[org.org_stop , next_org.from - org.org_stop ]
314
- puts "DELETED #{org.org_stop} --#{del_str}--" if DEBUG
315
- del = Deleted.new( org.stop , org.org_stop , del_str)
316
- add_chunk( del )
317
- end
318
- end
319
- # now find the parts that were added (gaps in the matching of the edited file)
320
- adds = {}
321
- each_pair do |chunk , next_chunk |
322
- if chunk.stop < next_chunk.start
323
- add = too_chunk.subchunk( chunk.stop , next_chunk.start - chunk.stop , -1 )
324
- puts "ADDING #{add} " if DEBUG
325
- chunk.added = add # hang the add onto the chunk
326
- # this following logic has fixed some cases, where the matching had
327
- # been somewhat unintuitive. Though correct it produced
328
- # unneccessary conflicts, in conjunction with deletes
329
- while add.str[0] == next_chunk.str[0] and
330
- add.str[0] != 32 and # not spaces, avoid whitespace headaches
331
- chunk.org_stop == next_chunk.from
332
- puts "before: #{chunk} \nNext:#{next_chunk}" if DEBUG
333
- add.rotate #put the first to the end
334
- remove_chunk( next_chunk )
335
- # move the first from the next to the end of the last
336
- chunk.push( next_chunk.pop )
337
- puts "after: #{chunk} \nNext:#{next_chunk}" if DEBUG
338
- add_chunk( next_chunk )
339
- end unless chunk.kind_of?(Deleted) or next_chunk.kind_of?(Deleted)
340
- end
341
- end
342
- end
343
-
344
- # helper to iterate over each pair in the edited file order
345
- def each_pair
346
- return if @chunks.length < 2
347
- idx = 1
348
- chunk = @chunks[0]
349
- while idx < @chunks.length
350
- next_chunk = @chunks[idx]
351
- yield(chunk , next_chunk)
352
- chunk = next_chunk
353
- idx = idx + 1
354
- end
355
- end
356
-
357
- # helper to iterate over each pair in the original file order
358
- def each_org_pair
359
- return if @org_chunks.length < 2
360
- idx = 1
361
- chunk = @org_chunks[0]
362
- while idx < @org_chunks.length
363
- next_chunk = @org_chunks[idx]
364
- yield(chunk , next_chunk)
365
- chunk = next_chunk
366
- idx = idx + 1
367
- end
368
- end
369
-
370
- # get the next chunk in edited file order
371
- def get_next( prev )
372
- idx = @chunks.index prev
373
- return nil unless idx
374
- return nil if idx == @chunks.length - 1
375
- nekst = @chunks[idx + 1 ]
376
- return nekst
377
- end
378
-
379
- # add this chunk. This implementation keeps the order of both
380
- # arrays correct all the time
381
- def add_chunk( chunk )
382
- raise "Nil added " if not chunk
383
- raise "False added " if chunk == false
384
- @chunks.push( chunk )
385
- @chunks.sort! { |a , b |
386
- ret = a.start <=> b.start
387
- # so this adds the Deleted chunks into the edited file too
388
- if ret == 0
389
- ret = -1 if a.kind_of? Deleted
390
- ret = 1 if b.kind_of? Deleted
391
- end
392
- ret
393
- }
394
- @org_chunks.push(chunk)
395
- @org_chunks.sort! do |a , b | a.from <=> b.from end
396
- end
397
-
398
- def remove_chunk( chunk ) # for rotation, will be readded
399
- @chunks.delete(chunk)
400
- @org_chunks.delete(chunk)
401
- end
402
-
403
- #find the chunk that starts at the given position in the original file
404
- def find_from pos
405
- each_org do | chunk |
406
- #puts "FOUND for #{pos} #{chunk}"
407
- return chunk if chunk.from == pos
408
- end
409
- raise "Not found #{pos} in\n#{self}"
410
- # hmmm this was here for some reason I don't recall
411
- # return chunk.next if chunk.added and chunk.added.start == pos
412
- end
413
-
414
- # find the chunk left to these positions (original and edited) and return
415
- # the maximum bound a new chunk can expand too in both coordinates.
416
- def find_left_rim org , pos
417
- start_rim , two_rim = 0 ,0
418
- each_org do | two |
419
- start_rim = two.org_stop if start_rim <= two.org_stop and two.org_stop <= org
420
- end
421
- each do | one |
422
- two_rim = one.stop if two_rim <= one.stop and one.stop <= pos
423
- end
424
- #puts "Left rim #{org} #{pos} is #{start_rim} #{two_rim}" if DEBUG
425
- return start_rim , two_rim
426
- end
427
-
428
- # find the chunk right to these positions (original and edited) and return
429
- # the maximum bound a new chunk can expand too in both coordinates.
430
- def find_right_rim start , two , start_start , two_start
431
- start_rim , two_rim = start_start , two_start
432
- each_org do | tw |
433
- start_rim = tw.from if start <= tw.from and tw.from <= start_rim
434
- end
435
- each do | one |
436
- two_rim = one.start if two <= one.start and one.start <= two_rim
437
- end
438
- #puts "\Right rim #{start} #{two} is #{start_rim} #{two_rim}" if DEBUG
439
- return start_rim , two_rim
440
- end
441
-
442
- # that part is done if the are (start-stop) is already included in the
443
- # patches (first if) or the org part overlaps any of the patches org's
444
- # the second case is then a copy
445
- def done? two , org
446
- #puts "checking done? \n #{two} \n #{org} "
447
- each do |chunk|
448
- return true if chunk.overlaps? two
449
- end
450
- each_org do |chunk|
451
- return true if chunk.org_overlaps? org
452
- end
453
- #puts "NOT DONE? : \n #{self}"
454
- false
455
- end
456
-
457
- # yields all chunks in the sequence in edited file order
458
- def each
459
- @chunks.each do |chunk|
460
- yield chunk if chunk
461
- end
462
- end
463
-
464
- # yields all chunks in original file order
465
- def each_org
466
- @org_chunks.each do |chunk|
467
- yield chunk if chunk
468
- end
469
- end
470
-
471
- # change all chunks in this sequence so that they don't have overlaps with
472
- # any of the chunks in the given sequence. done both ways results in
473
- # non-overlapping sequences
474
- def no_overlap sequence
475
- each_org do |one|
476
- sequence.each_org do |two|
477
- break_at( one , two.from ) if one.org_includes?( two.from )
478
- break_at( one , two.org_stop ) if one.org_includes?( two.org_stop )
479
- end
480
- end
481
- end
482
-
483
- # split in two at pos (thus assuming pos is included) and link the
484
- def break_at( chunk , pos )
485
- return if pos == chunk.from or pos == chunk.org_stop
486
- old_s = chunk.to_s
487
- new_chunk = chunk.split_at_org!(pos)
488
- if not new_chunk.kind_of? Deleted
489
- new_chunk.added = chunk.added
490
- chunk.added = nil
491
- end
492
- #puts "SPLIT #{pos}\nBEFORE #{old_s}\nOLD:#{chunk} \nNEW:#{new_chunk} \n" if DEBUG
493
- idx = @chunks.index(chunk)
494
- @chunks[idx+1,0] = new_chunk
495
- idx = @org_chunks.index(chunk)
496
- @org_chunks[idx+1,0] = new_chunk
497
- end
498
-
499
- end
500
-
501
- # this is a little holder class (struct?) that represents a piece of text in
502
- # a file.
503
-
504
- class Chunk
505
- # the byte index into the file where the string is in (the edited file)
506
- attr_reader :start
507
- #length of the string (somewhat redundant with the string below)
508
- attr_reader :length
509
- # the actual string. This is just here for convinience, it's in the file
510
- attr_reader :str
511
- # the index into the original file where the string starts, -1 for adds
512
- attr_reader :from
513
- attr :added , true # a chunk that was added (if there is such a one)
514
- attr :whitespace , true # the table for whitespace
515
-
516
- # cut the chunk to max 71 characters for readable output
517
- def Chunk::short_string( s )
518
- if s.length < 71
519
- return "--" + s.to_s + "--"
520
- else
521
- return "--" + s[0,20] + "...Cut #{s.length-40} chars..." + s[s.length - 20 , 20] + "--"
522
- end
523
- end
524
-
525
- def initialize( start , length , string , from = -1)
526
- raise "Error nil string passed start=#{start} length=#{length} str=-#{str}=" if string.nil?
527
- @start , @length , @str , @from = start , length , string , from
528
- @whitespace = []
529
- end
530
-
531
- # outputs all attributes and a readable version of the string
532
- # also whitespace if present
533
- def to_s #for debug output
534
- st = "start=#{start} len=#{length} stop=#{stop} from=#{from} org_stop=#{org_stop} "
535
- st += Chunk::short_string(real_string)
536
- st += " \n added=#{added} " unless added.nil?
537
- st += " \n whitespace=#{@whitespace.length} " unless @whitespace.empty?
538
- ws_count = 0
539
- @whitespace.each do | start , s |
540
- st += "-" + start.to_s + " " + s.length.to_s + " "
541
- st += "n " if s.include?( "\n" )
542
- ws_count += 1
543
- break if ws_count > 5
544
- end
545
- st
546
- end
547
-
548
- # put the first character at the end
549
- def rotate
550
- @str = @str[1..-1] + @str[0,1]
551
- @start += 1
552
- end
553
-
554
- # puts the char at the end of the string, adjusting the length
555
- # add the whitespace if it's not nil
556
- def push( arg )
557
- char , space = arg
558
- @str << char
559
- @length += 1
560
- @whitespace << space unless space.nil?
561
- end
562
-
563
- # return the first char, and remove it from the string, adjusting length + start
564
- # also return any whitespace entry, if there is such a thing
565
- def pop
566
- white = nil
567
- if (not @whitespace.empty?) and (@whitespace.first[0] == @start )
568
- white = @whitespace.delete_at(0)
569
- puts "White --#{white}--#{@start}"
570
- end
571
- char = @str[0]
572
- @str = @str[1..-1]
573
- @length -= 1
574
- @start += 1
575
- @from += 1 if @from != -1
576
- return [ char , white ]
577
- end
578
-
579
- # squeeze the whitespace, ie for all sequences of whitespace(space,tab,newline),
580
- # and all non space whitespaces, replace it with a single whitespace and record
581
- # the change in the array
582
- def squeeze
583
- old = @str.dup
584
- @whitespace = []
585
- at = 0
586
- while ( index = @str.index(/\s+/ , at ) )
587
- at = index + $&.length
588
- if $& != ' ' # do nothing for single spaces
589
- @whitespace.push [ index , $& ]
590
- @str[index , $&.length] = ' '
591
- end
592
- end
593
- @length = @str.length
594
- throw old if DEBUG and old != real_string
595
- end
596
-
597
- # unsqueeze whitespace if present
598
- def real_string
599
- return @str if @whitespace.empty?
600
- stri = @str.dup
601
- #puts "--" + str + "--" + @str.length.to_s
602
- begin
603
- @whitespace.reverse.each do | index , st |
604
- stri[index - @start ,1] = st
605
- end
606
- rescue
607
- st = "start=#{start} len=#{length} stop=#{stop} from=#{from} org_stop=#{org_stop} " + @str
608
- st += " \n whitespace=#{@whitespace.length} "
609
- @whitespace.each do | start , s |
610
- st += "-" + start.to_s + " " + s.length.to_s + " "
611
- st += "n " if s.include?( "\n" )
612
- end
613
- puts st
614
- raise
615
- end
616
- stri
617
- end
618
-
619
- # get a substring from the chunk and carry whitespace table accross
620
- # start is in the files coordinates (not the strings of the chunk)
621
- def subchunk( startt , len , fromm )
622
- stri = @str[ startt - @start , len ]
623
- table = []
624
- @whitespace.each do | arr |
625
- table << arr if arr[0] >= startt and arr[0] < ( startt + len )
626
- end
627
- chunk = Chunk.new( startt , len , stri , fromm )
628
- chunk.whitespace = table
629
- #puts "SUB at #{startt} #{len} #{chunk}" if fromm == 62
630
- chunk
631
- end
632
-
633
- # index of where the string ends.
634
- # this should be called end, but that's a keyword.
635
- def stop
636
- @start + @length
637
- end
638
-
639
- # index of where the string ends in the original file (nonsense for adds)
640
- def org_stop
641
- @from + @length
642
- end
643
-
644
- def add? # adds are not copied, hence have no from attribute.
645
- @from == -1 # a copy carries a positive number as offset into the original
646
- end
647
-
648
- # is the point (char index) in the original copied string
649
- def org_includes? point
650
- ( @from != -1 ) and ( @from <= point ) and ( point < org_stop )
651
- end
652
-
653
- def includes_copy? copy # is the copy chunk fully inside this
654
- (copy.start >= @start) and (copy.stop <= stop)
655
- end
656
-
657
- # return a substring in the original files coordinates
658
- def rstring( fro , to )
659
- to = org_stop if to == -1
660
- throw "error #{fro} #{to} #{self}" if fro < @from or to > org_stop
661
- @length -= to - fro
662
- @str[ fro - @from , to - @from ]
663
- end
664
-
665
- # does some part of two overlap. always takes me 5 minutes to get
666
- def overlaps? two # but a drawing helps
667
- start > two.start ? start < two.stop : stop > two.start
668
- end
669
-
670
- #does any part of the original overlap (from - org_stop )
671
- def org_overlaps? two
672
- from > two.from ? from < two.org_stop : org_stop > two.from
673
- end
674
-
675
- # this joins two chunks, which are presumed to be adds (so no fiddling with from)
676
- # self is changed and the argument untouched (to be deleted)
677
- def join_adds add
678
- @str += add.str
679
- @length = @str.length
680
- end
681
-
682
- #split the chunk into two at the given position,
683
- # change this and return the right one
684
- def split_at_org! pos
685
- #puts "SPLIT #{pos} #{self}"
686
- throw "position not in chunk #{pos} : #{self}" unless org_includes?( pos )
687
- left_length = pos - @from
688
- right_length = org_stop - pos
689
- right = Chunk.new( @start + left_length , right_length , @str[left_length, right_length] , pos )
690
- right.whitespace = @whitespace.dup.delete_if do | index , s |
691
- index < right.start
692
- end
693
- #puts " split #{right} "
694
- throw "Right split error #{self} , #{right} :#{pos}" if right.length != right_length
695
- @str = @str[0, left_length]
696
- raise "Error nil string =#{start} length=#{length} str=-#{@str}=" if @str.nil?
697
- @length = @str.length
698
- @whitespace.delete_if do | index , s |
699
- index >= right.start
700
- end
701
- #puts " white #{@whitespace} "
702
- #puts " left #{self} "
703
- throw "Left split error #{self} , #{right} :#{pos} :#{left_length}" if @length != left_length
704
- return right
705
- end
706
-
707
- end
708
-
709
- # a seperate class for deleted chunks (for destinction)
710
- class Deleted < Chunk
711
-
712
- def initialize start , from , string
713
- @start = start
714
- @length = string.length
715
- @str = string
716
- @from = from
717
- @whitespace = []
718
- raise "Error nil string =#{start} length=#{length} str=-#{@str}=" if string.nil?
719
- end
720
-
721
- def stop # no length in the modified file
722
- @start
723
- end
724
-
725
- def split_at_org! pos
726
- raise "position not in chunk #{pos} : #{self}" unless org_includes?( pos )
727
- left_length = pos - @from
728
- right_length = org_stop - pos
729
- right = Deleted.new( @start + left_length , pos , @str[left_length, @length] )
730
- raise "Back to the right drawingboard #{self} , #{right} :#{pos}" if right.length != right_length
731
- @str = @str[0, left_length]
732
- @length = @str.length
733
- raise "Back to the left drawingboard #{self} , #{right} :#{pos} :#{left_length}" if @length != left_length
734
- raise "Error nil string =#{start} length=#{length} str=-#{@str}=" if @str.nil?
735
- return right
736
- end
737
-
738
- def to_s
739
- super.to_s + " deleted"
740
- end
741
-
742
- end
743
-
744
- def main()
745
-
746
- ignore_whitespace = false
747
-
748
- args = ARGV.dup
749
-
750
- if args[0] == "-w"
751
- ignore_whitespace = true
752
- args.shift
753
- end
754
- start = File.new( args.shift ).read
755
- one = File.new( args.shift ).read
756
- two = File.new( args.shift ).read
757
-
758
- result = Merge3::three_way( start , one , two , ignore_whitespace )
759
-
760
- puts result
761
-
762
- end
763
-
764
- main() if $0 == __FILE__
765
-