facets 3.0.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.index +11 -7
- data/CONTRIBUTING.md +112 -0
- data/HISTORY.md +38 -0
- data/{README.rdoc → README.md} +59 -59
- data/demo/core/array/after.md +13 -0
- data/demo/core/array/arrange.md +17 -0
- data/demo/core/array/before.md +14 -0
- data/demo/core/array/collapse.md +15 -0
- data/demo/core/array/collisions.md +30 -0
- data/demo/core/array/commonality.md +31 -0
- data/demo/core/array/conjoin.md +47 -0
- data/demo/core/array/contains.md +9 -0
- data/demo/core/array/delete_unless.md +13 -0
- data/demo/core/array/delete_values.md +10 -0
- data/demo/core/array/delete_values_at.md +15 -0
- data/demo/core/array/divide.md +14 -0
- data/demo/core/array/duplicates.md +14 -0
- data/demo/core/array/each_overlap.md +12 -0
- data/demo/core/array/each_pair.md +13 -0
- data/demo/core/array/each_value.md +12 -0
- data/demo/core/array/entropy.md +13 -0
- data/demo/core/array/extract_options.md +13 -0
- data/demo/core/array/first.md +11 -0
- data/demo/core/array/from.md +11 -0
- data/demo/core/array/ideal_entropy.md +11 -0
- data/demo/core/array/intersection.md +11 -0
- data/demo/core/array/last.md +11 -0
- data/demo/core/array/median.md +23 -0
- data/demo/core/array/merge.md +15 -0
- data/demo/core/array/missing.md +10 -0
- data/demo/core/array/mode.md +9 -0
- data/demo/core/array/nonuniq.md +16 -0
- data/demo/core/array/not_empty.md +8 -0
- data/demo/core/array/occur.md +18 -0
- data/demo/core/array/occurrence.md +13 -0
- data/demo/core/array/only.md +9 -0
- data/demo/core/array/op_pow.md +10 -0
- data/demo/core/array/pad.md +28 -0
- data/demo/core/array/peek.md +10 -0
- data/demo/core/array/poke.md +15 -0
- data/demo/core/array/probability +8 -0
- data/demo/core/array/pull.md +10 -0
- data/demo/core/array/recurse.md +10 -0
- data/demo/core/array/recursively.md +20 -0
- data/demo/core/array/reject_values.md +10 -0
- data/demo/core/array/splice.md +14 -0
- data/demo/core/array/split.md +13 -0
- data/demo/core/array/squeeze.md +14 -0
- data/demo/core/array/step.md +16 -0
- data/demo/core/array/store.md +9 -0
- data/demo/core/array/thru.md +12 -0
- data/demo/core/array/to_h.md +11 -0
- data/demo/core/array/traverse.md +20 -0
- data/demo/core/array/uniq_by.md +16 -0
- data/demo/core/array/unique_permutation.md +14 -0
- data/demo/core/array/zip.md +8 -0
- data/demo/core/binding/caller.md +57 -0
- data/demo/core/binding/defined.md +10 -0
- data/demo/core/binding/opvars.md +16 -0
- data/demo/core/binding/self.md +6 -0
- data/demo/core/class/descendants.md +13 -0
- data/demo/core/class/to_proc.md +11 -0
- data/demo/core/comparable/at_least.md +11 -0
- data/demo/core/comparable/at_most.md +11 -0
- data/demo/core/comparable/bound.md +13 -0
- data/demo/core/comparable/cap.md +11 -0
- data/demo/core/comparable/clip.md +29 -0
- data/demo/core/comparable/cmp.md +18 -0
- data/demo/core/comparable/op_get.md +32 -0
- data/demo/core/dir/ascend.md +24 -0
- data/demo/core/dir/descend.md +16 -0
- data/demo/core/dir/multiglob.md +41 -0
- data/demo/core/dir/parent.md +6 -0
- data/demo/core/dir/recurse.md +41 -0
- data/demo/core/exception/detail.md +19 -0
- data/demo/core/{facets.rdoc → facets.md} +1 -1
- data/demo/core/filetest/root.md +13 -0
- data/demo/core/hash/recursively.md +21 -0
- data/demo/core/indexable.md +95 -0
- data/demo/core/integer/bitmask.md +46 -0
- data/demo/core/integer/{factorial.rdoc → factorial.md} +1 -1
- data/demo/core/integer/{length.rdoc → length.md} +1 -1
- data/demo/core/integer/{multiple.rdoc → multiple.md} +3 -1
- data/demo/core/integer/of.md +11 -0
- data/demo/core/integer/{ordinal.rdoc → ordinal.md} +3 -1
- data/demo/core/integer/{of.rdoc → times_collect.md} +2 -7
- data/demo/core/matchdata/match.md +7 -0
- data/demo/core/matchdata/matchset.md +7 -0
- data/demo/core/matchdata/matchtree.md +10 -0
- data/demo/core/module/cattr.md +43 -0
- data/demo/core/module/class_extend.md +64 -0
- data/demo/core/module/{class_inheritor.rdoc → class_inheritor.md} +2 -2
- data/demo/core/module/{copy_inheritor.rdoc → copy_inheritor.md} +4 -4
- data/demo/core/module/include_as.md +31 -0
- data/demo/core/module/method_space.md +24 -0
- data/demo/core/string/acronym.md +9 -0
- data/demo/core/string/{align.rdoc → align.md} +10 -10
- data/demo/core/string/ascii_only.md +37 -0
- data/demo/core/string/{bracket.rdoc → bracket.md} +10 -10
- data/demo/core/string/camelcase.md +47 -0
- data/demo/core/string/{capitalized.rdoc → capitalized.md} +9 -9
- data/demo/core/string/characters.md +11 -0
- data/demo/core/string/{cleanlines.rdoc → cleanlines.md} +3 -3
- data/demo/core/string/cleave.md +49 -0
- data/demo/core/string/compress_lines.md +22 -0
- data/demo/core/string/crypt.md +15 -0
- data/demo/core/string/divide.md +9 -0
- data/demo/core/string/each_word.md +11 -0
- data/demo/core/string/edit_distance.md +15 -0
- data/demo/core/string/exclude.md +15 -0
- data/demo/core/string/expand_tabs.md +69 -0
- data/demo/core/string/fold.md +14 -0
- data/demo/core/string/indent.md +65 -0
- data/demo/core/string/index_all.md +14 -0
- data/demo/core/string/interpolate.md +8 -0
- data/demo/core/string/lchomp.md +14 -0
- data/demo/core/string/line_wrap.md +7 -0
- data/demo/core/string/lowercase.md +12 -0
- data/demo/core/string/methodize.md +22 -0
- data/demo/core/string/modulize.md +22 -0
- data/demo/core/string/mscan.md +10 -0
- data/demo/core/string/natcmp.md +10 -0
- data/demo/core/string/nchar.md +9 -0
- data/demo/core/string/{newlines.rdoc → newlines.md} +3 -3
- data/demo/core/string/number.md +27 -0
- data/demo/core/string/op_div.md +10 -0
- data/demo/core/string/op_sub.md +7 -0
- data/demo/core/string/pathize.md +22 -0
- data/demo/core/string/quote.md +20 -0
- data/demo/core/string/random.md +25 -0
- data/demo/core/string/range.md +19 -0
- data/demo/core/string/remove.md +33 -0
- data/demo/core/string/rewrite.md +9 -0
- data/demo/core/string/shatter.md +9 -0
- data/demo/core/string/similarity.md +12 -0
- data/demo/core/string/snakecase.md +14 -0
- data/demo/core/string/splice.md +28 -0
- data/demo/core/string/squish.md +27 -0
- data/demo/core/string/store.md +10 -0
- data/demo/core/string/subtract.md +8 -0
- data/demo/core/string/titlecase.md +8 -0
- data/demo/core/string/to_re.md +22 -0
- data/demo/core/string/{margin.rdoc → trim.md} +14 -14
- data/demo/core/string/unbracket.md +24 -0
- data/demo/core/string/underscore.md +17 -0
- data/demo/core/string/unfold.md +9 -0
- data/demo/core/string/unindent.md +65 -0
- data/demo/core/string/unquote.md +6 -0
- data/demo/core/string/uppercase.md +15 -0
- data/demo/core/string/variablize.md +7 -0
- data/demo/core/string/word_wrap.md +54 -0
- data/demo/core/string/words.md +13 -0
- data/demo/core/string/xor.md +8 -0
- data/lib/core/facets.yml +11 -7
- data/lib/core/facets/array.rb +1 -0
- data/lib/core/facets/array/average.rb +16 -0
- data/lib/core/facets/array/collapse.rb +4 -0
- data/lib/core/facets/array/delete_values_at.rb +1 -0
- data/lib/core/facets/array/divide.rb +7 -0
- data/lib/core/facets/array/duplicates.rb +2 -0
- data/lib/core/facets/array/each_pair.rb +1 -4
- data/lib/core/facets/array/first.rb +1 -0
- data/lib/core/facets/array/from.rb +11 -16
- data/lib/core/facets/array/intersection.rb +1 -1
- data/lib/core/facets/array/last.rb +1 -0
- data/lib/core/facets/array/mode.rb +2 -2
- data/lib/core/facets/array/occurrence.rb +4 -3
- data/lib/core/facets/array/op_pow.rb +0 -2
- data/lib/core/facets/array/probability.rb +1 -1
- data/lib/core/facets/array/recursively.rb +2 -2
- data/lib/core/facets/array/splice.rb +1 -1
- data/lib/core/facets/array/standard_deviation.rb +23 -0
- data/lib/core/facets/array/to_h.rb +0 -3
- data/lib/core/facets/array/uniq_by.rb +4 -0
- data/lib/core/facets/array/variance.rb +20 -0
- data/lib/core/facets/binding.rb +0 -1
- data/lib/core/facets/enumerable/cluster.rb +6 -4
- data/lib/core/facets/enumerable/hashify.rb +27 -31
- data/lib/core/facets/enumerable/sum.rb +12 -2
- data/lib/core/facets/file/atomic_open.rb +1 -1
- data/lib/core/facets/hash/except.rb +13 -1
- data/lib/core/facets/indexable.rb +1 -1
- data/lib/core/facets/kernel/ergo.rb +3 -3
- data/lib/core/facets/kernel/like.rb +1 -1
- data/lib/core/facets/matchdata/matchtree.rb +2 -0
- data/lib/core/facets/numeric/delimit.rb +20 -0
- data/lib/core/facets/range/nudge.rb +29 -0
- data/lib/core/facets/string.rb +0 -2
- data/lib/core/facets/string/indent.rb +0 -8
- data/lib/core/facets/string/margin.rb +0 -4
- data/lib/core/facets/string/random.rb +13 -3
- data/lib/core/facets/string/similarity.rb +7 -6
- data/lib/standard/facets/enumargs.rb +5 -0
- data/lib/standard/facets/math/percentile.rb +1 -1
- data/lib/standard/facets/net/http.rb +33 -14
- data/lib/standard/facets/timer.rb +3 -3
- data/test/core/array/test_average.rb +16 -0
- data/test/core/array/test_before.rb +21 -0
- data/test/core/array/test_collapse.rb +10 -1
- data/test/core/array/test_delete_unless.rb +17 -0
- data/test/core/array/test_delete_values.rb +31 -0
- data/test/core/array/test_divide.rb +10 -0
- data/test/core/array/test_each_pair.rb +16 -0
- data/test/core/array/test_each_value.rb +16 -0
- data/test/core/array/test_from.rb +42 -0
- data/test/core/array/test_op_pow.rb +13 -0
- data/test/core/array/test_standard_deviation.rb +18 -0
- data/test/core/array/test_to_h.rb +14 -0
- data/test/core/array/test_uniq_by.rb +7 -0
- data/test/core/array/test_variance.rb +17 -0
- data/test/core/array/test_zip.rb +13 -0
- data/test/core/dir/test_each_child.rb +1 -1
- data/test/core/dir/test_multiglob.rb +1 -1
- data/test/core/enumerable/test_cluster.rb +36 -0
- data/test/core/enumerable/test_hashify.rb +113 -0
- data/test/core/hash/test_expect.rb +11 -1
- data/test/core/kernel/test_ergo.rb +7 -5
- data/test/core/{object/test_replace.rb → kernel/test_instance_replace.rb} +6 -28
- data/test/core/numeric/test_delimit.rb +68 -0
- data/test/core/numeric/{test_round.rb → test_round_to.rb} +27 -27
- data/test/core/range/test_nudge.rb +32 -0
- data/test/core/range/{test_to_r.rb → test_to_rng.rb} +3 -3
- data/test/core/string/test_acronym.rb +14 -0
- data/test/core/string/test_ascii_only.rb +21 -0
- data/test/core/string/test_compress_lines.rb +9 -0
- data/test/core/string/test_crypt.rb +17 -0
- data/test/core/string/test_index_all.rb +4 -0
- data/test/core/string/test_random.rb +25 -0
- data/test/core/string/test_remove.rb +14 -0
- data/test/core/string/test_similarity.rb +9 -1
- data/test/core/struct/test_replace.rb +18 -0
- data/test/standard/test_enumargs.rb +26 -10
- data/test/standard/test_timer.rb +1 -1
- metadata +634 -588
- data/CONTRIBUTE.md +0 -78
- data/demo/core/array/combination.rdoc +0 -19
- data/demo/core/array/delete.rdoc +0 -23
- data/demo/core/array/index.rdoc +0 -14
- data/demo/core/array/merge.rdoc +0 -15
- data/demo/core/array/only.rdoc +0 -9
- data/demo/core/array/pad.rdoc +0 -28
- data/demo/core/array/permutation.rdoc +0 -10
- data/demo/core/array/product.rdoc +0 -26
- data/demo/core/array/recursively.rdoc +0 -16
- data/demo/core/array/rotate.rdoc +0 -30
- data/demo/core/array/select.rdoc +0 -8
- data/demo/core/array/uniq_by.rdoc +0 -9
- data/demo/core/binding/caller.rdoc +0 -57
- data/demo/core/binding/defined.rdoc +0 -10
- data/demo/core/binding/eval.rdoc +0 -8
- data/demo/core/binding/local_variables.rdoc +0 -26
- data/demo/core/binding/opvars.rdoc +0 -16
- data/demo/core/binding/self.rdoc +0 -6
- data/demo/core/class/descendants.rdoc +0 -10
- data/demo/core/class/to_proc.rdoc +0 -8
- data/demo/core/comparable/cap.rdoc +0 -20
- data/demo/core/comparable/clip.rdoc +0 -37
- data/demo/core/comparable/cmp.rdoc +0 -18
- data/demo/core/comparable/op_get.rdoc +0 -29
- data/demo/core/dir/ascend.rdoc +0 -24
- data/demo/core/dir/descend.rdoc +0 -14
- data/demo/core/dir/multiglob.rdoc +0 -41
- data/demo/core/dir/parent.rdoc +0 -6
- data/demo/core/dir/recurse.rdoc +0 -41
- data/demo/core/exception/detail.rdoc +0 -12
- data/demo/core/filetest/root.rdoc +0 -6
- data/demo/core/hash/recursively.rdoc +0 -21
- data/demo/core/indexable.rdoc +0 -95
- data/demo/core/integer/bitmask.rdoc +0 -46
- data/demo/core/integer/even.rdoc +0 -12
- data/demo/core/integer/odd.rdoc +0 -12
- data/demo/core/matchdata/match.rdoc +0 -7
- data/demo/core/matchdata/matchset.rdoc +0 -15
- data/demo/core/module/cattr.rdoc +0 -43
- data/demo/core/module/class_extend.rdoc +0 -64
- data/demo/core/module/method_space.rdoc +0 -55
- data/demo/core/string/bytes.rdoc +0 -8
- data/demo/core/string/camelcase.rdoc +0 -47
- data/demo/core/string/characters.rdoc +0 -11
- data/demo/core/string/cleave.rdoc +0 -49
- data/demo/core/string/divide.rdoc +0 -9
- data/demo/core/string/each_char.rdoc +0 -9
- data/demo/core/string/each_word.rdoc +0 -9
- data/demo/core/string/end_with.rdoc +0 -6
- data/demo/core/string/expand_tabs.rdoc +0 -69
- data/demo/core/string/fold.rdoc +0 -14
- data/demo/core/string/indent.rdoc +0 -65
- data/demo/core/string/interpolate.rdoc +0 -7
- data/demo/core/string/lchomp.rdoc +0 -14
- data/demo/core/string/line_wrap.rdoc +0 -7
- data/demo/core/string/lines.rdoc +0 -8
- data/demo/core/string/methodize.rdoc +0 -22
- data/demo/core/string/modulize.rdoc +0 -22
- data/demo/core/string/mscan.rdoc +0 -10
- data/demo/core/string/natcmp.rdoc +0 -10
- data/demo/core/string/nchar.rdoc +0 -9
- data/demo/core/string/op_sub.rdoc +0 -7
- data/demo/core/string/pathize.rdoc +0 -22
- data/demo/core/string/quote.rdoc +0 -20
- data/demo/core/string/range.rdoc +0 -19
- data/demo/core/string/rewrite.rdoc +0 -9
- data/demo/core/string/shatter.rdoc +0 -9
- data/demo/core/string/snakecase.rdoc +0 -10
- data/demo/core/string/splice.rdoc +0 -28
- data/demo/core/string/start_with.rdoc +0 -7
- data/demo/core/string/subtract.rdoc +0 -8
- data/demo/core/string/tab.rdoc +0 -16
- data/demo/core/string/tabto.rdoc +0 -29
- data/demo/core/string/titlecase.rdoc +0 -8
- data/demo/core/string/to_re.rdoc +0 -22
- data/demo/core/string/unfold.rdoc +0 -9
- data/demo/core/string/unindent.rdoc +0 -65
- data/demo/core/string/unquote.rdoc +0 -6
- data/demo/core/string/variablize.rdoc +0 -7
- data/demo/core/string/word_wrap.rdoc +0 -54
- data/demo/core/string/words.rdoc +0 -13
- data/demo/core/string/xor.rdoc +0 -8
- data/lib/core/facets/binding/local_variables.rb +0 -16
- data/lib/core/facets/string/tab.rb +0 -2
- data/lib/core/facets/string/tabto.rb +0 -2
- data/test/core/array/test_after.rb +0 -27
- data/test/core/array/test_combination.rb +0 -25
- data/test/core/array/test_index.rb +0 -20
- data/test/core/array/test_permutation.rb +0 -20
- data/test/core/array/test_product.rb +0 -64
- data/test/core/array/test_rotate.rb +0 -38
- data/test/core/array/test_select.rb +0 -16
- data/test/core/binding/test_eval.rb +0 -15
- data/test/core/binding/test_local_variables.rb +0 -36
- data/test/core/enumerable/test_cluster_by.rb +0 -30
- data/test/core/enumerable/test_count.rb +0 -32
- data/test/core/enumerable/test_each_with_object.rb +0 -18
- data/test/core/enumerable/test_group_by.rb +0 -36
- data/test/core/enumerable/test_none.rb +0 -29
- data/test/core/enumerable/test_one.rb +0 -34
- data/test/core/enumerable/test_take.rb +0 -15
- data/test/core/hash/test_select.rb +0 -44
- data/test/core/hash/test_url_params.rb +0 -26
- data/test/core/integer/test_even.rb +0 -24
- data/test/core/integer/test_odd.rb +0 -24
- data/test/core/kernel/test_require_relative.rb +0 -12
- data/test/core/nilclass/test_to_f.rb +0 -13
- data/test/core/proc/test_curry.rb +0 -38
- data/test/core/string/test_bytes.rb +0 -13
- data/test/core/string/test_each_char.rb +0 -17
- data/test/core/string/test_end_with.rb +0 -24
- data/test/core/string/test_lines.rb +0 -15
- data/test/core/string/test_start_with.rb +0 -24
- data/test/core/string/test_tab.rb +0 -16
- data/test/core/symbol/test_to_proc.rb +0 -35
- data/test/core/to_hash_tc.rb +0 -210
- data/test/core/unboundmethod/test_name.rb +0 -19
data/CONTRIBUTE.md
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
# CONTRIBUTING TO FACETS
|
2
|
-
|
3
|
-
* Facets methods must have no external dependencies. (The only possible
|
4
|
-
exception to this is if the functor gets spun-off as a separate gem along
|
5
|
-
with related methods, but for now that's not happening.)
|
6
|
-
|
7
|
-
* Each method must be in it's own file of the same name. If the method ends
|
8
|
-
with `=` or `?` just leave it off the file name.
|
9
|
-
|
10
|
-
* On rare occasion two or more methods can be very tightly related. In these
|
11
|
-
cases the methods can all go in a single file under the name of the method
|
12
|
-
considered most significant. Usually files for the other methods should
|
13
|
-
still be created that simply require the main file.
|
14
|
-
|
15
|
-
* Methods must be tested either via a Lemon unit test or a QED demo,
|
16
|
-
preferably both. The Lemon unit tests are for testing a method in
|
17
|
-
detail whereas the QED demos are for demonstrating usage.
|
18
|
-
|
19
|
-
* Facets is divided into two parts, *core* and *standard* libraries.
|
20
|
-
All of the core library is loaded by default when using `require 'facets'`
|
21
|
-
(actually, almost all). The standard library (sometimes called the *more*
|
22
|
-
library) must be required per-script.
|
23
|
-
|
24
|
-
* Some core methods are included on a *trial* basis, and these are not
|
25
|
-
necessary loaded automatically with `require 'facets'`.
|
26
|
-
|
27
|
-
* Standard libraries that are not extensions of existing standard libraries
|
28
|
-
do not have to be divvied up into individual method files. But note that
|
29
|
-
full classes and/or modules are less likely to make it into Facets, as
|
30
|
-
these sorts of additions to Facets are only for very basic sorts of things.
|
31
|
-
Otherwise they'd deserve their own gem.
|
32
|
-
|
33
|
-
* When submitting new methods for consideration, it is best if each method
|
34
|
-
(or *tightly related* set of methods) is in it's own pull request. If you
|
35
|
-
have only one method to submit then a simple commit will do the tirck. If
|
36
|
-
you have more than one it best to use separate branches. Let me emphasizes
|
37
|
-
this point because it makes it *much more likely* that your pull request
|
38
|
-
will be merged. If you submit a bunch of methods in a single pull request,
|
39
|
-
it is very likely that it will not be merged even if methods you submitted
|
40
|
-
are accepted!!!
|
41
|
-
|
42
|
-
* Don't be discouraged when you get feedback about a method that isn't
|
43
|
-
all sunshine and roses. Facets has been around long enough now that
|
44
|
-
it needs to maintain a certain degree of quality control, and that means
|
45
|
-
serious discernment about what goes into the library. That includes
|
46
|
-
having in depth discussions the merits of methods, even about the best
|
47
|
-
name for a method --even if the functionality has been accepted the name
|
48
|
-
may not!
|
49
|
-
|
50
|
-
* When making a commit, if the commit is only a documentation change, then
|
51
|
-
and `[doc]` to the end of the first line of commit message. If it is only
|
52
|
-
a change to tests then add `[test]`. If the change only effects build files
|
53
|
-
then add `[admin]`. For actual code changes, if the change is not somethng
|
54
|
-
anyone would notice, use `[tweak]` or `[minor]` (minor being slightly more
|
55
|
-
improtant than tweak). For typical code changes no comment tag is necessary.
|
56
|
-
If the change fixes a bug that was reported via the issue system be sure to
|
57
|
-
reference the issue id in the message using `#` and add `[bug]`. If a change
|
58
|
-
is a significant change to the API, then end the message with `[major]`.
|
59
|
-
These are all rules of thumb, and no expects them to be applied perfectly.
|
60
|
-
|
61
|
-
## Documentation
|
62
|
-
|
63
|
-
Facets started when the only choice for API documentation was RDoc. So originally
|
64
|
-
that's how methods were documented. Since then both YARD and Tomdoc have come
|
65
|
-
along. And some of these documentation styles have creeped into a number of
|
66
|
-
methods. So right now, things are a bit messy. But going forward it looks like we
|
67
|
-
are going to settle on Tomdoc as the official documentation style (but using
|
68
|
-
the tomparse gem's extensions). Using Tomdoc will give us reasonable
|
69
|
-
interoperabiltiy with both RDoc and YARD, both of which now have support for
|
70
|
-
Tomdoc (albeit support is not 100% the same, but hopefully it's close enough).
|
71
|
-
|
72
|
-
Offically we publish documentation via rubydoc.info, which is the YARD server,
|
73
|
-
and via the Facets website in Shomen JSON format.
|
74
|
-
|
75
|
-
When writting documentation for a method it is best to give a simple summary
|
76
|
-
explaination, followed by some basic examples. Follow that up with deeper
|
77
|
-
explaination if needed, including *when* and *why* the method could be useful.
|
78
|
-
|
@@ -1,19 +0,0 @@
|
|
1
|
-
== Array#combination
|
2
|
-
|
3
|
-
require 'facets/array/combination'
|
4
|
-
|
5
|
-
finds pairs of combinations
|
6
|
-
|
7
|
-
e = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4]]
|
8
|
-
a = [1,2,3,4]
|
9
|
-
r = a.combination(2).to_a
|
10
|
-
r.assert == e
|
11
|
-
|
12
|
-
can also take a block
|
13
|
-
|
14
|
-
e = [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]
|
15
|
-
r = []
|
16
|
-
a = [1,2,3,4]
|
17
|
-
a.combination(2){ |a,b| r << [a,b] }
|
18
|
-
r.assert == e
|
19
|
-
|
data/demo/core/array/delete.rdoc
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
== Array#delete_unless
|
2
|
-
|
3
|
-
require 'facets/array/delete'
|
4
|
-
|
5
|
-
a = [1,2,3]
|
6
|
-
a.delete_unless{ |e| e == 2 }
|
7
|
-
a.assert == [2]
|
8
|
-
|
9
|
-
== Array#delete_values
|
10
|
-
|
11
|
-
a = [1,2,3,4]
|
12
|
-
a.delete_values(1,2).assert == [1,2]
|
13
|
-
a.assert == [3,4]
|
14
|
-
|
15
|
-
== Array#delete_values_at
|
16
|
-
|
17
|
-
a = [1,2,3,4]
|
18
|
-
a.delete_values_at(1,2).assert == [2,3]
|
19
|
-
a.assert == [1,4]
|
20
|
-
a = [1,2,3,4]
|
21
|
-
a.delete_values_at(0..2).assert == [1,2,3]
|
22
|
-
a.assert == [4]
|
23
|
-
|
data/demo/core/array/index.rdoc
DELETED
data/demo/core/array/merge.rdoc
DELETED
data/demo/core/array/only.rdoc
DELETED
data/demo/core/array/pad.rdoc
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
== Array#pad
|
2
|
-
|
3
|
-
require 'facets/array/pad'
|
4
|
-
|
5
|
-
r = [0,1,2,3].pad(7,"x")
|
6
|
-
x = [0,1,2,3,"x","x","x"]
|
7
|
-
r.assert == x
|
8
|
-
|
9
|
-
negative index
|
10
|
-
|
11
|
-
r = [0,1,2,3].pad(-7,"n")
|
12
|
-
x = ["n","n","n",0,1,2,3]
|
13
|
-
r.assert == x
|
14
|
-
|
15
|
-
== Array#pad!
|
16
|
-
|
17
|
-
a = [0,1,2,3]
|
18
|
-
r = a.pad!(6,"y")
|
19
|
-
x = [0,1,2,3,"y","y"]
|
20
|
-
r.assert == x
|
21
|
-
|
22
|
-
negative index
|
23
|
-
|
24
|
-
a = [0,1,2,3]
|
25
|
-
r = a.pad!(-6,"q")
|
26
|
-
x = ["q","q",0,1,2,3]
|
27
|
-
r.assert == x
|
28
|
-
|
@@ -1,26 +0,0 @@
|
|
1
|
-
== Array#product
|
2
|
-
|
3
|
-
require 'facets/array/product'
|
4
|
-
|
5
|
-
single argument
|
6
|
-
|
7
|
-
r = [1,2,3].product([4,5,6])
|
8
|
-
x = [[1, 4],[1, 5],[1, 6],[2, 4],[2, 5],[2, 6],[3, 4],[3, 5],[3, 6]]
|
9
|
-
r.assert == x
|
10
|
-
|
11
|
-
multiple arguments
|
12
|
-
|
13
|
-
a = %w|a b|
|
14
|
-
b = %w|a x|
|
15
|
-
c = %w|x y|
|
16
|
-
r = a.product(b, c)
|
17
|
-
x = [ ["a", "a", "x"],
|
18
|
-
["a", "a", "y"],
|
19
|
-
["a", "x", "x"],
|
20
|
-
["a", "x", "y"],
|
21
|
-
["b", "a", "x"],
|
22
|
-
["b", "a", "y"],
|
23
|
-
["b", "x", "x"],
|
24
|
-
["b", "x", "y"] ]
|
25
|
-
r.assert == x
|
26
|
-
|
@@ -1,16 +0,0 @@
|
|
1
|
-
== Array#recursive
|
2
|
-
|
3
|
-
require 'facets/array/recursively'
|
4
|
-
|
5
|
-
each
|
6
|
-
|
7
|
-
r = []
|
8
|
-
[1,2,['a','b']].recursively.each{ |v| r << v }
|
9
|
-
r.assert == [1,2,'a','b']
|
10
|
-
|
11
|
-
|
12
|
-
map
|
13
|
-
|
14
|
-
r = [1,2,['a','b']].recursively.map{ |v| v.succ }
|
15
|
-
r.assert == [2,3,['b','c']]
|
16
|
-
|
data/demo/core/array/rotate.rdoc
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
== Array#rotate
|
2
|
-
|
3
|
-
require 'facets/array/rotate'
|
4
|
-
|
5
|
-
clockwise
|
6
|
-
|
7
|
-
a = [1,2,3]
|
8
|
-
r = a.rotate
|
9
|
-
r.assert == [2,3,1]
|
10
|
-
|
11
|
-
counter-clockwise
|
12
|
-
|
13
|
-
a = [1,2,3]
|
14
|
-
r = a.rotate(-1)
|
15
|
-
r.assert == [3,1,2]
|
16
|
-
|
17
|
-
== Array#rotate!
|
18
|
-
|
19
|
-
clockwise
|
20
|
-
|
21
|
-
a = [1,2,3]
|
22
|
-
a.rotate!
|
23
|
-
a.assert == [2,3,1]
|
24
|
-
|
25
|
-
counter-clockwise
|
26
|
-
|
27
|
-
a = [1,2,3]
|
28
|
-
a.rotate!(-1)
|
29
|
-
a.assert == [3,1,2]
|
30
|
-
|
data/demo/core/array/select.rdoc
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
The caller.rb script includes a few related methods.
|
2
|
-
We will use the following code to demonstrate their use.
|
3
|
-
|
4
|
-
require 'facets/binding/caller'
|
5
|
-
|
6
|
-
a = 1
|
7
|
-
b = 2
|
8
|
-
x = "hello"
|
9
|
-
|
10
|
-
@bind = binding
|
11
|
-
@line = __LINE__ # the line number must be updated if it moves
|
12
|
-
@file = __FILE__ # why does it equal basename only?
|
13
|
-
|
14
|
-
== Binding#caller
|
15
|
-
|
16
|
-
@bind.caller
|
17
|
-
|
18
|
-
== Binding#callstack
|
19
|
-
|
20
|
-
@bind.callstack.assert.is_a?(Array)
|
21
|
-
|
22
|
-
== Binding#__LINE__
|
23
|
-
|
24
|
-
@bind.__LINE__.assert == @line - 1
|
25
|
-
|
26
|
-
== Binding#__FILE__
|
27
|
-
|
28
|
-
@bind.__FILE__.assert == @file
|
29
|
-
|
30
|
-
== Binding#__DIR__
|
31
|
-
|
32
|
-
@bind.__DIR__.assert == File.dirname(@file)
|
33
|
-
|
34
|
-
== Binding#__callee__
|
35
|
-
|
36
|
-
This only works for certain versions.
|
37
|
-
|
38
|
-
def alternate_callee
|
39
|
-
binding
|
40
|
-
end
|
41
|
-
|
42
|
-
unless RUBY_VERSION < "1.9"
|
43
|
-
alternate_callee.__callee__.assert == :alternate_callee
|
44
|
-
end
|
45
|
-
|
46
|
-
== Binding#__method__
|
47
|
-
|
48
|
-
This only works for certain versions.
|
49
|
-
|
50
|
-
def alternate_method
|
51
|
-
binding
|
52
|
-
end
|
53
|
-
|
54
|
-
unless RUBY_VERSION < "1.8.7"
|
55
|
-
alternate_method.__method__.assert == :alternate_method
|
56
|
-
end
|
57
|
-
|
data/demo/core/binding/eval.rdoc
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
== Binding#local_variables
|
2
|
-
|
3
|
-
require 'facets/binding/local_variables'
|
4
|
-
|
5
|
-
a = 1
|
6
|
-
b = 2
|
7
|
-
x = "hello"
|
8
|
-
|
9
|
-
unless RUBY_VERSION > "1.9"
|
10
|
-
|
11
|
-
lvars = binding.local_variables
|
12
|
-
|
13
|
-
lvars.assert.include?('a')
|
14
|
-
lvars.assert.include?('b')
|
15
|
-
lvars.assert.include?('x')
|
16
|
-
|
17
|
-
else
|
18
|
-
|
19
|
-
lvars = binding.local_variables
|
20
|
-
|
21
|
-
lvars.assert.include?(:a)
|
22
|
-
lvars.assert.include?(:b)
|
23
|
-
lvars.assert.include?(:x)
|
24
|
-
|
25
|
-
end
|
26
|
-
|
data/demo/core/binding/self.rdoc
DELETED