polyfill 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +37 -0
- data/README.md +14 -13
- data/lib/polyfill/v2_4.rb +4 -0
- data/lib/polyfill/v2_4/array/concat.rb +4 -2
- data/lib/polyfill/v2_4/comparable/clamp.rb +10 -14
- data/lib/polyfill/v2_4/float/ceil.rb +4 -2
- data/lib/polyfill/v2_4/float/floor.rb +4 -2
- data/lib/polyfill/v2_4/float/truncate.rb +4 -2
- data/lib/polyfill/v2_4/hash.rb +15 -0
- data/lib/polyfill/v2_4/hash/compact.rb +19 -0
- data/lib/polyfill/v2_4/hash/compact_e.rb +19 -0
- data/lib/polyfill/v2_4/hash/transform_values.rb +29 -0
- data/lib/polyfill/v2_4/hash/transform_values_e.rb +29 -0
- data/lib/polyfill/v2_4/integer/ceil.rb +4 -2
- data/lib/polyfill/v2_4/integer/digits.rb +4 -8
- data/lib/polyfill/v2_4/integer/floor.rb +4 -2
- data/lib/polyfill/v2_4/integer/round.rb +4 -2
- data/lib/polyfill/v2_4/integer/truncate.rb +4 -2
- data/lib/polyfill/v2_4/match_data.rb +11 -0
- data/lib/polyfill/v2_4/match_data/named_captures.rb +21 -0
- data/lib/polyfill/v2_4/match_data/values_at.rb +21 -0
- data/lib/polyfill/v2_4/numeric.rb +4 -4
- data/lib/polyfill/v2_4/numeric/finite_q.rb +19 -0
- data/lib/polyfill/v2_4/numeric/infinite_q.rb +19 -0
- data/lib/polyfill/v2_4/string/concat.rb +4 -2
- data/lib/polyfill/v2_4/string/prepend.rb +4 -2
- data/lib/polyfill/version.rb +1 -1
- metadata +13 -4
- data/lib/polyfill/v2_4/numeric/finite__q.rb +0 -23
- data/lib/polyfill/v2_4/numeric/infinite__q.rb +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d536c32a25db0ccb7bbbe70e7e921c35a97d95f
|
4
|
+
data.tar.gz: e8b0d4bf4c7ece75a844065d2407ce761e093564
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4eb22154fb993d183068e2f8a7345b05a298b040d6911c2c4dbf71fbe5c524b505a2074067012d8d87b8afb90e83c50673a59b094a4c437058509c49fc98dca6
|
7
|
+
data.tar.gz: f2bacc5168680b5fa4a3b4a4c29d7e83cc8467d45fc4e78b9f551161ea0f898f72c8aa8a6e97f0e2951cf3516a6cf5dbafe5105bdea638c4fec2a71981171ad3
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# [0.2.0][]
|
2
|
+
|
3
|
+
## Added
|
4
|
+
|
5
|
+
- v2.4 MatchData#named_captures
|
6
|
+
- v2.4 MatchData#values_at
|
7
|
+
- v2.4 Hash#compact
|
8
|
+
- v2.4 Hash#compact!
|
9
|
+
- v2.4 Hash#transform_values
|
10
|
+
- v2.4 Hash#transform_values!
|
11
|
+
|
12
|
+
## Changes
|
13
|
+
|
14
|
+
- Modules are camel case instead of only uppercasing the first letter of the method name.
|
15
|
+
- Modules for predicate methods now end with `Q` instead of `__Q`.
|
16
|
+
- Modules for dangerous methods now end with `E` instead of `__E`.
|
17
|
+
- Methods will no longer attempt to fix `#respond_to?`, `#methods`, or `.instance_methods`. This will be revisited later with a more comprehensive solution.
|
18
|
+
|
19
|
+
# [0.1.0][] (2017-03-14)
|
20
|
+
|
21
|
+
- v2.4 Array#concat
|
22
|
+
- v2.4 Comparable#clamp
|
23
|
+
- v2.4 Float#ceil
|
24
|
+
- v2.4 Float#floor
|
25
|
+
- v2.4 Float#truncate
|
26
|
+
- v2.4 Integer#ceil
|
27
|
+
- v2.4 Integer#digits
|
28
|
+
- v2.4 Integer#floor
|
29
|
+
- v2.4 Integer#round
|
30
|
+
- v2.4 Integer#truncate
|
31
|
+
- v2.4 Numeric#finite?
|
32
|
+
- v2.4 Numeric#infinite?
|
33
|
+
- v2.4 String#concat?
|
34
|
+
- v2.4 String#prepend?
|
35
|
+
|
36
|
+
[0.2.0]: https://github.com/AaronLasseigne/polyfill/compare/v0.1.0...v0.2.0
|
37
|
+
[0.1.0]: https://github.com/AaronLasseigne/polyfill/compare/v0.0.0...v0.1.0
|
data/README.md
CHANGED
@@ -32,7 +32,7 @@ See the [implementation table](#implementation-table) for specifics about what h
|
|
32
32
|
Add it to your Gemfile:
|
33
33
|
|
34
34
|
```ruby
|
35
|
-
gem 'polyfill', '0.
|
35
|
+
gem 'polyfill', '0.2.0'
|
36
36
|
```
|
37
37
|
|
38
38
|
Or install it manually:
|
@@ -70,15 +70,16 @@ using Polyfill::V2_4::Array
|
|
70
70
|
using Polyfill::V2_4::String
|
71
71
|
```
|
72
72
|
|
73
|
-
To use a particular method, we can add it after the object. The
|
74
|
-
|
75
|
-
have their question converted to a `
|
76
|
-
exclamation mark) have their exclamation replaced with `
|
73
|
+
To use a particular method, we can add it after the object. The method is
|
74
|
+
converted to camel case. Predicate methods (ending with a question mark)
|
75
|
+
have their question converted to a `Q`. Dangerous methods (ending with an
|
76
|
+
exclamation mark) have their exclamation replaced with `E`.
|
77
77
|
|
78
78
|
```ruby
|
79
79
|
using Polyfill::V2_4::Array::Concat
|
80
|
-
using Polyfill::V2_4::Dir::
|
81
|
-
using Polyfill::V2_4::Hash::
|
80
|
+
using Polyfill::V2_4::Dir::EmptyQ # :empty?
|
81
|
+
using Polyfill::V2_4::Hash::CompactE # :compact!
|
82
|
+
using Polyfill::V2_4::Hash::TransformValues # :transform_values!
|
82
83
|
```
|
83
84
|
|
84
85
|
Any method can be accessed as a stand-alone module by adding `Method` to
|
@@ -119,10 +120,10 @@ method is only defined if the Ruby version requires it.
|
|
119
120
|
| | #floor | Yes |
|
120
121
|
| | #round | No |
|
121
122
|
| | #truncate | Yes |
|
122
|
-
| Hash | #compact |
|
123
|
-
| | #compact! |
|
124
|
-
| | #transform_values |
|
125
|
-
| | #transform_values! |
|
123
|
+
| Hash | #compact | Yes |
|
124
|
+
| | #compact! | Yes |
|
125
|
+
| | #transform_values | Yes |
|
126
|
+
| | #transform_values! | Yes |
|
126
127
|
| Integer | #ceil | Yes |
|
127
128
|
| | #digits | Yes |
|
128
129
|
| | #floor | Yes |
|
@@ -134,8 +135,8 @@ method is only defined if the Ruby version requires it.
|
|
134
135
|
| | #readline | No |
|
135
136
|
| | #readlines | No |
|
136
137
|
| Kernel | #clone | No |
|
137
|
-
| MatchData | #named_captures |
|
138
|
-
| | #values_at |
|
138
|
+
| MatchData | #named_captures | Yes |
|
139
|
+
| | #values_at | Yes |
|
139
140
|
| Module | #refine | No |
|
140
141
|
| | .used_modules | No |
|
141
142
|
| Numeric | #finite? | Yes |
|
data/lib/polyfill/v2_4.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'polyfill/v2_4/array'
|
2
2
|
require 'polyfill/v2_4/comparable'
|
3
3
|
require 'polyfill/v2_4/float'
|
4
|
+
require 'polyfill/v2_4/hash'
|
4
5
|
require 'polyfill/v2_4/integer'
|
6
|
+
require 'polyfill/v2_4/match_data'
|
5
7
|
require 'polyfill/v2_4/numeric'
|
6
8
|
require 'polyfill/v2_4/string'
|
7
9
|
|
@@ -10,7 +12,9 @@ module Polyfill
|
|
10
12
|
include Array
|
11
13
|
include Comparable
|
12
14
|
include Float
|
15
|
+
include Hash
|
13
16
|
include Integer
|
17
|
+
include MatchData
|
14
18
|
include Numeric
|
15
19
|
include String
|
16
20
|
end
|
@@ -12,22 +12,18 @@ module Polyfill
|
|
12
12
|
return max if max < self
|
13
13
|
self
|
14
14
|
end if RUBY_VERSION < '2.4.0'
|
15
|
-
|
16
|
-
def respond_to?(method, *)
|
17
|
-
return true if method.to_sym == :clamp
|
18
|
-
|
19
|
-
super
|
20
|
-
end if RUBY_VERSION < '2.4.0'
|
21
15
|
end
|
22
16
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
17
|
+
if RUBY_VERSION < '2.4.0'
|
18
|
+
refine ::Numeric do
|
19
|
+
include Method
|
20
|
+
end
|
21
|
+
refine ::String do
|
22
|
+
include Method
|
23
|
+
end
|
24
|
+
refine ::Time do
|
25
|
+
include Method
|
26
|
+
end
|
31
27
|
end
|
32
28
|
end
|
33
29
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'polyfill/v2_4/hash/compact'
|
2
|
+
require 'polyfill/v2_4/hash/compact_e'
|
3
|
+
require 'polyfill/v2_4/hash/transform_values'
|
4
|
+
require 'polyfill/v2_4/hash/transform_values_e'
|
5
|
+
|
6
|
+
module Polyfill
|
7
|
+
module V2_4
|
8
|
+
module Hash
|
9
|
+
include Compact
|
10
|
+
include CompactE
|
11
|
+
include TransformValues
|
12
|
+
include TransformValuesE
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Polyfill
|
2
|
+
module V2_4
|
3
|
+
module Hash
|
4
|
+
module Compact
|
5
|
+
module Method
|
6
|
+
def compact
|
7
|
+
reject { |_, v| v.nil? }
|
8
|
+
end if RUBY_VERSION < '2.4.0'
|
9
|
+
end
|
10
|
+
|
11
|
+
if RUBY_VERSION < '2.4.0'
|
12
|
+
refine ::Hash do
|
13
|
+
include Method
|
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 Hash
|
4
|
+
module CompactE
|
5
|
+
module Method
|
6
|
+
def compact!
|
7
|
+
reject! { |_, v| v.nil? }
|
8
|
+
end if RUBY_VERSION < '2.4.0'
|
9
|
+
end
|
10
|
+
|
11
|
+
if RUBY_VERSION < '2.4.0'
|
12
|
+
refine ::Hash do
|
13
|
+
include Method
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Polyfill
|
2
|
+
module V2_4
|
3
|
+
module Hash
|
4
|
+
module TransformValues
|
5
|
+
module Method
|
6
|
+
def transform_values
|
7
|
+
unless block_given?
|
8
|
+
return Enumerator.new(keys.size) do |yielder|
|
9
|
+
each_with_object({}) do |(k, v), acc|
|
10
|
+
acc[k] = yielder.yield(v)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
each_with_object({}) do |(k, v), acc|
|
16
|
+
acc[k] = yield(v)
|
17
|
+
end
|
18
|
+
end if RUBY_VERSION < '2.4.0'
|
19
|
+
end
|
20
|
+
|
21
|
+
if RUBY_VERSION < '2.4.0'
|
22
|
+
refine ::Hash do
|
23
|
+
include Method
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Polyfill
|
2
|
+
module V2_4
|
3
|
+
module Hash
|
4
|
+
module TransformValuesE
|
5
|
+
module Method
|
6
|
+
def transform_values!
|
7
|
+
unless block_given?
|
8
|
+
return Enumerator.new(keys.size) do |yielder|
|
9
|
+
replace(each_with_object({}) do |(k, v), acc|
|
10
|
+
acc[k] = yielder.yield(v)
|
11
|
+
end)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
replace(each_with_object({}) do |(k, v), acc|
|
16
|
+
acc[k] = yield(v)
|
17
|
+
end)
|
18
|
+
end if RUBY_VERSION < '2.4.0'
|
19
|
+
end
|
20
|
+
|
21
|
+
if RUBY_VERSION < '2.4.0'
|
22
|
+
refine ::Hash do
|
23
|
+
include Method
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -17,16 +17,12 @@ module Polyfill
|
|
17
17
|
end
|
18
18
|
acc
|
19
19
|
end if RUBY_VERSION < '2.4.0'
|
20
|
-
|
21
|
-
def respond_to?(method, *)
|
22
|
-
return true if method.to_sym == :digits
|
23
|
-
|
24
|
-
super
|
25
|
-
end if RUBY_VERSION < '2.4.0'
|
26
20
|
end
|
27
21
|
|
28
|
-
|
29
|
-
|
22
|
+
if RUBY_VERSION < '2.4.0'
|
23
|
+
refine ::Integer do
|
24
|
+
include Method
|
25
|
+
end
|
30
26
|
end
|
31
27
|
end
|
32
28
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Polyfill
|
2
|
+
module V2_4
|
3
|
+
module MatchData
|
4
|
+
module NamedCaptures
|
5
|
+
module Method
|
6
|
+
def named_captures
|
7
|
+
names.each_with_object({}) do |name, acc|
|
8
|
+
acc[name] = self[name]
|
9
|
+
end
|
10
|
+
end if RUBY_VERSION < '2.4.0'
|
11
|
+
end
|
12
|
+
|
13
|
+
if RUBY_VERSION < '2.4.0'
|
14
|
+
refine ::MatchData do
|
15
|
+
include Method
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Polyfill
|
2
|
+
module V2_4
|
3
|
+
module MatchData
|
4
|
+
module ValuesAt
|
5
|
+
module Method
|
6
|
+
def values_at(*indexes)
|
7
|
+
indexes.each_with_object([]) do |index, acc|
|
8
|
+
acc.push(self[index])
|
9
|
+
end
|
10
|
+
end if RUBY_VERSION < '2.4.0'
|
11
|
+
end
|
12
|
+
|
13
|
+
if RUBY_VERSION < '2.4.0'
|
14
|
+
refine ::MatchData do
|
15
|
+
include Method
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
require 'polyfill/v2_4/numeric/
|
2
|
-
require 'polyfill/v2_4/numeric/
|
1
|
+
require 'polyfill/v2_4/numeric/finite_q'
|
2
|
+
require 'polyfill/v2_4/numeric/infinite_q'
|
3
3
|
|
4
4
|
module Polyfill
|
5
5
|
module V2_4
|
6
6
|
module Numeric
|
7
|
-
include
|
8
|
-
include
|
7
|
+
include FiniteQ
|
8
|
+
include InfiniteQ
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Polyfill
|
2
|
+
module V2_4
|
3
|
+
module Numeric
|
4
|
+
module FiniteQ
|
5
|
+
module Method
|
6
|
+
def finite?
|
7
|
+
true
|
8
|
+
end if RUBY_VERSION < '2.4.0'
|
9
|
+
end
|
10
|
+
|
11
|
+
if RUBY_VERSION < '2.4.0'
|
12
|
+
refine ::Numeric do
|
13
|
+
include Method
|
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 Numeric
|
4
|
+
module InfiniteQ
|
5
|
+
module Method
|
6
|
+
def infinite?
|
7
|
+
nil
|
8
|
+
end if RUBY_VERSION < '2.4.0'
|
9
|
+
end
|
10
|
+
|
11
|
+
if RUBY_VERSION < '2.4.0'
|
12
|
+
refine ::Numeric do
|
13
|
+
include Method
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/polyfill/version.rb
CHANGED
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.
|
4
|
+
version: 0.2.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-
|
11
|
+
date: 2017-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -62,6 +62,7 @@ files:
|
|
62
62
|
- ".gitignore"
|
63
63
|
- ".rspec"
|
64
64
|
- ".travis.yml"
|
65
|
+
- CHANGELOG.md
|
65
66
|
- CONTRIBUTING.md
|
66
67
|
- Gemfile
|
67
68
|
- LICENSE.txt
|
@@ -79,15 +80,23 @@ files:
|
|
79
80
|
- lib/polyfill/v2_4/float/ceil.rb
|
80
81
|
- lib/polyfill/v2_4/float/floor.rb
|
81
82
|
- lib/polyfill/v2_4/float/truncate.rb
|
83
|
+
- 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
|
82
88
|
- lib/polyfill/v2_4/integer.rb
|
83
89
|
- lib/polyfill/v2_4/integer/ceil.rb
|
84
90
|
- lib/polyfill/v2_4/integer/digits.rb
|
85
91
|
- lib/polyfill/v2_4/integer/floor.rb
|
86
92
|
- lib/polyfill/v2_4/integer/round.rb
|
87
93
|
- lib/polyfill/v2_4/integer/truncate.rb
|
94
|
+
- 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
|
88
97
|
- lib/polyfill/v2_4/numeric.rb
|
89
|
-
- lib/polyfill/v2_4/numeric/
|
90
|
-
- lib/polyfill/v2_4/numeric/
|
98
|
+
- lib/polyfill/v2_4/numeric/finite_q.rb
|
99
|
+
- lib/polyfill/v2_4/numeric/infinite_q.rb
|
91
100
|
- lib/polyfill/v2_4/string.rb
|
92
101
|
- lib/polyfill/v2_4/string/concat.rb
|
93
102
|
- lib/polyfill/v2_4/string/prepend.rb
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module Polyfill
|
2
|
-
module V2_4
|
3
|
-
module Numeric
|
4
|
-
module Finite__Q
|
5
|
-
module Method
|
6
|
-
def finite?
|
7
|
-
true
|
8
|
-
end if RUBY_VERSION < '2.4.0'
|
9
|
-
|
10
|
-
def respond_to?(method, *)
|
11
|
-
return true if method.to_sym == :finite?
|
12
|
-
|
13
|
-
super
|
14
|
-
end if RUBY_VERSION < '2.4.0'
|
15
|
-
end
|
16
|
-
|
17
|
-
refine ::Numeric do
|
18
|
-
include Method
|
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 Infinite__Q
|
5
|
-
module Method
|
6
|
-
def infinite?
|
7
|
-
nil
|
8
|
-
end if RUBY_VERSION < '2.4.0'
|
9
|
-
|
10
|
-
def respond_to?(method, *)
|
11
|
-
return true if method.to_sym == :infinite?
|
12
|
-
|
13
|
-
super
|
14
|
-
end if RUBY_VERSION < '2.4.0'
|
15
|
-
end
|
16
|
-
|
17
|
-
refine ::Numeric do
|
18
|
-
include Method
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|