polyfill 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.travis.yml +2 -1
- data/CHANGELOG.md +41 -0
- data/CONTRIBUTING.md +2 -1
- data/README.md +363 -248
- data/lib/polyfill.rb +1 -0
- data/lib/polyfill/internal_utils.rb +20 -1
- data/lib/polyfill/v2_3/hash.rb +9 -8
- data/lib/polyfill/v2_4/array.rb +1 -1
- data/lib/polyfill/v2_4/enumerable.rb +1 -1
- data/lib/polyfill/v2_4/enumerator/lazy.rb +1 -1
- data/lib/polyfill/v2_4/float.rb +3 -3
- data/lib/polyfill/v2_4/integer.rb +5 -5
- data/lib/polyfill/v2_4/string.rb +1 -1
- data/lib/polyfill/v2_5.rb +9 -0
- data/lib/polyfill/v2_5/hash.rb +25 -0
- data/lib/polyfill/v2_5/integer.rb +36 -0
- data/lib/polyfill/v2_5/kernel.rb +15 -0
- data/lib/polyfill/v2_5/string.rb +43 -0
- data/lib/polyfill/version.rb +1 -1
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b139f1e058fce855365397a2bbe902b2092da2a3a6e64e9326d6d136487a2e31
|
4
|
+
data.tar.gz: e58e5b7b5ed9ee95375abfdc9f959730fbb4e900df86f5db11017a4241212a71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 314f9d7bdd0385f0fb2682b9f4b1a2a2d30b967ee454a91c77aeeeeef651600a38a42642cc83b01c25197b7ae3e6180cbe91b45e7ebdf37713e9c305cfd0c384
|
7
|
+
data.tar.gz: 4bf25f12ca82bb158353cc89994c46f04e0f183ba39e43c063d3195c7b5f486b00182912760daa4f6f5812d6f45ee6d282f03dac6a0cdc7e906aa428d035122a
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,43 @@
|
|
1
|
+
# Master
|
2
|
+
|
3
|
+
# [1.1.0][] (2018-02-23)
|
4
|
+
|
5
|
+
## Added
|
6
|
+
|
7
|
+
- The verison now uses Gem::Version for easier comparisons
|
8
|
+
- v2.5 Integer#allbits?
|
9
|
+
- v2.5 Integer#anybits?
|
10
|
+
- v2.5 Integer#ceil
|
11
|
+
- v2.5 Integer#floor
|
12
|
+
- v2.5 Integer#nobits?
|
13
|
+
- v2.5 Integer#round
|
14
|
+
- v2.5 Integer#truncate
|
15
|
+
- v2.5 Hash#slice
|
16
|
+
- v2.5 Hash#transform_keys
|
17
|
+
- v2.5 Kernel#yield_self
|
18
|
+
- v2.5 String#casecmp
|
19
|
+
- v2.5 String#casecmp?
|
20
|
+
- v2.5 String#delete_prefix
|
21
|
+
- v2.5 String#delete_prefix!
|
22
|
+
- v2.5 String#delete_suffix
|
23
|
+
- v2.5 String#delete_suffix!
|
24
|
+
- v2.5 String#start_with?
|
25
|
+
|
26
|
+
## Fixed
|
27
|
+
|
28
|
+
The following threw a `NoMethodError` instead of a `TypeError` when an
|
29
|
+
incorrect type was passed:
|
30
|
+
|
31
|
+
- v2.4 Float#ceil
|
32
|
+
- v2.4 Float#floor
|
33
|
+
- v2.4 Float#truncate
|
34
|
+
- v2.4 Integer#ceil
|
35
|
+
- v2.4 Integer#digits
|
36
|
+
- v2.4 Integer#floor
|
37
|
+
- v2.4 Integer#round
|
38
|
+
- v2.4 Integer#truncate
|
39
|
+
- v2.4 String#casecmp?
|
40
|
+
|
1
41
|
# [1.0.1][] (2017-06-03)
|
2
42
|
|
3
43
|
## Fixed
|
@@ -174,6 +214,7 @@
|
|
174
214
|
- v2.4 String#concat?
|
175
215
|
- v2.4 String#prepend?
|
176
216
|
|
217
|
+
[1.1.0]: https://github.com/AaronLasseigne/polyfill/compare/v1.0.1...v1.1.0
|
177
218
|
[1.0.1]: https://github.com/AaronLasseigne/polyfill/compare/v1.0.0...v1.0.1
|
178
219
|
[1.0.0]: https://github.com/AaronLasseigne/polyfill/compare/v0.10.0...v1.0.0
|
179
220
|
[0.10.0]: https://github.com/AaronLasseigne/polyfill/compare/v0.9.0...v0.10.0
|
data/CONTRIBUTING.md
CHANGED
@@ -9,7 +9,8 @@ please add it to the documentation.
|
|
9
9
|
|
10
10
|
A list of changes can be found at:
|
11
11
|
|
12
|
-
* https://raw.githubusercontent.com/ruby/ruby/
|
12
|
+
* https://raw.githubusercontent.com/ruby/ruby/v2_5_0/NEWS
|
13
|
+
* https://raw.githubusercontent.com/ruby/ruby/v2_4_2/NEWS
|
13
14
|
* https://raw.githubusercontent.com/ruby/ruby/v2_3_4/NEWS
|
14
15
|
* https://raw.githubusercontent.com/ruby/ruby/v2_2_7/NEWS
|
15
16
|
|
data/README.md
CHANGED
@@ -17,6 +17,7 @@ monkey patching** that may cause issues outside of your use.
|
|
17
17
|
- [Polyfill](#polyfill-1)
|
18
18
|
- [Polyfill.get](#polyfillget)
|
19
19
|
- [Implementation Table](#implementation-table)
|
20
|
+
- [2.5](#25)
|
20
21
|
- [2.4](#24)
|
21
22
|
- [2.3](#23)
|
22
23
|
- [2.2](#22)
|
@@ -26,7 +27,7 @@ monkey patching** that may cause issues outside of your use.
|
|
26
27
|
Add it to your Gemfile:
|
27
28
|
|
28
29
|
```ruby
|
29
|
-
gem 'polyfill', '~> 1.
|
30
|
+
gem 'polyfill', '~> 1.1'
|
30
31
|
```
|
31
32
|
|
32
33
|
Or install it manually:
|
@@ -39,7 +40,7 @@ This project uses [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
39
40
|
|
40
41
|
## Goals
|
41
42
|
|
42
|
-
1. Features should ideally mimic the true behavior (
|
43
|
+
1. Features should ideally mimic the true behavior (quirks, error messages, etc).
|
43
44
|
2. Features should not significantly burden the runtime.
|
44
45
|
3. Keep everything modular so users can be specific or broad in their usage.
|
45
46
|
|
@@ -119,260 +120,374 @@ end
|
|
119
120
|
|
120
121
|
## Implementation Table
|
121
122
|
|
123
|
+
✓ = Implemented, ✗ = Not Implemented, P = Partially Implemented
|
124
|
+
|
125
|
+
Partial implemented features will be explained in the "Changes" section of the
|
126
|
+
table. The explanation will follow "**Differences:**".
|
127
|
+
|
128
|
+
### 2.5
|
129
|
+
|
130
|
+
Attempting to modify frozen objects now throws `FrozenError` instead of
|
131
|
+
`RuntimeError`. Methods where this change occurred are not listed below even
|
132
|
+
though they have techically changed. `FrozenError` is a subclass of
|
133
|
+
`RuntimeError` so it is safe to continue rescuing `RuntimeError` if needed.
|
134
|
+
|
135
|
+
| | Object | Method | Changes |
|
136
|
+
|:-:| ---------------- | ------------------------ | ------- |
|
137
|
+
| ✗ | Array | #append | New (alias for `push`)
|
138
|
+
| ✗ | | #prepend | New (alias for `unshift`)
|
139
|
+
| ✗ | BigDecimal | #clone | Returns the receiver itself instead of making a new instance.
|
140
|
+
| ✗ | | #dup | Returns the receiver itself instead of making a new instance.
|
141
|
+
| ✗ | Dir | .children | New
|
142
|
+
| ✗ | | .each_child | New
|
143
|
+
| ✗ | | #glob | Accepts a new optional keyword argument, `:base`.
|
144
|
+
| ✗ | Enumerable | #any? | Accepts a pattern argument.
|
145
|
+
| ✗ | | #all? | Accepts a pattern argument.
|
146
|
+
| ✗ | | #none? | Accepts a pattern argument.
|
147
|
+
| ✗ | | #one? | Accepts a pattern argument.
|
148
|
+
| ✗ | ERB | .result_with_hash | New
|
149
|
+
| ✗ | Exception | #full_message | New
|
150
|
+
| ✗ | File | .identical? | Support ReFS 128bit ino on Windows 8.1 and later.
|
151
|
+
| ✗ | | .lutime | New
|
152
|
+
| ✗ | | .open | Accepts a new optional keyword argument, `:newline`.
|
153
|
+
| ✗ | | #path | Raises an `IOError` for files opened with `File::Constants::TMPFILE` option.
|
154
|
+
| ✗ | File::Stat | #atime | Support fractional second timestamps on Windows 8 and later.
|
155
|
+
| ✗ | | #ctime | Support fractional second timestamps on Windows 8 and later.
|
156
|
+
| ✗ | | #ino | Support ReFS 128bit ino on Windows 8.1 and later.
|
157
|
+
| ✗ | | #mtime | Support fractional second timestamps on Windows 8 and later.
|
158
|
+
| ✓ | Hash | #slice | New
|
159
|
+
| ✓ | | #transform_keys | New
|
160
|
+
| ✗ | | #transform_keys! | New
|
161
|
+
| ✓ | Integer | #allbits? | New
|
162
|
+
| ✓ | | #anybits? | New
|
163
|
+
| ✓ | | #ceil | Always return an Integer.
|
164
|
+
| ✓ | | #floor | Always return an Integer.
|
165
|
+
| ✓ | | #nobits? | New
|
166
|
+
| ✗ | | #pow | Same as `**` but it accepts an optional modulo argument for calculating modular exponentiation.
|
167
|
+
| ✓ | | #round | Always return an Integer.
|
168
|
+
| ✗ | | .sqrt | New
|
169
|
+
| ✓ | | #truncate | Always return an Integer.
|
170
|
+
| ✗ | IO | #pread | New
|
171
|
+
| ✗ | | #pwrite | New
|
172
|
+
| ✗ | | #write | Accepts multiple arguments.
|
173
|
+
| ✗ | IOError | #close | Instead of raising an error with the message "stream closed", the message will be "stream closed in another thread".
|
174
|
+
| ✗ | IPAddr | #link_local? | New
|
175
|
+
| ✗ | | #loopback? | New
|
176
|
+
| ✗ | | .new | No longer accepts an invalid address mask.
|
177
|
+
| ✗ | | #prefix? | New
|
178
|
+
| ✗ | | #private? | New
|
179
|
+
| ✓ | Kernel | #yield_self | New
|
180
|
+
| ✗ | | #pp | New
|
181
|
+
| ✗ | | #warn | Accepts a new optional keyword argument, `:uplevel`.
|
182
|
+
| ✗ | KeyError | #key | New
|
183
|
+
| ✗ | | #receiver | New
|
184
|
+
| ✗ | Matrix | .combine | New
|
185
|
+
| ✗ | | #combine | New
|
186
|
+
| ✗ | | #entrywise_product | New
|
187
|
+
| ✗ | | #hadamard_product | New
|
188
|
+
| ✗ | Method | #=== | New
|
189
|
+
| ✗ | Module | #attr | Is now public.
|
190
|
+
| ✗ | | #attr_accessor | Is now public.
|
191
|
+
| ✗ | | #attr_reader | Is now public.
|
192
|
+
| ✗ | | #attr_writer | Is now public.
|
193
|
+
| ✗ | | #alias_method | Is now public.
|
194
|
+
| ✗ | | #define_method | Is now public.
|
195
|
+
| ✗ | | #remove_method | Is now public.
|
196
|
+
| ✗ | | #undef_method | Is now public.
|
197
|
+
| ✗ | Net::HTTP | #max_version | New
|
198
|
+
| ✗ | | #min_version | New
|
199
|
+
| ✗ | | .new | Accepts a new optional keyword argument, `:no_proxy`.
|
200
|
+
| ✗ | | #proxy_pass | Reflects the http_proxy environment variable if the system's environment variable is multiuser safe.
|
201
|
+
| ✗ | | #proxy_user | Reflects the http_proxy environment variable if the system's environment variable is multiuser safe.
|
202
|
+
| ✗ | Numeric | #< | No longer hide exceptions from `#coerce` and will return `nil` if coercion is impossible.
|
203
|
+
| ✗ | | #<= | No longer hide exceptions from `#coerce` and will return `nil` if coercion is impossible.
|
204
|
+
| ✗ | | #> | No longer hide exceptions from `#coerce` and will return `nil` if coercion is impossible.
|
205
|
+
| ✗ | | #>= | No longer hide exceptions from `#coerce` and will return `nil` if coercion is impossible.
|
206
|
+
| ✗ | | #step | No longer hides errors from coerce method when given a step value which cannot be compared with #> to 0.
|
207
|
+
| ✗ | Pathname | #glob | New
|
208
|
+
| ✗ | Process | .last_status | New (alias of `$?`)
|
209
|
+
| ✗ | | .times | Precision is improved if getrusage(2) exists.
|
210
|
+
| ✗ | Range | .initialize | No longer hides exceptions when comparing begin and end with `<=>` and raise a "bad value for range" `ArgumentError` but instead lets the exception from the `<=>` call go through.
|
211
|
+
| ✗ | Random | #urandom | Renamed from `raw_seed`.
|
212
|
+
| ✗ | SecureRandom | .alphanumeric | New
|
213
|
+
| ✗ | Set | #=== | New (alias of `include?`)
|
214
|
+
| ✗ | | #reset | New
|
215
|
+
| ✗ | | #to_s | New (alias of `inspect`)
|
216
|
+
| ✓ | String | #casecmp | Returns `nil` for non-string arguments instead of raising a `TypeError`.
|
217
|
+
| ✓ | | #casecmp? | Returns `nil` for non-string arguments instead of raising a `TypeError`.
|
218
|
+
| ✓ | | #delete_prefix | New
|
219
|
+
| P | | #delete_prefix! | New **Differences:** Throws `RuntimeError` instead of `FrozenError` when attempting to modify a frozen string.
|
220
|
+
| ✓ | | #delete_suffix | New (alias of `chomp`)
|
221
|
+
| P | | #delete_suffix! | New (alias of `chomp!`) **Differences:** Throws `RuntimeError` instead of `FrozenError` when attempting to modify a frozen string.
|
222
|
+
| ✗ | | #each_grapheme_cluster | New
|
223
|
+
| ✗ | | #grapheme_clusters | New
|
224
|
+
| P | | #start_with? | Accepts regular expression arguments. **Differences:** Does not set `Regexp` globals.
|
225
|
+
| ✗ | | #undump | New
|
226
|
+
| ✗ | StringIO | #write | Accepts multiple arguments.
|
227
|
+
| ✗ | StringScanner | #captures | New
|
228
|
+
| ✗ | | #size | New
|
229
|
+
| ✗ | | #values_at | New
|
230
|
+
| ✗ | Struct | .new | Accepts a new optional keyword argument, `:keyword_init`.
|
231
|
+
| ✗ | Thread | #fetch | New
|
232
|
+
| ✗ | | #name= | Description set by `Thread#name=` is now visible on Windows 10.
|
233
|
+
| ✗ | Time | #at | Accepts a third argument which specifies the unit of the second argument.
|
234
|
+
| ✗ | URI | .open | New (alias of `Kernel.open`)
|
235
|
+
| ✗ | Zlib::GzipWriter | #write | Accepts multiple arguments.
|
236
|
+
|
122
237
|
### 2.4
|
123
238
|
|
124
|
-
| Object | Method |
|
125
|
-
|
126
|
-
| Array | #concat |
|
127
|
-
| | #max |
|
128
|
-
| | #min |
|
129
|
-
| | #pack |
|
130
|
-
| | #sum |
|
131
|
-
| BasicObject | #\_\_send\_\_ |
|
132
|
-
| Binding | #irb |
|
133
|
-
| Comparable | #clamp |
|
134
|
-
| CSV | #new |
|
135
|
-
| Dir | .empty? |
|
136
|
-
| Enumerable | #chunk |
|
137
|
-
| | #sum |
|
138
|
-
| | #uniq |
|
139
|
-
| Enumerator::Lazy | #chunk_while |
|
140
|
-
| | #uniq |
|
141
|
-
| File | .empty? |
|
142
|
-
| FileTest | .empty? |
|
143
|
-
| Float | #ceil |
|
144
|
-
| | #floor |
|
145
|
-
| | #round |
|
146
|
-
| | #truncate |
|
147
|
-
| Hash | #compact |
|
148
|
-
| | #compact! |
|
149
|
-
| | #transform_values |
|
150
|
-
| | #transform_values! |
|
151
|
-
| Integer | #ceil |
|
152
|
-
| | #digits |
|
153
|
-
| | #floor |
|
154
|
-
| | #round |
|
155
|
-
| | #truncate |
|
156
|
-
| IO | #each_line |
|
157
|
-
| | .foreach |
|
158
|
-
| | #gets |
|
159
|
-
| | #lines |
|
160
|
-
| | #readline |
|
161
|
-
| | #readlines |
|
162
|
-
| | .readlines |
|
163
|
-
| IPAddr | #== |
|
164
|
-
| | #<=> |
|
165
|
-
| Kernel | #send |
|
166
|
-
| Logger | #new |
|
167
|
-
| MatchData | #named_captures |
|
168
|
-
| | #values_at |
|
169
|
-
| Module | #refine |
|
170
|
-
| | .used_modules |
|
171
|
-
| Net::HTTP | #post |
|
172
|
-
| Net::FTP | #new |
|
173
|
-
| | #status |
|
174
|
-
| Numeric | #clone |
|
175
|
-
| | #dup |
|
176
|
-
| | #finite? |
|
177
|
-
| | #infinite? |
|
178
|
-
| Object | #clone |
|
179
|
-
| OptionParser | #order |
|
180
|
-
| | #order! |
|
181
|
-
| | #parse |
|
182
|
-
| | #parse! |
|
183
|
-
| | #permute |
|
184
|
-
| | #permute! |
|
185
|
-
| Pathname | #empty? |
|
186
|
-
| Readline | #quoting_detection_proc |
|
187
|
-
| | #quoting_detection_proc= |
|
188
|
-
| REXML::Element | #[] |
|
189
|
-
| Rational | #round |
|
190
|
-
| Regexp | #match? |
|
191
|
-
| Set | #compare_by_identity |
|
192
|
-
| | #compare_by_identity? |
|
193
|
-
| String | #capitalize |
|
194
|
-
| | #capitalize! |
|
195
|
-
| | #casecmp? |
|
196
|
-
| | #concat |
|
197
|
-
| | #downcase |
|
198
|
-
| | #downcase! |
|
199
|
-
| | #each_line |
|
200
|
-
| | #lines |
|
201
|
-
| | #match? |
|
202
|
-
| | .new |
|
203
|
-
| | #prepend |
|
204
|
-
| | #swapcase |
|
205
|
-
| | #swapcase! |
|
206
|
-
| | #unpack1 |
|
207
|
-
| | #upcase |
|
208
|
-
| | #upcase! |
|
209
|
-
| StringIO | #each_line |
|
210
|
-
| | #gets |
|
211
|
-
| | #readline |
|
212
|
-
| | #readlines |
|
213
|
-
| Symbol | #capitalize |
|
214
|
-
| | #capitalize! |
|
215
|
-
| | #casecmp? |
|
216
|
-
| | #downcase |
|
217
|
-
| | #downcase! |
|
218
|
-
| | #match |
|
219
|
-
| | #match? |
|
220
|
-
| | #swapcase |
|
221
|
-
| | #swapcase! |
|
222
|
-
| | #to_proc |
|
223
|
-
| | #upcase |
|
224
|
-
| | #upcase! |
|
225
|
-
| Thread | #report\_on\_exception |
|
226
|
-
| | .report\_on\_exception |
|
227
|
-
| TracePoint | #callee_id |
|
228
|
-
| Warning | #warn |
|
239
|
+
| | Object | Method | Changes |
|
240
|
+
|:-:| ---------------- | ------------------------ | ------- |
|
241
|
+
| ✓ | Array | #concat | Accepts multiple arguments.
|
242
|
+
| ✗ | | #max | This method already existed but was inherited from `Enumerable`. It was optimized on `Array` so redefining `Enumerable#max` no longer affects this.
|
243
|
+
| ✗ | | #min | This method already existed but was inherited from `Enumerable`. It was optimized on `Array` so redefining `Enumerable#min` no longer affects this.
|
244
|
+
| ✗ | | #pack | Accepts a new optional keyword argument, `buffer`.
|
245
|
+
| ✓ | | #sum | Like `Enumerable#sum` but does not depend on the definition of `each`.
|
246
|
+
| ✗ | BasicObject | #\_\_send\_\_ | Supports refined methods.
|
247
|
+
| ✗ | Binding | #irb | Start a REPL session like `binding.pry`.
|
248
|
+
| ✓ | Comparable | #clamp | New
|
249
|
+
| ✗ | CSV | #new | Accepts a new optional keyword argument, `liberal_parsing`.
|
250
|
+
| ✓ | Dir | .empty? | New
|
251
|
+
| ✓ | Enumerable | #chunk | Calling without a block returns an enumerator.
|
252
|
+
| ✓ | | #sum |
|
253
|
+
| ✓ | | #uniq |
|
254
|
+
| ✓ | Enumerator::Lazy | #chunk_while |
|
255
|
+
| ✓ | | #uniq |
|
256
|
+
| ✓ | File | .empty? |
|
257
|
+
| ✗ | FileTest | .empty? |
|
258
|
+
| ✓ | Float | #ceil | Accepts an optional digits argument.
|
259
|
+
| ✓ | | #floor | Accepts an optional digits argument.
|
260
|
+
| ✗ | | #round | Accepts an optional digits argument and provides a new optional keyword argument, `half`.
|
261
|
+
| ✓ | | #truncate | Accepts an optional digits argument.
|
262
|
+
| ✓ | Hash | #compact |
|
263
|
+
| ✓ | | #compact! |
|
264
|
+
| ✓ | | #transform_values |
|
265
|
+
| ✓ | | #transform_values! |
|
266
|
+
| ✓ | Integer | #ceil | Accepts an optional digits argument.
|
267
|
+
| ✓ | | #digits |
|
268
|
+
| ✓ | | #floor | Accepts an optional digits argument.
|
269
|
+
| ✓ | | #round | Accepts an optional digits argument and provides a new optional keyword argument, `half`.
|
270
|
+
| ✓ | | #truncate | Accepts an optional digits argument.
|
271
|
+
| ✓ | IO | #each_line | Accepts a new optional keyword argument, `chomp`.
|
272
|
+
| ✓ | | .foreach | Accepts a new optional keyword argument, `chomp`.
|
273
|
+
| ✓ | | #gets | Accepts a new optional keyword argument, `chomp`.
|
274
|
+
| ✓ | | #lines |
|
275
|
+
| ✓ | | #readline |
|
276
|
+
| ✓ | | #readlines |
|
277
|
+
| ✓ | | .readlines | Accepts a new optional keyword argument, `chomp`.
|
278
|
+
| ✓ | IPAddr | #== | No longer raises an exception if coercion fails.
|
279
|
+
| ✓ | | #<=> | No longer raises an exception if coercion fails.
|
280
|
+
| ✗ | Kernel | #send | Supports refined methods.
|
281
|
+
| ✗ | Logger | #new |
|
282
|
+
| ✓ | MatchData | #named_captures |
|
283
|
+
| ✓ | | #values_at | Supports named captures.
|
284
|
+
| ✗ | Module | #refine | Accepts a module as an argument.
|
285
|
+
| ✗ | | .used_modules |
|
286
|
+
| ✗ | Net::HTTP | #post | New
|
287
|
+
| ✗ | Net::FTP | #new | Supports hash style options.
|
288
|
+
| ✗ | | #status | Accepts a new optional keyword argument, `pathname`.
|
289
|
+
| ✓ | Numeric | #clone |
|
290
|
+
| ✓ | | #dup |
|
291
|
+
| ✓ | | #finite? |
|
292
|
+
| ✓ | | #infinite? |
|
293
|
+
| ✓ | Object | #clone |
|
294
|
+
| ✗ | OptionParser | #order |
|
295
|
+
| ✗ | | #order! |
|
296
|
+
| ✗ | | #parse |
|
297
|
+
| ✗ | | #parse! |
|
298
|
+
| ✗ | | #permute |
|
299
|
+
| ✗ | | #permute! |
|
300
|
+
| ✓ | Pathname | #empty? |
|
301
|
+
| ✗ | Readline | #quoting_detection_proc |
|
302
|
+
| ✗ | | #quoting_detection_proc= |
|
303
|
+
| ✗ | REXML::Element | #[] | If `String` or `Symbol` is specified, attribute value is returned. Otherwise, Nth child is returned.
|
304
|
+
| ✗ | Rational | #round |
|
305
|
+
| ✓ | Regexp | #match? | New
|
306
|
+
| ✗ | Set | #compare_by_identity | New
|
307
|
+
| ✗ | | #compare_by_identity? | New
|
308
|
+
| ✗ | String | #capitalize | Supports Unicode and accepts several new keyword arguments.
|
309
|
+
| ✗ | | #capitalize! | Supports Unicode and accepts several new keyword arguments.
|
310
|
+
| P | | #casecmp? | New **Differences:** Does not support Unicode characters.
|
311
|
+
| ✓ | | #concat | Now accepts multiple arguments.
|
312
|
+
| ✗ | | #downcase | Supports Unicode and accepts several new keyword arguments.
|
313
|
+
| ✗ | | #downcase! | Supports Unicode and accepts several new keyword arguments.
|
314
|
+
| ✓ | | #each_line | Accepts a new optional keyword argument, `chomp`.
|
315
|
+
| ✓ | | #lines | Accepts a new optional keyword argument, `chomp`.
|
316
|
+
| ✓ | | #match? |
|
317
|
+
| P | | .new | Accepts a new optional keyword argument, `capacity`. **Differences:** Allows `:capacity` option to pass but does nothing with it.
|
318
|
+
| ✓ | | #prepend | Now accepts multiple arguments.
|
319
|
+
| ✗ | | #swapcase | Supports Unicode and accepts several new keyword arguments.
|
320
|
+
| ✗ | | #swapcase! | Supports Unicode and accepts several new keyword arguments.
|
321
|
+
| ✓ | | #unpack1 |
|
322
|
+
| ✗ | | #upcase | Supports Unicode and accepts several new keyword arguments.
|
323
|
+
| ✗ | | #upcase! | Supports Unicode and accepts several new keyword arguments.
|
324
|
+
| ✓ | StringIO | #each_line | Accepts a new optional keyword argument, `chomp`.
|
325
|
+
| ✓ | | #gets | Accepts a new optional keyword argument, `chomp`.
|
326
|
+
| ✓ | | #readline | Accepts a new optional keyword argument, `chomp`.
|
327
|
+
| ✓ | | #readlines | Accepts a new optional keyword argument, `chomp`.
|
328
|
+
| ✗ | Symbol | #capitalize | Supports Unicode and accepts several new keyword arguments.
|
329
|
+
| ✗ | | #capitalize! | Supports Unicode and accepts several new keyword arguments.
|
330
|
+
| P | | #casecmp? | New **Differences:** Does not support Unicode characters.
|
331
|
+
| ✗ | | #downcase | Supports Unicode and accepts several new keyword arguments.
|
332
|
+
| ✗ | | #downcase! | Supports Unicode and accepts several new keyword arguments.
|
333
|
+
| ✓ | | #match |
|
334
|
+
| ✓ | | #match? |
|
335
|
+
| ✗ | | #swapcase | Supports Unicode and accepts several new keyword arguments.
|
336
|
+
| ✗ | | #swapcase! | Supports Unicode and accepts several new keyword arguments.
|
337
|
+
| ✗ | | #to_proc |
|
338
|
+
| ✗ | | #upcase | Supports Unicode and accepts several new keyword arguments.
|
339
|
+
| ✗ | | #upcase! | Supports Unicode and accepts several new keyword arguments.
|
340
|
+
| ✗ | Thread | #report\_on\_exception |
|
341
|
+
| ✗ | | .report\_on\_exception |
|
342
|
+
| ✗ | TracePoint | #callee_id |
|
343
|
+
| ✗ | Warning | #warn | New
|
229
344
|
|
230
345
|
### 2.3
|
231
346
|
|
232
|
-
| Object | Method |
|
233
|
-
|
234
|
-
| ARGF | #read_nonblock |
|
235
|
-
| Array | #bsearch_index |
|
236
|
-
| | #dig |
|
237
|
-
| | #flatten | No
|
238
|
-
| | #flatten! | No
|
239
|
-
| | #inspect | No
|
240
|
-
| | #pack |
|
241
|
-
| Base64 | .urlsafe_encode64 |
|
242
|
-
| | .urlsafe_decode64 |
|
243
|
-
| BasicSocket | #recv |
|
244
|
-
| | #recv_nonblock |
|
245
|
-
| | #recvmsg_nonblock |
|
246
|
-
| | #sendmsg_nonblock |
|
247
|
-
| Comparable | #== | No
|
248
|
-
| Coverage | .peek_result |
|
249
|
-
| Enumerable | #chunk | No
|
250
|
-
| | #chunk_while |
|
251
|
-
| | #grep_v |
|
252
|
-
| | #slice_before |
|
253
|
-
| Enumerator::Lazy | #grep_v |
|
254
|
-
| File | .mkfifo |
|
255
|
-
| File::Stat | #ino |
|
256
|
-
| Hash | #< |
|
257
|
-
| | #<= |
|
258
|
-
| | #> |
|
259
|
-
| | #>= |
|
260
|
-
| | #dig |
|
261
|
-
| | #fetch_values |
|
262
|
-
| | #inspect | No
|
263
|
-
| | #to_proc |
|
264
|
-
| IO | #advise | No
|
265
|
-
| | #close |
|
266
|
-
| | #each_codepoint |
|
267
|
-
| | #wait_readable | No
|
268
|
-
| Kernel | #loop |
|
269
|
-
| Logger | #level= |
|
270
|
-
| | #reopen |
|
271
|
-
| Module | #define_method |
|
272
|
-
| | #deprecate_constant |
|
273
|
-
| NameError | #receiver |
|
274
|
-
| Net::FTP | .default_passive= |
|
275
|
-
| | #mlst |
|
276
|
-
| | #mlsd |
|
277
|
-
| Net::HTTP | #open_timeout |
|
278
|
-
| Numeric | #negative? |
|
279
|
-
| | #positive? |
|
280
|
-
| Object | #define_singleton_method |
|
281
|
-
| | #timeout |
|
282
|
-
| ObjectSpace | .count_symbols |
|
283
|
-
| | .count_imemo_objects |
|
284
|
-
| | .internal_class_of |
|
285
|
-
| | .internal_super_of |
|
286
|
-
| OpenSSL::SSL::SSLSocket | #accept_nonblock |
|
287
|
-
| | #connect_nonblock |
|
288
|
-
| Pathname | #ascend |
|
289
|
-
| | #descend |
|
290
|
-
| Queue | #close |
|
291
|
-
| Socket | #accept_nonblock |
|
292
|
-
| | #connect_nonblock |
|
293
|
-
| String | #+@ |
|
294
|
-
| | #-@ |
|
295
|
-
| | .new |
|
296
|
-
| | #unpack |
|
297
|
-
| StringIO | #set_encoding | No
|
298
|
-
| Struct | #dig |
|
299
|
-
| TCPServer | #accept_nonblock |
|
300
|
-
| Thread | #name |
|
301
|
-
| | #name= |
|
302
|
-
| UNIXServer | #accept_nonblock |
|
303
|
-
| Vector | #round |
|
347
|
+
| | Object | Method | Changes |
|
348
|
+
|:-:| ----------------------- | ------------------------ | ------- |
|
349
|
+
| ✗ | ARGF | #read_nonblock | Accepts a new optional keyword argument, `exception`.
|
350
|
+
| ✗ | Array | #bsearch_index |
|
351
|
+
| ✓ | | #dig | New
|
352
|
+
| ✗ | | #flatten | No longer calls `to_ary` on elements beyond the given level.
|
353
|
+
| ✗ | | #flatten! | No longer calls `to_ary` on elements beyond the given level.
|
354
|
+
| ✗ | | #inspect | No longer raises an error if its content returns a string which is not compatible with `Encoding.default_external`.
|
355
|
+
| ✗ | | #pack | Add `j` and `J` directives for pointer width integer type.
|
356
|
+
| ✗ | Base64 | .urlsafe_encode64 | Accepts a new optional keyword argument, `padding`.
|
357
|
+
| ✗ | | .urlsafe_decode64 | Accepts a new optional keyword argument, `padding`.
|
358
|
+
| ✗ | BasicSocket | #recv | Allow an output `String` buffer argument.
|
359
|
+
| ✗ | | #recv_nonblock | Allow an output `String` buffer argument.
|
360
|
+
| ✗ | | #recvmsg_nonblock | Accepts a new keyword argument, `exception`.
|
361
|
+
| ✗ | | #sendmsg_nonblock | Accepts a new keyword argument, `exception`.
|
362
|
+
| ✗ | Comparable | #== | No longer rescues exceptions.
|
363
|
+
| ✗ | Coverage | .peek_result | New
|
364
|
+
| ✗ | Enumerable | #chunk | No longer accepts the `initial_state` keyword argument.
|
365
|
+
| ✓ | | #chunk_while |
|
366
|
+
| ✓ | | #grep_v | New
|
367
|
+
| ✓ | | #slice_before | No longer accepts the `initial_state` keyword argument.
|
368
|
+
| ✓ | Enumerator::Lazy | #grep_v | New
|
369
|
+
| ✗ | File | .mkfifo |
|
370
|
+
| ✗ | File::Stat | #ino | On Windows, it always returned `0`, but now returns `BY_HANDLE_FILE_INFORMATION.nFileIndexHigh/Low`.
|
371
|
+
| ✗ | Hash | #< |
|
372
|
+
| ✗ | | #<= |
|
373
|
+
| ✗ | | #> |
|
374
|
+
| ✗ | | #>= |
|
375
|
+
| ✓ | | #dig | New
|
376
|
+
| ✓ | | #fetch_values |
|
377
|
+
| ✗ | | #inspect | No longer raises an error if its content returns a string which is not compatible with `Encoding.default_external`.
|
378
|
+
| P | | #to_proc | New **Differences:** Works in every respect but returns a `lambda` instead of a `proc`. Returning a `proc` may be an error in MRI's implementation. See: https://bugs.ruby-lang.org/issues/12671)
|
379
|
+
| ✗ | IO | #advise | No longer raises Errno::ENOSYS in cases where it was detected at build time but not available at runtime.
|
380
|
+
| ✗ | | #close | Doesn't raise when the IO object is closed.
|
381
|
+
| ✗ | | #each_codepoint | Raises an exception at incomplete character before EOF when conversion takes place.
|
382
|
+
| ✗ | | #wait_readable | No longer checks FIONREAD.
|
383
|
+
| ✓ | Kernel | #loop | When stopped by a StopIteration exception, returns what the enumerator has returned instead of nil.
|
384
|
+
| ✗ | Logger | #level= |
|
385
|
+
| ✗ | | #reopen | New
|
386
|
+
| ✗ | Module | #define_method | Now requires a method body, `Proc`, `Method`, or a block.
|
387
|
+
| ✗ | | #deprecate_constant |
|
388
|
+
| ✗ | NameError | #receiver | New
|
389
|
+
| ✗ | Net::FTP | .default_passive= | New
|
390
|
+
| ✗ | | #mlst | New
|
391
|
+
| ✗ | | #mlsd | New
|
392
|
+
| ✗ | Net::HTTP | #open_timeout | Now has a default value of `60`.
|
393
|
+
| ✓ | Numeric | #negative? | New
|
394
|
+
| ✓ | | #positive? | New
|
395
|
+
| ✗ | Object | #define_singleton_method | Now requires a method body, `Proc`, `Method`, or a block.
|
396
|
+
| ✗ | | #timeout | Warns that it is deprecated.
|
397
|
+
| ✗ | ObjectSpace | .count_symbols | New
|
398
|
+
| ✗ | | .count_imemo_objects | New
|
399
|
+
| ✗ | | .internal_class_of | New
|
400
|
+
| ✗ | | .internal_super_of | New
|
401
|
+
| ✗ | OpenSSL::SSL::SSLSocket | #accept_nonblock | Accepts a new keyword argument, `exception`.
|
402
|
+
| ✗ | | #connect_nonblock | Accepts a new keyword argument, `exception`.
|
403
|
+
| ✗ | Pathname | #ascend |
|
404
|
+
| ✗ | | #descend |
|
405
|
+
| ✗ | Queue | #close |
|
406
|
+
| ✗ | Socket | #accept_nonblock | Accepts a new keyword argument, `exception`.
|
407
|
+
| ✗ | | #connect_nonblock | Accepts a new keyword argument, `exception`.
|
408
|
+
| ✓ | String | #+@ | New
|
409
|
+
| ✓ | | #-@ | New
|
410
|
+
| ✓ | | .new | Accepts a new keyword argument, `encoding`.
|
411
|
+
| ✗ | | #unpack | Add `j` and `J` directives for pointer width integer type.
|
412
|
+
| ✗ | StringIO | #set_encoding | No longer sets the encoding of its buffer string.
|
413
|
+
| ✓ | Struct | #dig | New
|
414
|
+
| ✗ | TCPServer | #accept_nonblock | Accepts a new keyword argument, `exception`.
|
415
|
+
| ✗ | Thread | #name | New
|
416
|
+
| ✗ | | #name= | New
|
417
|
+
| ✗ | UNIXServer | #accept_nonblock | Accepts a new keyword argument, `exception`.
|
418
|
+
| ✗ | Vector | #round | New
|
304
419
|
|
305
420
|
### 2.2
|
306
421
|
|
307
|
-
| Object | Method |
|
308
|
-
|
309
|
-
| Binding | #local_variables |
|
310
|
-
| | #receiver |
|
311
|
-
| Dir | #fileno |
|
312
|
-
| Enumerable | #max |
|
313
|
-
| | #max_by |
|
314
|
-
| | #min |
|
315
|
-
| | #min_by |
|
316
|
-
| | #slice_after |
|
317
|
-
| | #slice_when |
|
318
|
-
| Etc | .confstr |
|
319
|
-
| | .sysconf |
|
320
|
-
| | .nprocessors |
|
321
|
-
| | .uname |
|
322
|
-
| Float | #next_float |
|
323
|
-
| | #prev_float |
|
324
|
-
| File | .birthtime |
|
325
|
-
| | #birthtime |
|
326
|
-
| File::Stat | #birthtime |
|
327
|
-
| Find | .find |
|
328
|
-
| GC | .latest_gc_info |
|
329
|
-
| | .stat |
|
330
|
-
| IO | #each_codepoint |
|
331
|
-
| | #nonblock_read |
|
332
|
-
| | #nonblock_write |
|
333
|
-
| | #pathconf |
|
334
|
-
| Kernel | #itself |
|
335
|
-
| | #throw |
|
336
|
-
| Math | .atan2 |
|
337
|
-
| | .log |
|
338
|
-
| Matrix | #+@ |
|
339
|
-
| | #-@ |
|
340
|
-
| | #adjugate |
|
341
|
-
| | #cofactor |
|
342
|
-
| | #first_minor |
|
343
|
-
| | .hstack |
|
344
|
-
| | #hstack |
|
345
|
-
| | #laplace_expansion |
|
346
|
-
| | .vstack |
|
347
|
-
| | #vstack |
|
348
|
-
| Method | #curry |
|
349
|
-
| | #super_method |
|
350
|
-
| ObjectSpace | .memsize_of |
|
351
|
-
| Pathname | #/ |
|
352
|
-
| | #birthtime |
|
353
|
-
| | #find |
|
354
|
-
| Prime | .prime? |
|
355
|
-
| Process | .spawn |
|
356
|
-
| String | #unicode_normalize |
|
357
|
-
| | #unicode_normalize! |
|
358
|
-
| | #unicode_normalized? |
|
359
|
-
| Time | .httpdate |
|
360
|
-
| | .parse |
|
361
|
-
| | .rfc2822 |
|
362
|
-
| | .strptime |
|
363
|
-
| | .xmlschema |
|
364
|
-
| TSort | .each_strongly_connected_component |
|
365
|
-
| | .each_strongly_connected_component_from |
|
366
|
-
| | .tsort_each |
|
367
|
-
| Vector | #+@ |
|
368
|
-
| | #-@ |
|
369
|
-
| | #angle_with |
|
370
|
-
| | .basis |
|
371
|
-
| | #cross |
|
372
|
-
| | #cross_product |
|
373
|
-
| | #dot |
|
374
|
-
| | .independent? |
|
375
|
-
| | #independent? |
|
422
|
+
| | Object | Method | Changes |
|
423
|
+
|:-:| ---------- | --------------------------------------- | ------- |
|
424
|
+
| ✗ | Binding | #local_variables | New
|
425
|
+
| ✗ | | #receiver | New
|
426
|
+
| ✗ | Dir | #fileno | New
|
427
|
+
| ✓ | Enumerable | #max | Accepts a new optional argument to return multiple elements.
|
428
|
+
| ✓ | | #max_by | Accepts a new optional argument to return multiple elements.
|
429
|
+
| ✓ | | #min | Accepts a new optional argument to return multiple elements.
|
430
|
+
| ✓ | | #min_by | Accepts a new optional argument to return multiple elements.
|
431
|
+
| ✓ | | #slice_after | New
|
432
|
+
| ✓ | | #slice_when | New
|
433
|
+
| ✗ | Etc | .confstr | New
|
434
|
+
| ✗ | | .sysconf | New
|
435
|
+
| ✗ | | .nprocessors | New
|
436
|
+
| ✗ | | .uname | New
|
437
|
+
| ✗ | Float | #next_float | New
|
438
|
+
| ✗ | | #prev_float | New
|
439
|
+
| ✗ | File | .birthtime | New
|
440
|
+
| ✗ | | #birthtime | New
|
441
|
+
| ✗ | File::Stat | #birthtime | New
|
442
|
+
| ✗ | Find | .find | Accepts a new optional keyword argument, `ignore_error`.
|
443
|
+
| ✗ | GC | .latest_gc_info |
|
444
|
+
| ✗ | | .stat |
|
445
|
+
| ✗ | IO | #each_codepoint |
|
446
|
+
| ✗ | | #nonblock_read | Supports pipes on Windows.
|
447
|
+
| ✗ | | #nonblock_write | Supports pipes on Windows.
|
448
|
+
| ✗ | | #pathconf | New
|
449
|
+
| ✓ | Kernel | #itself | New
|
450
|
+
| ✗ | | #throw | Raises `UncaughtThrowError`, subclass of `ArgumentError` when there is no corresponding catch block, instead of `ArgumentError`.
|
451
|
+
| ✗ | Math | .atan2 | Now returns values like as expected by C99 if both two arguments are infinity.
|
452
|
+
| ✗ | | .log | Now raises `Math::DomainError` instead of returning `NaN` if the base is less than 0, and returns `NaN` instead of -infinity if both of two arguments are 0.
|
453
|
+
| ✗ | Matrix | #+@ | New
|
454
|
+
| ✗ | | #-@ | New
|
455
|
+
| ✗ | | #adjugate | New
|
456
|
+
| ✗ | | #cofactor | New
|
457
|
+
| ✗ | | #first_minor | New
|
458
|
+
| ✗ | | .hstack | New
|
459
|
+
| ✗ | | #hstack | New
|
460
|
+
| ✗ | | #laplace_expansion | New
|
461
|
+
| ✗ | | .vstack | New
|
462
|
+
| ✗ | | #vstack | New
|
463
|
+
| ✗ | Method | #curry | New
|
464
|
+
| ✗ | | #super_method | New
|
465
|
+
| ✗ | ObjectSpace | .memsize_of |
|
466
|
+
| ✗ | Pathname | #/ | New (alias of `#+`)
|
467
|
+
| ✗ | | #birthtime | New
|
468
|
+
| ✗ | | #find | Accepts a new optional keyword argument, `ignore_error`.
|
469
|
+
| ✗ | Prime | .prime? | Now returns `false` for negative numbers.
|
470
|
+
| ✗ | Process | .spawn |
|
471
|
+
| ✗ | String | #unicode_normalize | New
|
472
|
+
| ✗ | | #unicode_normalize! | New
|
473
|
+
| ✗ | | #unicode_normalized? | New
|
474
|
+
| ✗ | Time | .httpdate |
|
475
|
+
| ✗ | | .parse | May produce fixed-offset `Time` objects.
|
476
|
+
| ✗ | | .rfc2822 | May produce fixed-offset `Time` objects.
|
477
|
+
| ✗ | | .strptime | May produce fixed-offset `Time` objects. Raises `ArgumentError` when there is no date information.
|
478
|
+
| ✗ | | .xmlschema | May produce fixed-offset `Time` objects.
|
479
|
+
| ✗ | TSort | .each_strongly_connected_component | Returns an enumerator if no block is given.
|
480
|
+
| ✗ | | .each_strongly_connected_component_from | Returns an enumerator if no block is given.
|
481
|
+
| ✗ | | .tsort_each | Returns an enumerator if no block is given.
|
482
|
+
| ✓ | Vector | #+@ | New
|
483
|
+
| ✗ | | #-@ | New
|
484
|
+
| ✗ | | #angle_with | New
|
485
|
+
| ✗ | | .basis | New
|
486
|
+
| ✗ | | #cross | New (alias of `#cross_product`)
|
487
|
+
| ✗ | | #cross_product | New
|
488
|
+
| ✗ | | #dot | New (alias of `#inner_product`)
|
489
|
+
| ✗ | | .independent? | New
|
490
|
+
| ✗ | | #independent? | New
|
376
491
|
|
377
492
|
## Contributing
|
378
493
|
|
data/lib/polyfill.rb
CHANGED
@@ -3,7 +3,8 @@ module Polyfill
|
|
3
3
|
VERSIONS = {
|
4
4
|
'2.2' => 'V2_2',
|
5
5
|
'2.3' => 'V2_3',
|
6
|
-
'2.4' => 'V2_4'
|
6
|
+
'2.4' => 'V2_4',
|
7
|
+
'2.5' => 'V2_5'
|
7
8
|
}.freeze
|
8
9
|
private_constant :VERSIONS
|
9
10
|
|
@@ -89,5 +90,23 @@ module Polyfill
|
|
89
90
|
Polyfill::Module.const_set("M#{mod.object_id}", mod)
|
90
91
|
end
|
91
92
|
module_function :create_module
|
93
|
+
|
94
|
+
def to_str(obj)
|
95
|
+
unless obj.respond_to?(:to_str)
|
96
|
+
raise TypeError, "no implicit conversion of #{obj.class} into String"
|
97
|
+
end
|
98
|
+
|
99
|
+
obj.to_str
|
100
|
+
end
|
101
|
+
module_function :to_str
|
102
|
+
|
103
|
+
def to_int(obj)
|
104
|
+
unless obj.respond_to?(:to_int)
|
105
|
+
raise TypeError, "no implicit conversion of #{obj.class} into Integer"
|
106
|
+
end
|
107
|
+
|
108
|
+
obj.to_int
|
109
|
+
end
|
110
|
+
module_function :to_int
|
92
111
|
end
|
93
112
|
end
|
data/lib/polyfill/v2_3/hash.rb
CHANGED
@@ -25,15 +25,16 @@ module Polyfill
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def fetch_values(*keys)
|
28
|
-
|
29
|
-
|
30
|
-
if block_given?
|
31
|
-
fetch(key, &::Proc.new)
|
32
|
-
else
|
33
|
-
fetch(key)
|
34
|
-
end
|
28
|
+
if block_given?
|
29
|
+
block = ::Proc.new
|
35
30
|
|
36
|
-
|
31
|
+
keys.each_with_object([]) do |key, values|
|
32
|
+
values << fetch(key, &block)
|
33
|
+
end
|
34
|
+
else
|
35
|
+
keys.each_with_object([]) do |key, values|
|
36
|
+
values << fetch(key)
|
37
|
+
end
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
data/lib/polyfill/v2_4/array.rb
CHANGED
data/lib/polyfill/v2_4/float.rb
CHANGED
@@ -2,7 +2,7 @@ module Polyfill
|
|
2
2
|
module V2_4
|
3
3
|
module Float
|
4
4
|
def ceil(ndigits = 0)
|
5
|
-
ndigits =
|
5
|
+
ndigits = InternalUtils.to_int(ndigits)
|
6
6
|
return super() if ndigits == 0
|
7
7
|
|
8
8
|
if ndigits > 0
|
@@ -15,7 +15,7 @@ module Polyfill
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def floor(ndigits = 0)
|
18
|
-
ndigits =
|
18
|
+
ndigits = InternalUtils.to_int(ndigits)
|
19
19
|
return super() if ndigits == 0
|
20
20
|
|
21
21
|
if ndigits > 0
|
@@ -28,7 +28,7 @@ module Polyfill
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def truncate(ndigits = 0)
|
31
|
-
ndigits =
|
31
|
+
ndigits = InternalUtils.to_int(ndigits)
|
32
32
|
return super() if ndigits == 0
|
33
33
|
|
34
34
|
if ndigits > 0
|
@@ -2,7 +2,7 @@ module Polyfill
|
|
2
2
|
module V2_4
|
3
3
|
module Integer
|
4
4
|
def ceil(ndigits = 0)
|
5
|
-
ndigits =
|
5
|
+
ndigits = InternalUtils.to_int(ndigits)
|
6
6
|
return super() if ndigits == 0
|
7
7
|
return to_f if ndigits > 0
|
8
8
|
|
@@ -11,7 +11,7 @@ module Polyfill
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def digits(base = 10)
|
14
|
-
base =
|
14
|
+
base = InternalUtils.to_int(base)
|
15
15
|
raise Math::DomainError, 'out of domain' if self < 0
|
16
16
|
raise ArgumentError, 'negative radix' if base < 0
|
17
17
|
raise ArgumentError, "invalid radix #{base}" if base < 2
|
@@ -26,7 +26,7 @@ module Polyfill
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def floor(ndigits = 0)
|
29
|
-
ndigits =
|
29
|
+
ndigits = InternalUtils.to_int(ndigits)
|
30
30
|
return super() if ndigits == 0
|
31
31
|
return to_f if ndigits > 0
|
32
32
|
|
@@ -38,7 +38,7 @@ module Polyfill
|
|
38
38
|
unless [nil, :down, :even, :up, 'down', 'even', 'up'].include?(half)
|
39
39
|
raise ArgumentError, "invalid rounding mode: #{half}"
|
40
40
|
end
|
41
|
-
ndigits =
|
41
|
+
ndigits = InternalUtils.to_int(ndigits)
|
42
42
|
return super() if ndigits == 0
|
43
43
|
return to_f if ndigits > 0
|
44
44
|
|
@@ -47,7 +47,7 @@ module Polyfill
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def truncate(ndigits = 0)
|
50
|
-
ndigits =
|
50
|
+
ndigits = InternalUtils.to_int(ndigits)
|
51
51
|
return super() if ndigits == 0
|
52
52
|
return to_f if ndigits > 0
|
53
53
|
|
data/lib/polyfill/v2_4/string.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
module Polyfill
|
2
|
+
module V2_5
|
3
|
+
module Hash
|
4
|
+
def slice(*keys)
|
5
|
+
keys.each_with_object({}) do |k, acc|
|
6
|
+
acc[k] = self[k] if key?(k)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def transform_keys
|
11
|
+
unless block_given?
|
12
|
+
return ::Enumerator.new(keys.size) do |yielder|
|
13
|
+
each_with_object({}) do |(k, v), acc|
|
14
|
+
acc[yielder.yield(k)] = v
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
each_with_object({}) do |(k, v), acc|
|
20
|
+
acc[yield(k)] = v
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Polyfill
|
2
|
+
module V2_5
|
3
|
+
module Integer
|
4
|
+
using Polyfill(Integer: %w[#ceil #floor #round #truncate], version: '2.4')
|
5
|
+
|
6
|
+
def ceil(*)
|
7
|
+
super.to_i
|
8
|
+
end
|
9
|
+
|
10
|
+
def floor(*)
|
11
|
+
super.to_i
|
12
|
+
end
|
13
|
+
|
14
|
+
def round(*)
|
15
|
+
super.to_i
|
16
|
+
end
|
17
|
+
|
18
|
+
def truncate(*)
|
19
|
+
super.to_i
|
20
|
+
end
|
21
|
+
|
22
|
+
def allbits?(mask)
|
23
|
+
imask = InternalUtils.to_int(mask)
|
24
|
+
self & imask == imask
|
25
|
+
end
|
26
|
+
|
27
|
+
def anybits?(mask)
|
28
|
+
self & InternalUtils.to_int(mask) != 0
|
29
|
+
end
|
30
|
+
|
31
|
+
def nobits?(mask)
|
32
|
+
self & InternalUtils.to_int(mask) == 0
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Polyfill
|
2
|
+
module V2_5
|
3
|
+
module String
|
4
|
+
def casecmp(other_str)
|
5
|
+
super
|
6
|
+
rescue TypeError
|
7
|
+
nil
|
8
|
+
end
|
9
|
+
|
10
|
+
def casecmp?(other_str)
|
11
|
+
super
|
12
|
+
rescue TypeError
|
13
|
+
nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def delete_prefix(prefix)
|
17
|
+
sub(/\A#{InternalUtils.to_str(prefix)}/, ''.freeze)
|
18
|
+
end
|
19
|
+
|
20
|
+
def delete_prefix!(prefix)
|
21
|
+
prev = dup
|
22
|
+
current = sub!(/\A#{InternalUtils.to_str(prefix)}/, ''.freeze)
|
23
|
+
prev == current ? nil : current
|
24
|
+
end
|
25
|
+
|
26
|
+
def delete_suffix(suffix)
|
27
|
+
chomp(suffix)
|
28
|
+
end
|
29
|
+
|
30
|
+
def delete_suffix!(suffix)
|
31
|
+
chomp!(suffix)
|
32
|
+
end
|
33
|
+
|
34
|
+
def start_with?(*prefixes)
|
35
|
+
super if prefixes.grep(Regexp).empty?
|
36
|
+
|
37
|
+
prefixes.any? do |prefix|
|
38
|
+
prefix.is_a?(Regexp) ? self[/\A#{prefix}/] : super(prefix)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
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: 1.0
|
4
|
+
version: 1.1.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:
|
11
|
+
date: 2018-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -120,6 +120,11 @@ files:
|
|
120
120
|
- lib/polyfill/v2_4/string.rb
|
121
121
|
- lib/polyfill/v2_4/string_io.rb
|
122
122
|
- lib/polyfill/v2_4/symbol.rb
|
123
|
+
- lib/polyfill/v2_5.rb
|
124
|
+
- lib/polyfill/v2_5/hash.rb
|
125
|
+
- lib/polyfill/v2_5/integer.rb
|
126
|
+
- lib/polyfill/v2_5/kernel.rb
|
127
|
+
- lib/polyfill/v2_5/string.rb
|
123
128
|
- lib/polyfill/version.rb
|
124
129
|
- polyfill.gemspec
|
125
130
|
homepage: ''
|
@@ -142,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
147
|
version: '0'
|
143
148
|
requirements: []
|
144
149
|
rubyforge_project:
|
145
|
-
rubygems_version: 2.
|
150
|
+
rubygems_version: 2.7.3
|
146
151
|
signing_key:
|
147
152
|
specification_version: 4
|
148
153
|
summary: Adds newer Ruby methods to older versions.
|