polyfill 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +23 -1
  3. data/README.md +30 -44
  4. data/lib/polyfill.rb +63 -0
  5. data/lib/polyfill/v2_4.rb +8 -0
  6. data/lib/polyfill/v2_4/array.rb +2 -2
  7. data/lib/polyfill/v2_4/array/instance.rb +11 -0
  8. data/lib/polyfill/v2_4/array/instance/concat.rb +32 -0
  9. data/lib/polyfill/v2_4/comparable.rb +2 -2
  10. data/lib/polyfill/v2_4/comparable/instance.rb +11 -0
  11. data/lib/polyfill/v2_4/comparable/instance/clamp.rb +37 -0
  12. data/lib/polyfill/v2_4/dir.rb +9 -0
  13. data/lib/polyfill/v2_4/dir/class.rb +11 -0
  14. data/lib/polyfill/v2_4/dir/class/empty_q.rb +25 -0
  15. data/lib/polyfill/v2_4/file.rb +9 -0
  16. data/lib/polyfill/v2_4/file/class.rb +11 -0
  17. data/lib/polyfill/v2_4/file/class/empty_q.rb +25 -0
  18. data/lib/polyfill/v2_4/float.rb +2 -6
  19. data/lib/polyfill/v2_4/float/instance.rb +15 -0
  20. data/lib/polyfill/v2_4/float/instance/ceil.rb +34 -0
  21. data/lib/polyfill/v2_4/float/instance/floor.rb +34 -0
  22. data/lib/polyfill/v2_4/float/instance/truncate.rb +34 -0
  23. data/lib/polyfill/v2_4/hash.rb +2 -8
  24. data/lib/polyfill/v2_4/hash/instance.rb +17 -0
  25. data/lib/polyfill/v2_4/hash/instance/compact.rb +25 -0
  26. data/lib/polyfill/v2_4/hash/instance/compact_e.rb +25 -0
  27. data/lib/polyfill/v2_4/hash/instance/transform_values.rb +35 -0
  28. data/lib/polyfill/v2_4/hash/instance/transform_values_e.rb +35 -0
  29. data/lib/polyfill/v2_4/integer.rb +2 -10
  30. data/lib/polyfill/v2_4/integer/instance.rb +19 -0
  31. data/lib/polyfill/v2_4/integer/instance/ceil.rb +30 -0
  32. data/lib/polyfill/v2_4/integer/instance/digits.rb +36 -0
  33. data/lib/polyfill/v2_4/integer/instance/floor.rb +30 -0
  34. data/lib/polyfill/v2_4/integer/instance/round.rb +33 -0
  35. data/lib/polyfill/v2_4/integer/instance/truncate.rb +30 -0
  36. data/lib/polyfill/v2_4/io.rb +11 -0
  37. data/lib/polyfill/v2_4/io/class.rb +13 -0
  38. data/lib/polyfill/v2_4/io/class/foreach.rb +67 -0
  39. data/lib/polyfill/v2_4/io/class/readlines.rb +38 -0
  40. data/lib/polyfill/v2_4/io/instance.rb +17 -0
  41. data/lib/polyfill/v2_4/io/instance/each_line.rb +67 -0
  42. data/lib/polyfill/v2_4/io/instance/gets.rb +38 -0
  43. data/lib/polyfill/v2_4/io/instance/readline.rb +38 -0
  44. data/lib/polyfill/v2_4/io/instance/readlines.rb +38 -0
  45. data/lib/polyfill/v2_4/match_data.rb +2 -4
  46. data/lib/polyfill/v2_4/match_data/instance.rb +13 -0
  47. data/lib/polyfill/v2_4/match_data/instance/named_captures.rb +27 -0
  48. data/lib/polyfill/v2_4/match_data/instance/values_at.rb +27 -0
  49. data/lib/polyfill/v2_4/numeric.rb +2 -4
  50. data/lib/polyfill/v2_4/numeric/instance.rb +13 -0
  51. data/lib/polyfill/v2_4/numeric/instance/finite_q.rb +25 -0
  52. data/lib/polyfill/v2_4/numeric/instance/infinite_q.rb +25 -0
  53. data/lib/polyfill/v2_4/string.rb +2 -4
  54. data/lib/polyfill/v2_4/string/instance.rb +13 -0
  55. data/lib/polyfill/v2_4/string/instance/concat.rb +32 -0
  56. data/lib/polyfill/v2_4/string/instance/prepend.rb +32 -0
  57. data/lib/polyfill/v2_4/string_io.rb +9 -0
  58. data/lib/polyfill/v2_4/string_io/instance.rb +17 -0
  59. data/lib/polyfill/v2_4/string_io/instance/each_line.rb +19 -0
  60. data/lib/polyfill/v2_4/string_io/instance/gets.rb +19 -0
  61. data/lib/polyfill/v2_4/string_io/instance/readline.rb +19 -0
  62. data/lib/polyfill/v2_4/string_io/instance/readlines.rb +19 -0
  63. data/lib/polyfill/version.rb +1 -1
  64. metadata +51 -22
  65. data/lib/polyfill/v2_4/array/concat.rb +0 -26
  66. data/lib/polyfill/v2_4/comparable/clamp.rb +0 -31
  67. data/lib/polyfill/v2_4/float/ceil.rb +0 -28
  68. data/lib/polyfill/v2_4/float/floor.rb +0 -28
  69. data/lib/polyfill/v2_4/float/truncate.rb +0 -28
  70. data/lib/polyfill/v2_4/hash/compact.rb +0 -19
  71. data/lib/polyfill/v2_4/hash/compact_e.rb +0 -19
  72. data/lib/polyfill/v2_4/hash/transform_values.rb +0 -29
  73. data/lib/polyfill/v2_4/hash/transform_values_e.rb +0 -29
  74. data/lib/polyfill/v2_4/integer/ceil.rb +0 -24
  75. data/lib/polyfill/v2_4/integer/digits.rb +0 -30
  76. data/lib/polyfill/v2_4/integer/floor.rb +0 -24
  77. data/lib/polyfill/v2_4/integer/round.rb +0 -27
  78. data/lib/polyfill/v2_4/integer/truncate.rb +0 -24
  79. data/lib/polyfill/v2_4/match_data/named_captures.rb +0 -21
  80. data/lib/polyfill/v2_4/match_data/values_at.rb +0 -21
  81. data/lib/polyfill/v2_4/numeric/finite_q.rb +0 -19
  82. data/lib/polyfill/v2_4/numeric/infinite_q.rb +0 -19
  83. data/lib/polyfill/v2_4/string/concat.rb +0 -26
  84. data/lib/polyfill/v2_4/string/prepend.rb +0 -26
