facets 3.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
 
| 
         @@ -0,0 +1,47 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ## String#Camelcase
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
                require 'facets/string/camelcase'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            The `camelcase` method converts snakecase strings into camelcase strings.
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                "abc_xyz".camelcase.assert == "abcXyz"
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            Continious underscore characters are treated as if a single underscore
         
     | 
| 
      
 10 
     | 
    
         
            +
            character.
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                "abc____xyz".camelcase.assert == "abcXyz"
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            Without an argument the first character is left alone.
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                "Camel_case".camelcase.assert == "CamelCase"
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            Passing +:upper+ or +true+ to #camelcase captializes the first letter.
         
     | 
| 
      
 19 
     | 
    
         
            +
            This is known as upper-camelcase.
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                "Abc_xyz".camelcase(true).assert == "AbcXyz"
         
     | 
| 
      
 22 
     | 
    
         
            +
                "Abc____xyz".camelcase(:upper).assert == "AbcXyz"
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            Where as passing +false+ or +:lower+ downcases the first character,
         
     | 
| 
      
 25 
     | 
    
         
            +
            known as lower-camelcase.
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                "abc_xyz".camelcase(false).assert == "abcXyz"
         
     | 
| 
      
 28 
     | 
    
         
            +
                "abc____xyz".camelcase(false).assert == "abcXyz"
         
     | 
| 
      
 29 
     | 
    
         
            +
                "Abc_xyz".camelcase(:lower).assert == "abcXyz"
         
     | 
| 
      
 30 
     | 
    
         
            +
                "Abc____xyz".camelcase(:lower).assert == "abcXyz"
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            By passing a match string to the method we can make +camelcase+ 
         
     | 
| 
      
 33 
     | 
    
         
            +
            apply to each word in a string.
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                "abc xyz".camelcase(' ').assert  == "abcXyz"
         
     | 
| 
      
 36 
     | 
    
         
            +
                "abc  xyz".camelcase(/\s/).assert == "abcXyz"
         
     | 
| 
      
 37 
     | 
    
         
            +
                "abc\txyz".camelcase(/\s/).assert == "abcXyz"
         
     | 
| 
      
 38 
     | 
    
         
            +
                "abc\nxyz".camelcase(/\s/).assert == "abcXyz"
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
            ## String#lower_camelcase
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                "abc_xyz".lower_camelcase.assert == "abcXyz"
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
            ## String#upper_camelcase
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                "abc_xyz".upper_camelcase.assert == "AbcXyz"
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
         @@ -1,27 +1,27 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            ## String#capitalized?
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            String#capitalized? return true if a string begins with a capitalized
         
     | 
| 
       4 
4 
     | 
    
         
             
            letter, false otherwise.
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
      
 6 
     | 
    
         
            +
                require 'facets/string/capitalized'
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
      
 8 
     | 
    
         
            +
                'Abc'.assert.capitalized?
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
      
 10 
     | 
    
         
            +
            ## String#downcase?
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         
             
            In addition String#downcase? is provided which checks to see if the
         
     | 
| 
       13 
13 
     | 
    
         
             
            whole string is composed of lowercase letters.
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
      
 15 
     | 
    
         
            +
                'abc'.assert.downcase?
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
      
 17 
     | 
    
         
            +
                #'abc'.assert.lowercase?
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
      
 19 
     | 
    
         
            +
            ## String#upcase?
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
21 
     | 
    
         
             
            And String#upcase? which checks to see if the whole string is composed
         
     | 
| 
       22 
22 
     | 
    
         
             
            of uppercase letters.
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
      
 24 
     | 
    
         
            +
                'ABC'.assert.upcase?
         
     | 
| 
       25 
25 
     | 
    
         | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
      
 26 
     | 
    
         
            +
                #'ABC'.assert.uppercase?
         
     | 
| 
       27 
27 
     | 
    
         | 
| 
         @@ -1,10 +1,10 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            ## String#cleanlines
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            Thre String#cleanlines method works essentially the same as String#lines,
         
     | 
| 
       4 
4 
     | 
    
         
             
            returning an Array of line strings, but it also removes trailing whitespace
         
     | 
| 
       5 
5 
     | 
    
         
             
            from each line.
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
      
 7 
     | 
    
         
            +
                require 'facets/string/cleanlines'
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
      
 9 
     | 
    
         
            +
                "a \n b \nc".cleanlines.to_a.assert == ["a","b","c"]
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
         @@ -0,0 +1,49 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ## String#cleave
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
                require 'facets/string/cleave'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            no spaces short word
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                s, x = 'whole', ['whole', '']
         
     | 
| 
      
 8 
     | 
    
         
            +
                s.cleave.assert == x
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            no spaces long word
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                s, x = 'Supercalifragilisticexpialidocious' , ['Supercalifragilisticexpialidocious', '']
         
     | 
| 
      
 13 
     | 
    
         
            +
                s.cleave.assert == x
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            exact middle two words
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                s, x = 'fancy split', ['fancy', 'split']
         
     | 
