facets 1.7.0 → 1.7.30

Sign up to get free protection for your applications and to get access to all the features.
Files changed (456) hide show
  1. data/{meta/projectinfo → PROJECT} +1 -3
  2. data/README +114 -47
  3. data/VERSION +1 -0
  4. data/doc/{ChangeLog → CHANGELOG} +30 -0
  5. data/doc/{ChangeLog.pre1.5 → CHANGELOG.1} +0 -0
  6. data/{COPYING → doc/COPYING} +0 -0
  7. data/lib/facet/cache.rb +1 -0
  8. data/lib/facet/doublemetaphone.rb +1 -0
  9. data/lib/facet/enumerable/eachn.rb +1 -0
  10. data/lib/facet/file/self/null.rb +1 -0
  11. data/lib/facet/filesystem.rb +1 -0
  12. data/lib/facet/filetest/self/root.rb +1 -0
  13. data/lib/facet/hash/delete_at.rb +1 -0
  14. data/lib/facet/hash/delete_values.rb +1 -0
  15. data/lib/facet/hash/delete_values_at.rb +1 -0
  16. data/lib/facet/kernel/load_local.rb +1 -0
  17. data/lib/facet/main_as_module.rb +1 -0
  18. data/lib/facet/nilclass/to_path.rb +1 -0
  19. data/lib/facet/symbol/to_s.rb +1 -0
  20. data/lib/facets.rb +1 -0
  21. data/lib/facets/core/array/delete_values_at.rb +2 -0
  22. data/lib/facets/core/array/op_fetch.rb +27 -0
  23. data/lib/facets/core/array/op_store.rb +2 -47
  24. data/lib/facets/core/enumerable/each_by.rb +91 -2
  25. data/lib/facets/core/enumerable/eachn.rb +41 -0
  26. data/lib/facets/core/file/self/null.rb +17 -0
  27. data/lib/facets/core/filetest/self/root.rb +13 -0
  28. data/lib/facets/core/hash/delete_at.rb +10 -0
  29. data/lib/facets/core/hash/delete_values.rb +20 -0
  30. data/lib/facets/core/hash/delete_values_at.rb +24 -0
  31. data/lib/facets/core/hash/each.rb +26 -11
  32. data/lib/facets/core/kernel/load_local.rb +26 -0
  33. data/lib/facets/core/nilclass/to_path.rb +18 -0
  34. data/lib/facets/core/symbol/to_s.rb +10 -0
  35. data/lib/facets/more/association.rb +1 -1
  36. data/lib/facets/more/cache.rb +81 -0
  37. data/lib/facets/more/command.rb +11 -1
  38. data/lib/facets/more/doublemetaphone.rb +371 -0
  39. data/lib/facets/more/filesystem.rb +43 -0
  40. data/lib/facets/more/main_as_module.rb +42 -0
  41. data/lib/facets/more/taskable.rb +89 -212
  42. data/setup.rb +204 -181
  43. data/test/lib/facets/core/array/test_at_rand.rb +1 -1
  44. data/test/lib/facets/core/array/test_delete_unless.rb +1 -1
  45. data/test/lib/facets/core/array/test_delete_values.rb +1 -1
  46. data/test/lib/facets/core/array/test_delete_values_at.rb +1 -1
  47. data/test/lib/facets/core/array/test_first.rb +1 -1
  48. data/test/lib/facets/core/array/test_head.rb +1 -1
  49. data/test/lib/facets/core/array/test_last_index.rb +1 -1
  50. data/test/lib/facets/core/array/test_merge.rb +1 -1
  51. data/test/lib/facets/core/array/test_mid.rb +1 -1
  52. data/test/lib/facets/core/array/test_middle.rb +1 -1
  53. data/test/lib/facets/core/array/test_op_fetch.rb +9 -1
  54. data/test/lib/facets/core/array/test_op_store.rb +1 -1
  55. data/test/lib/facets/core/array/test_pick.rb +1 -1
  56. data/test/lib/facets/core/array/test_pos.rb +1 -1
  57. data/test/lib/facets/core/array/test_pot.rb +1 -1
  58. data/test/lib/facets/core/array/test_pull.rb +1 -1
  59. data/test/lib/facets/core/array/test_rand_index.rb +1 -1
  60. data/test/lib/facets/core/array/test_rand_subset.rb +1 -1
  61. data/test/lib/facets/core/array/test_range.rb +1 -1
  62. data/test/lib/facets/core/array/test_rotate.rb +1 -1
  63. data/test/lib/facets/core/array/test_select.rb +1 -1
  64. data/test/lib/facets/core/array/test_shuffle.rb +1 -1
  65. data/test/lib/facets/core/array/test_thru.rb +1 -1
  66. data/test/lib/facets/core/array/test_to_b.rb +1 -1
  67. data/test/lib/facets/core/array/test_to_h.rb +1 -1
  68. data/test/lib/facets/core/array/test_to_hash.rb +1 -1
  69. data/test/lib/facets/core/binding/self/test_of_caller.rb +1 -1
  70. data/test/lib/facets/core/binding/test___LINE__.rb +1 -1
  71. data/test/lib/facets/core/binding/test_call_stack.rb +1 -1
  72. data/test/lib/facets/core/binding/test_called.rb +1 -1
  73. data/test/lib/facets/core/binding/test_caller.rb +1 -1
  74. data/test/lib/facets/core/binding/test_defined.rb +1 -1
  75. data/test/lib/facets/core/binding/test_eval.rb +1 -1
  76. data/test/lib/facets/core/binding/test_local_variables.rb +1 -1
  77. data/test/lib/facets/core/binding/test_method_name.rb +1 -1
  78. data/test/lib/facets/core/binding/test_op_fetch.rb +1 -1
  79. data/test/lib/facets/core/binding/test_op_store.rb +1 -1
  80. data/test/lib/facets/core/binding/test_self.rb +1 -1
  81. data/test/lib/facets/core/class/test_cattr.rb +1 -1
  82. data/test/lib/facets/core/class/test_descendents.rb +1 -1
  83. data/test/lib/facets/core/class/test_method_name.rb +1 -1
  84. data/test/lib/facets/core/class/test_remove_descendents.rb +1 -1
  85. data/test/lib/facets/core/class/test_unix_path.rb +1 -1
  86. data/test/lib/facets/core/comparable/test_at_least.rb +1 -1
  87. data/test/lib/facets/core/comparable/test_clip.rb +1 -1
  88. data/test/lib/facets/core/comparable/test_cmp.rb +1 -1
  89. data/test/lib/facets/core/continuation/self/test_create.rb +1 -1
  90. data/test/lib/facets/core/date/test_days_in_month.rb +1 -1
  91. data/test/lib/facets/core/date/test_days_of_month.rb +1 -1
  92. data/test/lib/facets/core/date/test_stamp.rb +1 -1
  93. data/test/lib/facets/core/date/test_to_date.rb +1 -1
  94. data/test/lib/facets/core/date/test_to_s.rb +1 -1
  95. data/test/lib/facets/core/date/test_to_time.rb +1 -1
  96. data/test/lib/facets/core/dir/self/test_ancestor.rb +1 -1
  97. data/test/lib/facets/core/dir/self/test_ascend.rb +1 -1
  98. data/test/lib/facets/core/enumerable/self/test_combinations.rb +1 -1
  99. data/test/lib/facets/core/enumerable/self/test_cross.rb +1 -1
  100. data/test/lib/facets/core/enumerable/test_collect_with_index.rb +1 -1
  101. data/test/lib/facets/core/enumerable/test_commonality.rb +1 -1
  102. data/test/lib/facets/core/enumerable/test_compact_collect.rb +1 -1
  103. data/test/lib/facets/core/enumerable/test_count.rb +1 -1
  104. data/test/lib/facets/core/enumerable/test_cross.rb +1 -1
  105. data/test/lib/facets/core/enumerable/test_each_by.rb +71 -0
  106. data/test/lib/facets/core/enumerable/test_each_combination.rb +1 -1
  107. data/test/lib/facets/core/enumerable/test_each_pair.rb +1 -1
  108. data/test/lib/facets/core/enumerable/test_each_unique_pair.rb +1 -1
  109. data/test/lib/facets/core/enumerable/test_eachn.rb +34 -0
  110. data/test/lib/facets/core/enumerable/test_entropy.rb +1 -1
  111. data/test/lib/facets/core/enumerable/test_every.rb +1 -1
  112. data/test/lib/facets/core/enumerable/test_ew.rb +1 -1
  113. data/test/lib/facets/core/enumerable/test_filter_collect.rb +1 -1
  114. data/test/lib/facets/core/enumerable/test_find_collisions.rb +1 -1
  115. data/test/lib/facets/core/enumerable/test_frequency.rb +1 -1
  116. data/test/lib/facets/core/enumerable/test_graph.rb +1 -1
  117. data/test/lib/facets/core/enumerable/test_ideal_entropy.rb +1 -1
  118. data/test/lib/facets/core/enumerable/test_none.rb +1 -1
  119. data/test/lib/facets/core/enumerable/test_occur.rb +1 -1
  120. data/test/lib/facets/core/enumerable/test_one.rb +1 -1
  121. data/test/lib/facets/core/enumerable/test_op_pow.rb +1 -1
  122. data/test/lib/facets/core/enumerable/test_partition_by.rb +1 -1
  123. data/test/lib/facets/core/enumerable/test_permute.rb +1 -1
  124. data/test/lib/facets/core/enumerable/test_probability.rb +1 -1
  125. data/test/lib/facets/core/enumerable/test_to_h.rb +1 -1
  126. data/test/lib/facets/core/enumerable/test_uniq_by.rb +1 -1
  127. data/test/lib/facets/core/file/self/test_create.rb +1 -1
  128. data/test/lib/facets/core/file/self/test_open_as_string.rb +1 -1
  129. data/test/lib/facets/core/file/self/test_read_list.rb +1 -1
  130. data/test/lib/facets/core/file/self/test_sanitize.rb +1 -1
  131. data/test/lib/facets/core/file/self/test_split_all.rb +1 -1
  132. data/test/lib/facets/core/float/test_round_at.rb +1 -1
  133. data/test/lib/facets/core/float/test_round_to.rb +1 -1
  134. data/test/lib/facets/core/hash/self/test_zipnew.rb +1 -1
  135. data/test/lib/facets/core/hash/test_alias.rb +1 -1
  136. data/test/lib/facets/core/hash/test_assert_has_keys.rb +1 -1
  137. data/test/lib/facets/core/hash/test_assert_has_only_keys.rb +1 -1
  138. data/test/lib/facets/core/hash/test_at.rb +1 -1
  139. data/test/lib/facets/core/hash/test_collate.rb +1 -1
  140. data/test/lib/facets/core/hash/test_each.rb +1 -1
  141. data/test/lib/facets/core/hash/test_each_with_index.rb +1 -1
  142. data/test/lib/facets/core/hash/test_each_with_key.rb +1 -1
  143. data/test/lib/facets/core/hash/test_graph.rb +1 -1
  144. data/test/lib/facets/core/hash/test_has_keys.rb +1 -1
  145. data/test/lib/facets/core/hash/test_has_only_keys.rb +1 -1
  146. data/test/lib/facets/core/hash/test_inverse.rb +1 -1
  147. data/test/lib/facets/core/hash/test_normalize_keys.rb +1 -1
  148. data/test/lib/facets/core/hash/test_op_fetch.rb +1 -1
  149. data/test/lib/facets/core/hash/test_op_lshift.rb +1 -1
  150. data/test/lib/facets/core/hash/test_rand_key.rb +1 -1
  151. data/test/lib/facets/core/hash/test_rand_pair.rb +1 -1
  152. data/test/lib/facets/core/hash/test_rand_value.rb +1 -1
  153. data/test/lib/facets/core/hash/test_replace_each.rb +1 -1
  154. data/test/lib/facets/core/hash/test_shuffle.rb +1 -1
  155. data/test/lib/facets/core/hash/test_slice.rb +1 -1
  156. data/test/lib/facets/core/hash/test_stringify_keys.rb +1 -1
  157. data/test/lib/facets/core/hash/test_swap.rb +1 -1
  158. data/test/lib/facets/core/hash/test_swapkey.rb +1 -1
  159. data/test/lib/facets/core/hash/test_symbolize_keys.rb +1 -1
  160. data/test/lib/facets/core/hash/test_to_h.rb +1 -1
  161. data/test/lib/facets/core/hash/test_to_ostruct.rb +1 -1
  162. data/test/lib/facets/core/hash/test_to_ostruct_recurse.rb +1 -1
  163. data/test/lib/facets/core/hash/test_traverse.rb +1 -1
  164. data/test/lib/facets/core/hash/test_update_each.rb +1 -1
  165. data/test/lib/facets/core/hash/test_update_keys.rb +1 -1
  166. data/test/lib/facets/core/hash/test_update_values.rb +1 -1
  167. data/test/lib/facets/core/hash/test_weave.rb +1 -1
  168. data/test/lib/facets/core/integer/test_factorial.rb +1 -1
  169. data/test/lib/facets/core/integer/test_multiple.rb +1 -1
  170. data/test/lib/facets/core/integer/test_of.rb +1 -1
  171. data/test/lib/facets/core/integer/test_ordinal.rb +1 -1
  172. data/test/lib/facets/core/integer/test_times_collect.rb +1 -1
  173. data/test/lib/facets/core/kernel/test___class__.rb +1 -1
  174. data/test/lib/facets/core/kernel/test_as.rb +1 -1
  175. data/test/lib/facets/core/kernel/test_assign_from.rb +1 -1
  176. data/test/lib/facets/core/kernel/test_assign_with.rb +1 -1
  177. data/test/lib/facets/core/kernel/test_bool.rb +1 -1
  178. data/test/lib/facets/core/kernel/test_bug.rb +1 -1
  179. data/test/lib/facets/core/kernel/test_call_stack.rb +1 -1
  180. data/test/lib/facets/core/kernel/test_called.rb +1 -1
  181. data/test/lib/facets/core/kernel/test_callee.rb +1 -1
  182. data/test/lib/facets/core/kernel/test_constant.rb +1 -1
  183. data/test/lib/facets/core/kernel/test_copy.rb +1 -1
  184. data/test/lib/facets/core/kernel/test_deep_copy.rb +1 -1
  185. data/test/lib/facets/core/kernel/test_demo.rb +1 -1
  186. data/test/lib/facets/core/kernel/test_fn.rb +1 -1
  187. data/test/lib/facets/core/kernel/test_get_by_id.rb +1 -1
  188. data/test/lib/facets/core/kernel/test_here.rb +1 -1
  189. data/test/lib/facets/core/kernel/test_in.rb +1 -1
  190. data/test/lib/facets/core/kernel/test_instance_exec.rb +1 -1
  191. data/test/lib/facets/core/kernel/test_maybe.rb +1 -1
  192. data/test/lib/facets/core/kernel/test_metaclass.rb +1 -1
  193. data/test/lib/facets/core/kernel/test_method.rb +1 -1
  194. data/test/lib/facets/core/kernel/test_methods.rb +1 -1
  195. data/test/lib/facets/core/kernel/test_new.rb +1 -1
  196. data/test/lib/facets/core/kernel/test_object_class.rb +1 -1
  197. data/test/lib/facets/core/kernel/test_object_hexid.rb +1 -1
  198. data/test/lib/facets/core/kernel/test_quaclass.rb +1 -1
  199. data/test/lib/facets/core/kernel/test_require_all.rb +1 -1
  200. data/test/lib/facets/core/kernel/test_require_esc.rb +1 -1
  201. data/test/lib/facets/core/kernel/test_require_facet.rb +1 -1
  202. data/test/lib/facets/core/kernel/test_resc.rb +1 -1
  203. data/test/lib/facets/core/kernel/test_returning.rb +1 -1
  204. data/test/lib/facets/core/kernel/test_send_as.rb +1 -1
  205. data/test/lib/facets/core/kernel/test_set_from.rb +1 -1
  206. data/test/lib/facets/core/kernel/test_set_with.rb +1 -1
  207. data/test/lib/facets/core/kernel/test_silently.rb +1 -1
  208. data/test/lib/facets/core/kernel/test_singleton.rb +1 -1
  209. data/test/lib/facets/core/kernel/test_singleton_class.rb +1 -1
  210. data/test/lib/facets/core/kernel/test_superior.rb +1 -1
  211. data/test/lib/facets/core/kernel/test_supermethod.rb +1 -1
  212. data/test/lib/facets/core/kernel/test_this.rb +1 -1
  213. data/test/lib/facets/core/kernel/test_to_b.rb +1 -1
  214. data/test/lib/facets/core/kernel/test_to_bool.rb +1 -1
  215. data/test/lib/facets/core/kernel/test_to_data.rb +1 -1
  216. data/test/lib/facets/core/kernel/test_uri.rb +1 -1
  217. data/test/lib/facets/core/kernel/test_val.rb +1 -1
  218. data/test/lib/facets/core/kernel/test_with_accessor.rb +1 -1
  219. data/test/lib/facets/core/matchdata/test_match.rb +1 -1
  220. data/test/lib/facets/core/matchdata/test_matchtree.rb +1 -1
  221. data/test/lib/facets/core/module/test_abstract.rb +1 -1
  222. data/test/lib/facets/core/module/test_alias_module_function.rb +1 -1
  223. data/test/lib/facets/core/module/test_ancestor.rb +1 -1
  224. data/test/lib/facets/core/module/test_basename.rb +1 -1
  225. data/test/lib/facets/core/module/test_by_name.rb +1 -1
  226. data/test/lib/facets/core/module/test_class_extension.rb +1 -1
  227. data/test/lib/facets/core/module/test_clone_using.rb +1 -1
  228. data/test/lib/facets/core/module/test_dirname.rb +1 -1
  229. data/test/lib/facets/core/module/test_equate_on.rb +1 -1
  230. data/test/lib/facets/core/module/test_include_as.rb +1 -1
  231. data/test/lib/facets/core/module/test_initializer.rb +1 -1
  232. data/test/lib/facets/core/module/test_instance_methods.rb +1 -1
  233. data/test/lib/facets/core/module/test_integrate.rb +1 -1
  234. data/test/lib/facets/core/module/test_memoize.rb +1 -1
  235. data/test/lib/facets/core/module/test_modspace.rb +1 -1
  236. data/test/lib/facets/core/module/test_namespace.rb +1 -1
  237. data/test/lib/facets/core/module/test_nesting.rb +1 -1
  238. data/test/lib/facets/core/module/test_nodef.rb +1 -1
  239. data/test/lib/facets/core/module/test_on_included.rb +1 -1
  240. data/test/lib/facets/core/module/test_redef.rb +1 -1
  241. data/test/lib/facets/core/module/test_redefine_method.rb +1 -1
  242. data/test/lib/facets/core/module/test_redirect.rb +1 -1
  243. data/test/lib/facets/core/module/test_redirect_method.rb +1 -1
  244. data/test/lib/facets/core/module/test_remove.rb +1 -1
  245. data/test/lib/facets/core/module/test_rename.rb +1 -1
  246. data/test/lib/facets/core/module/test_rename_method.rb +1 -1
  247. data/test/lib/facets/core/module/test_revisal.rb +1 -1
  248. data/test/lib/facets/core/module/test_shadow_method.rb +1 -1
  249. data/test/lib/facets/core/module/test_sort_on.rb +1 -1
  250. data/test/lib/facets/core/module/test_this.rb +1 -1
  251. data/test/lib/facets/core/module/test_wrap.rb +1 -1
  252. data/test/lib/facets/core/module/test_wrap_method.rb +1 -1
  253. data/test/lib/facets/core/nilclass/test_blank.rb +1 -1
  254. data/test/lib/facets/core/nilclass/test_empty.rb +1 -1
  255. data/test/lib/facets/core/nilclass/test_include.rb +1 -1
  256. data/test/lib/facets/core/nilclass/test_op_fetch.rb +1 -1
  257. data/test/lib/facets/core/nilclass/test_size.rb +1 -1
  258. data/test/lib/facets/core/nilclass/test_to_h.rb +1 -1
  259. data/test/lib/facets/core/numeric/test_approx.rb +1 -1
  260. data/test/lib/facets/core/numeric/test_ceil_multiple.rb +1 -1
  261. data/test/lib/facets/core/numeric/test_distance.rb +1 -1
  262. data/test/lib/facets/core/numeric/test_succ.rb +1 -1
  263. data/test/lib/facets/core/numeric/test_to_b.rb +1 -1
  264. data/test/lib/facets/core/ostruct/test___merge__.rb +1 -1
  265. data/test/lib/facets/core/ostruct/test___update__.rb +1 -1
  266. data/test/lib/facets/core/ostruct/test_op_fetch.rb +1 -1
  267. data/test/lib/facets/core/ostruct/test_op_store.rb +1 -1
  268. data/test/lib/facets/core/proc/test_compose.rb +1 -1
  269. data/test/lib/facets/core/proc/test_op_mul.rb +1 -1
  270. data/test/lib/facets/core/proc/test_to_method.rb +1 -1
  271. data/test/lib/facets/core/range/test_to_r.rb +1 -1
  272. data/test/lib/facets/core/range/test_to_range.rb +1 -1
  273. data/test/lib/facets/core/range/test_umbrella.rb +1 -1
  274. data/test/lib/facets/core/range/test_within.rb +1 -1
  275. data/test/lib/facets/core/regexp/test_arity.rb +1 -1
  276. data/test/lib/facets/core/regexp/test_to_re.rb +1 -1
  277. data/test/lib/facets/core/regexp/test_to_regexp.rb +1 -1
  278. data/test/lib/facets/core/string/self/test_interpolate.rb +1 -1
  279. data/test/lib/facets/core/string/self/test_patterns.rb +1 -1
  280. data/test/lib/facets/core/string/self/test_rand_letter.rb +1 -1
  281. data/test/lib/facets/core/string/test_align_center.rb +1 -1
  282. data/test/lib/facets/core/string/test_at_rand.rb +1 -1
  283. data/test/lib/facets/core/string/test_basename.rb +1 -1
  284. data/test/lib/facets/core/string/test_blank.rb +1 -1
  285. data/test/lib/facets/core/string/test_bracket.rb +1 -1
  286. data/test/lib/facets/core/string/test_camelcase.rb +1 -1
  287. data/test/lib/facets/core/string/test_camelize.rb +1 -1
  288. data/test/lib/facets/core/string/test_capitalized.rb +1 -1
  289. data/test/lib/facets/core/string/test_chars.rb +1 -1
  290. data/test/lib/facets/core/string/test_cmp.rb +1 -1
  291. data/test/lib/facets/core/string/test_demodulize.rb +1 -1
  292. data/test/lib/facets/core/string/test_divide.rb +1 -1
  293. data/test/lib/facets/core/string/test_downcase.rb +1 -1
  294. data/test/lib/facets/core/string/test_dresner.rb +1 -1
  295. data/test/lib/facets/core/string/test_each_char.rb +1 -1
  296. data/test/lib/facets/core/string/test_each_word.rb +1 -1
  297. data/test/lib/facets/core/string/test_first.rb +1 -1
  298. data/test/lib/facets/core/string/test_fold.rb +1 -1
  299. data/test/lib/facets/core/string/test_humanize.rb +1 -1
  300. data/test/lib/facets/core/string/test_indent.rb +1 -1
  301. data/test/lib/facets/core/string/test_index_all.rb +1 -1
  302. data/test/lib/facets/core/string/test_last.rb +1 -1
  303. data/test/lib/facets/core/string/test_line_wrap.rb +1 -1
  304. data/test/lib/facets/core/string/test_lines.rb +1 -1
  305. data/test/lib/facets/core/string/test_lowercase.rb +1 -1
  306. data/test/lib/facets/core/string/test_margin.rb +1 -1
  307. data/test/lib/facets/core/string/test_methodize.rb +1 -1
  308. data/test/lib/facets/core/string/test_modulize.rb +1 -1
  309. data/test/lib/facets/core/string/test_mscan.rb +1 -1
  310. data/test/lib/facets/core/string/test_natcmp.rb +1 -1
  311. data/test/lib/facets/core/string/test_nchar.rb +1 -1
  312. data/test/lib/facets/core/string/test_pathize.rb +1 -1
  313. data/test/lib/facets/core/string/test_pop.rb +1 -1
  314. data/test/lib/facets/core/string/test_pot.rb +1 -1
  315. data/test/lib/facets/core/string/test_push.rb +1 -1
  316. data/test/lib/facets/core/string/test_quote.rb +1 -1
  317. data/test/lib/facets/core/string/test_rand_byte.rb +1 -1
  318. data/test/lib/facets/core/string/test_rand_index.rb +1 -1
  319. data/test/lib/facets/core/string/test_range.rb +1 -1
  320. data/test/lib/facets/core/string/test_range_all.rb +1 -1
  321. data/test/lib/facets/core/string/test_range_of_line.rb +1 -1
  322. data/test/lib/facets/core/string/test_regesc.rb +1 -1
  323. data/test/lib/facets/core/string/test_shatter.rb +1 -1
  324. data/test/lib/facets/core/string/test_shift.rb +1 -1
  325. data/test/lib/facets/core/string/test_shuffle.rb +1 -1
  326. data/test/lib/facets/core/string/test_similarity.rb +1 -1
  327. data/test/lib/facets/core/string/test_singular.rb +1 -1
  328. data/test/lib/facets/core/string/test_soundex.rb +1 -1
  329. data/test/lib/facets/core/string/test_succ.rb +1 -1
  330. data/test/lib/facets/core/string/test_to_a.rb +1 -1
  331. data/test/lib/facets/core/string/test_to_b.rb +1 -1
  332. data/test/lib/facets/core/string/test_to_const.rb +1 -1
  333. data/test/lib/facets/core/string/test_to_date.rb +1 -1
  334. data/test/lib/facets/core/string/test_to_proc.rb +1 -1
  335. data/test/lib/facets/core/string/test_to_re.rb +1 -1
  336. data/test/lib/facets/core/string/test_to_time.rb +1 -1
  337. data/test/lib/facets/core/string/test_unix_crypt.rb +1 -1
  338. data/test/lib/facets/core/string/test_unpack.rb +1 -1
  339. data/test/lib/facets/core/string/test_unshift.rb +1 -1
  340. data/test/lib/facets/core/string/test_upcase.rb +1 -1
  341. data/test/lib/facets/core/string/test_whitespace.rb +1 -1
  342. data/test/lib/facets/core/string/test_word_filter.rb +1 -1
  343. data/test/lib/facets/core/string/test_word_wrap.rb +1 -1
  344. data/test/lib/facets/core/string/test_words.rb +1 -1
  345. data/test/lib/facets/core/symbol/test_camelcase.rb +1 -1
  346. data/test/lib/facets/core/symbol/test_camelize.rb +1 -1
  347. data/test/lib/facets/core/symbol/test_capitalize.rb +1 -1
  348. data/test/lib/facets/core/symbol/test_capitalized.rb +1 -1
  349. data/test/lib/facets/core/symbol/test_downcase.rb +1 -1
  350. data/test/lib/facets/core/symbol/test_not.rb +1 -1
  351. data/test/lib/facets/core/symbol/test_pad.rb +1 -1
  352. data/test/lib/facets/core/symbol/test_succ.rb +1 -1
  353. data/test/lib/facets/core/symbol/test_to_const.rb +1 -1
  354. data/test/lib/facets/core/symbol/test_to_proc.rb +1 -1
  355. data/test/lib/facets/core/symbol/test_to_str.rb +1 -1
  356. data/test/lib/facets/core/symbol/test_underscore.rb +1 -1
  357. data/test/lib/facets/core/symbol/test_upcase.rb +1 -1
  358. data/test/lib/facets/core/time/test_change.rb +1 -1
  359. data/test/lib/facets/core/time/test_elapse.rb +1 -1
  360. data/test/lib/facets/core/time/test_stamp.rb +1 -1
  361. data/test/lib/facets/core/time/test_to_date.rb +1 -1
  362. data/test/lib/facets/core/time/test_to_s.rb +1 -1
  363. data/test/lib/facets/core/time/test_to_time.rb +1 -1
  364. data/test/lib/facets/more/test_annattr.rb +1 -1
  365. data/test/lib/facets/more/test_annotation.rb +1 -1
  366. data/test/lib/facets/more/test_ansicode.rb +1 -1
  367. data/test/lib/facets/more/test_association.rb +1 -1
  368. data/test/lib/facets/more/test_autoarray.rb +1 -1
  369. data/test/lib/facets/more/test_basicobject.rb +1 -1
  370. data/test/lib/facets/more/test_bbcode.rb +1 -1
  371. data/test/lib/facets/more/test_binaryreader.rb +1 -1
  372. data/test/lib/facets/more/test_bitmask.rb +1 -1
  373. data/test/lib/facets/more/test_bytes.rb +1 -1
  374. data/test/lib/facets/more/test_classmethods.rb +1 -1
  375. data/test/lib/facets/more/test_command.rb +1 -1
  376. data/test/lib/facets/more/test_coroutine.rb +1 -1
  377. data/test/lib/facets/more/test_crypt.rb +1 -1
  378. data/test/lib/facets/more/test_cut.rb +1 -1
  379. data/test/lib/facets/more/test_dictionary.rb +1 -1
  380. data/test/lib/facets/more/test_elementor.rb +1 -1
  381. data/test/lib/facets/more/test_enumerablepass.rb +1 -1
  382. data/test/lib/facets/more/test_floatstring.rb +1 -1
  383. data/test/lib/facets/more/test_functor.rb +1 -1
  384. data/test/lib/facets/more/test_htmlbuilder.rb +1 -1
  385. data/test/lib/facets/more/test_infinity.rb +1 -1
  386. data/test/lib/facets/more/test_inheritor.rb +1 -1
  387. data/test/lib/facets/more/test_instance_intercept.rb +1 -1
  388. data/test/lib/facets/more/test_interval.rb +1 -1
  389. data/test/lib/facets/more/test_json.rb +1 -1
  390. data/test/lib/facets/more/test_lisp.rb +1 -1
  391. data/test/lib/facets/more/test_lisp_format.rb +1 -1
  392. data/test/lib/facets/more/test_lrucache.rb +1 -1
  393. data/test/lib/facets/more/test_mathconstants.rb +1 -1
  394. data/test/lib/facets/more/test_methodfilter.rb +1 -1
  395. data/test/lib/facets/more/test_methodprobe.rb +1 -1
  396. data/test/lib/facets/more/test_multipliers.rb +1 -1
  397. data/test/lib/facets/more/test_multiton.rb +1 -1
  398. data/test/lib/facets/more/test_nackclass.rb +1 -1
  399. data/test/lib/facets/more/test_nilcomparable.rb +1 -1
  400. data/test/lib/facets/more/test_opencascade.rb +1 -1
  401. data/test/lib/facets/more/test_openobject.rb +1 -1
  402. data/test/lib/facets/more/test_overload.rb +1 -1
  403. data/test/lib/facets/more/test_paramix.rb +1 -1
  404. data/test/lib/facets/more/test_pqueue.rb +1 -1
  405. data/test/lib/facets/more/test_predicate.rb +1 -1
  406. data/test/lib/facets/more/test_preinitialize.rb +1 -1
  407. data/test/lib/facets/more/test_promoteself.rb +1 -1
  408. data/test/lib/facets/more/test_recorder.rb +1 -1
  409. data/test/lib/facets/more/test_snapshot.rb +1 -1
  410. data/test/lib/facets/more/test_statichash.rb +1 -1
  411. data/test/lib/facets/more/test_syncarray.rb +1 -1
  412. data/test/lib/facets/more/test_synchash.rb +1 -1
  413. data/test/lib/facets/more/test_tagiterator.rb +1 -1
  414. data/test/lib/facets/more/test_taskable.rb +28 -7
  415. data/test/lib/facets/more/test_timer.rb +1 -1
  416. data/test/lib/facets/more/test_times.rb +1 -1
  417. data/test/lib/facets/more/test_tuple.rb +1 -1
  418. data/test/lib/facets/more/test_typecast.rb +1 -1
  419. data/test/lib/facets/more/test_uninheritable.rb +1 -1
  420. data/test/lib/facets/more/test_units.rb +1 -1
  421. data/test/lib/facets/more/test_xmlbuilder.rb +1 -1
  422. data/test/lib/facets/more/test_xmlhelper.rb +1 -1
  423. data/test/lib/facets/more/test_xoxo.rb +1 -1
  424. data/test/lib/facets/more/test_yamlstruct.rb +1 -1
  425. data/util/announce +20 -0
  426. data/util/changelog +8 -0
  427. data/util/count +8 -0
  428. data/util/extest +8 -0
  429. data/util/list +38 -0
  430. data/util/package +9 -0
  431. data/util/prepare +12 -0
  432. data/util/redirect +34 -0
  433. data/util/release +13 -0
  434. data/util/setup +7 -0
  435. data/util/test +7 -0
  436. data/util/version +8 -0
  437. metadata +1514 -1491
  438. data/doc/CAUTION +0 -55
  439. data/doc/IMPORTANT +0 -8
  440. data/doc/LATEST +0 -41
  441. data/doc/history/ANN-0.6.0 +0 -40
  442. data/doc/history/ANN-0.6.1 +0 -36
  443. data/doc/history/ANN-0.6.3 +0 -43
  444. data/doc/history/ANN-0.7.0 +0 -59
  445. data/doc/history/ANN-0.8.1 +0 -127
  446. data/doc/history/INTRO +0 -172
  447. data/doc/history/README +0 -223
  448. data/doc/history/README-OLD +0 -180
  449. data/doc/manifest +0 -1209
  450. data/doc/scrap/Rakefile.old +0 -181
  451. data/lib/facet/enumerable/each_slice.rb +0 -1
  452. data/lib/facets/core/enumerable/each_slice.rb +0 -131
  453. data/meta/reapfile +0 -184
  454. data/meta/task +0 -74
  455. data/meta/tasks/calibre.rb +0 -16
  456. data/meta/version +0 -1