@@ -0,0 +1,13 @@
1
+ require 'polyfill/v2_4/match_data/instance/named_captures'
2
+ require 'polyfill/v2_4/match_data/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
@@ -0,0 +1,27 @@
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
+ if RUBY_VERSION < '2.4.0'
15
+ refine ::MatchData 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
27
+ end
@@ -0,0 +1,27 @@
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
+ if RUBY_VERSION < '2.4.0'
15
+ refine ::MatchData 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
27
+ end
@@ -1,11 +1,9 @@
1
- require 'polyfill/v2_4/numeric/finite_q'
2
- require 'polyfill/v2_4/numeric/infinite_q'
1
+ require 'polyfill/v2_4/numeric/instance'
3
2
 
4
3
  module Polyfill
5
4
  module V2_4
6
5
  module Numeric
7
- include FiniteQ
8
- include InfiniteQ
6
+ include Instance
9
7
  end
10
8
  end
11
9
  end
@@ -0,0 +1,13 @@
1
+ require 'polyfill/v2_4/numeric/instance/finite_q'
2
+ require 'polyfill/v2_4/numeric/instance/infinite_q'
3
+
4
+ module Polyfill
5
+ module V2_4
6
+ module Numeric
7
+ module Instance
8
+ include FiniteQ
9
+ include InfiniteQ
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,25 @@
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
+ if RUBY_VERSION < '2.4.0'
13
+ refine ::Numeric do
14
+ include Method
15
+ end
16
+
17
+ def self.included(base)
18
+ base.include Method
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
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
+ if RUBY_VERSION < '2.4.0'
13
+ refine ::Numeric do
14
+ include Method
15
+ end
16
+
17
+ def self.included(base)
18
+ base.include Method
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,11 +1,9 @@
1
- require 'polyfill/v2_4/string/concat'
2
- require 'polyfill/v2_4/string/prepend'
1
+ require 'polyfill/v2_4/string/instance'
3
2
 
4
3
  module Polyfill
5
4
  module V2_4
6
5
  module String
