facets 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (353) hide show
  1. checksums.yaml +4 -4
  2. data/.index +11 -7
  3. data/CONTRIBUTING.md +112 -0
  4. data/HISTORY.md +38 -0
  5. data/{README.rdoc → README.md} +59 -59
  6. data/demo/core/array/after.md +13 -0
  7. data/demo/core/array/arrange.md +17 -0
  8. data/demo/core/array/before.md +14 -0
  9. data/demo/core/array/collapse.md +15 -0
  10. data/demo/core/array/collisions.md +30 -0
  11. data/demo/core/array/commonality.md +31 -0
  12. data/demo/core/array/conjoin.md +47 -0
  13. data/demo/core/array/contains.md +9 -0
  14. data/demo/core/array/delete_unless.md +13 -0
  15. data/demo/core/array/delete_values.md +10 -0
  16. data/demo/core/array/delete_values_at.md +15 -0
  17. data/demo/core/array/divide.md +14 -0
  18. data/demo/core/array/duplicates.md +14 -0
  19. data/demo/core/array/each_overlap.md +12 -0
  20. data/demo/core/array/each_pair.md +13 -0
  21. data/demo/core/array/each_value.md +12 -0
  22. data/demo/core/array/entropy.md +13 -0
  23. data/demo/core/array/extract_options.md +13 -0
  24. data/demo/core/array/first.md +11 -0
  25. data/demo/core/array/from.md +11 -0
  26. data/demo/core/array/ideal_entropy.md +11 -0
  27. data/demo/core/array/intersection.md +11 -0
  28. data/demo/core/array/last.md +11 -0
  29. data/demo/core/array/median.md +23 -0
  30. data/demo/core/array/merge.md +15 -0
  31. data/demo/core/array/missing.md +10 -0
  32. data/demo/core/array/mode.md +9 -0
  33. data/demo/core/array/nonuniq.md +16 -0
  34. data/demo/core/array/not_empty.md +8 -0
  35. data/demo/core/array/occur.md +18 -0
  36. data/demo/core/array/occurrence.md +13 -0
  37. data/demo/core/array/only.md +9 -0
  38. data/demo/core/array/op_pow.md +10 -0
  39. data/demo/core/array/pad.md +28 -0
  40. data/demo/core/array/peek.md +10 -0
  41. data/demo/core/array/poke.md +15 -0
  42. data/demo/core/array/probability +8 -0
  43. data/demo/core/array/pull.md +10 -0
  44. data/demo/core/array/recurse.md +10 -0
  45. data/demo/core/array/recursively.md +20 -0
  46. data/demo/core/array/reject_values.md +10 -0
  47. data/demo/core/array/splice.md +14 -0
  48. data/demo/core/array/split.md +13 -0
  49. data/demo/core/array/squeeze.md +14 -0
  50. data/demo/core/array/step.md +16 -0
  51. data/demo/core/array/store.md +9 -0
  52. data/demo/core/array/thru.md +12 -0
  53. data/demo/core/array/to_h.md +11 -0
  54. data/demo/core/array/traverse.md +20 -0
  55. data/demo/core/array/uniq_by.md +16 -0
  56. data/demo/core/array/unique_permutation.md +14 -0
  57. data/demo/core/array/zip.md +8 -0
  58. data/demo/core/binding/caller.md +57 -0
  59. data/demo/core/binding/defined.md +10 -0
  60. data/demo/core/binding/opvars.md +16 -0
  61. data/demo/core/binding/self.md +6 -0
  62. data/demo/core/class/descendants.md +13 -0
  63. data/demo/core/class/to_proc.md +11 -0
  64. data/demo/core/comparable/at_least.md +11 -0
  65. data/demo/core/comparable/at_most.md +11 -0
  66. data/demo/core/comparable/bound.md +13 -0
  67. data/demo/core/comparable/cap.md +11 -0
  68. data/demo/core/comparable/clip.md +29 -0
  69. data/demo/core/comparable/cmp.md +18 -0
  70. data/demo/core/comparable/op_get.md +32 -0
  71. data/demo/core/dir/ascend.md +24 -0
  72. data/demo/core/dir/descend.md +16 -0
  73. data/demo/core/dir/multiglob.md +41 -0
  74. data/demo/core/dir/parent.md +6 -0
  75. data/demo/core/dir/recurse.md +41 -0
  76. data/demo/core/exception/detail.md +19 -0
  77. data/demo/core/{facets.rdoc → facets.md} +1 -1
  78. data/demo/core/filetest/root.md +13 -0
  79. data/demo/core/hash/recursively.md +21 -0
  80. data/demo/core/indexable.md +95 -0
  81. data/demo/core/integer/bitmask.md +46 -0
  82. data/demo/core/integer/{factorial.rdoc → factorial.md} +1 -1
  83. data/demo/core/integer/{length.rdoc → length.md} +1 -1
  84. data/demo/core/integer/{multiple.rdoc → multiple.md} +3 -1
  85. data/demo/core/integer/of.md +11 -0
  86. data/demo/core/integer/{ordinal.rdoc → ordinal.md} +3 -1
  87. data/demo/core/integer/{of.rdoc → times_collect.md} +2 -7
  88. data/demo/core/matchdata/match.md +7 -0
  89. data/demo/core/matchdata/matchset.md +7 -0
  90. data/demo/core/matchdata/matchtree.md +10 -0
  91. data/demo/core/module/cattr.md +43 -0
  92. data/demo/core/module/class_extend.md +64 -0
  93. data/demo/core/module/{class_inheritor.rdoc → class_inheritor.md} +2 -2
  94. data/demo/core/module/{copy_inheritor.rdoc → copy_inheritor.md} +4 -4
  95. data/demo/core/module/include_as.md +31 -0
  96. data/demo/core/module/method_space.md +24 -0
  97. data/demo/core/string/acronym.md +9 -0
  98. data/demo/core/string/{align.rdoc → align.md} +10 -10
  99. data/demo/core/string/ascii_only.md +37 -0
  100. data/demo/core/string/{bracket.rdoc → bracket.md} +10 -10
  101. data/demo/core/string/camelcase.md +47 -0
  102. data/demo/core/string/{capitalized.rdoc → capitalized.md} +9 -9
  103. data/demo/core/string/characters.md +11 -0
  104. data/demo/core/string/{cleanlines.rdoc → cleanlines.md} +3 -3
  105. data/demo/core/string/cleave.md +49 -0
  106. data/demo/core/string/compress_lines.md +22 -0
  107. data/demo/core/string/crypt.md +15 -0
  108. data/demo/core/string/divide.md +9 -0
  109. data/demo/core/string/each_word.md +11 -0
  110. data/demo/core/string/edit_distance.md +15 -0
  111. data/demo/core/string/exclude.md +15 -0
  112. data/demo/core/string/expand_tabs.md +69 -0
  113. data/demo/core/string/fold.md +14 -0
  114. data/demo/core/string/indent.md +65 -0
  115. data/demo/core/string/index_all.md +14 -0
  116. data/demo/core/string/interpolate.md +8 -0
  117. data/demo/core/string/lchomp.md +14 -0
  118. data/demo/core/string/line_wrap.md +7 -0
  119. data/demo/core/string/lowercase.md +12 -0
  120. data/demo/core/string/methodize.md +22 -0
  121. data/demo/core/string/modulize.md +22 -0
  122. data/demo/core/string/mscan.md +10 -0
  123. data/demo/core/string/natcmp.md +10 -0
  124. data/demo/core/string/nchar.md +9 -0
  125. data/demo/core/string/{newlines.rdoc → newlines.md} +3 -3
  126. data/demo/core/string/number.md +27 -0
  127. data/demo/core/string/op_div.md +10 -0
  128. data/demo/core/string/op_sub.md +7 -0
  129. data/demo/core/string/pathize.md +22 -0
  130. data/demo/core/string/quote.md +20 -0
  131. data/demo/core/string/random.md +25 -0
  132. data/demo/core/string/range.md +19 -0
  133. data/demo/core/string/remove.md +33 -0
  134. data/demo/core/string/rewrite.md +9 -0
  135. data/demo/core/string/shatter.md +9 -0
  136. data/demo/core/string/similarity.md +12 -0
  137. data/demo/core/string/snakecase.md +14 -0
  138. data/demo/core/string/splice.md +28 -0
  139. data/demo/core/string/squish.md +27 -0
  140. data/demo/core/string/store.md +10 -0
  141. data/demo/core/string/subtract.md +8 -0
  142. data/demo/core/string/titlecase.md +8 -0
  143. data/demo/core/string/to_re.md +22 -0
  144. data/demo/core/string/{margin.rdoc → trim.md} +14 -14
  145. data/demo/core/string/unbracket.md +24 -0
  146. data/demo/core/string/underscore.md +17 -0
  147. data/demo/core/string/unfold.md +9 -0
  148. data/demo/core/string/unindent.md +65 -0
  149. data/demo/core/string/unquote.md +6 -0
  150. data/demo/core/string/uppercase.md +15 -0
  151. data/demo/core/string/variablize.md +7 -0
  152. data/demo/core/string/word_wrap.md +54 -0
  153. data/demo/core/string/words.md +13 -0
  154. data/demo/core/string/xor.md +8 -0
  155. data/lib/core/facets.yml +11 -7
  156. data/lib/core/facets/array.rb +1 -0
  157. data/lib/core/facets/array/average.rb +16 -0
  158. data/lib/core/facets/array/collapse.rb +4 -0
  159. data/lib/core/facets/array/delete_values_at.rb +1 -0
  160. data/lib/core/facets/array/divide.rb +7 -0
  161. data/lib/core/facets/array/duplicates.rb +2 -0
  162. data/lib/core/facets/array/each_pair.rb +1 -4
  163. data/lib/core/facets/array/first.rb +1 -0
  164. data/lib/core/facets/array/from.rb +11 -16
  165. data/lib/core/facets/array/intersection.rb +1 -1
  166. data/lib/core/facets/array/last.rb +1 -0
  167. data/lib/core/facets/array/mode.rb +2 -2
  168. data/lib/core/facets/array/occurrence.rb +4 -3
  169. data/lib/core/facets/array/op_pow.rb +0 -2
  170. data/lib/core/facets/array/probability.rb +1 -1
  171. data/lib/core/facets/array/recursively.rb +2 -2
  172. data/lib/core/facets/array/splice.rb +1 -1
  173. data/lib/core/facets/array/standard_deviation.rb +23 -0
  174. data/lib/core/facets/array/to_h.rb +0 -3
  175. data/lib/core/facets/array/uniq_by.rb +4 -0
  176. data/lib/core/facets/array/variance.rb +20 -0
  177. data/lib/core/facets/binding.rb +0 -1
  178. data/lib/core/facets/enumerable/cluster.rb +6 -4
  179. data/lib/core/facets/enumerable/hashify.rb +27 -31
  180. data/lib/core/facets/enumerable/sum.rb +12 -2
  181. data/lib/core/facets/file/atomic_open.rb +1 -1
  182. data/lib/core/facets/hash/except.rb +13 -1
  183. data/lib/core/facets/indexable.rb +1 -1
  184. data/lib/core/facets/kernel/ergo.rb +3 -3
  185. data/lib/core/facets/kernel/like.rb +1 -1
  186. data/lib/core/facets/matchdata/matchtree.rb +2 -0
  187. data/lib/core/facets/numeric/delimit.rb +20 -0
  188. data/lib/core/facets/range/nudge.rb +29 -0
  189. data/lib/core/facets/string.rb +0 -2
  190. data/lib/core/facets/string/indent.rb +0 -8
  191. data/lib/core/facets/string/margin.rb +0 -4
  192. data/lib/core/facets/string/random.rb +13 -3
  193. data/lib/core/facets/string/similarity.rb +7 -6
  194. data/lib/standard/facets/enumargs.rb +5 -0
  195. data/lib/standard/facets/math/percentile.rb +1 -1
  196. data/lib/standard/facets/net/http.rb +33 -14
  197. data/lib/standard/facets/timer.rb +3 -3
  198. data/test/core/array/test_average.rb +16 -0
  199. data/test/core/array/test_before.rb +21 -0
  200. data/test/core/array/test_collapse.rb +10 -1
  201. data/test/core/array/test_delete_unless.rb +17 -0
  202. data/test/core/array/test_delete_values.rb +31 -0
  203. data/test/core/array/test_divide.rb +10 -0
  204. data/test/core/array/test_each_pair.rb +16 -0
  205. data/test/core/array/test_each_value.rb +16 -0
  206. data/test/core/array/test_from.rb +42 -0
  207. data/test/core/array/test_op_pow.rb +13 -0
  208. data/test/core/array/test_standard_deviation.rb +18 -0
  209. data/test/core/array/test_to_h.rb +14 -0
  210. data/test/core/array/test_uniq_by.rb +7 -0
  211. data/test/core/array/test_variance.rb +17 -0
  212. data/test/core/array/test_zip.rb +13 -0
  213. data/test/core/dir/test_each_child.rb +1 -1
  214. data/test/core/dir/test_multiglob.rb +1 -1
  215. data/test/core/enumerable/test_cluster.rb +36 -0
  216. data/test/core/enumerable/test_hashify.rb +113 -0
  217. data/test/core/hash/test_expect.rb +11 -1
  218. data/test/core/kernel/test_ergo.rb +7 -5
  219. data/test/core/{object/test_replace.rb → kernel/test_instance_replace.rb} +6 -28
  220. data/test/core/numeric/test_delimit.rb +68 -0
  221. data/test/core/numeric/{test_round.rb → test_round_to.rb} +27 -27
  222. data/test/core/range/test_nudge.rb +32 -0
  223. data/test/core/range/{test_to_r.rb → test_to_rng.rb} +3 -3
  224. data/test/core/string/test_acronym.rb +14 -0
  225. data/test/core/string/test_ascii_only.rb +21 -0
  226. data/test/core/string/test_compress_lines.rb +9 -0
  227. data/test/core/string/test_crypt.rb +17 -0
  228. data/test/core/string/test_index_all.rb +4 -0
  229. data/test/core/string/test_random.rb +25 -0
  230. data/test/core/string/test_remove.rb +14 -0
  231. data/test/core/string/test_similarity.rb +9 -1
  232. data/test/core/struct/test_replace.rb +18 -0
  233. data/test/standard/test_enumargs.rb +26 -10
  234. data/test/standard/test_timer.rb +1 -1
  235. metadata +634 -588
  236. data/CONTRIBUTE.md +0 -78
  237. data/demo/core/array/combination.rdoc +0 -19
  238. data/demo/core/array/delete.rdoc +0 -23
  239. data/demo/core/array/index.rdoc +0 -14
  240. data/demo/core/array/merge.rdoc +0 -15
  241. data/demo/core/array/only.rdoc +0 -9
  242. data/demo/core/array/pad.rdoc +0 -28
  243. data/demo/core/array/permutation.rdoc +0 -10
  244. data/demo/core/array/product.rdoc +0 -26
  245. data/demo/core/array/recursively.rdoc +0 -16
  246. data/demo/core/array/rotate.rdoc +0 -30
  247. data/demo/core/array/select.rdoc +0 -8
  248. data/demo/core/array/uniq_by.rdoc +0 -9
  249. data/demo/core/binding/caller.rdoc +0 -57
  250. data/demo/core/binding/defined.rdoc +0 -10
  251. data/demo/core/binding/eval.rdoc +0 -8
  252. data/demo/core/binding/local_variables.rdoc +0 -26
  253. data/demo/core/binding/opvars.rdoc +0 -16
  254. data/demo/core/binding/self.rdoc +0 -6
  255. data/demo/core/class/descendants.rdoc +0 -10
  256. data/demo/core/class/to_proc.rdoc +0 -8
  257. data/demo/core/comparable/cap.rdoc +0 -20
  258. data/demo/core/comparable/clip.rdoc +0 -37
  259. data/demo/core/comparable/cmp.rdoc +0 -18
  260. data/demo/core/comparable/op_get.rdoc +0 -29
  261. data/demo/core/dir/ascend.rdoc +0 -24
  262. data/demo/core/dir/descend.rdoc +0 -14
  263. data/demo/core/dir/multiglob.rdoc +0 -41
  264. data/demo/core/dir/parent.rdoc +0 -6
  265. data/demo/core/dir/recurse.rdoc +0 -41
  266. data/demo/core/exception/detail.rdoc +0 -12
  267. data/demo/core/filetest/root.rdoc +0 -6
  268. data/demo/core/hash/recursively.rdoc +0 -21
  269. data/demo/core/indexable.rdoc +0 -95
  270. data/demo/core/integer/bitmask.rdoc +0 -46
  271. data/demo/core/integer/even.rdoc +0 -12
  272. data/demo/core/integer/odd.rdoc +0 -12
  273. data/demo/core/matchdata/match.rdoc +0 -7
  274. data/demo/core/matchdata/matchset.rdoc +0 -15
  275. data/demo/core/module/cattr.rdoc +0 -43
  276. data/demo/core/module/class_extend.rdoc +0 -64
  277. data/demo/core/module/method_space.rdoc +0 -55
  278. data/demo/core/string/bytes.rdoc +0 -8
  279. data/demo/core/string/camelcase.rdoc +0 -47
  280. data/demo/core/string/characters.rdoc +0 -11
  281. data/demo/core/string/cleave.rdoc +0 -49
  282. data/demo/core/string/divide.rdoc +0 -9
  283. data/demo/core/string/each_char.rdoc +0 -9
  284. data/demo/core/string/each_word.rdoc +0 -9
  285. data/demo/core/string/end_with.rdoc +0 -6
  286. data/demo/core/string/expand_tabs.rdoc +0 -69
  287. data/demo/core/string/fold.rdoc +0 -14
  288. data/demo/core/string/indent.rdoc +0 -65
  289. data/demo/core/string/interpolate.rdoc +0 -7
  290. data/demo/core/string/lchomp.rdoc +0 -14
  291. data/demo/core/string/line_wrap.rdoc +0 -7
  292. data/demo/core/string/lines.rdoc +0 -8
  293. data/demo/core/string/methodize.rdoc +0 -22
  294. data/demo/core/string/modulize.rdoc +0 -22
  295. data/demo/core/string/mscan.rdoc +0 -10
  296. data/demo/core/string/natcmp.rdoc +0 -10
  297. data/demo/core/string/nchar.rdoc +0 -9
  298. data/demo/core/string/op_sub.rdoc +0 -7
  299. data/demo/core/string/pathize.rdoc +0 -22
  300. data/demo/core/string/quote.rdoc +0 -20
  301. data/demo/core/string/range.rdoc +0 -19
  302. data/demo/core/string/rewrite.rdoc +0 -9
  303. data/demo/core/string/shatter.rdoc +0 -9
  304. data/demo/core/string/snakecase.rdoc +0 -10
  305. data/demo/core/string/splice.rdoc +0 -28
  306. data/demo/core/string/start_with.rdoc +0 -7
  307. data/demo/core/string/subtract.rdoc +0 -8
  308. data/demo/core/string/tab.rdoc +0 -16
  309. data/demo/core/string/tabto.rdoc +0 -29
  310. data/demo/core/string/titlecase.rdoc +0 -8
  311. data/demo/core/string/to_re.rdoc +0 -22
  312. data/demo/core/string/unfold.rdoc +0 -9
  313. data/demo/core/string/unindent.rdoc +0 -65
  314. data/demo/core/string/unquote.rdoc +0 -6
  315. data/demo/core/string/variablize.rdoc +0 -7
  316. data/demo/core/string/word_wrap.rdoc +0 -54
  317. data/demo/core/string/words.rdoc +0 -13
  318. data/demo/core/string/xor.rdoc +0 -8
  319. data/lib/core/facets/binding/local_variables.rb +0 -16
  320. data/lib/core/facets/string/tab.rb +0 -2
  321. data/lib/core/facets/string/tabto.rb +0 -2
  322. data/test/core/array/test_after.rb +0 -27
  323. data/test/core/array/test_combination.rb +0 -25
  324. data/test/core/array/test_index.rb +0 -20
  325. data/test/core/array/test_permutation.rb +0 -20
  326. data/test/core/array/test_product.rb +0 -64
  327. data/test/core/array/test_rotate.rb +0 -38
  328. data/test/core/array/test_select.rb +0 -16
  329. data/test/core/binding/test_eval.rb +0 -15
  330. data/test/core/binding/test_local_variables.rb +0 -36
  331. data/test/core/enumerable/test_cluster_by.rb +0 -30
  332. data/test/core/enumerable/test_count.rb +0 -32
  333. data/test/core/enumerable/test_each_with_object.rb +0 -18
  334. data/test/core/enumerable/test_group_by.rb +0 -36
  335. data/test/core/enumerable/test_none.rb +0 -29
  336. data/test/core/enumerable/test_one.rb +0 -34
  337. data/test/core/enumerable/test_take.rb +0 -15
  338. data/test/core/hash/test_select.rb +0 -44
  339. data/test/core/hash/test_url_params.rb +0 -26
  340. data/test/core/integer/test_even.rb +0 -24
  341. data/test/core/integer/test_odd.rb +0 -24
  342. data/test/core/kernel/test_require_relative.rb +0 -12
  343. data/test/core/nilclass/test_to_f.rb +0 -13
  344. data/test/core/proc/test_curry.rb +0 -38
  345. data/test/core/string/test_bytes.rb +0 -13
  346. data/test/core/string/test_each_char.rb +0 -17
  347. data/test/core/string/test_end_with.rb +0 -24
  348. data/test/core/string/test_lines.rb +0 -15
  349. data/test/core/string/test_start_with.rb +0 -24
  350. data/test/core/string/test_tab.rb +0 -16
  351. data/test/core/symbol/test_to_proc.rb +0 -35
  352. data/test/core/to_hash_tc.rb +0 -210
  353. data/test/core/unboundmethod/test_name.rb +0 -19