@@ -0,0 +1,41 @@
1
+ #--
2
+ # Martin DeMello
3
+ #++
4
+
5
+ require 'enumerator'
6
+
7
+ module Enumerable
8
+ def eachn(&block)
9
+ n = block.arity.abs
10
+ each_slice(n) {|i| block.call(*i)}
11
+ end
12
+ end
13
+
14
+
15
+ # _____ _
16
+ # |_ _|__ ___| |_
17
+ # | |/ _ \/ __| __|
18
+ # | | __/\__ \ |_
19
+ # |_|\___||___/\__|
20
+ #
21
+ =begin test
22
+
23
+ require 'test/unit'
24
+
25
+ class TCEnumerable < Test::Unit::TestCase
26
+
27
+ def test_eachn
28
+ x = []
29
+ [1,2,3,4].eachn{ |a,b| x << [a,b] }
30
+ o = [[1,2],[3,4]]
31
+ assert_equal( o, x )
32
+
33
+ x = []
34
+ [1,2,3,4,5].eachn{ |a,b,c| x << [a,b,c] }
35
+ o = [[1,2,3],[4,5,nil]]
36
+ assert_equal( o, x )
37
+ end
38
+
39
+ end
40
+
41
+ =end
@@ -0,0 +1,17 @@
1
+ #--
2
+ # Cedit goes to Daniel Burger
3
+ #++
4
+
5
+ def File.null
6
+ case RUBY_PLATFORM
7
+ when /mswin/i
8
+ 'NUL'
9
+ when /amiga/i
10
+ 'NIL:'
11
+ when /openvms/i
12
+ 'NL:'
13
+ else
14
+ '/dev/null'
15
+ end
16
+ end
17
+
@@ -0,0 +1,13 @@
1
+ #--
2
+ # Special Thanks to Jeffrey Schwab.
3
+ #++
4
+
5
+ # Is the specified directory the root directory?
6
+
7
+ def FileTest.root?(dir)
8
+ pth = File.expand_path(dir)
9
+ return true if pth == '/'
10
+ return true if pth =~ /^(\w:)?\/$/
11
+ false
12
+ end
13
+
@@ -0,0 +1,10 @@
1
+ #--
2
+ # Credit goes to Daniel Schierbeck
3
+ #++
4
+
5
+ class Hash
6
+
7
+ alias :delete_at :delete
8
+
9
+ end
10
+
@@ -0,0 +1,20 @@
1
+ #--
2
+ # Credit goes to Daniel Schierbeck
3
+ #++
4
+
5
+ class Hash
6
+
7
+ # Minor modification to Ruby's Hash#delete method
8
+ # allowing it to take multiple keys.
9
+ #
10
+ # hsh = { :a => 1, :b => 2 }
11
+ # hsh.delete_values(1)
12
+ # hsh #=> { :b => 2 }
13
+ #
14
+
15
+ def delete_values(*values)
16
+ keys.map{|key| delete(key) if values.include?(fetch(key)) }
17
+ end
18
+
19
+ end
20
+
@@ -0,0 +1,24 @@
1
+ #--
2
+ # Credit goes to Daniel Schierbeck
3
+ #++
4
+
5
+ class Hash
6
+
7
+ # Minor modification to Ruby's Hash#delete method
8
+ # allowing it to take multiple keys.
9
+ #
10
+ # This works niely with hahs#[] and Hash#[]= facets.
11
+ #
12
+ # hsh[:a, :b, :c] = 1, 2, 3
13
+ #
14
+ # a, b, c = hsh.delete_values_at(:a, :b, :c)
15
+ #
16
+ # [a, b, c] #=> [1, 2, 3]
17
+ # hsh #=> {}
18
+ #
19
+ def delete_values_at(*keys, &block)
20
+ keys.map{|key| delete(key, &block) }
21
+ end
22
+
23
+ end
24
+
@@ -1,3 +1,10 @@
1
+ #--
2
+ # Special thanks to Daniel Schierbeck.
3
+ #++
4
+
5
+ # TODO Deprecate Hash#each
6
+ warn "Hash#each is being deprecated"
7
+
1
8
 
