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
data/.gitignore
CHANGED
data/.gitmodules
ADDED
data/.travis.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
+
---
|
1
2
|
language: ruby
|
2
3
|
rvm:
|
3
|
-
- "1.8.6"
|
4
4
|
- "1.8.7"
|
5
5
|
- "1.9.2"
|
6
6
|
- "1.9.3"
|
@@ -10,4 +10,13 @@ rvm:
|
|
10
10
|
- rbx-18mode
|
11
11
|
- rbx-19mode
|
12
12
|
|
13
|
-
|
13
|
+
matrix:
|
14
|
+
allow_failures:
|
15
|
+
- rvm: "2.0.0" # Must wait for 2.0.0p0...
|
16
|
+
- rvm: jruby-18mode
|
17
|
+
- rvm: jruby-19mode
|
18
|
+
- rvm: rbx-18mode
|
19
|
+
- rvm: rbx-19mode
|
20
|
+
|
21
|
+
before_install:
|
22
|
+
- git submodule update --init --recursive
|
data/CHANGELOG.rdoc
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
= Backports --- History
|
2
2
|
|
3
|
+
== Version 3.1.0 - March 5th, 2013
|
4
|
+
|
5
|
+
* Backports can now be loaded separately!
|
6
|
+
|
7
|
+
* Small tweaks and fixes for many methods to pass more RubySpecs
|
8
|
+
|
3
9
|
== Version 3.0.0 - February 24th, 2013
|
4
10
|
|
5
11
|
* Features of 2.0.0 are now required when requiring 'backports'.
|
data/Gemfile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
# Declare your gem's dependencies in backports.gemspec.
|
4
|
+
# Bundler will treat runtime dependencies like base dependencies, and
|
5
|
+
# development dependencies will be added by default to the :development group.
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
# jquery-rails is used by the dummy application
|
9
|
+
group :test do
|
10
|
+
gem "rake"
|
11
|
+
gem 'mspec', :git => 'git://github.com/rubyspec/mspec.git'
|
12
|
+
end
|
13
|
+
|
14
|
+
# Declare any dependencies that are still in development here instead of in
|
15
|
+
# your gemspec. These might include edge Rails or gems from your path or
|
16
|
+
# Git. Remember to move these dependencies to your gemspec before releasing
|
17
|
+
# your gem to rubygems.org.
|
18
|
+
|
19
|
+
# To use debugger
|
20
|
+
# gem 'ruby-debug19', :require => 'ruby-debug'
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
GIT
|
2
|
+
remote: git://github.com/rubyspec/mspec.git
|
3
|
+
revision: 69c388b1187789f4996eda7dec4c1404fcd6b742
|
4
|
+
specs:
|
5
|
+
mspec (1.5.18)
|
6
|
+
|
7
|
+
PATH
|
8
|
+
remote: .
|
9
|
+
specs:
|
10
|
+
backports (3.0.3)
|
11
|
+
|
12
|
+
GEM
|
13
|
+
remote: http://rubygems.org/
|
14
|
+
specs:
|
15
|
+
rake (10.0.3)
|
16
|
+
|
17
|
+
PLATFORMS
|
18
|
+
java
|
19
|
+
ruby
|
20
|
+
|
21
|
+
DEPENDENCIES
|
22
|
+
backports!
|
23
|
+
mspec!
|
24
|
+
rake
|
data/README.rdoc
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
= Backports Library
|
1
|
+
= Backports Library {<img src="https://travis-ci.org/marcandre/backports.png?branch=master">}[https://travis-ci.org/marcandre/backports]
|
2
2
|
|
3
3
|
* Yearning to use some of the new cool features in Ruby 2.0.0 while using 1.8.6?
|
4
4
|
* One of your client is stuck with Ruby 1.8.6 but you want to use a gem using some features of 1.8.7?
|
@@ -6,7 +6,16 @@
|
|
6
6
|
|
7
7
|
This gem is for you!
|
8
8
|
|
9
|
-
The goal of 'backports' is to make it easier to write ruby code that runs across different versions of Ruby.
|
9
|
+
The goal of 'backports' is to make it easier to write ruby code that runs across different versions of Ruby.
|
10
|
+
|
11
|
+
For example, if you want to use flat_map, even in Ruby implementations that don't include it, as well as the new bsearch method:
|
12
|
+
|
13
|
+
require 'backports/1.9.2/enumerable/flat_map'
|
14
|
+
require 'backports/2.0.0/array/bsearch'
|
15
|
+
|
16
|
+
This will enable Enumerable#flat_map and Array#bsearch, using the native versions if available or otherwise provide a pure Ruby version.
|
17
|
+
|
18
|
+
You can load many backports at once. For example, any version of Ruby up to today's standards:
|
10
19
|
|
11
20
|
require 'backports'
|
12
21
|
|
@@ -16,12 +25,12 @@ This will bring in all the features of 1.8.7 and many features of Ruby 1.9.x and
|
|
16
25
|
|
17
26
|
== What's inside
|
18
27
|
|
19
|
-
|
28
|
+
Goals for backported features:
|
20
29
|
1. Won't break older code
|
21
30
|
2. Pure Ruby (no C extensions)
|
22
31
|
3. Pass RubySpec[http://github.com/rubyspec/rubyspec]
|
23
32
|
|
24
|
-
Let's be a bit more precise about the breaking code business. It is of course entirely possible that code will break, for example some core methods are monkeypatched or if the code relies on a certain call raising an exception. Example: <tt>[42].sample rescue "dum example"</tt> will return <tt>"dum example"</tt> without this gem and <tt>42</tt> with it.
|
33
|
+
Let's be a bit more precise about the "breaking code" business. It is of course entirely possible that code will break, for example some core methods are monkeypatched or if the code relies on a certain call raising an exception. Example: <tt>[42].sample rescue "dum example"</tt> will return <tt>"dum example"</tt> without this gem and <tt>42</tt> with it.
|
25
34
|
|
26
35
|
A real incompatibility is, for example, <tt>Module::instance_methods</tt> which returns strings in 1.8 and symbols in 1.9. No change can be made without the risk of breaking existing code. Such incompatibilities are left unchanged, although you can require some of these changes in addition (see below)
|
27
36
|
|
@@ -38,7 +47,23 @@ Some generic and self-contained features of active-support are also included. By
|
|
38
47
|
To use:
|
39
48
|
|
40
49
|
require 'rubygems'
|
41
|
-
|
50
|
+
# For only specific backports:
|
51
|
+
require 'backports/1.9.1/kernel/require_relative'
|
52
|
+
require 'backports/2.0.0/enumerable/lazy'
|
53
|
+
|
54
|
+
# For all backports up to a given version
|
55
|
+
require 'backports/1.9.2' # All backports for Ruby 1.9.2 and below
|
56
|
+
|
57
|
+
# Or for all backports
|
58
|
+
require 'backports'
|
59
|
+
|
60
|
+
Note: about a dozen of backports have a dependency that will be also loaded. For example, the backport of Enumerable#flat_map uses flatten(1), so if required from Ruby 1.8.6 (where Array#flatten does not accept an argument), the backport for Ruby's 1.8.7 flatten with an argument will also be loaded.
|
61
|
+
|
62
|
+
With bundler, add to your Gemfile:
|
63
|
+
|
64
|
+
gem 'backports', :load => false
|
65
|
+
|
66
|
+
Run <tt>bundle install</tt> and require the desired backports.
|
42
67
|
|
43
68
|
Compatible with Ruby 1.8.6, 1.8.7, 1.9.1, 1.9.2, 1.9.3, JRuby and Rubinius.
|
44
69
|
|
@@ -46,12 +71,12 @@ Compatible with Ruby 1.8.6, 1.8.7, 1.9.1, 1.9.2, 1.9.3, JRuby and Rubinius.
|
|
46
71
|
|
47
72
|
== Ruby 1.8.7
|
48
73
|
|
49
|
-
Complete Ruby 1.8.7 backporting (core language). Refer to the official list of changes[https://github.com/ruby/ruby/blob/ruby_1_8_7/NEWS].
|
74
|
+
Complete Ruby 1.8.7 backporting (core language). Refer to the official list of changes[https://github.com/ruby/ruby/blob/ruby_1_8_7/NEWS]. That's about 130 backports!
|
50
75
|
|
51
76
|
Only exceptions:
|
52
77
|
* String#gsub (the form returning an enumerator)
|
53
78
|
* GC.stress= (not implemented)
|
54
|
-
* Array#choice (removed in 1.9, use Array#sample instead)
|
79
|
+
* Array#choice (removed in 1.9, use 1.9.1's Array#sample instead)
|
55
80
|
|
56
81
|
To include _only_ these backports, <tt>require "backports/1.8.7"</tt>
|
57
82
|
|
@@ -64,6 +89,7 @@ Ruby 1.8.8 has been officially cancelled. As of version 2.2, <tt>require "backpo
|
|
64
89
|
Additionally, the following Ruby 1.9 features have been backported:
|
65
90
|
* Array
|
66
91
|
* +try_convert+
|
92
|
+
* +sample+
|
67
93
|
|
68
94
|
* Enumerable
|
69
95
|
* +each_with_object+
|
@@ -275,7 +301,6 @@ Some backports would create incompatibilities in their current Ruby version but
|
|
275
301
|
|
276
302
|
These must be imported in addition to the backports gem, for example:
|
277
303
|
|
278
|
-
require "backports"
|
279
304
|
require "backports/force/hash_select"
|
280
305
|
{}.select{} # => {}, even in Ruby 1.8
|
281
306
|
|
@@ -287,11 +312,14 @@ Thanks for the bug reports and patches, in particular the repeat offenders:
|
|
287
312
|
* Konstantin Haase ( rkh[https://github.com/rkh])
|
288
313
|
* Roger Pack ( rdp[http://github.com/rdp] )
|
289
314
|
|
290
|
-
The best way to submit a patch is to also submit a patch to RubySpec[https://github.com/rubyspec/rubyspec] and then a patch to backports that make it pass the spec. To test rubyspec
|
315
|
+
The best way to submit a patch is to also submit a patch to RubySpec[https://github.com/rubyspec/rubyspec] and then a patch to backports that make it pass the spec. To test rubyspec:
|
291
316
|
|
292
|
-
|
317
|
+
git submodule init && git submodule update # => pulls rubyspecs
|
318
|
+
rake spec[array/bsearch] # => tests Array#bsearch
|
319
|
+
rake spec[array/*] # => tests all backported Array methods
|
320
|
+
rake spec (or rake spec[*/*]) # => all rubyspecs for backported methods
|
293
321
|
|
294
|
-
|
322
|
+
Failures that are acceptable are added the to `tags` file.
|
295
323
|
|
296
324
|
= License
|
297
325
|
|
data/Rakefile
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
-
|
1
|
+
begin
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
rescue LoadError
|
4
|
+
# bundler not installed
|
5
|
+
end
|
2
6
|
|
3
7
|
require 'rake/testtask'
|
4
8
|
Rake::TestTask.new(:test) do |test|
|
@@ -6,3 +10,96 @@ Rake::TestTask.new(:test) do |test|
|
|
6
10
|
test.pattern = 'test/**/*_test.rb'
|
7
11
|
test.verbose = false
|
8
12
|
end
|
13
|
+
|
14
|
+
task :spec, :path, :action do |t, args|
|
15
|
+
args.with_defaults(:path => '*/*', :action => 'ci')
|
16
|
+
stats = [[0] * 5]
|
17
|
+
not_found = []
|
18
|
+
mspec_cmds(args[:path], args[:action]) do |cmd, path|
|
19
|
+
result = `#{cmd}`
|
20
|
+
match = result.match(/(\d+) files?, (\d+) examples?, (\d+) expectations?, (\d+) failures?, (\d+) errors?/)
|
21
|
+
if match.nil?
|
22
|
+
puts "*** mspec returned with unexpected results:"
|
23
|
+
puts result
|
24
|
+
puts "Command was:", cmd
|
25
|
+
fail "Unexpected output from mspec"
|
26
|
+
end
|
27
|
+
_, ex, p, f, e = data = match.captures.map{|x| x.to_i}
|
28
|
+
not_found << path if ex == 0
|
29
|
+
stats << data
|
30
|
+
if f + e > 0
|
31
|
+
puts cmd
|
32
|
+
puts result
|
33
|
+
else
|
34
|
+
print "."
|
35
|
+
STDOUT.flush
|
36
|
+
end
|
37
|
+
end
|
38
|
+
$:.unshift 'lib'
|
39
|
+
require 'backports/rails'
|
40
|
+
_, ex, p, f, e = stats = stats.transpose.map{|x| x.sum}
|
41
|
+
puts "*** Overall:", stats.zip(%w[files examples expectations failures errors]).map{|a| a.join(' ')}.join(', ')
|
42
|
+
puts "No spec found for #{not_found.join(', ')}" unless not_found.empty?
|
43
|
+
fail unless f + e == 0
|
44
|
+
end
|
45
|
+
|
46
|
+
task :all_spec do # Necessary because of argument passing bug in 1.8.7
|
47
|
+
Rake::Task[:spec].invoke
|
48
|
+
end
|
49
|
+
|
50
|
+
task :spec_tag, :path do |t, args|
|
51
|
+
Rake::Task[:spec].invoke(args[:path], 'tag -G fails')
|
52
|
+
end
|
53
|
+
|
54
|
+
task :default => [:test, :all_spec]
|
55
|
+
|
56
|
+
DEPENDENCIES = Hash.new([]).merge!(
|
57
|
+
'1.8.7/argf/chars' => 'backports/1.8.7/string/each_char',
|
58
|
+
'1.8.7/argf/each_char' => 'backports/1.8.7/string/each_char',
|
59
|
+
'1.8.7/array/cycle' => 'backports/1.8.7/stop_iteration',
|
60
|
+
'1.8.7/enumerable/entries' => ['backports/1.8.7/enumerable/each_with_index', 'backports/1.8.7/enumerable/to_a'],
|
61
|
+
'1.8.7/enumerator/rewind' => 'backports/1.8.7/enumerator/next',
|
62
|
+
'1.8.7/hash/reject' => 'backports/1.8.7/integer/even',
|
63
|
+
'1.9.1/hash/rassoc' => 'backports/1.8.7/hash/key',
|
64
|
+
'1.9.1/proc/lambda' => 'backports/1.9.1/proc/curry',
|
65
|
+
'1.9.2/complex/to_r' => 'complex',
|
66
|
+
'1.9.2/array/select' => 'backports/1.8.7/array/select',
|
67
|
+
'1.9.2/hash/select' => 'backports/1.8.7/hash/select',
|
68
|
+
'1.9.2/enumerable/each_entry' => 'backports/1.8.7/enumerable/each_with_index',
|
69
|
+
'2.0.0/hash/to_h' => 'backports/1.9.1/hash/default_proc'
|
70
|
+
)
|
71
|
+
{
|
72
|
+
:each_with_index => %w[enumerable/detect enumerable/find enumerable/find_all enumerable/select enumerable/to_a],
|
73
|
+
:first => %w[enumerable/cycle io/bytes io/chars io/each_byte io/each_char io/lines io/each_line]
|
74
|
+
}.each do |req, libs|
|
75
|
+
libs.each{|l| DEPENDENCIES["1.8.7/#{l}"] = "backports/1.8.7/enumerable/#{req}" }
|
76
|
+
end
|
77
|
+
|
78
|
+
# These cause actual errors while loading in 1.8:
|
79
|
+
IGNORE_IN_18 = %w[
|
80
|
+
1.9.1/symbol/length
|
81
|
+
1.9.1/symbol/size
|
82
|
+
1.9.3/string/byteslice
|
83
|
+
1.8.7/proc/yield
|
84
|
+
1.9.1/proc/case_compare
|
85
|
+
]
|
86
|
+
def mspec_cmds(pattern, action='ci')
|
87
|
+
pattern = "lib/backports/*.*.*/#{pattern}.rb"
|
88
|
+
Dir.glob(pattern) do |lib_path|
|
89
|
+
_match, version, path = lib_path.match(/backports\/(\d\.\d\.\d)\/(.*)\.rb/).to_a
|
90
|
+
next if path =~ /stdlib/
|
91
|
+
next if version <= RUBY_VERSION
|
92
|
+
version_path = "#{version}/#{path}"
|
93
|
+
next if IGNORE_IN_18.include? version_path if RUBY_VERSION < '1.9'
|
94
|
+
deps = [*DEPENDENCIES[version_path]].map{|p| "-r #{p}"}.join(' ')
|
95
|
+
klass, method = path.split('/')
|
96
|
+
path = [klass.gsub('_', ''), method].join('/') # don't ask me why RubySpec uses matchdata instead of match_data
|
97
|
+
yield %W[mspec #{action}
|
98
|
+
-I lib
|
99
|
+
-r ./set_version/#{version}
|
100
|
+
#{deps}
|
101
|
+
-r backports/#{version_path}
|
102
|
+
rubyspec/core/#{path}_spec.rb
|
103
|
+
].join(' '), path
|
104
|
+
end
|
105
|
+
end
|
data/default.mspec
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
if (Backports::TARGET_VERSION rescue false) # Conf loaded at different times, not sure why
|
2
|
+
class MSpecScript
|
3
|
+
# The set of substitutions to transform a spec filename
|
4
|
+
# into a tag filename.
|
5
|
+
set :tags_patterns, [ [%r(rubyspec/), "tags/#{RUBY_VERSION}/"] ]
|
6
|
+
end
|
7
|
+
|
8
|
+
SpecGuard.ruby_version_override = Backports::TARGET_VERSION if Backports::TARGET_VERSION > RUBY_VERSION
|
9
|
+
end
|
data/lib/backports.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
require "backports/tools"
|
2
|
+
require "backports/version"
|
3
|
+
require "backports/2.0"
|
4
|
+
require "backports/rails"
|
data/lib/backports/1.8.7.rb
CHANGED
data/lib/backports/1.8.7/argf.rb
CHANGED
@@ -1,44 +1,3 @@
|
|
1
|
-
|
2
|
-
# No official documentation...
|
1
|
+
require 'backports/tools'
|
3
2
|
|
4
|
-
|
5
|
-
Backports.make_block_optional self, :each, :each_line, :each_byte, :force => true
|
6
|
-
end
|
7
|
-
|
8
|
-
def each_char
|
9
|
-
return to_enum(:each_char) unless block_given?
|
10
|
-
if $KCODE == "UTF-8"
|
11
|
-
lookup = 7.downto(4)
|
12
|
-
while c = read(1) do
|
13
|
-
n = c[0]
|
14
|
-
leftmost_zero_bit = lookup.find{|i| n[i].zero? }
|
15
|
-
case leftmost_zero_bit
|
16
|
-
when 7 # ASCII
|
17
|
-
yield c
|
18
|
-
when 6 # UTF 8 complementary characters
|
19
|
-
next # Encoding error, ignore
|
20
|
-
else
|
21
|
-
more = read(6-leftmost_zero_bit)
|
22
|
-
break unless more
|
23
|
-
yield c+more
|
24
|
-
end
|
25
|
-
end
|
26
|
-
else
|
27
|
-
while s = read(1)
|
28
|
-
yield s
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
self
|
33
|
-
end unless method_defined? :each_char
|
34
|
-
|
35
|
-
# No official documentation...
|
36
|
-
Backports.alias_method self, :getbyte, :getc
|
37
|
-
|
38
|
-
# No official documentation...
|
39
|
-
Backports.alias_method self, :readbyte, :readchar
|
40
|
-
|
41
|
-
Backports.alias_method self, :bytes, :each_byte
|
42
|
-
Backports.alias_method self, :chars, :each_char
|
43
|
-
Backports.alias_method self, :lines, :each_line
|
44
|
-
end
|
3
|
+
Backports.require_relative_dir
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'backports/1.8.7/argf/each_byte'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'backports/1.8.7/argf/each_char'
|
@@ -0,0 +1,35 @@
|
|
1
|
+
unless ARGF.respond_to? :each_char
|
2
|
+
require 'backports/tools'
|
3
|
+
require 'enumerator'
|
4
|
+
|
5
|
+
class << ARGF
|
6
|
+
def each_char
|
7
|
+
return to_enum(:each_char) unless block_given?
|
8
|
+
if $KCODE == "UTF-8"
|
9
|
+
lookup = 7.downto(4)
|
10
|
+
while c = read(1) do
|
11
|
+
n = c[0]
|
12
|
+
leftmost_zero_bit = lookup.find{|i| n[i].zero? }
|
13
|
+
case leftmost_zero_bit
|
14
|
+
when 7 # ASCII
|
15
|
+
yield c
|
16
|
+
when 6 # UTF 8 complementary characters
|
17
|
+
next # Encoding error, ignore
|
18
|
+
else
|
19
|
+
more = read(6-leftmost_zero_bit)
|
20
|
+
break unless more
|
21
|
+
yield c+more
|
22
|
+
end
|
23
|
+
end
|
24
|
+
else
|
25
|
+
while s = read(1)
|
26
|
+
yield s
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
self
|
31
|
+
end
|
32
|
+
|
33
|
+
Backports.alias_method self, :chars, :each_char
|
34
|
+
end
|
35
|
+
end
|