backports 3.0.3 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -1
- data/.gitmodules +3 -0
- data/.travis.yml +11 -2
- data/CHANGELOG.rdoc +6 -0
- data/Gemfile +20 -0
- data/Gemfile.lock +24 -0
- data/README.rdoc +39 -11
- data/Rakefile +98 -1
- data/default.mspec +9 -0
- data/lib/backports.rb +4 -4
- data/lib/backports/1.8.7.rb +2 -3
- data/lib/backports/1.8.7/argf.rb +2 -43
- data/lib/backports/1.8.7/argf/bytes.rb +1 -0
- data/lib/backports/1.8.7/argf/chars.rb +1 -0
- data/lib/backports/1.8.7/argf/each.rb +3 -0
- data/lib/backports/1.8.7/argf/each_byte.rb +9 -0
- data/lib/backports/1.8.7/argf/each_char.rb +35 -0
- data/lib/backports/1.8.7/argf/each_line.rb +3 -0
- data/lib/backports/1.8.7/argf/getbyte.rb +5 -0
- data/lib/backports/1.8.7/argf/lines.rb +5 -0
- data/lib/backports/1.8.7/argf/readbyte.rb +5 -0
- data/lib/backports/1.8.7/array.rb +2 -207
- data/lib/backports/1.8.7/array/collect.rb +3 -0
- data/lib/backports/1.8.7/array/combination.rb +24 -0
- data/lib/backports/1.8.7/array/cycle.rb +16 -0
- data/lib/backports/1.8.7/array/delete_if.rb +3 -0
- data/lib/backports/1.8.7/array/each.rb +3 -0
- data/lib/backports/1.8.7/array/each_index.rb +3 -0
- data/lib/backports/1.8.7/array/find_index.rb +1 -0
- data/lib/backports/1.8.7/array/flatten.rb +47 -0
- data/lib/backports/1.8.7/array/index.rb +15 -0
- data/lib/backports/1.8.7/array/map.rb +3 -0
- data/lib/backports/1.8.7/array/permutation.rb +30 -0
- data/lib/backports/1.8.7/array/pop.rb +15 -0
- data/lib/backports/1.8.7/array/product.rb +32 -0
- data/lib/backports/1.8.7/array/reject.rb +3 -0
- data/lib/backports/1.8.7/array/reverse_each.rb +3 -0
- data/lib/backports/1.8.7/array/rindex.rb +15 -0
- data/lib/backports/1.8.7/array/select.rb +3 -0
- data/lib/backports/1.8.7/array/shift.rb +13 -0
- data/lib/backports/1.8.7/array/shuffle.rb +17 -0
- data/lib/backports/1.8.7/binding.rb +3 -6
- data/lib/backports/1.8.7/binding/eval.rb +7 -0
- data/lib/backports/1.8.7/dir.rb +2 -57
- data/lib/backports/1.8.7/dir/each.rb +7 -0
- data/lib/backports/1.8.7/dir/foreach.rb +9 -0
- data/lib/backports/1.8.7/dir/mktmpdir.rb +44 -0
- data/lib/backports/1.8.7/enumerable.rb +2 -240
- data/lib/backports/1.8.7/enumerable/count.rb +17 -0
- data/lib/backports/1.8.7/enumerable/cycle.rb +24 -0
- data/lib/backports/1.8.7/enumerable/detect.rb +3 -0
- data/lib/backports/1.8.7/enumerable/drop.rb +13 -0
- data/lib/backports/1.8.7/enumerable/drop_while.rb +16 -0
- data/lib/backports/1.8.7/enumerable/each_cons.rb +4 -0
- data/lib/backports/1.8.7/enumerable/each_slice.rb +4 -0
- data/lib/backports/1.8.7/enumerable/each_with_index.rb +3 -0
- data/lib/backports/1.8.7/enumerable/entries.rb +11 -0
- data/lib/backports/1.8.7/enumerable/find.rb +3 -0
- data/lib/backports/1.8.7/enumerable/find_all.rb +3 -0
- data/lib/backports/1.8.7/enumerable/find_index.rb +21 -0
- data/lib/backports/1.8.7/enumerable/first.rb +21 -0
- data/lib/backports/1.8.7/enumerable/group_by.rb +14 -0
- data/lib/backports/1.8.7/enumerable/inject.rb +14 -0
- data/lib/backports/1.8.7/enumerable/max_by.rb +16 -0
- data/lib/backports/1.8.7/enumerable/min_by.rb +16 -0
- data/lib/backports/1.8.7/enumerable/minmax.rb +21 -0
- data/lib/backports/1.8.7/enumerable/minmax_by.rb +19 -0
- data/lib/backports/1.8.7/enumerable/none.rb +7 -0
- data/lib/backports/1.8.7/enumerable/one.rb +23 -0
- data/lib/backports/1.8.7/enumerable/partition.rb +3 -0
- data/lib/backports/1.8.7/enumerable/reduce.rb +1 -0
- data/lib/backports/1.8.7/enumerable/reject.rb +3 -0
- data/lib/backports/1.8.7/enumerable/reverse_each.rb +12 -0
- data/lib/backports/1.8.7/enumerable/select.rb +3 -0
- data/lib/backports/1.8.7/enumerable/sort_by.rb +3 -0
- data/lib/backports/1.8.7/enumerable/take.rb +9 -0
- data/lib/backports/1.8.7/enumerable/take_while.rb +14 -0
- data/lib/backports/1.8.7/enumerable/to_a.rb +12 -0
- data/lib/backports/1.8.7/enumerator.rb +2 -31
- data/lib/backports/1.8.7/enumerator/each.rb +6 -0
- data/lib/backports/1.8.7/enumerator/next.rb +15 -0
- data/lib/backports/1.8.7/enumerator/rewind.rb +13 -0
- data/lib/backports/1.8.7/enumerator/with_index.rb +14 -0
- data/lib/backports/1.8.7/env.rb +3 -3
- data/lib/backports/1.8.7/env/delete_if.rb +3 -0
- data/lib/backports/1.8.7/env/each.rb +3 -0
- data/lib/backports/1.8.7/env/each_key.rb +3 -0
- data/lib/backports/1.8.7/env/each_pair.rb +3 -0
- data/lib/backports/1.8.7/env/each_value.rb +3 -0
- data/lib/backports/1.8.7/env/reject.rb +4 -0
- data/lib/backports/1.8.7/env/select.rb +3 -0
- data/lib/backports/1.8.7/fixnum.rb +2 -10
- data/lib/backports/1.8.7/fixnum/div.rb +7 -0
- data/lib/backports/1.8.7/fixnum/fdiv.rb +7 -0
- data/lib/backports/1.8.7/float.rb +3 -4
- data/lib/backports/1.8.7/float/fdiv.rb +3 -0
- data/lib/backports/1.8.7/gc.rb +2 -10
- data/lib/backports/1.8.7/gc/stress.rb +9 -0
- data/lib/backports/1.8.7/hash.rb +2 -41
- data/lib/backports/1.8.7/hash/constructor.rb +25 -0
- data/lib/backports/1.8.7/hash/delete_if.rb +3 -0
- data/lib/backports/1.8.7/hash/each.rb +3 -0
- data/lib/backports/1.8.7/hash/each_key.rb +3 -0
- data/lib/backports/1.8.7/hash/each_pair.rb +3 -0
- data/lib/backports/1.8.7/hash/each_value.rb +3 -0
- data/lib/backports/1.8.7/hash/eql.rb +1 -0
- data/lib/backports/1.8.7/hash/hash.rb +17 -0
- data/lib/backports/1.8.7/hash/key.rb +3 -0
- data/lib/backports/1.8.7/hash/reject.rb +3 -0
- data/lib/backports/1.8.7/hash/select.rb +3 -0
- data/lib/backports/1.8.7/integer.rb +2 -23
- data/lib/backports/1.8.7/integer/downto.rb +3 -0
- data/lib/backports/1.8.7/integer/even.rb +7 -0
- data/lib/backports/1.8.7/integer/odd.rb +7 -0
- data/lib/backports/1.8.7/integer/ord.rb +7 -0
- data/lib/backports/1.8.7/integer/pred.rb +7 -0
- data/lib/backports/1.8.7/integer/times.rb +3 -0
- data/lib/backports/1.8.7/integer/upto.rb +3 -0
- data/lib/backports/1.8.7/io.rb +2 -42
- data/lib/backports/1.8.7/io/bytes.rb +1 -0
- data/lib/backports/1.8.7/io/chars.rb +1 -0
- data/lib/backports/1.8.7/io/each.rb +3 -0
- data/lib/backports/1.8.7/io/each_byte.rb +6 -0
- data/lib/backports/1.8.7/io/each_char.rb +34 -0
- data/lib/backports/1.8.7/io/each_line.rb +6 -0
- data/lib/backports/1.8.7/io/foreach.rb +7 -0
- data/lib/backports/1.8.7/io/getbyte.rb +3 -0
- data/lib/backports/1.8.7/io/lines.rb +1 -0
- data/lib/backports/1.8.7/io/readbyte.rb +3 -0
- data/lib/backports/1.8.7/kernel.rb +2 -35
- data/lib/backports/1.8.7/kernel/__method__.rb +8 -0
- data/lib/backports/1.8.7/kernel/instance_exec.rb +10 -0
- data/lib/backports/1.8.7/kernel/tap.rb +8 -0
- data/lib/backports/1.8.7/method.rb +2 -46
- data/lib/backports/1.8.7/method/name.rb +49 -0
- data/lib/backports/1.8.7/module.rb +3 -7
- data/lib/backports/1.8.7/module/class_exec.rb +1 -0
- data/lib/backports/1.8.7/module/module_exec.rb +11 -0
- data/lib/backports/1.8.7/numeric.rb +3 -3
- data/lib/backports/1.8.7/numeric/step.rb +3 -0
- data/lib/backports/1.8.7/object_space.rb +3 -5
- data/lib/backports/1.8.7/object_space/each_object.rb +5 -0
- data/lib/backports/1.8.7/proc.rb +3 -4
- data/lib/backports/1.8.7/proc/yield.rb +3 -0
- data/lib/backports/1.8.7/process.rb +3 -5
- data/lib/backports/1.8.7/process/exec.rb +3 -0
- data/lib/backports/1.8.7/range.rb +3 -4
- data/lib/backports/1.8.7/range/each.rb +3 -0
- data/lib/backports/1.8.7/range/step.rb +3 -0
- data/lib/backports/1.8.7/regexp.rb +3 -12
- data/lib/backports/1.8.7/regexp/union.rb +11 -0
- data/lib/backports/1.8.7/stop_iteration.rb +14 -0
- data/lib/backports/1.8.7/string.rb +2 -91
- data/lib/backports/1.8.7/string/bytes.rb +1 -0
- data/lib/backports/1.8.7/string/bytesize.rb +3 -0
- data/lib/backports/1.8.7/string/each.rb +3 -0
- data/lib/backports/1.8.7/string/each_byte.rb +5 -0
- data/lib/backports/1.8.7/string/each_char.rb +13 -0
- data/lib/backports/1.8.7/string/each_line.rb +5 -0
- data/lib/backports/1.8.7/string/end_with.rb +12 -0
- data/lib/backports/1.8.7/string/lines.rb +1 -0
- data/lib/backports/1.8.7/string/partition.rb +20 -0
- data/lib/backports/1.8.7/string/rpartition.rb +19 -0
- data/lib/backports/1.8.7/string/start_with.rb +12 -0
- data/lib/backports/1.8.7/string/upto.rb +15 -0
- data/lib/backports/1.8.7/struct.rb +3 -3
- data/lib/backports/1.8.7/struct/each.rb +3 -0
- data/lib/backports/1.8.7/struct/each_pair.rb +3 -0
- data/lib/backports/1.8.7/symbol.rb +3 -6
- data/lib/backports/1.8.7/symbol/to_proc.rb +8 -0
- data/lib/backports/1.8.8.rb +1 -3
- data/lib/backports/1.8.rb +1 -3
- data/lib/backports/1.9.1.rb +2 -4
- data/lib/backports/1.9.1/array.rb +3 -8
- data/lib/backports/1.9.1/array/sample.rb +19 -0
- data/lib/backports/1.9.1/array/try_convert.rb +7 -0
- data/lib/backports/1.9.1/dir.rb +3 -3
- data/lib/backports/1.9.1/dir/to_path.rb +3 -0
- data/lib/backports/1.9.1/enumerable.rb +2 -18
- data/lib/backports/1.9.1/enumerable/each_with_index.rb +14 -0
- data/lib/backports/1.9.1/enumerable/each_with_object.rb +9 -0
- data/lib/backports/1.9.1/enumerator.rb +2 -40
- data/lib/backports/1.9.1/enumerator/new.rb +40 -0
- data/lib/backports/1.9.1/enumerator/with_object.rb +6 -0
- data/lib/backports/1.9.1/env.rb +3 -3
- data/lib/backports/1.9.1/env/key.rb +5 -0
- data/lib/backports/1.9.1/file.rb +2 -43
- data/lib/backports/1.9.1/file/atime.rb +5 -0
- data/lib/backports/1.9.1/file/basename.rb +5 -0
- data/lib/backports/1.9.1/file/binary.rb +6 -0
- data/lib/backports/1.9.1/file/blockdev.rb +5 -0
- data/lib/backports/1.9.1/file/chardev.rb +5 -0
- data/lib/backports/1.9.1/file/chmod.rb +5 -0
- data/lib/backports/1.9.1/file/chown.rb +5 -0
- data/lib/backports/1.9.1/file/ctime.rb +5 -0
- data/lib/backports/1.9.1/file/delete.rb +5 -0
- data/lib/backports/1.9.1/file/directory.rb +5 -0
- data/lib/backports/1.9.1/file/dirname.rb +5 -0
- data/lib/backports/1.9.1/file/executable.rb +5 -0
- data/lib/backports/1.9.1/file/executable_real.rb +5 -0
- data/lib/backports/1.9.1/file/exist.rb +5 -0
- data/lib/backports/1.9.1/file/exists.rb +5 -0
- data/lib/backports/1.9.1/file/expand_path.rb +14 -0
- data/lib/backports/1.9.1/file/extname.rb +5 -0
- data/lib/backports/1.9.1/file/file.rb +5 -0
- data/lib/backports/1.9.1/file/ftype.rb +5 -0
- data/lib/backports/1.9.1/file/grpowned.rb +5 -0
- data/lib/backports/1.9.1/file/join.rb +5 -0
- data/lib/backports/1.9.1/file/lchmod.rb +5 -0
- data/lib/backports/1.9.1/file/lchown.rb +5 -0
- data/lib/backports/1.9.1/file/link.rb +5 -0
- data/lib/backports/1.9.1/file/lstat.rb +5 -0
- data/lib/backports/1.9.1/file/mtime.rb +5 -0
- data/lib/backports/1.9.1/file/new.rb +5 -0
- data/lib/backports/1.9.1/file/open.rb +23 -0
- data/lib/backports/1.9.1/file/owned.rb +5 -0
- data/lib/backports/1.9.1/file/pipe.rb +5 -0
- data/lib/backports/1.9.1/file/readable.rb +5 -0
- data/lib/backports/1.9.1/file/readable_real.rb +5 -0
- data/lib/backports/1.9.1/file/readlink.rb +5 -0
- data/lib/backports/1.9.1/file/rename.rb +5 -0
- data/lib/backports/1.9.1/file/setgid.rb +5 -0
- data/lib/backports/1.9.1/file/setuid.rb +5 -0
- data/lib/backports/1.9.1/file/size.rb +14 -0
- data/lib/backports/1.9.1/file/socket.rb +5 -0
- data/lib/backports/1.9.1/file/split.rb +5 -0
- data/lib/backports/1.9.1/file/stat.rb +5 -0
- data/lib/backports/1.9.1/file/sticky.rb +5 -0
- data/lib/backports/1.9.1/file/symlink.rb +6 -0
- data/lib/backports/1.9.1/file/to_path.rb +3 -0
- data/lib/backports/1.9.1/file/truncate.rb +5 -0
- data/lib/backports/1.9.1/file/unlink.rb +5 -0
- data/lib/backports/1.9.1/file/writable.rb +5 -0
- data/lib/backports/1.9.1/file/writable_real.rb +5 -0
- data/lib/backports/1.9.1/file/zero.rb +5 -0
- data/lib/backports/1.9.1/float.rb +3 -19
- data/lib/backports/1.9.1/float/round.rb +21 -0
- data/lib/backports/1.9.1/hash.rb +2 -35
- data/lib/backports/1.9.1/hash/assoc.rb +12 -0
- data/lib/backports/1.9.1/hash/default_proc.rb +14 -0
- data/lib/backports/1.9.1/hash/rassoc.rb +9 -0
- data/lib/backports/1.9.1/hash/try_convert.rb +7 -0
- data/lib/backports/1.9.1/integer.rb +2 -21
- data/lib/backports/1.9.1/integer/magnitude.rb +3 -0
- data/lib/backports/1.9.1/integer/round.rb +24 -0
- data/lib/backports/1.9.1/io.rb +2 -33
- data/lib/backports/1.9.1/io/binread.rb +10 -0
- data/lib/backports/1.9.1/io/open.rb +21 -0
- data/lib/backports/1.9.1/io/try_convert.rb +7 -0
- data/lib/backports/1.9.1/io/ungetbyte.rb +3 -0
- data/lib/backports/1.9.1/kernel.rb +2 -39
- data/lib/backports/1.9.1/kernel/__callee__.rb +7 -0
- data/lib/backports/1.9.1/kernel/define_singleton_method.rb +9 -0
- data/lib/backports/1.9.1/kernel/public_method.rb +11 -0
- data/lib/backports/1.9.1/kernel/public_send.rb +13 -0
- data/lib/backports/1.9.1/kernel/require_relative.rb +14 -0
- data/lib/backports/1.9.1/math.rb +2 -24
- data/lib/backports/1.9.1/math/log.rb +22 -0
- data/lib/backports/1.9.1/math/log2.rb +5 -0
- data/lib/backports/1.9.1/numeric.rb +3 -9
- data/lib/backports/1.9.1/numeric/round.rb +11 -0
- data/lib/backports/1.9.1/proc.rb +2 -53
- data/lib/backports/1.9.1/proc/case_compare.rb +6 -0
- data/lib/backports/1.9.1/proc/curry.rb +24 -0
- data/lib/backports/1.9.1/proc/lambda.rb +40 -0
- data/lib/backports/1.9.1/range.rb +3 -3
- data/lib/backports/1.9.1/range/cover.rb +3 -0
- data/lib/backports/1.9.1/regexp.rb +3 -8
- data/lib/backports/1.9.1/regexp/try_convert.rb +7 -0
- data/lib/backports/1.9.1/stdlib.rb +1 -1
- data/lib/backports/1.9.1/string.rb +2 -44
- data/lib/backports/1.9.1/string/ascii_only.rb +7 -0
- data/lib/backports/1.9.1/string/chr.rb +7 -0
- data/lib/backports/1.9.1/string/clear.rb +8 -0
- data/lib/backports/1.9.1/string/codepoints.rb +8 -0
- data/lib/backports/1.9.1/string/each_codepoint.rb +3 -0
- data/lib/backports/1.9.1/string/getbyte.rb +3 -0
- data/lib/backports/1.9.1/string/ord.rb +7 -0
- data/lib/backports/1.9.1/string/setbyte.rb +3 -0
- data/lib/backports/1.9.1/string/try_convert.rb +7 -0
- data/lib/backports/1.9.1/symbol.rb +2 -31
- data/lib/backports/1.9.1/symbol/capitalize.rb +7 -0
- data/lib/backports/1.9.1/symbol/casecmp.rb +8 -0
- data/lib/backports/1.9.1/symbol/comparable.rb +7 -0
- data/lib/backports/1.9.1/symbol/comparison.rb +8 -0
- data/lib/backports/1.9.1/symbol/downcase.rb +7 -0
- data/lib/backports/1.9.1/symbol/element_reference.rb +7 -0
- data/lib/backports/1.9.1/symbol/empty.rb +7 -0
- data/lib/backports/1.9.1/symbol/length.rb +7 -0
- data/lib/backports/1.9.1/symbol/match.rb +9 -0
- data/lib/backports/1.9.1/symbol/next.rb +1 -0
- data/lib/backports/1.9.1/symbol/size.rb +7 -0
- data/lib/backports/1.9.1/symbol/succ.rb +8 -0
- data/lib/backports/1.9.1/symbol/swapcase.rb +7 -0
- data/lib/backports/1.9.1/symbol/upcase.rb +7 -0
- data/lib/backports/1.9.2.rb +2 -4
- data/lib/backports/1.9.2/array.rb +2 -109
- data/lib/backports/1.9.2/array/keep_if.rb +8 -0
- data/lib/backports/1.9.2/array/product.rb +26 -0
- data/lib/backports/1.9.2/array/repeated_combination.rb +25 -0
- data/lib/backports/1.9.2/array/repeated_permutation.rb +26 -0
- data/lib/backports/1.9.2/array/rotate.rb +17 -0
- data/lib/backports/1.9.2/array/select.rb +8 -0
- data/lib/backports/1.9.2/array/sort_by.rb +9 -0
- data/lib/backports/1.9.2/array/uniq.rb +29 -0
- data/lib/backports/1.9.2/complex.rb +3 -6
- data/lib/backports/1.9.2/complex/to_r.rb +10 -0
- data/lib/backports/1.9.2/dir.rb +3 -5
- data/lib/backports/1.9.2/dir/home.rb +5 -0
- data/lib/backports/1.9.2/enumerable.rb +2 -73
- data/lib/backports/1.9.2/enumerable/chunk.rb +39 -0
- data/lib/backports/1.9.2/enumerable/collect_concat.rb +1 -0
- data/lib/backports/1.9.2/enumerable/each_entry.rb +11 -0
- data/lib/backports/1.9.2/enumerable/flat_map.rb +11 -0
- data/lib/backports/1.9.2/enumerable/slice_before.rb +30 -0
- data/lib/backports/1.9.2/float.rb +3 -4
- data/lib/backports/1.9.2/float/infinity.rb +3 -0
- data/lib/backports/1.9.2/float/nan.rb +3 -0
- data/lib/backports/1.9.2/hash.rb +2 -10
- data/lib/backports/1.9.2/hash/keep_if.rb +8 -0
- data/lib/backports/1.9.2/hash/select.rb +9 -0
- data/lib/backports/1.9.2/kernel.rb +3 -5
- data/lib/backports/1.9.2/kernel/singleton_class.rb +7 -0
- data/lib/backports/1.9.2/random.rb +1 -1
- data/lib/backports/1.9.2/stdlib.rb +1 -1
- data/lib/backports/1.9.2/stdlib/matrix.rb +9 -8
- data/lib/backports/1.9.2/stdlib/set.rb +1 -1
- data/lib/backports/1.9.3.rb +2 -4
- data/lib/backports/1.9.3/file.rb +3 -14
- data/lib/backports/1.9.3/file/null.rb +16 -0
- data/lib/backports/1.9.3/io.rb +2 -31
- data/lib/backports/1.9.3/io/advise.rb +24 -0
- data/lib/backports/1.9.3/io/binwrite.rb +7 -0
- data/lib/backports/1.9.3/io/write.rb +7 -0
- data/lib/backports/1.9.3/string.rb +2 -38
- data/lib/backports/1.9.3/string/byteslice.rb +36 -0
- data/lib/backports/1.9.3/string/prepend.rb +10 -0
- data/lib/backports/1.9.rb +1 -3
- data/lib/backports/2.0.0.rb +2 -4
- data/lib/backports/2.0.0/array.rb +2 -29
- data/lib/backports/2.0.0/array/bsearch.rb +32 -0
- data/lib/backports/2.0.0/enumerable.rb +2 -11
- data/lib/backports/2.0.0/enumerable/lazy.rb +216 -0
- data/lib/backports/2.0.0/enumerator.rb +3 -0
- data/lib/backports/2.0.0/enumerator/lazy.rb +1 -203
- data/lib/backports/2.0.0/env.rb +3 -0
- data/lib/backports/2.0.0/env/to_h.rb +5 -0
- data/lib/backports/2.0.0/hash.rb +2 -18
- data/lib/backports/2.0.0/hash/default_proc.rb +16 -0
- data/lib/backports/2.0.0/hash/to_h.rb +7 -0
- data/lib/backports/2.0.0/nil.rb +3 -0
- data/lib/backports/2.0.0/nil/to_h.rb +7 -0
- data/lib/backports/2.0.0/range.rb +2 -48
- data/lib/backports/2.0.0/range/bsearch.rb +49 -0
- data/lib/backports/2.0.0/stdlib/abbrev.rb +1 -0
- data/lib/backports/2.0.0/stdlib/fake_stdlib_lib.rb +1 -0
- data/lib/backports/2.0.0/stdlib/ostruct.rb +1 -1
- data/lib/backports/2.0.0/struct.rb +3 -7
- data/lib/backports/2.0.0/struct/to_h.rb +9 -0
- data/lib/backports/2.0.rb +1 -3
- data/lib/backports/basic_object.rb +29 -29
- data/lib/backports/{1.9.2 → extra}/random/MT19937.rb +2 -2
- data/lib/backports/{1.9.2 → extra}/random/bits_and_bytes.rb +1 -1
- data/lib/backports/{1.9.2 → extra}/random/implementation.rb +1 -1
- data/lib/backports/extra/random/load.rb +17 -0
- data/lib/backports/force/array_map.rb +1 -1
- data/lib/backports/force/enumerable_map.rb +1 -1
- data/lib/backports/force/hash_select.rb +1 -1
- data/lib/backports/force/string_size.rb +1 -1
- data/lib/backports/rails.rb +2 -2
- data/lib/backports/rails/enumerable.rb +1 -1
- data/lib/backports/rails/hash.rb +1 -1
- data/lib/backports/rails/kernel.rb +1 -1
- data/lib/backports/rails/module.rb +1 -1
- data/lib/backports/rails/string.rb +6 -6
- data/lib/backports/tools.rb +74 -64
- data/lib/backports/version.rb +1 -1
- data/set_version/1.8.7.rb +1 -0
- data/set_version/1.9.1.rb +1 -0
- data/set_version/1.9.2.rb +1 -0
- data/set_version/1.9.3.rb +1 -0
- data/set_version/2.0.0.rb +1 -0
- data/set_version/setter.rb +14 -0
- data/tags/1.8.6/core/array/rotate_spec.rb +2 -0
- data/tags/1.8.6/core/array/uniq_spec.rb +3 -0
- data/tags/1.8.6/core/complex/to_r_spec.rb +3 -0
- data/tags/1.8.6/core/enumerable/each_entry_spec.rb +1 -0
- data/tags/1.8.6/core/enumerator/next_spec.rb +1 -0
- data/tags/1.8.6/core/env/to_h_spec.rb +2 -0
- data/tags/1.8.6/core/file/join_spec.rb +3 -0
- data/tags/1.8.6/core/file/lchmod_spec.rb +2 -0
- data/tags/1.8.6/core/file/new_spec.rb +2 -0
- data/tags/1.8.6/core/file/open_spec.rb +10 -0
- data/tags/1.8.6/core/file/to_path_spec.rb +1 -0
- data/tags/1.8.6/core/fixnum/fdiv_spec.rb +1 -0
- data/tags/1.8.6/core/gc/stress_spec.rb +2 -0
- data/tags/1.8.6/core/hash/assoc_spec.rb +1 -0
- data/tags/1.8.6/core/hash/default_proc_spec.rb +2 -0
- data/tags/1.8.6/core/hash/eql_spec.rb +3 -0
- data/tags/1.8.6/core/hash/hash_spec.rb +3 -0
- data/tags/1.8.6/core/hash/keep_if_spec.rb +1 -0
- data/tags/1.8.6/core/hash/select_spec.rb +1 -0
- data/tags/1.8.6/core/integer/round_spec.rb +1 -0
- data/tags/1.8.6/core/io/binread_spec.rb +7 -0
- data/tags/1.8.6/core/io/chars_spec.rb +1 -0
- data/tags/1.8.6/core/io/each_char_spec.rb +1 -0
- data/tags/1.8.6/core/io/lines_spec.rb +1 -0
- data/tags/1.8.6/core/io/open_spec.rb +24 -0
- data/tags/1.8.6/core/io/ungetbyte_spec.rb +4 -0
- data/tags/1.8.6/core/io/write_spec.rb +3 -0
- data/tags/1.8.6/core/kernel/__callee___spec.rb +5 -0
- data/tags/1.8.6/core/kernel/__method___spec.rb +1 -0
- data/tags/1.8.6/core/kernel/define_singleton_method_spec.rb +2 -0
- data/tags/1.8.6/core/kernel/public_method_spec.rb +2 -0
- data/tags/1.8.6/core/math/log2_spec.rb +4 -0
- data/tags/1.8.6/core/math/log_spec.rb +3 -0
- data/tags/1.8.6/core/module/class_exec_spec.rb +2 -0
- data/tags/1.8.6/core/module/module_exec_spec.rb +2 -0
- data/tags/1.8.6/core/numeric/step_spec.rb +12 -0
- data/tags/1.8.6/core/proc/curry_spec.rb +4 -0
- data/tags/1.8.6/core/range/step_spec.rb +12 -0
- data/tags/1.8.6/core/string/getbyte_spec.rb +6 -0
- data/tags/1.8.6/core/string/partition_spec.rb +1 -0
- data/tags/1.8.6/core/string/prepend_spec.rb +1 -0
- data/tags/1.8.6/core/string/rpartition_spec.rb +1 -0
- data/tags/1.8.6/core/string/setbyte_spec.rb +5 -0
- data/tags/1.8.6/core/string/upto_spec.rb +1 -0
- data/tags/1.8.6/core/symbol/capitalize_spec.rb +3 -0
- data/tags/1.8.6/core/symbol/comparison_spec.rb +1 -0
- data/tags/1.8.6/core/symbol/downcase_spec.rb +2 -0
- data/tags/1.8.6/core/symbol/element_reference_spec.rb +2 -0
- data/tags/1.8.6/core/symbol/empty_spec.rb +1 -0
- data/tags/1.8.6/core/symbol/match_spec.rb +2 -0
- data/tags/1.8.6/core/symbol/swapcase_spec.rb +2 -0
- data/tags/1.8.6/core/symbol/upcase_spec.rb +1 -0
- data/tags/1.8.7/core/array/rotate_spec.rb +2 -0
- data/tags/1.8.7/core/array/uniq_spec.rb +3 -0
- data/tags/1.8.7/core/complex/to_r_spec.rb +3 -0
- data/tags/1.8.7/core/env/to_h_spec.rb +2 -0
- data/tags/1.8.7/core/file/lchmod_spec.rb +2 -0
- data/tags/1.8.7/core/file/new_spec.rb +1 -0
- data/tags/1.8.7/core/file/open_spec.rb +1 -0
- data/tags/1.8.7/core/file/readlink_spec.rb +6 -0
- data/tags/1.8.7/core/file/to_path_spec.rb +1 -0
- data/tags/1.8.7/core/hash/assoc_spec.rb +1 -0
- data/tags/1.8.7/core/hash/default_proc_spec.rb +2 -0
- data/tags/1.8.7/core/hash/keep_if_spec.rb +1 -0
- data/tags/1.8.7/core/hash/rassoc_spec.rb +1 -0
- data/tags/1.8.7/core/hash/select_spec.rb +1 -0
- data/tags/1.8.7/core/integer/round_spec.rb +1 -0
- data/tags/1.8.7/core/io/binread_spec.rb +7 -0
- data/tags/1.8.7/core/io/open_spec.rb +25 -0
- data/tags/1.8.7/core/io/ungetbyte_spec.rb +4 -0
- data/tags/1.8.7/core/io/write_spec.rb +3 -0
- data/tags/1.8.7/core/kernel/__callee___spec.rb +5 -0
- data/tags/1.8.7/core/kernel/define_singleton_method_spec.rb +2 -0
- data/tags/1.8.7/core/kernel/public_method_spec.rb +1 -0
- data/tags/1.8.7/core/math/log2_spec.rb +4 -0
- data/tags/1.8.7/core/math/log_spec.rb +3 -0
- data/tags/1.8.7/core/proc/curry_spec.rb +3 -0
- data/tags/1.8.7/core/string/getbyte_spec.rb +5 -0
- data/tags/1.8.7/core/string/prepend_spec.rb +1 -0
- data/tags/1.8.7/core/string/setbyte_spec.rb +5 -0
- data/tags/1.8.7/core/symbol/capitalize_spec.rb +3 -0
- data/tags/1.8.7/core/symbol/comparison_spec.rb +1 -0
- data/tags/1.8.7/core/symbol/downcase_spec.rb +2 -0
- data/tags/1.8.7/core/symbol/element_reference_spec.rb +2 -0
- data/tags/1.8.7/core/symbol/empty_spec.rb +1 -0
- data/tags/1.8.7/core/symbol/match_spec.rb +2 -0
- data/tags/1.8.7/core/symbol/swapcase_spec.rb +2 -0
- data/tags/1.8.7/core/symbol/upcase_spec.rb +1 -0
- data/tags/1.9.1/core/array/rotate_spec.rb +1 -0
- data/tags/1.9.1/core/env/to_h_spec.rb +2 -0
- data/tags/1.9.1/core/hash/default_proc_spec.rb +1 -0
- data/tags/1.9.1/core/io/write_spec.rb +2 -0
- data/tags/1.9.2/core/io/write_spec.rb +2 -0
- data/test/README +1 -1
- data/test/_backport_guards_test.rb +140 -0
- data/test/{test_lazy.rb → lazy_test.rb} +25 -20
- data/test/{test_socket_interaction.rb → socket_interaction_test.rb} +3 -3
- data/test/test_helper.rb +0 -4
- metadata +392 -16
- data/lib/backports/1.9.2/match_data.rb +0 -3
- data/lib/backports/1.9.2/random/load.rb +0 -16
- data/lib/backports/2.0.0/nil_class.rb +0 -5
- data/test/std_lib_loading_test.rb +0 -57
- data/test/test__me_first.rb +0 -51
@@ -0,0 +1,14 @@
|
|
1
|
+
unless Hash.method_defined? :default_proc=
|
2
|
+
require 'backports/tools'
|
3
|
+
|
4
|
+
class Hash
|
5
|
+
def default_proc=(proc)
|
6
|
+
if proc == nil # nil accepted in Ruby 2.0
|
7
|
+
self.default = nil
|
8
|
+
self
|
9
|
+
else
|
10
|
+
replace(Hash.new(&Backports.coerce_to(proc, Proc, :to_proc)).merge!(self))
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -1,22 +1,3 @@
|
|
1
|
-
|
2
|
-
Backports.alias_method self, :magnitude, :abs
|
1
|
+
require 'backports/tools'
|
3
2
|
|
4
|
-
|
5
|
-
def round_with_digits(ndigits=0)
|
6
|
-
ndigits = Backports::coerce_to_int(ndigits)
|
7
|
-
case
|
8
|
-
when ndigits.zero?
|
9
|
-
self
|
10
|
-
when ndigits > 0
|
11
|
-
Float(self)
|
12
|
-
else
|
13
|
-
pow = 10 ** (-ndigits)
|
14
|
-
remain = self % pow
|
15
|
-
comp = self < 0 ? :<= : :<
|
16
|
-
remain -= pow unless remain.send(comp, pow / 2)
|
17
|
-
self - remain
|
18
|
-
end
|
19
|
-
end
|
20
|
-
Backports.alias_method_chain self, :round, :digits
|
21
|
-
end
|
22
|
-
end
|
3
|
+
Backports.require_relative_dir
|
@@ -0,0 +1,24 @@
|
|
1
|
+
if Integer.instance_method(:round).arity.zero?
|
2
|
+
require 'backports/tools'
|
3
|
+
|
4
|
+
class Integer
|
5
|
+
def round_with_digits(ndigits=0)
|
6
|
+
ndigits = Backports::coerce_to_int(ndigits)
|
7
|
+
case
|
8
|
+
when ndigits.zero?
|
9
|
+
self
|
10
|
+
when ndigits > 0
|
11
|
+
raise RangeError if ndigits >= 1<<31
|
12
|
+
Float(self)
|
13
|
+
else
|
14
|
+
pow = 10 ** (-ndigits)
|
15
|
+
return 0 if pow.is_a?(Float) # when ndigits hugely negative
|
16
|
+
remain = self % pow
|
17
|
+
comp = self < 0 ? :<= : :<
|
18
|
+
remain -= pow unless remain.send(comp, pow / 2)
|
19
|
+
self - remain
|
20
|
+
end
|
21
|
+
end
|
22
|
+
Backports.alias_method_chain self, :round, :digits
|
23
|
+
end
|
24
|
+
end
|
data/lib/backports/1.9.1/io.rb
CHANGED
@@ -1,34 +1,3 @@
|
|
1
|
-
|
2
|
-
class << self
|
3
|
-
def binread(file, *arg)
|
4
|
-
raise ArgumentError, "wrong number of arguments (#{1+arg.size} for 1..3)" unless arg.size < 3
|
5
|
-
File.open(Backports.convert_to_path(file),"rb") do |f|
|
6
|
-
f.read(*arg)
|
7
|
-
end
|
8
|
-
end unless method_defined? :binread
|
1
|
+
require 'backports/tools'
|
9
2
|
|
10
|
-
|
11
|
-
Backports.try_convert(obj, IO, :to_io)
|
12
|
-
end unless method_defined? :try_convert
|
13
|
-
|
14
|
-
begin
|
15
|
-
File.open(__FILE__) { |f| IO.open(f.fileno, :mode => 'r').close }
|
16
|
-
rescue StandardError
|
17
|
-
def open_with_options_hash(*args)
|
18
|
-
if args.size > 2 || args[1].is_a?(Hash)
|
19
|
-
fd, mode, options = (args << Backports::Undefined)
|
20
|
-
args = [fd, Backports.combine_mode_and_option(mode, options)]
|
21
|
-
end
|
22
|
-
if block_given?
|
23
|
-
open_without_options_hash(*args){|f| yield f}
|
24
|
-
else
|
25
|
-
open_without_options_hash(*args)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
Backports.alias_method_chain self, :open, :options_hash
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
Backports.alias_method self, :ungetbyte, :ungetc
|
34
|
-
end
|
3
|
+
Backports.require_relative_dir
|
@@ -0,0 +1,10 @@
|
|
1
|
+
unless IO.respond_to? :binread
|
2
|
+
require 'backports/tools'
|
3
|
+
|
4
|
+
def IO.binread(file, *arg)
|
5
|
+
raise ArgumentError, "wrong number of arguments (#{1+arg.size} for 1..3)" unless arg.size < 3
|
6
|
+
File.open(Backports.convert_to_path(file),"rb") do |f|
|
7
|
+
f.read(*arg)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
begin
|
2
|
+
File.open(__FILE__) { |f| IO.open(f.fileno, :mode => 'r').close }
|
3
|
+
rescue TypeError
|
4
|
+
require 'backports/tools'
|
5
|
+
|
6
|
+
class << IO
|
7
|
+
def open_with_options_hash(*args)
|
8
|
+
if args.size > 2 || args[1].respond_to?(:to_hash)
|
9
|
+
fd, mode, options = (args << Backports::Undefined)
|
10
|
+
args = [fd, Backports.combine_mode_and_option(mode, options)]
|
11
|
+
end
|
12
|
+
if block_given?
|
13
|
+
open_without_options_hash(*args){|f| yield f}
|
14
|
+
else
|
15
|
+
open_without_options_hash(*args)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
Backports.alias_method_chain self, :open, :options_hash
|
20
|
+
end
|
21
|
+
end
|
@@ -1,40 +1,3 @@
|
|
1
|
-
|
2
|
-
alias_method :__callee__, :__method__ unless (__callee__ || true rescue false)
|
1
|
+
require 'backports/tools'
|
3
2
|
|
4
|
-
|
5
|
-
def define_singleton_method(*args, &block)
|
6
|
-
class << self
|
7
|
-
self
|
8
|
-
end.send(:define_method, *args, &block)
|
9
|
-
end unless method_defined? :define_singleton_method
|
10
|
-
|
11
|
-
# Standard in ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/Object.html]
|
12
|
-
def require_relative(relative_feature)
|
13
|
-
file = caller.first.split(/:\d/,2).first
|
14
|
-
if /\A\((.*)\)/ =~ file # eval, etc.
|
15
|
-
raise LoadError, "require_relative is called in #{$1}"
|
16
|
-
end
|
17
|
-
require File.expand_path(relative_feature, File.dirname(file))
|
18
|
-
end unless private_method_defined? :require_relative
|
19
|
-
private :require_relative
|
20
|
-
|
21
|
-
# Standard in ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/Object.html]
|
22
|
-
def public_method(meth)
|
23
|
-
if respond_to?(meth) && !protected_methods.include?(meth.to_s)
|
24
|
-
method(meth)
|
25
|
-
else
|
26
|
-
raise NameError, "undefined method `#{meth}' for class `#{self.class}'"
|
27
|
-
end
|
28
|
-
end unless method_defined? :public_method
|
29
|
-
|
30
|
-
# Standard in ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/Object.html]
|
31
|
-
def public_send(method, *args, &block)
|
32
|
-
if respond_to?(method) && !protected_methods.include?(method.to_s)
|
33
|
-
send(method, *args, &block)
|
34
|
-
else
|
35
|
-
:foo.generate_a_no_method_error_in_preparation_for_method_missing rescue nil
|
36
|
-
# otherwise a NameError might be raised when we call method_missing ourselves
|
37
|
-
method_missing(method.to_sym, *args, &block)
|
38
|
-
end
|
39
|
-
end unless method_defined? :public_send
|
40
|
-
end
|
3
|
+
Backports.require_relative_dir
|
@@ -0,0 +1,11 @@
|
|
1
|
+
unless Kernel.method_defined? :public_method
|
2
|
+
module Kernel
|
3
|
+
def public_method(meth)
|
4
|
+
if respond_to?(meth) && !protected_methods.include?(meth.to_s)
|
5
|
+
method(meth)
|
6
|
+
else
|
7
|
+
raise NameError, "undefined method `#{meth}' for class `#{self.class}'"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
unless Kernel.method_defined? :public_send
|
2
|
+
module Kernel
|
3
|
+
def public_send(method, *args, &block)
|
4
|
+
if respond_to?(method) && !protected_methods.include?(method.to_s)
|
5
|
+
send(method, *args, &block)
|
6
|
+
else
|
7
|
+
:foo.generate_a_no_method_error_in_preparation_for_method_missing rescue nil
|
8
|
+
# otherwise a NameError might be raised when we call method_missing ourselves
|
9
|
+
method_missing(method.to_sym, *args, &block)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
unless Kernel.private_method_defined? :require_relative
|
2
|
+
require 'backports/tools'
|
3
|
+
|
4
|
+
module Kernel
|
5
|
+
def require_relative(relative_feature)
|
6
|
+
file = caller.first.split(/:\d/,2).first
|
7
|
+
if /\A\((.*)\)/ =~ file # eval, etc.
|
8
|
+
raise LoadError, "require_relative is called in #{$1}"
|
9
|
+
end
|
10
|
+
require File.expand_path(Backports.convert_path(relative_feature), File.dirname(file))
|
11
|
+
end
|
12
|
+
private :require_relative
|
13
|
+
end
|
14
|
+
end
|
data/lib/backports/1.9.1/math.rb
CHANGED
@@ -1,25 +1,3 @@
|
|
1
|
-
|
2
|
-
unless (log(2, 2) rescue false)
|
3
|
-
# Standard in Ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/Math.html]
|
4
|
-
class << self
|
5
|
-
def log_with_optional_base(numeric, base = Backports::Undefined)
|
6
|
-
if base.equal?(Backports::Undefined)
|
7
|
-
# Math.log(n) in 1.9.1 no longer accepts string arguments as it
|
8
|
-
# did on 1.8.x, but we won't risk redefining existing behavior
|
9
|
-
# when called with just one argument.
|
10
|
-
log_without_optional_base(numeric)
|
11
|
-
else
|
12
|
-
# Math.log(n, b) in 1.9.1 does not accept string arguments:
|
13
|
-
raise TypeError, "can't convert String into Float" if numeric.is_a?(String) || base.is_a?(String)
|
14
|
-
log_without_optional_base(numeric) / log_without_optional_base(base)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
Backports.alias_method_chain self, :log, :optional_base
|
1
|
+
require 'backports/tools'
|
18
2
|
|
19
|
-
|
20
|
-
def log2(numeric)
|
21
|
-
log(numeric, 2)
|
22
|
-
end unless method_defined? :log2
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
3
|
+
Backports.require_relative_dir
|
@@ -0,0 +1,22 @@
|
|
1
|
+
unless (Math.log(2, 2) rescue false)
|
2
|
+
# Standard in Ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/Math.html]
|
3
|
+
class << Math
|
4
|
+
require 'backports/tools'
|
5
|
+
|
6
|
+
def log_with_optional_base(numeric, base = Backports::Undefined)
|
7
|
+
if base.equal?(Backports::Undefined)
|
8
|
+
# Math.log(n) in 1.9.1 no longer accepts string arguments as it
|
9
|
+
# did on 1.8.x, but we won't risk redefining existing behavior
|
10
|
+
# when called with just one argument.
|
11
|
+
log_without_optional_base(numeric)
|
12
|
+
else
|
13
|
+
# Math.log(n, b) in 1.9.1 does not accept string arguments:
|
14
|
+
raise TypeError, "can't convert String into Float" if numeric.is_a?(String) || base.is_a?(String)
|
15
|
+
log_without_optional_base(numeric) / log_without_optional_base(base)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
Backports.alias_method_chain self, :log, :optional_base
|
19
|
+
|
20
|
+
# Standard in Ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/Math.html]
|
21
|
+
end
|
22
|
+
end
|
@@ -1,9 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
ndigits = Backports::coerce_to_int(ndigits)
|
5
|
-
ndigits.zero? ? round_without_digits : Float(self).round(ndigits)
|
6
|
-
end
|
7
|
-
Backports.alias_method_chain self, :round, :digits
|
8
|
-
end
|
9
|
-
end
|
1
|
+
require 'backports/tools'
|
2
|
+
|
3
|
+
Backports.require_relative_dir
|
@@ -0,0 +1,11 @@
|
|
1
|
+
if Numeric.instance_method(:round).arity.zero?
|
2
|
+
require 'backports/tools'
|
3
|
+
|
4
|
+
class Numeric
|
5
|
+
def round_with_digits(ndigits=0)
|
6
|
+
ndigits = Backports::coerce_to_int(ndigits)
|
7
|
+
ndigits.zero? ? round_without_digits : Float(self).round(ndigits)
|
8
|
+
end
|
9
|
+
Backports.alias_method_chain self, :round, :digits
|
10
|
+
end
|
11
|
+
end
|
data/lib/backports/1.9.1/proc.rb
CHANGED
@@ -1,54 +1,3 @@
|
|
1
|
-
|
2
|
-
class Proc
|
3
|
-
# Standard in Ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/Proc.html]
|
4
|
-
def lambda?
|
5
|
-
!!@is_lambda
|
6
|
-
end
|
7
|
-
end
|
1
|
+
require 'backports/tools'
|
8
2
|
|
9
|
-
|
10
|
-
def to_proc_with_lambda_tracking
|
11
|
-
proc = to_proc_without_lambda_tracking
|
12
|
-
proc.instance_variable_set :@is_lambda, true
|
13
|
-
proc
|
14
|
-
end
|
15
|
-
Backports.alias_method_chain self, :to_proc, :lambda_tracking
|
16
|
-
end
|
17
|
-
|
18
|
-
module Kernel
|
19
|
-
def lambda_with_lambda_tracking(&block)
|
20
|
-
Backports.track_lambda block, lambda_without_lambda_tracking(&block), true
|
21
|
-
end
|
22
|
-
|
23
|
-
def proc_with_lambda_tracking(&block)
|
24
|
-
Backports.track_lambda block, proc_without_lambda_tracking(&block)
|
25
|
-
end
|
26
|
-
|
27
|
-
Backports.alias_method_chain self, :lambda, :lambda_tracking
|
28
|
-
Backports.alias_method_chain self, :proc, :lambda_tracking
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
class Proc
|
33
|
-
# Standard in Ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/Proc.html]
|
34
|
-
def curry(argc = nil)
|
35
|
-
min_argc = arity < 0 ? -arity - 1 : arity
|
36
|
-
argc ||= min_argc
|
37
|
-
if lambda? and arity < 0 ? argc < min_argc : argc != arity
|
38
|
-
raise ArgumentError, "wrong number of arguments (#{argc} for #{min_argc})"
|
39
|
-
end
|
40
|
-
creator = lambda? ? :lambda : :proc
|
41
|
-
block = send(creator) do |*args|
|
42
|
-
if args.count >= argc
|
43
|
-
call(*args)
|
44
|
-
else
|
45
|
-
send(creator) do |*more_args|
|
46
|
-
args += more_args
|
47
|
-
block.call(*args)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end unless method_defined? :curry
|
52
|
-
|
53
|
-
alias_method :===, :call unless Proc.new{true} === 42
|
54
|
-
end
|
3
|
+
Backports.require_relative_dir
|