2
9
  class Hash
3
10
 
@@ -15,17 +22,25 @@ class Hash
15
22
  # WARNING! Use with caution. Methods from other libraries
16
23
  # may depend on the old behavior, expecting a two element
17
24
  # array to be passed into a single block argument.
18
- #
19
- def each(&yld)
20
- case yld.arity
21
- when 0
22
- when 1
23
- each_value{|v| yield(v)}
24
- else
25
- each_pair{|k,v| yld.call(k,v)}
26
- end
27
- self
28
- end
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
29
44
 
30
45
  end
31
46
 
@@ -0,0 +1,26 @@
1
+
2
+ module Kernel
3
+
4
+ private
5
+
6
+ # Load file from same dir as calling script.
7
+ #
8
+ # load_local 'templib'
9
+ #
10
+ def load_local( fname, safe=nil )
11
+ #fdir = File.expand_path( File.dirname( caller[0] ) )
12
+ fdir = File.dirname( caller[0] )
13
+ load( File.join( fdir, fname ), safe )
14
+ end
15
+
16
+ end
17
+
18
+
19
+ # _____ _
20
+ # |_ _|__ ___| |_
21
+ # | |/ _ \/ __| __|
22
+ # | | __/\__ \ |_
23
+ # |_|\___||___/\__|
24
+ #
25
+ # NO RESONABLE WAY TO DO
26
+ # (THAT I CAN THINK OF)
@@ -0,0 +1,18 @@
1
+
2
+ def NilClass
3
+
4
+ def to_path
5
+ case RUBY_PLATFORM
6
+ when /mswin/i
7
+ 'NUL'
8
+ when /amiga/i
9
+ 'NIL:'
10
+ when /openvms/i
11
+ 'NL:'
12
+ else
13
+ '/dev/null'
14
+ end
15
+ end
16
+
17
+ end
18
+
@@ -0,0 +1,10 @@
1
+ class Symbol
2
+
3
+ # Same functionality as before, just a touch more efficient.
4
+
5
+ def to_s
6
+ @to_s || (@to_s = id2name.freeze)
7
+ end
8
+
9
+ end
10
+
@@ -49,7 +49,7 @@
49
49
  #
