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,25 +0,0 @@
|
|
1
|
-
module Polyfill
|
2
|
-
module V2_4
|
3
|
-
module MatchData
|
4
|
-
module Instance
|
5
|
-
module NamedCaptures
|
6
|
-
module Method
|
7
|
-
def named_captures
|
8
|
-
names.each_with_object({}) do |name, acc|
|
9
|
-
acc[name] = self[name]
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
refine ::MatchData 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,25 +0,0 @@
|
|
1
|
-
module Polyfill
|
2
|
-
module V2_4
|
3
|
-
module MatchData
|
4
|
-
module Instance
|
5
|
-
module ValuesAt
|
6
|
-
module Method
|
7
|
-
def values_at(*indexes)
|
8
|
-
indexes.each_with_object([]) do |index, acc|
|
9
|
-
acc.push(self[index])
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
refine ::MatchData 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,17 +0,0 @@
|
|
1
|
-
require_relative 'instance/clone'
|
2
|
-
require_relative 'instance/dup'
|
3
|
-
require_relative 'instance/finite_q'
|
4
|
-
require_relative 'instance/infinite_q'
|
5
|
-
|
6
|
-
module Polyfill
|
7
|
-
module V2_4
|
8
|
-
module Numeric
|
9
|
-
module Instance
|
10
|
-
include Dup
|
11
|
-
include Clone
|
12
|
-
include FiniteQ
|
13
|
-
include InfiniteQ
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module Polyfill
|
2
|
-
module V2_4
|
3
|
-
module Numeric
|
4
|
-
module Instance
|
5
|
-
module Clone
|
6
|
-
module Method
|
7
|
-
def clone(freeze: true) # rubocop:disable Lint/UnusedMethodArgument
|
8
|
-
self
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
refine ::Numeric 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,23 +0,0 @@
|
|
1
|
-
module Polyfill
|
2
|
-
module V2_4
|
3
|
-
module Numeric
|
4
|
-
module Instance
|
5
|
-
module Dup
|
6
|
-
module Method
|
7
|
-
def dup
|
8
|
-
self
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
refine ::Numeric 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,23 +0,0 @@
|
|
1
|
-
module Polyfill
|
2
|
-
module V2_4
|
3
|
-
module Numeric
|
4
|
-
module Instance
|
5
|
-
module FiniteQ
|
6
|
-
module Method
|
7
|
-
def finite?
|
8
|
-
true
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
refine ::Numeric 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,23 +0,0 @@
|
|
1
|
-
module Polyfill
|
2
|
-
module V2_4
|
3
|
-
module Numeric
|
4
|
-
module Instance
|
5
|
-
module InfiniteQ
|
6
|
-
module Method
|
7
|
-
def infinite?
|
8
|
-
nil
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
refine ::Numeric 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,29 +0,0 @@
|
|
1
|
-
module Polyfill
|
2
|
-
module V2_4
|
3
|
-
module Object
|
4
|
-
module Instance
|
5
|
-
module Clone
|
6
|
-
module Method
|
7
|
-
def clone(freeze: true)
|
8
|
-
return super() if freeze
|
9
|
-
|
10
|
-
cloned = dup
|
11
|
-
(singleton_class.ancestors - self.class.ancestors).drop(1).each do |ancestor|
|
12
|
-
cloned.extend(ancestor)
|
13
|
-
end
|
14
|
-
cloned
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
refine ::Object do
|
19
|
-
include Method
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.included(base)
|
23
|
-
base.include Method
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'pathname'
|
2
|
-
|
3
|
-
module Polyfill
|
4
|
-
module V2_4
|
5
|
-
module Pathname
|
6
|
-
module Instance
|
7
|
-
module EmptyQ
|
8
|
-
module Method
|
9
|
-
def empty?
|
10
|
-
if directory?
|
11
|
-
children.empty?
|
12
|
-
else
|
13
|
-
zero?
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
refine ::Pathname do
|
19
|
-
include Method
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.included(base)
|
23
|
-
base.include Method
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module Polyfill
|
2
|
-
module V2_4
|
3
|
-
module Regexp
|
4
|
-
module Instance
|
5
|
-
module MatchQ
|
6
|
-
module Method
|
7
|
-
def match?(string, position = 0)
|
8
|
-
!!(string[position..-1] =~ self)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
refine ::Regexp 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,26 +0,0 @@
|
|
1
|
-
module Polyfill
|
2
|
-
module V2_4
|
3
|
-
module String
|
4
|
-
module Class
|
5
|
-
module New
|
6
|
-
module Method
|
7
|
-
def new(*args)
|
8
|
-
hash = args.find { |arg| arg.is_a?(::Hash) }
|
9
|
-
hash && hash.delete(:capacity) if hash
|
10
|
-
|
11
|
-
super(*args)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
refine ::String.singleton_class do
|
16
|
-
include Method
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.included(base)
|
20
|
-
base.include Method
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require_relative 'instance/casecmp_q'
|
2
|
-
require_relative 'instance/concat'
|
3
|
-
require_relative 'instance/each_line'
|
4
|
-
require_relative 'instance/lines'
|
5
|
-
require_relative 'instance/match_q'
|
6
|
-
require_relative 'instance/prepend'
|
7
|
-
require_relative 'instance/unpack1'
|
8
|
-
|
9
|
-
module Polyfill
|
10
|
-
module V2_4
|
11
|
-
module String
|
12
|
-
module Instance
|
13
|
-
include CasecmpQ
|
14
|
-
include Concat
|
15
|
-
include EachLine
|
16
|
-
include Lines
|
17
|
-
include MatchQ
|
18
|
-
include Prepend
|
19
|
-
include Unpack1
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module Polyfill
|
2
|
-
module V2_4
|
3
|
-
module String
|
4
|
-
module Instance
|
5
|
-
module CasecmpQ
|
6
|
-
module Method
|
7
|
-
def casecmp?(other)
|
8
|
-
casecmp(other.to_str) == 0
|
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 Concat
|
6
|
-
module Method
|
7
|
-
def concat(*others)
|
8
|
-
return super if others.length == 1
|
9
|
-
|
10
|
-
acc = '' << self
|
11
|
-
others.each do |other|
|
12
|
-
acc << 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,17 +0,0 @@
|
|
1
|
-
module Polyfill
|
2
|
-
module V2_4
|
3
|
-
module String
|
4
|
-
module Instance
|
5
|
-
module EachLine
|
6
|
-
refine ::String 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
|