polyfill 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/.travis.yml +3 -2
  4. data/CHANGELOG.md +26 -10
  5. data/CONTRIBUTING.md +0 -2
  6. data/README.md +107 -28
  7. data/lib/polyfill.rb +168 -74
  8. data/lib/polyfill/utils.rb +8 -3
  9. data/lib/polyfill/v2_2.rb +9 -0
  10. data/lib/polyfill/v2_2/enumerable.rb +34 -0
  11. data/lib/polyfill/v2_2/kernel.rb +9 -0
  12. data/lib/polyfill/v2_3.rb +2 -0
  13. data/lib/polyfill/v2_3/array.rb +22 -3
  14. data/lib/polyfill/v2_3/enumerable.rb +48 -3
  15. data/lib/polyfill/v2_3/enumerator/lazy.rb +7 -3
  16. data/lib/polyfill/v2_3/hash.rb +39 -3
  17. data/lib/polyfill/v2_3/kernel.rb +17 -0
  18. data/lib/polyfill/v2_3/string.rb +23 -5
  19. data/lib/polyfill/v2_3/struct.rb +22 -3
  20. data/lib/polyfill/v2_4/array.rb +25 -3
  21. data/lib/polyfill/v2_4/comparable.rb +9 -3
  22. data/lib/polyfill/v2_4/dir.rb +5 -3
  23. data/lib/polyfill/v2_4/enumerable.rb +28 -3
  24. data/lib/polyfill/v2_4/enumerator/lazy.rb +15 -3
  25. data/lib/polyfill/v2_4/file.rb +5 -3
  26. data/lib/polyfill/v2_4/float.rb +38 -3
  27. data/lib/polyfill/v2_4/hash.rb +35 -3
  28. data/lib/polyfill/v2_4/i_p_addr.rb +11 -3
  29. data/lib/polyfill/v2_4/integer.rb +53 -3
  30. data/lib/polyfill/v2_4/io.rb +166 -4
  31. data/lib/polyfill/v2_4/match_data.rb +11 -3
  32. data/lib/polyfill/v2_4/numeric.rb +15 -3
  33. data/lib/polyfill/v2_4/object.rb +9 -3
  34. data/lib/polyfill/v2_4/pathname.rb +7 -3
  35. data/lib/polyfill/v2_4/regexp.rb +3 -3
  36. data/lib/polyfill/v2_4/string.rb +110 -4
  37. data/lib/polyfill/v2_4/string_io.rb +166 -2
  38. data/lib/polyfill/v2_4/symbol.rb +17 -3
  39. data/lib/polyfill/version.rb +1 -1
  40. data/polyfill.gemspec +1 -1
  41. metadata +7 -98
  42. data/lib/polyfill/v2_3/array/instance.rb +0 -11
  43. data/lib/polyfill/v2_3/array/instance/dig.rb +0 -42
  44. data/lib/polyfill/v2_3/enumerable/instance.rb +0 -15
  45. data/lib/polyfill/v2_3/enumerable/instance/chunk_while.rb +0 -70
  46. data/lib/polyfill/v2_3/enumerable/instance/grep_v.rb +0 -48
  47. data/lib/polyfill/v2_3/enumerable/instance/slice_before.rb +0 -48
  48. data/lib/polyfill/v2_3/enumerator/lazy/instance.rb +0 -13
  49. data/lib/polyfill/v2_3/enumerator/lazy/instance/grep_v.rb +0 -31
  50. data/lib/polyfill/v2_3/hash/instance.rb +0 -15
  51. data/lib/polyfill/v2_3/hash/instance/dig.rb +0 -17
  52. data/lib/polyfill/v2_3/hash/instance/fetch_values.rb +0 -32
  53. data/lib/polyfill/v2_3/hash/instance/to_proc.rb +0 -23
  54. data/lib/polyfill/v2_3/string/class.rb +0 -11
  55. data/lib/polyfill/v2_3/string/class/new.rb +0 -33
  56. data/lib/polyfill/v2_3/string/instance.rb +0 -13
  57. data/lib/polyfill/v2_3/string/instance/minus_unary.rb +0 -23
  58. data/lib/polyfill/v2_3/string/instance/plus_unary.rb +0 -23
  59. data/lib/polyfill/v2_3/struct/instance.rb +0 -11
  60. data/lib/polyfill/v2_3/struct/instance/dig.rb +0 -17
  61. data/lib/polyfill/v2_4/array/instance.rb +0 -13
  62. data/lib/polyfill/v2_4/array/instance/concat.rb +0 -30
  63. data/lib/polyfill/v2_4/array/instance/sum.rb +0 -17
  64. data/lib/polyfill/v2_4/comparable/instance.rb +0 -11
  65. data/lib/polyfill/v2_4/comparable/instance/clamp.rb +0 -35
  66. data/lib/polyfill/v2_4/dir/class.rb +0 -11
  67. data/lib/polyfill/v2_4/dir/class/empty_q.rb +0 -23
  68. data/lib/polyfill/v2_4/enumerable/instance.rb +0 -15
  69. data/lib/polyfill/v2_4/enumerable/instance/chunk.rb +0 -48
  70. data/lib/polyfill/v2_4/enumerable/instance/sum.rb +0 -52
  71. data/lib/polyfill/v2_4/enumerable/instance/uniq.rb +0 -45
  72. data/lib/polyfill/v2_4/enumerator/lazy/instance.rb +0 -15
  73. data/lib/polyfill/v2_4/enumerator/lazy/instance/chunk_while.rb +0 -29
  74. data/lib/polyfill/v2_4/enumerator/lazy/instance/uniq.rb +0 -33
  75. data/lib/polyfill/v2_4/file/class.rb +0 -11
  76. data/lib/polyfill/v2_4/file/class/empty_q.rb +0 -23
  77. data/lib/polyfill/v2_4/float/instance.rb +0 -15
  78. data/lib/polyfill/v2_4/float/instance/ceil.rb +0 -32
  79. data/lib/polyfill/v2_4/float/instance/floor.rb +0 -32
  80. data/lib/polyfill/v2_4/float/instance/truncate.rb +0 -32
  81. data/lib/polyfill/v2_4/hash/instance.rb +0 -17
  82. data/lib/polyfill/v2_4/hash/instance/compact.rb +0 -23
  83. data/lib/polyfill/v2_4/hash/instance/compact_e.rb +0 -23
  84. data/lib/polyfill/v2_4/hash/instance/transform_values.rb +0 -33
  85. data/lib/polyfill/v2_4/hash/instance/transform_values_e.rb +0 -33
  86. data/lib/polyfill/v2_4/i_p_addr/instance.rb +0 -13
  87. data/lib/polyfill/v2_4/i_p_addr/instance/equalequal.rb +0 -27
  88. data/lib/polyfill/v2_4/i_p_addr/instance/lessthanequalgreaterthan.rb +0 -27
  89. data/lib/polyfill/v2_4/integer/instance.rb +0 -19
  90. data/lib/polyfill/v2_4/integer/instance/ceil.rb +0 -28
  91. data/lib/polyfill/v2_4/integer/instance/digits.rb +0 -34
  92. data/lib/polyfill/v2_4/integer/instance/floor.rb +0 -28
  93. data/lib/polyfill/v2_4/integer/instance/round.rb +0 -31
  94. data/lib/polyfill/v2_4/integer/instance/truncate.rb +0 -28
  95. data/lib/polyfill/v2_4/io/class.rb +0 -13
  96. data/lib/polyfill/v2_4/io/class/foreach.rb +0 -55
  97. data/lib/polyfill/v2_4/io/class/readlines.rb +0 -37
  98. data/lib/polyfill/v2_4/io/instance.rb +0 -19
  99. data/lib/polyfill/v2_4/io/instance/each_line.rb +0 -54
  100. data/lib/polyfill/v2_4/io/instance/gets.rb +0 -37
  101. data/lib/polyfill/v2_4/io/instance/lines.rb +0 -54
  102. data/lib/polyfill/v2_4/io/instance/readline.rb +0 -37
  103. data/lib/polyfill/v2_4/io/instance/readlines.rb +0 -37
  104. data/lib/polyfill/v2_4/match_data/instance.rb +0 -13
  105. data/lib/polyfill/v2_4/match_data/instance/named_captures.rb +0 -25
  106. data/lib/polyfill/v2_4/match_data/instance/values_at.rb +0 -25
  107. data/lib/polyfill/v2_4/numeric/instance.rb +0 -17
  108. data/lib/polyfill/v2_4/numeric/instance/clone.rb +0 -23
  109. data/lib/polyfill/v2_4/numeric/instance/dup.rb +0 -23
  110. data/lib/polyfill/v2_4/numeric/instance/finite_q.rb +0 -23
  111. data/lib/polyfill/v2_4/numeric/instance/infinite_q.rb +0 -23
  112. data/lib/polyfill/v2_4/object/instance.rb +0 -11
  113. data/lib/polyfill/v2_4/object/instance/clone.rb +0 -29
  114. data/lib/polyfill/v2_4/pathname/instance.rb +0 -11
  115. data/lib/polyfill/v2_4/pathname/instance/empty_q.rb +0 -29
  116. data/lib/polyfill/v2_4/regexp/instance.rb +0 -11
  117. data/lib/polyfill/v2_4/regexp/instance/match_q.rb +0 -23
  118. data/lib/polyfill/v2_4/string/class.rb +0 -11
  119. data/lib/polyfill/v2_4/string/class/new.rb +0 -26
  120. data/lib/polyfill/v2_4/string/instance.rb +0 -23
  121. data/lib/polyfill/v2_4/string/instance/casecmp_q.rb +0 -23
  122. data/lib/polyfill/v2_4/string/instance/concat.rb +0 -30
  123. data/lib/polyfill/v2_4/string/instance/each_line.rb +0 -17
  124. data/lib/polyfill/v2_4/string/instance/lines.rb +0 -55
  125. data/lib/polyfill/v2_4/string/instance/match_q.rb +0 -23
  126. data/lib/polyfill/v2_4/string/instance/prepend.rb +0 -30
  127. data/lib/polyfill/v2_4/string/instance/unpack1.rb +0 -23
  128. data/lib/polyfill/v2_4/string_io/instance.rb +0 -17
  129. data/lib/polyfill/v2_4/string_io/instance/each_line.rb +0 -17
  130. data/lib/polyfill/v2_4/string_io/instance/gets.rb +0 -17
  131. data/lib/polyfill/v2_4/string_io/instance/readline.rb +0 -17
  132. data/lib/polyfill/v2_4/string_io/instance/readlines.rb +0 -17
  133. data/lib/polyfill/v2_4/symbol/instance.rb +0 -15
  134. data/lib/polyfill/v2_4/symbol/instance/casecmp_q.rb +0 -25
  135. data/lib/polyfill/v2_4/symbol/instance/match.rb +0 -27
  136. data/lib/polyfill/v2_4/symbol/instance/match_q.rb +0 -17