50
50
  # The method :>> is used to construct the association.
51
51
  # It is a rarely used method so it is generally available.
52
- # But you can't use an Association while extending the
52
+ # But you can't use an Association while extending
53
53
  # any of the following classes becuase they use #>> for
54
54
  # other things.
55
55
  #
@@ -0,0 +1,81 @@
1
+ # = once.rb
2
+ #
3
+ # == Copyright (c) 2004 Thomas Sawyer
4
+ #
5
+ # Ruby License
6
+ #
7
+ # This module is free software. You may use, modify, and/or redistribute this
8
+ # software under the same terms as Ruby.
9
+ #
10
+ # This program is distributed in the hope that it will be useful, but WITHOUT
11
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12
+ # FOR A PARTICULAR PURPOSE.
13
+ #
14
+ # == Author(s)
15
+ #
16
+ # * Thomas Sawyer
17
+
18
+ # Author:: Erik Veenstra, Thomas Sawyer
19
+ # Copyright:: Copyright (c) 2006 Erik Veenstra, Thomas Sawyer
20
+ # License:: Ruby License
21
+
22
+ # = Cache
23
+ #
24
+ # Cache objects are a kind of "delegator-with-cache".
25
+ #
26
+ # == Usage
27
+ #
28
+ # class X
29
+ # def initialize ; @tick = 0 ; end
30
+ # def tick; @tick + 1; end
31
+ # def cached; @cache ||= Cache.new( self ) ; end
32
+ # end
33
+ #
34
+ # x = X.new
35
+ # x.tick #=> 1
36
+ # x.cached.tick #=> 2
37
+ # x.tick #=> 3
38
+ # x.cached.tick #=> 2
39
+ # x.tick #=> 4
40
+ # x.cached.tick #=> 2
41
+ #
42
+ # You can also use to cache a collections of objects to gain code
43
+ # speed ups.
44
+ #
45
+ # points = points.collect{|point| Cache.cache(point)}
46
+ #
47
+ # After our algorithm has finished using points, we want to get rid of
48
+ # these Cache objects. That's easy:
49
+ #
50
+ # points = points.collect{|point| point.self }
51
+ #
52
+ # Or if you prefer (it is ever so slightly safer):
53
+ #
54
+ # points = points.collect{|point| Cache.uncache(point)}
55
+ #
56
+
57
+ class Cache
58
+
59
+ private :class, :clone, :display, :type, :method, :to_a, :to_s
60
+
61
+ def initialize(object)
62
+ @self = object
63
+ @cache = {}
64
+ end
65
+
66
+ def method_missing(method_name, *args, &block)
67
+ # Not thread-safe! Speed is important in caches... ;]
68
+ @cache[[method_name, args, block]] ||= @self.__send__(method_name, *args, &block)
69
+ end
70
+
71
+ def self; @self; end
72
+
73
+ def self.cache(object)
74
+ Cache.new(object)
75
+ end
76
+
77
+ def self.uncache(cached_object)
78
+ cached_object.self
79
+ end
80
+
81
+ end
@@ -207,7 +207,17 @@ class Console::Command
207
207
  end