7
- include Concat
8
- include Prepend
6
+ include Instance
9
7
  end
10
8
  end
11
9
  end
@@ -0,0 +1,13 @@
1
+ require 'polyfill/v2_4/string/instance/concat'
2
+ require 'polyfill/v2_4/string/instance/prepend'
3
+
4
+ module Polyfill
5
+ module V2_4
6
+ module String
7
+ module Instance
8
+ include Concat
9
+ include Prepend
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,32 @@
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
+ if RUBY_VERSION < '2.4.0'
20
+ refine ::String do
21
+ include Method
22
+ end
23
+
24
+ def self.included(base)
25
+ base.include Method
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,32 @@
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
+ if RUBY_VERSION < '2.4.0'
20
+ refine ::String do
21
+ include Method
22
+ end
23
+
24
+ def self.included(base)
25
+ base.include Method
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,9 @@
1
+ require 'polyfill/v2_4/string_io/instance'
2
+
3
+ module Polyfill
4
+ module V2_4
5
+ module StringIO
6
+ include Instance
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,17 @@
1
+ require 'polyfill/v2_4/string_io/instance/each_line'
2
+ require 'polyfill/v2_4/string_io/instance/gets'
3
+ require 'polyfill/v2_4/string_io/instance/readline'
4
+ require 'polyfill/v2_4/string_io/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
@@ -0,0 +1,19 @@
1
+ module Polyfill
2
+ module V2_4
3
+ module StringIO
4
+ module Instance
5
+ module EachLine
6
+ if RUBY_VERSION < '2.4.0'
7
+ refine ::StringIO do
8
+ include IO::Instance::EachLine::Method
9
+ end
10
+
11
+ def self.included(base)
12
+ base.include IO::Instance::EachLine::Method
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ module Polyfill
2
+ module V2_4
3
+ module StringIO
4
+ module Instance
5
+ module Gets
6
+ if RUBY_VERSION < '2.4.0'
7
+ refine ::StringIO do
8
+ include IO::Instance::Gets::Method
9
+ end
10
+
11
+ def self.included(base)
12
+ base.include IO::Instance::Gets::Method
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ module Polyfill
2
+ module V2_4
3
+ module StringIO
4
+ module Instance
5
+ module Readline
6
+ if RUBY_VERSION < '2.4.0'
7
+ refine ::StringIO do
8
+ include IO::Instance::Readline::Method
9
+ end
10
+
11
+ def self.included(base)
12
+ base.include IO::Instance::Readline::Method
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ module Polyfill
2
+ module V2_4
3
+ module StringIO
4
+ module Instance
5
+ module Readlines
6
+ if RUBY_VERSION < '2.4.0'
7
+ refine ::StringIO do
8
+ include IO::Instance::Readlines::Method
9
+ end
10
+
11
+ def self.included(base)
12
+ base.include IO::Instance::Readlines::Method
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,3 +1,3 @@
1
1
  module Polyfill
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '0.3.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polyfill
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Lasseigne
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-17 00:00:00.000000000 Z
11
+ date: 2017-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -73,33 +73,62 @@ files:
73
73
  - lib/polyfill.rb
74
74
  - lib/polyfill/v2_4.rb
75
75
  - lib/polyfill/v2_4/array.rb
76
- - lib/polyfill/v2_4/array/concat.rb
76
+ - lib/polyfill/v2_4/array/instance.rb
77
+ - lib/polyfill/v2_4/array/instance/concat.rb
77
78
  - lib/polyfill/v2_4/comparable.rb
78
- - lib/polyfill/v2_4/comparable/clamp.rb
79
+ - lib/polyfill/v2_4/comparable/instance.rb
80
+ - lib/polyfill/v2_4/comparable/instance/clamp.rb
81
+ - lib/polyfill/v2_4/dir.rb
82
+ - lib/polyfill/v2_4/dir/class.rb
83
+ - lib/polyfill/v2_4/dir/class/empty_q.rb
84
+ - lib/polyfill/v2_4/file.rb
85
+ - lib/polyfill/v2_4/file/class.rb
86
+ - lib/polyfill/v2_4/file/class/empty_q.rb
79
87
  - lib/polyfill/v2_4/float.rb