@@ -1,13 +0,0 @@
1
- require_relative 'instance/named_captures'
2
- require_relative 'instance/values_at'
3
-
4
- module Polyfill
5
- module V2_4
6
- module MatchData
7
- module Instance
8
- include NamedCaptures
9
- include ValuesAt
10
- end
11
- end
12
- end
13
- end
@@ -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,11 +0,0 @@
1
- require_relative 'instance/clone'
2
-
3
- module Polyfill
4
- module V2_4
5
- module Object
6
- module Instance
7
- include Clone
8
- end
9
- end
10
- end
11
- 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,11 +0,0 @@
1
- require_relative 'instance/empty_q'
2
-
3
- module Polyfill
4
- module V2_4
5
- module Pathname
6
- module Instance
7
- include EmptyQ
8
- end
9
- end
10
- end
11
- 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,11 +0,0 @@
1
- require_relative 'instance/match_q'
2
-
3
- module Polyfill
4
- module V2_4
5
- module Regexp
6
- module Instance
7
- include MatchQ
8
- end
9
- end
10
- end
11
- 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,11 +0,0 @@
1
- require_relative 'class/new'
2
-
3
- module Polyfill
4
- module V2_4
5
- module String
6
- module Class
7
- include New
8
- end
9
- end
10
- end
11
- 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