| 
      
 18 
     | 
    
         
            +
                s.cleave.assert == x
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            exact middle many words
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                s, x = 'All good Rubyists know how to party', ['All good Rubyists', 'know how to party']
         
     | 
| 
      
 23 
     | 
    
         
            +
                s.cleave.assert == x
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            closer to start
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                s, x = 'short splitter', ['short', 'splitter']
         
     | 
| 
      
 28 
     | 
    
         
            +
                s.cleave.assert == x
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
            closer to start
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                s, x = 'Four score and seven years ago...', ['Four score and', 'seven years ago...']
         
     | 
| 
      
 33 
     | 
    
         
            +
                s.cleave.assert == x
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
            closer to start
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                s, x = 'abc def ghijklm nop', ['abc def', 'ghijklm nop']
         
     | 
| 
      
 38 
     | 
    
         
            +
                s.cleave.assert == x
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
            closer to end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                s, x = 'extended split', ['extended', 'split']
         
     | 
| 
      
 43 
     | 
    
         
            +
                s.cleave.assert == x
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
            closer to end
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
                s, x = 'abc defghi jklm nop', [ 'abc defghi', 'jklm nop']
         
     | 
| 
      
 48 
     | 
    
         
            +
                s.cleave.assert == x
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,22 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ## String#compress_lines
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
                require 'facets/string/compress_lines'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            Matches any whitespace (including newline) at beginning and end of lines,
         
     | 
| 
      
 6 
     | 
    
         
            +
            and replaces with a single space.
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                string = <<-QUERY.compress_lines
         
     | 
| 
      
 9 
     | 
    
         
            +
                  SELECT name
         
     | 
| 
      
 10 
     | 
    
         
            +
                  FROM users
         
     | 
| 
      
 11 
     | 
    
         
            +
                QUERY
         
     | 
| 
      
 12 
     | 
    
         
            +
                string.assert == "SELECT name FROM users"
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            Matches any whitespace (including newline) at beginning and end of lines,
         
     | 
| 
      
 15 
     | 
    
         
            +
            and removes it.
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                string = <<-QUERY.compress_lines(false)
         
     | 
| 
      
 18 
     | 
    
         
            +
                  SELECT name
         
     | 
| 
      
 19 
     | 
    
         
            +
                  FROM users
         
     | 
| 
      
 20 
     | 
    
         
            +
                QUERY
         
     | 
| 
      
 21 
     | 
    
         
            +
                string.assert == "SELECT nameFROM users"
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,15 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ## String#crypt
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
                require 'facets/string/crypt'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            Adds a default salt to the built-in crypt method.
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            NOTE: This method is not a common core extension and is not
         
     | 
| 
      
 8 
     | 
    
         
            +
            loaded automatically when using <code>require 'facets'</code>.
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                 "abc".crypt('ZZ').assert.start_with?('ZZ')
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                 encrypted = "abc".crypt
         
     | 
| 
      
 13 
     | 
    
         
            +
                 salt = encrypted[0..1]
         
     | 
| 
      
 14 
     | 
    
         
            +
                 "abc".crypt(salt).assert == encrypted
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,15 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ## String#edit_distance
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
                require 'facets/string/edit_distance'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            Levenshtein distance algorithm implementation for Ruby, with UTF-8 support.
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            The Levenshtein distance is a measure of how similar two strings s and t are,
         
     | 
| 
      
 8 
     | 
    
         
            +
            calculated as the number of deletions/insertions/substitutions needed to
         
     | 
| 
      
 9 
     | 
    
         
            +
            transform s into t. The greater the distance, the more the strings differ.
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                d = "pretzel".edit_distance('pretzil')
         
     | 
| 
      
 12 
     | 
    
         
            +
                d.assert = 1
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                d = "zretzel".edit_distance('pretzil')
         
     | 
| 
      
 15 
     | 
    
         
            +
                d.assert = 2
         
     | 
| 
         @@ -0,0 +1,15 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ## String#exclude?
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
                require 'facets/string/exclude'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            The inverse of include?.
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                "aaaa".assert.exclude?('bb')
         
     | 
| 
      
 8 
     | 
    
         
            +
                "aaab".assert.exclude?('bb')
         
     | 
| 
      
 9 
     | 
    
         
            +
                "aaba".assert.exclude?('bb')
         
     | 
| 
      
 10 
     | 
    
         
            +
                "baaa".assert.exclude?('bb')
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                "abba".refute.exclude?('bb')
         
     | 
| 
      
 13 
     | 
    
         
            +
                "aabb".refute.exclude?('bb')
         
     | 
| 
      
 14 
     | 
    
         
            +
                "bbaa".refute.exclude?('bb')
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,69 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ## String#expand_tab
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
                require 'facets/string/expand_tab'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            We will use this string as a basis for demonstration.
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                tabs = <<-EOF.gsub(/^\s+\|/, '')
         
     | 