80
- - lib/polyfill/v2_4/float/ceil.rb
81
- - lib/polyfill/v2_4/float/floor.rb
82
- - lib/polyfill/v2_4/float/truncate.rb
88
+ - lib/polyfill/v2_4/float/instance.rb
89
+ - lib/polyfill/v2_4/float/instance/ceil.rb
90
+ - lib/polyfill/v2_4/float/instance/floor.rb
91
+ - lib/polyfill/v2_4/float/instance/truncate.rb
83
92
  - lib/polyfill/v2_4/hash.rb
84
- - lib/polyfill/v2_4/hash/compact.rb
85
- - lib/polyfill/v2_4/hash/compact_e.rb
86
- - lib/polyfill/v2_4/hash/transform_values.rb
87
- - lib/polyfill/v2_4/hash/transform_values_e.rb
93
+ - lib/polyfill/v2_4/hash/instance.rb
94
+ - lib/polyfill/v2_4/hash/instance/compact.rb
95
+ - lib/polyfill/v2_4/hash/instance/compact_e.rb
96
+ - lib/polyfill/v2_4/hash/instance/transform_values.rb
97
+ - lib/polyfill/v2_4/hash/instance/transform_values_e.rb
88
98
  - lib/polyfill/v2_4/integer.rb
89
- - lib/polyfill/v2_4/integer/ceil.rb
90
- - lib/polyfill/v2_4/integer/digits.rb
91
- - lib/polyfill/v2_4/integer/floor.rb
92
- - lib/polyfill/v2_4/integer/round.rb
93
- - lib/polyfill/v2_4/integer/truncate.rb
99
+ - lib/polyfill/v2_4/integer/instance.rb
100
+ - lib/polyfill/v2_4/integer/instance/ceil.rb
101
+ - lib/polyfill/v2_4/integer/instance/digits.rb
102
+ - lib/polyfill/v2_4/integer/instance/floor.rb
103
+ - lib/polyfill/v2_4/integer/instance/round.rb
104
+ - lib/polyfill/v2_4/integer/instance/truncate.rb
105
+ - lib/polyfill/v2_4/io.rb
106
+ - lib/polyfill/v2_4/io/class.rb
107
+ - lib/polyfill/v2_4/io/class/foreach.rb
108
+ - lib/polyfill/v2_4/io/class/readlines.rb
109
+ - lib/polyfill/v2_4/io/instance.rb
110
+ - lib/polyfill/v2_4/io/instance/each_line.rb
111
+ - lib/polyfill/v2_4/io/instance/gets.rb
112
+ - lib/polyfill/v2_4/io/instance/readline.rb
113
+ - lib/polyfill/v2_4/io/instance/readlines.rb
94
114
  - lib/polyfill/v2_4/match_data.rb
95
- - lib/polyfill/v2_4/match_data/named_captures.rb
96
- - lib/polyfill/v2_4/match_data/values_at.rb
115
+ - lib/polyfill/v2_4/match_data/instance.rb
116
+ - lib/polyfill/v2_4/match_data/instance/named_captures.rb
117
+ - lib/polyfill/v2_4/match_data/instance/values_at.rb
97
118
  - lib/polyfill/v2_4/numeric.rb
98
- - lib/polyfill/v2_4/numeric/finite_q.rb
99
- - lib/polyfill/v2_4/numeric/infinite_q.rb
119
+ - lib/polyfill/v2_4/numeric/instance.rb
120
+ - lib/polyfill/v2_4/numeric/instance/finite_q.rb
121
+ - lib/polyfill/v2_4/numeric/instance/infinite_q.rb
100
122
  - lib/polyfill/v2_4/string.rb
101
- - lib/polyfill/v2_4/string/concat.rb
102
- - lib/polyfill/v2_4/string/prepend.rb
123
+ - lib/polyfill/v2_4/string/instance.rb
124
+ - lib/polyfill/v2_4/string/instance/concat.rb
125
+ - lib/polyfill/v2_4/string/instance/prepend.rb
126
+ - lib/polyfill/v2_4/string_io.rb
127
+ - lib/polyfill/v2_4/string_io/instance.rb
128
+ - lib/polyfill/v2_4/string_io/instance/each_line.rb
129
+ - lib/polyfill/v2_4/string_io/instance/gets.rb
130
+ - lib/polyfill/v2_4/string_io/instance/readline.rb
131
+ - lib/polyfill/v2_4/string_io/instance/readlines.rb
103
132
  - lib/polyfill/version.rb
104
133
  - polyfill.gemspec
105
134
  homepage: ''