@@ -1,65 +0,0 @@
1
- == String#indent
2
-
3
- require 'facets/string/indent'
4
-
5
- positive
6
-
7
- "xyz".indent(4).assert == ' xyz'
8
- " xyz".indent(2).assert == ' xyz'
9
-
10
- multiline positive
11
-
12
- "abc\nxyz".indent(2).assert == " abc\n xyz"
13
-
14
- zero
15
-
16
- 'xyz'.indent(0).assert == 'xyz'
17
-
18
- negative
19
-
20
- ' xyz'.indent(-2).assert == ' xyz'
21
- ' xyz'. indent(-2).assert == 'xyz'
22
-
23
- multiline negative
24
-
25
- " abc\n xyz".indent(-2).assert == " abc\n xyz"
26
-
27
- negative more than is possible
28
-
29
- ' xyz'.indent(-3).assert == 'xyz'
30
-
31
- non-space positive
32
-
33
- "xyz".indent(4, '-').assert == '----xyz'
34
-
35
- non-space zero
36
-
37
- 'xyz'.indent(0, '-').assert == 'xyz'
38
-
39
- non-space negative non-matching character
40
-
41
- ' xyz'.indent(-2, '-').assert == ' xyz'
42
- ' xyz'. indent(-2, '-').assert == ' xyz'
43
-
44
- non-space negative
45
-
46
- '----xyz'.indent(-2, '-').assert == '--xyz'
47
- '--xyz'.indent(-2, '-').assert == 'xyz'
48
-
49
- Special regular expresion characters are escaped.
50
-
51
- ensure '.' is treated literally and not as wildcard
52
-
53
- ' xyz'.indent(-2, '.').assert == ' xyz'
54
- '..xyz'.indent(-2, '.').assert == 'xyz'
55
-
56
- ensure '*' is treated literally and not as wildcard
57
-
58
- ' xyz'.indent(-2, '*').assert == ' xyz'
59
- '**xyz'.indent(-2, '*').assert == 'xyz'
60
-
61
- ensure '^' is treated literally and not as line start
62
-
63
- ' xyz'.indent(-2, '^').assert == ' xyz'
64
- '^^xyz'.indent(-2, '^').assert == 'xyz'
65
-
@@ -1,7 +0,0 @@
1
- == String#interpolate
2
-
3
- require 'facets/string/interpolate'
4
-
5
- a = 1
6
- String.interpolate{ 'this is #{a}' }.assert == 'this is 1'
7
-
@@ -1,14 +0,0 @@
1
- == String#lchomp
2
-
3
- require 'facets/string/lchomp'
4
-
5
- s = "xxboo"
6
- r = s.lchomp("xx")
7
- r.assert == "boo"
8
-
9
- == String#lchomp!
10
-
11
- s = "xxboo"
12
- s.lchomp!("xx")
13
- s.assert == "boo"
14
-
@@ -1,7 +0,0 @@
1
- == String#line_wrap
2
-
3
- require 'facets/string/line_wrap'
4
-
5
- "abc123".line_wrap(3).assert == "abc\n123\n"
6
- "abcd123".line_wrap(4).assert == "abcd\n123\n"
7
-
@@ -1,8 +0,0 @@
1
- == String#lines
2
-
3
- Ruby 1.9 defined #lines to keep the newline character.
4
-
5
- require 'facets/string/lines'
6
-
7
- "a\nb\nc".lines.to_a.assert == ["a\n","b\n","c"]
8
-
@@ -1,22 +0,0 @@
1
- == String#methodize
2
-
3
- require 'facets/string/methodize'
4
-
5
- module name
6
-
7
- a = "FooBase"
8
- r = "foo_base"
9
- a.methodize.assert == r
10
-
11
- path name
12
-
13
- a = "foo/base"
14
- r = "foo__base"
15
- a.methodize.assert == r
16
-
17
- name space
18
-
19
- a = "Foo::Base"
20
- r = "foo__base"
21
- a.methodize.assert == r
22
-
@@ -1,22 +0,0 @@
1
- == String#modulize
2
-
3
- require 'facets/string/modulize'
4
-
5
- snakecase
6
-
7
- a = "foo_bar"
8
- r = "FooBar"
9
- a.modulize.assert == r
10
-
11
- path name
12
-
13
- a = "foo/bar"
14
- r = "Foo::Bar"
15
- a.modulize.assert == r
16
-
17
- on methodized string
18
-
19
- a = "foo__bar"
20
- r = "Foo::Bar"
21
- a.modulize.assert == r
22
-
@@ -1,10 +0,0 @@
1
- == String#mscan
2
-
3
- require 'facets/string/mscan'
4
-
5
- r = 'abc,def,gh'.mscan(/[,]/)
6
- assert( r.all?{ |md| MatchData === md } )
7
- r.to_a.length.assert == 2
8
- r[0][0].assert == ','
9
- r[1][0].assert == ','
10
-
@@ -1,10 +0,0 @@
1
- == String#natcmp
2
-
3
- require 'facets/string/natcmp'
4
-
5
- "my_prog_v1.1.0".natcmp( "my_prog_v1.2.0").assert == -1
6
- "my_prog_v1.2.0".natcmp("my_prog_v1.10.0").assert == -1
7
- "my_prog_v1.2.0".natcmp( "my_prog_v1.1.0").assert == 1
8
- "my_prog_v1.10.0".natcmp("my_prog_v1.2.0").assert == 1
9
- "my_prog_v1.0.0".natcmp( "my_prog_v1.0.0").assert == 0
10
-
@@ -1,9 +0,0 @@
1
- == String#nchar
2
-
3
- require 'facets/string/nchar'
4
-
5
- "abcxyz".nchar(3).assert == "abc"
6
- "abcxyz".nchar(-3).assert == "xyz"
7
- "abcxyz".nchar(3, 'HI').assert == "HIxyz"
8
- "abcxyz".nchar(-3, 'HI').assert == "abcHI"
9
-
@@ -1,7 +0,0 @@
1
- == String#-
2
-
3
- 'facets/string/op_sub'
4
-
5
- s = "xxbooxxfoo"
6
- (s - "xx").assert == "boofoo"
7
-
@@ -1,22 +0,0 @@
1
- == String#pathize
2
-
3
- require 'facets/string/pathize'
4
-
5
- module name
6
-
7
- a = "Foo::Base"
8
- x = "foo/base"
9
- a.pathize.assert == x
10
-
11
- path name
12
-
13
- a = "foo/base"
14
- x = "foo/base"
15
- a.pathize.assert == x
16
-
17
- name space
18
-
19
- a = "foo__base"
20
- x = "foo/base"
21
- a.pathize.assert == x
22
-
@@ -1,20 +0,0 @@
1
- == String#quote
2
-
3
- require 'facets/string/quote'
4
-
5
- The default is single quotes.
6
-
7
- 'hi'.quote.assert == %{"hi"}
8
-
9
- The type of quotes can be specified by name.
10
-
11
- 'hi'.quote(:single).assert == %{'hi'}
12
- 'hi'.quote(:double).assert == %{"hi"}
13
- 'hi'.quote(:back).assert == %{`hi`}
14
-
15
- They can also be specified by the first character of the name.
16
-
17
- 'hi'.quote(:s).assert == %{'hi'}
18
- 'hi'.quote(:d).assert == %{"hi"}
19
- 'hi'.quote(:b).assert == %{`hi`}
20
-
@@ -1,19 +0,0 @@
1
- == String#range
2
-
3
- require 'facets/string/range'
4
-
5
- "a123a567a9".range(/123/).assert == (1..3)
6
- "a123a567a9".range(/a/).assert == (0..0)
7
-
8
- == String#range_all
9
-
10
- "a123a123a9".range_all(/123/).assert == [ (1..3), (5..7) ]
11
- "a123a567a9".range_all(/a/).assert == [ (0..0), (4..4), (8..8) ]
12
-
13
- == String#range_of_line
14
-
15
- a = "0123\n456\n78"
16
- x = [0..4, 5..8, 9..10]
17
- r = a.range_of_line
18
- r.assert == x
19
-
@@ -1,9 +0,0 @@
1
- == String#rewrite
2
-
3
- require 'facets/string/rewrite'
4
-
5
- s = "HELLO TOMMY!"
6
- rules = [[ /TOMMY/, 'MAN' ]]
7
- r = s.rewrite(rules)
8
- r.assert == "HELLO MAN!"
9
-
@@ -1,9 +0,0 @@
1
- == String#shatter
2
-
3
- require 'facets/string/shatter'
4
-
5
- s = "<p>This<b>is</b>a test.</p>"
6
- r = s.shatter( /<.*?>/ )
7
- x = ["<p>", "This", "<b>", "is", "</b>", "a test.", "</p>"]
8
- r.assert == x
9
-
@@ -1,10 +0,0 @@
1
- == String#snakecase
2
-
3
- require 'facets/string/snakecase'
4
-
5
- 'my_name'.snakecase.assert == 'my_name'
6
-
7
- 'MyName'.snakecase.assert == 'my_name'
8
-
9
- 'URI'.snakecase.assert == 'uri'
10
-
@@ -1,28 +0,0 @@
1
- == String#splice
2
-
3
- require 'facets/string/splice'
4
-
5
- a = "HELLO"
6
- a.splice(1).assert == "E"
7
- a.assert == "HLLO"
8
-
9
- range
10
-
11
- a = "HELLO"
12
- a.splice(1..2).assert == "EL"
13
- a.assert == "HLO"
14
-
15
- store
16
-
17
- a = "HELLO"
18
- a.splice(1, "X")
19
- a.assert == "HXLLO"
20
-
21
- This could be done if class of 2nd arg is checked.
22
-
23
- #Unit :splice_length
24
- # a = "HELLO"
25
- # a.splice(1,2).assert == "EL"
26
- # a.assert == "HLO"
27
- #end
28
-
@@ -1,7 +0,0 @@
1
- == String#start_with?
2
-
3
- require 'facets/string/start_with'
4
-
5
- s = "xxboo"
6
- s.assert.start_with?('xx')
7
-
@@ -1,8 +0,0 @@
1
- == String#-
2
-
3
- require 'facets/string/subtract'
4
-
5
- ("foobar" - "oo").assert == "fbar"
6
- ("pizza pizza!" - "zz").assert == "pia pia!"
7
- ("letters" - /[a-z]+/).assert == ""
8
-
@@ -1,16 +0,0 @@
1
- == String#tab
2
-
3
- require 'facets/string/tab'
4
-
5
- a = "abc".tab(2)
6
- a.assert == " abc"
7
-
8
- If we add a new line we see that both are tabbed.
9
-
10
- a = "abc\nxyz".tab(2)
11
- a.assert == " abc\n xyz"
12
-
13
- Unlike #tabto, #tab indents all lines equally regardless of prior indention.
14
-
15
- a = "abc\n xyz".tab(2)
16
- a.assert == " abc\n xyz"
@@ -1,29 +0,0 @@
1
- == String#tabto
2
-
3
- require 'facets/string/tabto'
4
-
5
- String#tabto indeent lines relative to their current indentions. Using #tabto
6
- on a single line behaves just like #tab.
7
-
8
- a = "xyz".tabto(2)
9
- a.assert == " xyz"
10
-
11
- a = " xyz".tabto(2)
12
- a.assert == " xyz"
13
-
14
- If the string has multiple lines, then each line will be indented
15
- accordingly.
16
-
17
- a = "abc\nxyz".tabto(2)
18
- a.assert == " abc\n xyz"
19
-
20
- Unlike #tab, the left margin of indention is determined by the first
21
- non-blank line.
22
-
23
- a = " abc\n xyz".tabto(2)
24
- a.assert == " abc\n xyz"
25
-
26
- If we add a blank line at the begining it will be the same.
27
-
28
- a = " \n abc\n xyz".tabto(2)
29
- a.assert == " \n abc\n xyz"
@@ -1,8 +0,0 @@
1
- == String#titlecase
2
-
3
- require 'facets/string/titlecase'
4
-
5
- r = "try this out".titlecase
6
- x = "Try This Out"
7
- r.assert == x
8
-
@@ -1,22 +0,0 @@
1
- == String#to_re
2
-
3
- require 'facets/string/to_re'
4
-
5
- "abc".to_re.assert == /abc/
6
- "a+bc".to_re.assert == /a+bc/
7
- "a+bc".to_re(false).assert == /a+bc/
8
- "a+bc".to_re(true).assert == /a\+bc/
9
-
10
- escaped characters
11
-
12
- a = "?"
13
- b = /#{a.to_rx}/
14
- assert( b =~ "?" )
15
-
16
- == String#to_rx
17
-
18
- "abc".to_rx.assert == /abc/
19
- "a+bc".to_rx.assert == /a\+bc/
20
- "a+bc".to_rx(false).assert == /a+bc/
21
- "a+bc".to_rx(true).assert == /a\+bc/
22
-
@@ -1,9 +0,0 @@
1
- == String#unfold
2
-
3
- require 'facets/string/unfold'
4
-
5
- str = "This is a test of\nparagraph folding."
6
- res = str.unfold
7
- exp = "This is a test of paragraph folding."
8
- res.assert == exp
9
-
@@ -1,65 +0,0 @@
1
- == String#unindent
2
-
3
- require 'facets/string/unindent'
4
-
5
- We will use these two strings as a common basis for demonstration.
6
-
7
- ex1 = <<-EOF.gsub(/^\s*\|/,'')
8
- | I must go down to the seas again
9
- | The lonely sea and the sky
10
- | And all I want is a tall ship
11
- | And a star to steer her by
12
- EOF
13
-
14
- ex2 = <<-EOF.gsub(/^\s*\|/,'')
15
- | "Eek!"
16
- | She cried
17
- | As the mouse quietly scurried
18
- |by.
19
- EOF
20
-
21
- simple examples
22
-
23
- " xyz".unindent(-1).assert == " xyz"
24
- " xyz".unindent(0).assert == " xyz"
25
- " xyz".unindent(1).assert == " xyz"
26
- " xyz".unindent(2).assert == " xyz"
27
- " xyz".unindent(3).assert == "xyz"
28
- " xyz".unindent(4).assert == "xyz"
29
-
30
- large example unindented one space
31
-
32
- expected = <<-EOF.gsub(/^\s*\|/,'')
33
- | I must go down to the seas again
34
- | The lonely sea and the sky
35
- | And all I want is a tall ship
36
- | And a star to steer her by
37
- EOF
38
-
39
- actual = ex1.unindent(1)
40
- actual.assert == expected
41
-
42
- large example unindented four spaces
43
-
44
- expected = <<-EOF.gsub(/^\s*\|/,'')
45
- |I must go down to the seas again
46
- | The lonely sea and the sky
47
- |And all I want is a tall ship
48
- | And a star to steer her by
49
- EOF
50
-
51
- actual = ex1.unindent(4)
52
- actual.assert == expected
53
-
54
- unindent larger than current indention
55
-
56
- expected = <<-EOF.gsub(/^\s*\|/,'')
57
- |"Eek!"
58
- |She cried
59
- |As the mouse quietly scurried
60
- |by.
61
- EOF
62
-
63
- actual = ex2.unindent(100)
64
- actual.assert == expected
65
-