| 
      
 8 
     | 
    
         
            +
                |
         
     | 
| 
      
 9 
     | 
    
         
            +
                |\tOne tab
         
     | 
| 
      
 10 
     | 
    
         
            +
                | \tOne space and one tab
         
     | 
| 
      
 11 
     | 
    
         
            +
                |    \t Six spaces, a tab, and a space
         
     | 
| 
      
 12 
     | 
    
         
            +
                EOF
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            Expanding tabs 0.
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                expected = <<-EOF.gsub(/^\s+\|/, '')
         
     | 
| 
      
 17 
     | 
    
         
            +
                |
         
     | 
| 
      
 18 
     | 
    
         
            +
                |One tab
         
     | 
| 
      
 19 
     | 
    
         
            +
                | One space and one tab
         
     | 
| 
      
 20 
     | 
    
         
            +
                |     Six spaces, a tab, and a space
         
     | 
| 
      
 21 
     | 
    
         
            +
                EOF
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                tabs.expand_tabs(0).assert == expected
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            Expanding tabs 1.
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                expected = <<-EOF.gsub(/^\s+\|/, '')
         
     | 
| 
      
 28 
     | 
    
         
            +
                |
         
     | 
| 
      
 29 
     | 
    
         
            +
                | One tab
         
     | 
| 
      
 30 
     | 
    
         
            +
                |  One space and one tab
         
     | 
| 
      
 31 
     | 
    
         
            +
                |      Six spaces, a tab, and a space
         
     | 
| 
      
 32 
     | 
    
         
            +
                EOF
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                tabs.expand_tabs(1).assert == expected
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
            Expanding tabs 4.
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                expected = <<-EOF.gsub(/^\s+\|/, '')
         
     | 
| 
      
 39 
     | 
    
         
            +
                |
         
     | 
| 
      
 40 
     | 
    
         
            +
                |    One tab
         
     | 
| 
      
 41 
     | 
    
         
            +
                |    One space and one tab
         
     | 
| 
      
 42 
     | 
    
         
            +
                |         Six spaces, a tab, and a space
         
     | 
| 
      
 43 
     | 
    
         
            +
                EOF
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                tabs.expand_tabs(4).assert == expected
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
            Expanding tabs 8.
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                expected = <<-EOF.gsub(/^\s+\|/, '')
         
     | 
| 
      
 50 
     | 
    
         
            +
                |
         
     | 
| 
      
 51 
     | 
    
         
            +
                |        One tab
         
     | 
| 
      
 52 
     | 
    
         
            +
                |        One space and one tab
         
     | 
| 
      
 53 
     | 
    
         
            +
                |         Six spaces, a tab, and a space
         
     | 
| 
      
 54 
     | 
    
         
            +
                EOF
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
                tabs.expand_tabs.assert == expected
         
     | 
| 
      
 57 
     | 
    
         
            +
                tabs.expand_tabs(8).assert == expected
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
            Expanding tabs 16.
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
                expected = <<-EOF.gsub(/^\s+\|/, '')
         
     | 
| 
      
 62 
     | 
    
         
            +
                |
         
     | 
| 
      
 63 
     | 
    
         
            +
                |                One tab
         
     | 
| 
      
 64 
     | 
    
         
            +
                |                One space and one tab
         
     | 
| 
      
 65 
     | 
    
         
            +
                |                 Six spaces, a tab, and a space
         
     | 
| 
      
 66 
     | 
    
         
            +
                EOF
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
                tabs.expand_tabs(16).assert == expected
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,14 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ## String#fold
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
                require 'facets/string/fold'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
                s = "This is\na test.\n\nIt clumps\nlines of text."
         
     | 
| 
      
 6 
     | 
    
         
            +
                o = "This is a test.\n\nIt clumps lines of text."
         
     | 
| 
      
 7 
     | 
    
         
            +
                s.fold.assert == o
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            leave spaces
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                s = "This is\na test.\n\n  This is pre.\n  Leave alone.\n\nIt clumps\nlines of text."
         
     | 
| 
      
 12 
     | 
    
         
            +
                o = "This is a test.\n\n  This is pre.\n  Leave alone.\n\nIt clumps lines of text."
         
     | 
| 
      
 13 
     | 
    
         
            +
                s.fold(true).assert == o
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,65 @@ 
     | 
|
| 
      
 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 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,14 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ## String#index_all
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
                require 'facets/string/index_all'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            Returns an array of all index locations.  the reuse flag allows the trailing
         
     | 
| 
      
 6 
     | 
    
         
            +
            portion of a match to be resued for subsequent matches.
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                "abcabcabc".index_all('a')  #=> [0,3,6]
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                "a123a567a9".index_all(/a/)  #=> [0,4,8]
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                "bbb".index_all('bb', false)  #=> [0]
         
     | 
| 
      
 13 
     | 
    
         
            +
                "bbb".index_all('bb', true)   #=> [0,1]
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     |