polyfill 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/.travis.yml +3 -2
- data/CHANGELOG.md +26 -10
- data/CONTRIBUTING.md +0 -2
- data/README.md +107 -28
- data/lib/polyfill.rb +168 -74
- data/lib/polyfill/utils.rb +8 -3
- data/lib/polyfill/v2_2.rb +9 -0
- data/lib/polyfill/v2_2/enumerable.rb +34 -0
- data/lib/polyfill/v2_2/kernel.rb +9 -0
- data/lib/polyfill/v2_3.rb +2 -0
- data/lib/polyfill/v2_3/array.rb +22 -3
- data/lib/polyfill/v2_3/enumerable.rb +48 -3
- data/lib/polyfill/v2_3/enumerator/lazy.rb +7 -3
- data/lib/polyfill/v2_3/hash.rb +39 -3
- data/lib/polyfill/v2_3/kernel.rb +17 -0
- data/lib/polyfill/v2_3/string.rb +23 -5
- data/lib/polyfill/v2_3/struct.rb +22 -3
- data/lib/polyfill/v2_4/array.rb +25 -3
- data/lib/polyfill/v2_4/comparable.rb +9 -3
- data/lib/polyfill/v2_4/dir.rb +5 -3
- data/lib/polyfill/v2_4/enumerable.rb +28 -3
- data/lib/polyfill/v2_4/enumerator/lazy.rb +15 -3
- data/lib/polyfill/v2_4/file.rb +5 -3
- data/lib/polyfill/v2_4/float.rb +38 -3
- data/lib/polyfill/v2_4/hash.rb +35 -3
- data/lib/polyfill/v2_4/i_p_addr.rb +11 -3
- data/lib/polyfill/v2_4/integer.rb +53 -3
- data/lib/polyfill/v2_4/io.rb +166 -4
- data/lib/polyfill/v2_4/match_data.rb +11 -3
- data/lib/polyfill/v2_4/numeric.rb +15 -3
- data/lib/polyfill/v2_4/object.rb +9 -3
- data/lib/polyfill/v2_4/pathname.rb +7 -3
- data/lib/polyfill/v2_4/regexp.rb +3 -3
- data/lib/polyfill/v2_4/string.rb +110 -4
- data/lib/polyfill/v2_4/string_io.rb +166 -2
- data/lib/polyfill/v2_4/symbol.rb +17 -3
- data/lib/polyfill/version.rb +1 -1
- data/polyfill.gemspec +1 -1
- metadata +7 -98
- data/lib/polyfill/v2_3/array/instance.rb +0 -11
- data/lib/polyfill/v2_3/array/instance/dig.rb +0 -42
- data/lib/polyfill/v2_3/enumerable/instance.rb +0 -15
- data/lib/polyfill/v2_3/enumerable/instance/chunk_while.rb +0 -70
- data/lib/polyfill/v2_3/enumerable/instance/grep_v.rb +0 -48
- data/lib/polyfill/v2_3/enumerable/instance/slice_before.rb +0 -48
- data/lib/polyfill/v2_3/enumerator/lazy/instance.rb +0 -13
- data/lib/polyfill/v2_3/enumerator/lazy/instance/grep_v.rb +0 -31
- data/lib/polyfill/v2_3/hash/instance.rb +0 -15
- data/lib/polyfill/v2_3/hash/instance/dig.rb +0 -17
- data/lib/polyfill/v2_3/hash/instance/fetch_values.rb +0 -32
- data/lib/polyfill/v2_3/hash/instance/to_proc.rb +0 -23
- data/lib/polyfill/v2_3/string/class.rb +0 -11
- data/lib/polyfill/v2_3/string/class/new.rb +0 -33
- data/lib/polyfill/v2_3/string/instance.rb +0 -13
- data/lib/polyfill/v2_3/string/instance/minus_unary.rb +0 -23
- data/lib/polyfill/v2_3/string/instance/plus_unary.rb +0 -23
- data/lib/polyfill/v2_3/struct/instance.rb +0 -11
- data/lib/polyfill/v2_3/struct/instance/dig.rb +0 -17
- data/lib/polyfill/v2_4/array/instance.rb +0 -13
- data/lib/polyfill/v2_4/array/instance/concat.rb +0 -30
- data/lib/polyfill/v2_4/array/instance/sum.rb +0 -17
- data/lib/polyfill/v2_4/comparable/instance.rb +0 -11
- data/lib/polyfill/v2_4/comparable/instance/clamp.rb +0 -35
- data/lib/polyfill/v2_4/dir/class.rb +0 -11
- data/lib/polyfill/v2_4/dir/class/empty_q.rb +0 -23
- data/lib/polyfill/v2_4/enumerable/instance.rb +0 -15
- data/lib/polyfill/v2_4/enumerable/instance/chunk.rb +0 -48
- data/lib/polyfill/v2_4/enumerable/instance/sum.rb +0 -52
- data/lib/polyfill/v2_4/enumerable/instance/uniq.rb +0 -45
- data/lib/polyfill/v2_4/enumerator/lazy/instance.rb +0 -15
- data/lib/polyfill/v2_4/enumerator/lazy/instance/chunk_while.rb +0 -29
- data/lib/polyfill/v2_4/enumerator/lazy/instance/uniq.rb +0 -33
- data/lib/polyfill/v2_4/file/class.rb +0 -11
- data/lib/polyfill/v2_4/file/class/empty_q.rb +0 -23
- data/lib/polyfill/v2_4/float/instance.rb +0 -15
- data/lib/polyfill/v2_4/float/instance/ceil.rb +0 -32
- data/lib/polyfill/v2_4/float/instance/floor.rb +0 -32
- data/lib/polyfill/v2_4/float/instance/truncate.rb +0 -32
- data/lib/polyfill/v2_4/hash/instance.rb +0 -17
- data/lib/polyfill/v2_4/hash/instance/compact.rb +0 -23
- data/lib/polyfill/v2_4/hash/instance/compact_e.rb +0 -23
- data/lib/polyfill/v2_4/hash/instance/transform_values.rb +0 -33
- data/lib/polyfill/v2_4/hash/instance/transform_values_e.rb +0 -33
- data/lib/polyfill/v2_4/i_p_addr/instance.rb +0 -13
- data/lib/polyfill/v2_4/i_p_addr/instance/equalequal.rb +0 -27
- data/lib/polyfill/v2_4/i_p_addr/instance/lessthanequalgreaterthan.rb +0 -27
- data/lib/polyfill/v2_4/integer/instance.rb +0 -19
- data/lib/polyfill/v2_4/integer/instance/ceil.rb +0 -28
- data/lib/polyfill/v2_4/integer/instance/digits.rb +0 -34
- data/lib/polyfill/v2_4/integer/instance/floor.rb +0 -28
- data/lib/polyfill/v2_4/integer/instance/round.rb +0 -31
- data/lib/polyfill/v2_4/integer/instance/truncate.rb +0 -28
- data/lib/polyfill/v2_4/io/class.rb +0 -13
- data/lib/polyfill/v2_4/io/class/foreach.rb +0 -55
- data/lib/polyfill/v2_4/io/class/readlines.rb +0 -37
- data/lib/polyfill/v2_4/io/instance.rb +0 -19
- data/lib/polyfill/v2_4/io/instance/each_line.rb +0 -54
- data/lib/polyfill/v2_4/io/instance/gets.rb +0 -37
- data/lib/polyfill/v2_4/io/instance/lines.rb +0 -54
- data/lib/polyfill/v2_4/io/instance/readline.rb +0 -37
- data/lib/polyfill/v2_4/io/instance/readlines.rb +0 -37
- data/lib/polyfill/v2_4/match_data/instance.rb +0 -13
- data/lib/polyfill/v2_4/match_data/instance/named_captures.rb +0 -25
- data/lib/polyfill/v2_4/match_data/instance/values_at.rb +0 -25
- data/lib/polyfill/v2_4/numeric/instance.rb +0 -17
- data/lib/polyfill/v2_4/numeric/instance/clone.rb +0 -23
- data/lib/polyfill/v2_4/numeric/instance/dup.rb +0 -23
- data/lib/polyfill/v2_4/numeric/instance/finite_q.rb +0 -23
- data/lib/polyfill/v2_4/numeric/instance/infinite_q.rb +0 -23
- data/lib/polyfill/v2_4/object/instance.rb +0 -11
- data/lib/polyfill/v2_4/object/instance/clone.rb +0 -29
- data/lib/polyfill/v2_4/pathname/instance.rb +0 -11
- data/lib/polyfill/v2_4/pathname/instance/empty_q.rb +0 -29
- data/lib/polyfill/v2_4/regexp/instance.rb +0 -11
- data/lib/polyfill/v2_4/regexp/instance/match_q.rb +0 -23
- data/lib/polyfill/v2_4/string/class.rb +0 -11
- data/lib/polyfill/v2_4/string/class/new.rb +0 -26
- data/lib/polyfill/v2_4/string/instance.rb +0 -23
- data/lib/polyfill/v2_4/string/instance/casecmp_q.rb +0 -23
- data/lib/polyfill/v2_4/string/instance/concat.rb +0 -30
- data/lib/polyfill/v2_4/string/instance/each_line.rb +0 -17
- data/lib/polyfill/v2_4/string/instance/lines.rb +0 -55
- data/lib/polyfill/v2_4/string/instance/match_q.rb +0 -23
- data/lib/polyfill/v2_4/string/instance/prepend.rb +0 -30
- data/lib/polyfill/v2_4/string/instance/unpack1.rb +0 -23
- data/lib/polyfill/v2_4/string_io/instance.rb +0 -17
- data/lib/polyfill/v2_4/string_io/instance/each_line.rb +0 -17
- data/lib/polyfill/v2_4/string_io/instance/gets.rb +0 -17
- data/lib/polyfill/v2_4/string_io/instance/readline.rb +0 -17
- data/lib/polyfill/v2_4/string_io/instance/readlines.rb +0 -17
- data/lib/polyfill/v2_4/symbol/instance.rb +0 -15
- data/lib/polyfill/v2_4/symbol/instance/casecmp_q.rb +0 -25
- data/lib/polyfill/v2_4/symbol/instance/match.rb +0 -27
- data/lib/polyfill/v2_4/symbol/instance/match_q.rb +0 -17
@@ -1,55 +0,0 @@
|
|
1
|
-
require 'English'
|
2
|
-
|
3
|
-
module Polyfill
|
4
|
-
module V2_4
|
5
|
-
module String
|
6
|
-
module Instance
|
7
|
-
module Lines
|
8
|
-
module Method
|
9
|
-
def lines(*args)
|
10
|
-
hash, others = args.partition { |arg| arg.is_a?(::Hash) }
|
11
|
-
chomps = hash[0] && hash[0][:chomp]
|
12
|
-
|
13
|
-
unless block_given?
|
14
|
-
lines = super(*others)
|
15
|
-
|
16
|
-
if chomps
|
17
|
-
separator = others.find do |other|
|
18
|
-
other.respond_to?(:to_str)
|
19
|
-
end || $INPUT_RECORD_SEPARATOR
|
20
|
-
|
21
|
-
lines.each { |line| line.chomp!(separator) }
|
22
|
-
end
|
23
|
-
|
24
|
-
return lines
|
25
|
-
end
|
26
|
-
|
27
|
-
block =
|
28
|
-
if chomps
|
29
|
-
separator = others.find do |other|
|
30
|
-
other.respond_to?(:to_str)
|
31
|
-
end || $INPUT_RECORD_SEPARATOR
|
32
|
-
|
33
|
-
proc do |line|
|
34
|
-
yield(line.chomp(separator))
|
35
|
-
end
|
36
|
-
else
|
37
|
-
::Proc.new
|
38
|
-
end
|
39
|
-
|
40
|
-
super(*others, &block)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
refine ::String do
|
45
|
-
include Method
|
46
|
-
end
|
47
|
-
|
48
|
-
def self.included(base)
|
49
|
-
base.include Method
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module Polyfill
|
2
|
-
module V2_4
|
3
|
-
module String
|
4
|
-
module Instance
|
5
|
-
module MatchQ
|
6
|
-
module Method
|
7
|
-
def match?(pattern, position = 0)
|
8
|
-
!!(self[position..-1] =~ pattern)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
refine ::String do
|
13
|
-
include Method
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.included(base)
|
17
|
-
base.include Method
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
module Polyfill
|
2
|
-
module V2_4
|
3
|
-
module String
|
4
|
-
module Instance
|
5
|
-
module Prepend
|
6
|
-
module Method
|
7
|
-
def prepend(*others)
|
8
|
-
return super if others.length == 1
|
9
|
-
|
10
|
-
acc = '' << self
|
11
|
-
others.reverse_each do |other|
|
12
|
-
acc.prepend(other)
|
13
|
-
end
|
14
|
-
|
15
|
-
replace(acc)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
refine ::String do
|
20
|
-
include Method
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.included(base)
|
24
|
-
base.include Method
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module Polyfill
|
2
|
-
module V2_4
|
3
|
-
module String
|
4
|
-
module Instance
|
5
|
-
module Unpack1
|
6
|
-
module Method
|
7
|
-
def unpack1(*args)
|
8
|
-
unpack(*args).first
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
refine ::String do
|
13
|
-
include Method
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.included(base)
|
17
|
-
base.include Method
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require_relative 'instance/each_line'
|
2
|
-
require_relative 'instance/gets'
|
3
|
-
require_relative 'instance/readline'
|
4
|
-
require_relative 'instance/readlines'
|
5
|
-
|
6
|
-
module Polyfill
|
7
|
-
module V2_4
|
8
|
-
module StringIO
|
9
|
-
module Instance
|
10
|
-
include EachLine
|
11
|
-
include Gets
|
12
|
-
include Readline
|
13
|
-
include Readlines
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module Polyfill
|
2
|
-
module V2_4
|
3
|
-
module StringIO
|
4
|
-
module Instance
|
5
|
-
module EachLine
|
6
|
-
refine ::StringIO do
|
7
|
-
include IO::Instance::EachLine::Method
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.included(base)
|
11
|
-
base.include IO::Instance::EachLine::Method
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module Polyfill
|
2
|
-
module V2_4
|
3
|
-
module StringIO
|
4
|
-
module Instance
|
5
|
-
module Gets
|
6
|
-
refine ::StringIO do
|
7
|
-
include IO::Instance::Gets::Method
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.included(base)
|
11
|
-
base.include IO::Instance::Gets::Method
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module Polyfill
|
2
|
-
module V2_4
|
3
|
-
module StringIO
|
4
|
-
module Instance
|
5
|
-
module Readline
|
6
|
-
refine ::StringIO do
|
7
|
-
include IO::Instance::Readline::Method
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.included(base)
|
11
|
-
base.include IO::Instance::Readline::Method
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module Polyfill
|
2
|
-
module V2_4
|
3
|
-
module StringIO
|
4
|
-
module Instance
|
5
|
-
module Readlines
|
6
|
-
refine ::StringIO do
|
7
|
-
include IO::Instance::Readlines::Method
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.included(base)
|
11
|
-
base.include IO::Instance::Readlines::Method
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require_relative 'instance/casecmp_q'
|
2
|
-
require_relative 'instance/match_q'
|
3
|
-
require_relative 'instance/match'
|
4
|
-
|
5
|
-
module Polyfill
|
6
|
-
module V2_4
|
7
|
-
module Symbol
|
8
|
-
module Instance
|
9
|
-
include CasecmpQ
|
10
|
-
include Match
|
11
|
-
include MatchQ
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Polyfill
|
2
|
-
module V2_4
|
3
|
-
module Symbol
|
4
|
-
module Instance
|
5
|
-
module CasecmpQ
|
6
|
-
module Method
|
7
|
-
def casecmp?(other)
|
8
|
-
return nil unless other.is_a?(::Symbol)
|
9
|
-
|
10
|
-
casecmp(other) == 0
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
refine ::Symbol do
|
15
|
-
include Method
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.included(base)
|
19
|
-
base.include Method
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module Polyfill
|
2
|
-
module V2_4
|
3
|
-
module Symbol
|
4
|
-
module Instance
|
5
|
-
module Match
|
6
|
-
module Method
|
7
|
-
def match(*args)
|
8
|
-
if block_given?
|
9
|
-
to_s.match(*args, &::Proc.new)
|
10
|
-
else
|
11
|
-
to_s.match(*args)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
refine ::Symbol do
|
17
|
-
include Method
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.included(base)
|
21
|
-
base.include Method
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module Polyfill
|
2
|
-
module V2_4
|
3
|
-
module Symbol
|
4
|
-
module Instance
|
5
|
-
module MatchQ
|
6
|
-
refine ::Symbol do
|
7
|
-
include String::Instance::MatchQ::Method
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.included(base)
|
11
|
-
base.include String::Instance::MatchQ::Method
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|