208
208
 
209
209
  rescue ArgumentError => ex
210
- $stderr << "Could not run #{args.first}. #{ex.message.capitalize.chomp('.')}.\n"
210
+ if $TRACE
211
+ raise ex
212
+ else
213
+ $stderr << "Could not run #{args.first}. #{ex.message.capitalize.chomp('.')}.\n"
214
+ end
215
+ end
216
+
217
+ #
218
+
219
+ def __trace
220
+ $TRACE = true
211
221
  end
212
222
 
213
223
  # # We include a module here so you can define your own help command
@@ -0,0 +1,371 @@
1
+ #
2
+ # Ruby implementation of the Double Metaphone algorithm by Lawrence Philips,
3
+ # originally published in the June 2000 issue of C/C++ Users Journal.
4
+ #
5
+ # Based on Stephen Woodbridge's PHP version - http://swoodbridge.com/DoubleMetaPhone/
6
+ #
7
+ module DoubleMetaphone
8
+
9
+ # Returns the primary and secondary double metaphone tokens
10
+ # (the secondary will be nil if equal to the primary).
11
+ def self.[](str)
12
+ return memo[str]
13
+ end
14
+
15
+
16
+ private
17
+
18
+ def self.memo
19
+ @memo ||= Hash.new { |memo, str| memo[str] = double_metaphone(str) }
20
+ end
21
+
22
+ def self.double_metaphone(str)
23
+ primary, secondary, current = '', '', 0
24
+ original, length, last = "#{str} ".upcase, str.length, str.length - 1
25
+ if /^GN|KN|PN|WR|PS$/ =~ original[0, 2]
26
+ current += 1
27
+ end
28
+ if 'X' == original[0, 1]
29
+ primary << 'S'
30
+ secondary << 'S'
31
+ current += 1
32
+ end
33
+ while primary.length < 4 || secondary.length < 4
34
+ break if current > str.length
35
+ a, b, c = lookup(original, current, length, last)
36
+ primary << a if a
37
+ secondary << b if b
38
+ current += c if c
39
+ end
40
+ primary, secondary = primary[0, 4], secondary[0, 4]
41
+ return primary, (primary == secondary ? nil : secondary)
42
+ end
43
+
44
+ def self.slavo_germanic?(str)
45
+ /W|K|CZ|WITZ/ =~ str
46
+ end
47
+
48
+ def self.vowel?(str)
49
+ /^A|E|I|O|U|Y$/ =~ str
50
+ end
51
+
52
+ def self.lookup(str, pos, length, last)
53
+ case str[pos, 1]
54
+ when /^A|E|I|O|U|Y$/
55
+ if 0 == pos
56
+ return 'A', 'A', 1
57
+ else
58
+ return nil, nil, 1
59
+ end
60
+ when 'B'
61
+ return 'P', 'P', ('B' == str[pos + 1, 1] ? 2 : 1)
62
+ when 'Ç'
63
+ return 'S', 'S', 1
64
+ when 'C'
65
+ if pos > 1 &&
66
+ !vowel?(str[pos - 2, 1]) &&
67
+ 'ACH' == str[pos - 1, 3] &&
68
+ str[pos + 2, 1] != 'I' && (
69
+ str[pos + 2, 1] != 'E' ||
70
+ str[pos - 2, 6] =~ /^(B|M)ACHER$/
71
+ ) then
72
+ return 'K', 'K', 2
73
+ elsif 0 == pos && 'CAESAR' == str[pos, 6]
74
+ return 'S', 'S', 2
75
+ elsif 'CHIA' == str[pos, 4]
76
+ return 'K', 'K', 2
77
+ elsif 'CH' == str[pos, 2]
78
+ if 0 == pos && 'CHAE' == str[pos, 4]
79
+ return 'K', 'X', 2
80
+ elsif 0 == pos && (
81
+ ['HARAC', 'HARIS'].include?(str[pos + 1, 5]) ||
82
+ ['HOR', 'HYM', 'HIA', 'HEM'].include?(str[pos + 1, 3])
83
+ ) && str[0, 5] != 'CHORE' then
84
+ return 'K', 'K', 2
85
+ elsif ['VAN ','VON '].include?(str[0, 4]) ||
86
+ 'SCH' == str[0, 3] ||
87
+ ['ORCHES','ARCHIT','ORCHID'].include?(str[pos - 2, 6]) ||
88
+ ['T','S'].include?(str[pos + 2, 1]) || (
89
+ ((0 == pos) || ['A','O','U','E'].include?(str[pos - 1, 1])) &&
90
+ ['L','R','N','M','B','H','F','V','W',' '].include?(str[pos + 2, 1])
91
+ ) then
92
+ return 'K', 'K', 2
93
+ elsif pos > 0
94
+ return ('MC' == str[0, 2] ? 'K' : 'X'), 'K', 2
95
+ else
96
+ return 'X', 'X', 2
97
+ end
98
+ elsif 'CZ' == str[pos, 2] && 'WICZ' != str[pos - 2, 4]
99
+ return 'S', 'X', 2
100
+ elsif 'CIA' == str[pos + 1, 3]
101
+ return 'X', 'X', 3
102
+ elsif 'CC' == str[pos, 2] && !(1 == pos && 'M' == str[0, 1])
103
+ if /^I|E|H$/ =~ str[pos + 2, 1] && 'HU' != str[pos + 2, 2]
104
+ if (1 == pos && 'A' == str[pos - 1, 1]) ||
105
+ /^UCCE(E|S)$/ =~ str[pos - 1, 5] then
106
+ return 'KS', 'KS', 3
107
+ else
108
+ return 'X', 'X', 3
109
+ end
110
+ else
111
+ return 'K', 'K', 2
112
+ end
113
+ elsif /^C(K|G|Q)$/ =~ str[pos, 2]
114
+ return 'K', 'K', 2
115
+ elsif /^C(I|E|Y)$/ =~ str[pos, 2]
116
+ return 'S', (/^CI(O|E|A)$/ =~ str[pos, 3] ? 'X' : 'S'), 2
117
+ else
118
+ if /^ (C|Q|G)$/ =~ str[pos + 1, 2]
119
+ return 'K', 'K', 3
120
+ else
121
+ return 'K', 'K', (/^C|K|Q$/ =~ str[pos + 1, 1] && !(['CE','CI'].include?(str[pos + 1, 2])) ? 2 : 1)
122
+ end
123
+ end
124
+ when 'D'
125
+ if 'DG' == str[pos, 2]
126
+ if /^I|E|Y$/ =~ str[pos + 2, 1]
127
+ return 'J', 'J', 3
128
+ else
129
+ return 'TK', 'TK', 2
130
+ end
131
+ else
132
+ return 'T', 'T', (/^D(T|D)$/ =~ str[pos, 2] ? 2 : 1)
133
+ end
134
+ when 'F'
135
+ return 'F', 'F', ('F' == str[pos + 1, 1] ? 2 : 1)
136
+ when 'G'
137
+ if 'H' == str[pos + 1, 1]
138
+ if pos > 0 && !vowel?(str[pos - 1, 1])
139
+ return 'K', 'K', 2
140
+ elsif 0 == pos
141
+ if 'I' == str[pos + 2, 1]
142
+ return 'J', 'J', 2
143
+ else
144
+ return 'K', 'K', 2
145
+ end
146
+ elsif (pos > 1 && /^B|H|D$/ =~ str[pos - 2, 1]) ||
147
+ (pos > 2 && /^B|H|D$/ =~ str[pos - 3, 1]) ||
148
+ (pos > 3 && /^B|H$/ =~ str[pos - 4, 1])
149
+ return nil, nil, 2
150
+ else
151
+ if (pos > 2 && 'U' == str[pos - 1, 1] && /^C|G|L|R|T$/ =~ str[pos - 3, 1])
152
+ return 'F', 'F', 2
153
+ elsif pos > 0 && 'I' != str[pos - 1, 1]
154
+ return 'K', 'K', 2
155
+ else
156
+ return nil, nil, 2
157
+ end
158
+ end
159
+ elsif 'N' == str[pos + 1, 1]
160
+ if 1 == pos && vowel?(str[0, 1]) && !slavo_germanic?(str)
161
+ return 'KN', 'N', 2
162
+ else
163
+ if 'EY' != str[pos + 2, 2] && 'Y' != str[pos + 1, 1] && !slavo_germanic?(str)
164
+ return 'N', 'KN', 2
165
+ else
166
+ return 'KN', 'KN', 2
167
+ end
168
+ end
169
+ elsif 'LI' == str[pos + 1, 2] && !slavo_germanic?(str)
170
+ return 'KL', 'L', 2
171
+ elsif 0 == pos && ('Y' == str[pos + 1, 1] || /^(E(S|P|B|L|Y|I|R)|I(B|L|N|E))$/ =~ str[pos + 1, 2])
172
+ return 'K', 'J', 2
173
+ elsif (('ER' == str[pos + 1, 2] || 'Y' == str[pos + 1, 1]) &&
174
+ /^(D|R|M)ANGER$/ !~ str[0, 6] &&
175
+ /^E|I$/ !~ str[pos - 1, 1] &&
176
+ /^(R|O)GY$/ !~ str[pos - 1, 3])
177
+ return 'K', 'J', 2
178
+ elsif /^E|I|Y$/ =~ str[pos + 1, 1] || /^(A|O)GGI$/ =~ str[pos - 1, 4]
179
+ if (/^V(A|O)N $/ =~ str[0, 4] || 'SCH' == str[0, 3]) || 'ET' == str[pos + 1, 2]
180
+ return 'K', 'K', 2
181
+ else
182
+ if 'IER ' == str[pos + 1, 4]
183
+ return 'J', 'J', 2
184
+ else
185
+ return 'J', 'K', 2
186
+ end
187
+ end
188
+ elsif 'G' == str[pos + 1, 1]
189
+ return 'K', 'K', 2
190
+ else
191
+ return 'K', 'K', 1
192
+ end
193
+ when 'H'
194
+ if (0 == pos || vowel?(str[pos - 1, 1])) && vowel?(str[pos + 1, 1])
195
+ return 'H', 'H', 2
196
+ else
197
+ return nil, nil, 1
198
+ end
199
+ when 'J'
200
+ if 'JOSE' == str[pos, 4] || 'SAN ' == str[0, 4]
201
+ if (0 == pos && ' ' == str[pos + 4, 1]) || 'SAN ' == str[0, 4]
202
+ return 'H', 'H', 1
203
+ else
204
+ return 'J', 'H', 1
205
+ end
206
+ else
207
+ current = ('J' == str[pos + 1, 1] ? 2 : 1)
208
+
209
+ if 0 == pos && 'JOSE' != str[pos, 4]
210
+ return 'J', 'A', current
211
+ else
212
+ if vowel?(str[pos - 1, 1]) && !slavo_germanic?(str) && /^A|O$/ =~ str[pos + 1, 1]
213
+ return 'J', 'H', current
214
+ else
215
+ if last == pos
216
+ return 'J', nil, current
217
+ else
218
+ if /^L|T|K|S|N|M|B|Z$/ !~ str[pos + 1, 1] && /^S|K|L$/ !~ str[pos - 1, 1]
219
+ return 'J', 'J', current
220
+ else
221
+ return nil, nil, current
222
+ end
223
+ end
224
+ end
225
+ end
226
+ end
227
+ when 'K'
228
+ return 'K', 'K', ('K' == str[pos + 1, 1] ? 2 : 1)
229
+ when 'L'
230
+ if 'L' == str[pos + 1, 1]
231
+ if (((length - 3) == pos && /^(ILL(O|A)|ALLE)$/ =~ str[pos - 1, 4]) ||
232
+ ((/^(A|O)S$/ =~ str[last - 1, 2] || /^A|O$/ =~ str[last, 1]) && 'ALLE' == str[pos - 1, 4]))
233
+ return 'L', nil, 2
234
+ else
235
+ return 'L', 'L', 2
236
+ end
237
+ else
238
+ return 'L', 'L', 1
239
+ end
240
+ when 'M'
241
+ if ('UMB' == str[pos - 1, 3] &&
242
+ ((last - 1) == pos || 'ER' == str[pos + 2, 2])) || 'M' == str[pos + 1, 1]
243
+ return 'M', 'M', 2
244
+ else
245
+ return 'M', 'M', 1
246
+ end
247
+ when 'N'
248
+ return 'N', 'N', ('N' == str[pos + 1, 1] ? 2 : 1)
249
+ when 'Ñ'
250
+ return 'N', 'N', 1
251
+ when 'P'
252
+ if 'H' == str[pos + 1, 1]
253
+ return 'F', 'F', 2
254
+ else
255
+ return 'P', 'P', (/^P|B$/ =~ str[pos + 1, 1] ? 2 : 1)
256
+ end
257
+ when 'Q'
258
+ return 'K', 'K', ('Q' == str[pos + 1, 1] ? 2 : 1)
259
+ when 'R'
260
+ current = ('R' == str[pos + 1, 1] ? 2 : 1)
261
+
262
+ if last == pos && !slavo_germanic?(str) && 'IE' == str[pos - 2, 2] && /^M(E|A)$/ !~ str[pos - 4, 2]
263
+ return nil, 'R', current
264
+ else
265
+ return 'R', 'R', current
266
+ end
267
+ when 'S'
268
+ if /^(I|Y)SL$/ =~ str[pos - 1, 3]
269
+ return nil, nil, 1
270
+ elsif 0 == pos && 'SUGAR' == str[pos, 5]
271
+ return 'X', 'S', 1
272
+ elsif 'SH' == str[pos, 2]
273
+ if /^H(EIM|OEK|OLM|OLZ)$/ =~ str[pos + 1, 4]
274
+ return 'S', 'S', 2
275
+ else
276
+ return 'X', 'X', 2
277
+ end
278
+ elsif /^SI(O|A)$/ =~ str[pos, 3] || 'SIAN' == str[pos, 4]
279
+ return 'S', (slavo_germanic?(str) ? 'S' : 'X'), 3
280
+ elsif (0 == pos && /^M|N|L|W$/ =~ str[pos + 1, 1]) || 'Z' == str[pos + 1, 1]
281
+ return 'S', 'X', ('Z' == str[pos + 1, 1] ? 2 : 1)
282
+ elsif 'SC' == str[pos, 2]
283
+ if 'H' == str[pos + 2, 1]
284
+ if /^OO|ER|EN|UY|ED|EM$/ =~ str[pos + 3, 2]
285
+ return (/^E(R|N)$/ =~ str[pos + 3, 2] ? 'X' : 'SK'), 'SK', 3
286
+ else
287
+ return 'X', ((0 == pos && !vowel?(str[3, 1]) && ('W' != str[pos + 3, 1])) ? 'S' : 'X'), 3
288
+ end
289
+ elsif /^I|E|Y$/ =~ str[pos + 2, 1]
290
+ return 'S', 'S', 3
291
+ else
292
+ return 'SK', 'SK', 3
293
+ end
294
+ else
295
+ return (last == pos && /^(A|O)I$/ =~ str[pos - 2, 2] ? nil : 'S'), 'S', (/^S|Z$/ =~ str[pos + 1, 1] ? 2 : 1)
296
+ end
297
+ when 'T'
298
+ if 'TION' == str[pos, 4]
299
+ return 'X', 'X', 3
300
+ elsif /^T(IA|CH)$/ =~ str[pos, 3]
301
+ return 'X', 'X', 3
302
+ elsif 'TH' == str[pos, 2] || 'TTH' == str[pos, 3]
303
+ if /^(O|A)M$/ =~ str[pos + 2, 2] || /^V(A|O)N $/ =~ str[0, 4] || 'SCH' == str[0, 3]
304
+ return 'T', 'T', 2
305
+ else
306
+ return '0', 'T', 2
307
+ end
308
+ else
309
+ return 'T', 'T', (/^T|D$/ =~ str[pos + 1, 1] ? 2 : 1)
310
+ end
311
+ when 'V'
312
+ return 'F', 'F', ('V' == str[pos + 1, 1] ? 2 : 1)
313
+ when 'W'
314
+ if 'WR' == str[pos, 2]
315
+ return 'R', 'R', 2
316
+ end
317
+ pri, sec = nil, nil
318
+ if 0 == pos && (vowel?(str[pos + 1, 1]) || 'WH' == str[pos, 2])
319
+ pri = 'A'
320
+ sec = vowel?(str[pos + 1, 1]) ? 'F' : 'A'
321
+ end
322
+ if (last == pos && vowel?(str[pos - 1, 1])) || 'SCH' == str[0, 3] ||
323
+ /^EWSKI|EWSKY|OWSKI|OWSKY$/ =~ str[pos - 1, 5]
324
+ return pri, "#{sec}F", 1
325
+ elsif /^WI(C|T)Z$/ =~ str[pos, 4]
326
+ return "#{pri}TS", "#{sec}FX", 4
327
+ else
328
+ return pri, sec, 1
329
+ end
330
+ when 'X'
331
+ current = (/^C|X$/ =~ str[pos + 1, 1] ? 2 : 1)
332
+ if !(last == pos && (/^(I|E)AU$/ =~ str[pos - 3, 3] || /^(A|O)U$/ =~ str[pos - 2, 2]))
333
+ return 'KS', 'KS', current
334
+ else
335
+ return nil, nil, current
336
+ end
337
+ when 'Z'
338
+ if 'H' == str[pos + 1, 1]
339
+ return 'J', 'J', 2
340
+ else
341
+ current = ('Z' == str[pos + 1, 1] ? 2 : 1)
342
+ if /^Z(O|I|A)$/ =~ str[pos + 1, 2] || (slavo_germanic?(str) && (pos > 0 && 'T' != str[pos - 1, 1]))
343
+ return 'S', 'TS', current
344
+ else
345
+ return 'S', 'S', current
346
+ end
347
+ end
348
+ else
349
+ return nil, nil, 1
350
+ end
351
+ end # def lookup
352
+
353
+ end # module DoubleMetaphone
354
+
355
+ if __FILE__ == $0
356
+ require 'test/unit'
357
+ require 'rubygems'
358
+ require 'fastercsv'
359
+
360
+ # 1218 tests, 2436 assertions
361
+ class DoubleMetaphoneTest < Test::Unit::TestCase
362
+ FasterCSV.read('double_metaphone_test_data.csv', :col_sep => ', ').each_with_index do |row, i|
363
+ primary, secondary = DoubleMetaphone[row[0]]
364
+
365
+ define_method("test_#{i}") do
366
+ assert_equal row[1], primary
367
+ assert_equal row[2], (secondary.nil?? primary : secondary)
368
+ end
369
+ end
370
+ end
371
+ end