backports 3.21.0 → 3.22.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 +6 -0
- data/Gemfile +1 -1
- data/README.md +285 -159
- data/lib/backports/2.1.0/module/singleton_class.rb +8 -0
- data/lib/backports/2.3.0/struct/dig.rb +2 -0
- data/lib/backports/2.5.0/dir/children.rb +4 -0
- data/lib/backports/2.5.0/dir/each_child.rb +7 -0
- data/lib/backports/2.7.0/complex/{comparision.rb → comparison.rb} +0 -0
- data/lib/backports/2.7.0/enumerable/tally.rb +4 -3
- data/lib/backports/3.1.0/array/intersect.rb +16 -0
- data/lib/backports/3.1.0/array.rb +3 -0
- data/lib/backports/3.1.0/class/descendants.rb +11 -0
- data/lib/backports/3.1.0/class/subclasses.rb +11 -0
- data/lib/backports/3.1.0/class.rb +3 -0
- data/lib/backports/3.1.0/enumerable/compact.rb +5 -0
- data/lib/backports/3.1.0/enumerable/tally.rb +18 -0
- data/lib/backports/3.1.0/enumerable.rb +3 -0
- data/lib/backports/3.1.0/file/dirname.rb +16 -0
- data/lib/backports/3.1.0/file.rb +3 -0
- data/lib/backports/3.1.0/integer/try_convert.rb +5 -0
- data/lib/backports/3.1.0/integer.rb +3 -0
- data/lib/backports/3.1.0/match_data/match.rb +5 -0
- data/lib/backports/3.1.0/match_data/match_length.rb +6 -0
- data/lib/backports/3.1.0/match_data.rb +3 -0
- data/lib/backports/3.1.0/struct/keyword_init.rb +5 -0
- data/lib/backports/3.1.0/struct.rb +3 -0
- data/lib/backports/3.1.0.rb +3 -0
- data/lib/backports/3.1.rb +1 -0
- data/lib/backports/latest.rb +1 -1
- data/lib/backports/version.rb +1 -1
- metadata +24 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b29bdab2282a6e583c683ceb5d2a6665eba385330570cc99ec82935a3fd7156d
|
4
|
+
data.tar.gz: 9539d241f8d89982762c21432713d04d13567ce4c9392af5d54b38099e08cc3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6bfa34744270343976ea43ffab74f332e6652b681723cb18d6fa414327c57f994169dfca42efe75bed24a6cdccfeff0bb1c39f0f0ff61b056eb7333dfb514819
|
7
|
+
data.tar.gz: 83617fcaa2270b28c3f11ac41cf29a875da9bac572da23381bc990a0d5c452a0f12809114fb98478ad6887136d962a8116da41601f4cfb532065dea88614117a
|
data/CHANGELOG.md
CHANGED
@@ -8,6 +8,12 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|
8
8
|
|
9
9
|
Note: [Next major version (X-mas 2021?)](https://github.com/marcandre/backports/issues/139) may drop support for Ruby < 2.2, please comment.
|
10
10
|
|
11
|
+
## [3.21.0](https://github.com/marcandre/backports/compare/v3.20.1...v3.21.0) - 2021-03-31
|
12
|
+
|
13
|
+
### Added
|
14
|
+
|
15
|
+
* Added `String#unpack1` (Ruby 2.4) [#166]
|
16
|
+
|
11
17
|
## [3.20.1](https://github.com/marcandre/backports/compare/v3.20.0...v3.20.1) - 2021-01-03
|
12
18
|
|
13
19
|
### Fixed
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Backports Library [<img src="https://travis-ci.org/marcandre/backports.svg?branch=master">](https://travis-ci.org/marcandre/backports) [<img src="https://badge.fury.io/rb/backports.svg" alt="Gem Version" />](http://badge.fury.io/rb/backports) [![Tidelift](https://tidelift.com/badges/package/rubygems/backports)](https://tidelift.com/subscription/pkg/rubygems-backports?utm_source=rubygems-backports&utm_medium=referral&utm_campaign=readme)
|
2
2
|
|
3
|
-
Yearning to write a gem using some new cool features in Ruby 3.
|
3
|
+
Yearning to write a gem using some new cool features in Ruby 3.1 while
|
4
4
|
still supporting Ruby 2.5.x?
|
5
5
|
Have some legacy code in Ruby 1.8 but can't live without `flat_map`?
|
6
6
|
|
@@ -38,25 +38,26 @@ This will make sure that Hash responds to `dig`, `fetch_values`, `to_proc` and c
|
|
38
38
|
### Up to a specific Ruby version (for quick coding)
|
39
39
|
|
40
40
|
You can load all backports up to a specific version.
|
41
|
-
For example, to bring any version of Ruby mostly up to Ruby 3.
|
41
|
+
For example, to bring any version of Ruby mostly up to Ruby 3.1.0's standards:
|
42
42
|
|
43
|
-
require 'backports/3.
|
43
|
+
require 'backports/3.1.0'
|
44
44
|
|
45
45
|
This will bring in all the features of 1.8.7 and many features of Ruby 1.9.x
|
46
|
-
all the way up to Ruby 3.
|
46
|
+
all the way up to Ruby 3.1.0 (for all versions of Ruby)!
|
47
47
|
|
48
48
|
You may `require 'backports/latest'` as a
|
49
49
|
shortcut to the latest Ruby version supported.
|
50
50
|
|
51
|
-
|
51
|
+
_Note_: For production / public gems, it is highly recommended you only require
|
52
52
|
the backports you need explicitly.
|
53
53
|
|
54
|
-
|
54
|
+
_Note_: Although I am a Ruby committer, this gem is a personal project and is
|
55
55
|
not endorsed by ruby-core.
|
56
56
|
|
57
57
|
## What's inside
|
58
58
|
|
59
59
|
Goals for backported features:
|
60
|
+
|
60
61
|
1. Won't break older code
|
61
62
|
2. Pure Ruby (no C extensions)
|
62
63
|
3. Pass [ruby/spec](https://github.com/ruby/spec)
|
@@ -108,350 +109,464 @@ itself, JRuby and Rubinius.
|
|
108
109
|
|
109
110
|
# Complete List of backports
|
110
111
|
|
112
|
+
## Ruby 3.1 backports
|
113
|
+
|
114
|
+
#### Array
|
115
|
+
|
116
|
+
- `intersect?`
|
117
|
+
|
118
|
+
#### Class
|
119
|
+
|
120
|
+
- `descendants`
|
121
|
+
- `subclasses`
|
122
|
+
|
123
|
+
#### Enumerable
|
124
|
+
|
125
|
+
- `compact`
|
126
|
+
- `tally` (with hash argument)
|
127
|
+
|
128
|
+
### File
|
129
|
+
|
130
|
+
- `dirname` (with depth argument)
|
131
|
+
|
132
|
+
#### Integer
|
133
|
+
|
134
|
+
- `try_convert`
|
135
|
+
|
136
|
+
#### MatchData
|
137
|
+
|
138
|
+
- `match`
|
139
|
+
- `match_length`
|
140
|
+
|
141
|
+
#### Struct
|
142
|
+
|
143
|
+
- `keyword_init?`
|
144
|
+
|
111
145
|
## Ruby 3.0 backports
|
112
146
|
|
113
147
|
#### Env
|
114
|
-
|
148
|
+
|
149
|
+
- `except`
|
115
150
|
|
116
151
|
#### Hash
|
117
|
-
|
118
|
-
|
152
|
+
|
153
|
+
- `except`
|
154
|
+
- `transform_keys`, `transform_keys!` (with hash argument)
|
119
155
|
|
120
156
|
#### Ractor
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
157
|
+
|
158
|
+
- All methods, with the caveats:
|
159
|
+
- uses Ruby's `Thread` internally
|
160
|
+
- will not raise some errors when `Ractor` would (in particular `Ractor::IsolationError`)
|
161
|
+
- supported in Ruby 2.0+ only
|
125
162
|
|
126
163
|
#### Symbol
|
127
|
-
|
164
|
+
|
165
|
+
- `name`
|
128
166
|
|
129
167
|
## Ruby 2.7 backports
|
130
168
|
|
131
169
|
#### Array
|
132
|
-
|
170
|
+
|
171
|
+
- `intersection`
|
133
172
|
|
134
173
|
#### Comparable
|
135
|
-
|
174
|
+
|
175
|
+
- `clamp` (with range)
|
136
176
|
|
137
177
|
#### Complex
|
138
|
-
|
178
|
+
|
179
|
+
- `<=>`
|
139
180
|
|
140
181
|
#### Enumerable
|
141
|
-
|
142
|
-
|
182
|
+
|
183
|
+
- `filter_map`
|
184
|
+
- `tally`
|
143
185
|
|
144
186
|
#### Enumerator
|
145
|
-
|
187
|
+
|
188
|
+
- `produce` (class method)
|
146
189
|
|
147
190
|
#### Time
|
148
|
-
|
191
|
+
|
192
|
+
- `floor`, `ceil`
|
149
193
|
|
150
194
|
## Ruby 2.6 backports
|
151
195
|
|
152
196
|
#### Array
|
153
|
-
|
154
|
-
|
197
|
+
|
198
|
+
- `difference`, `union`
|
199
|
+
- `to_h` (with block)
|
155
200
|
|
156
201
|
#### Enumerable
|
157
|
-
|
158
|
-
|
202
|
+
|
203
|
+
- `chain`
|
204
|
+
- `to_h` (with block)
|
159
205
|
|
160
206
|
#### Enumerator::Chain (use Enumerable#chain)
|
161
207
|
|
162
208
|
#### Hash
|
163
|
-
|
164
|
-
|
209
|
+
|
210
|
+
- `merge`, `merge!`/`update` (with multiple arguments)
|
211
|
+
- `to_h` (with block)
|
165
212
|
|
166
213
|
#### Kernel
|
167
|
-
|
214
|
+
|
215
|
+
- `then`
|
168
216
|
|
169
217
|
#### Method
|
170
|
-
|
218
|
+
|
219
|
+
- `<<`, `>>`
|
171
220
|
|
172
221
|
#### Proc
|
173
|
-
|
222
|
+
|
223
|
+
- `<<`, `>>`
|
174
224
|
|
175
225
|
#### Range
|
176
|
-
|
226
|
+
|
227
|
+
- `cover?` (with `Range` argument)
|
177
228
|
|
178
229
|
## Ruby 2.5 backports
|
179
230
|
|
180
231
|
#### Array
|
181
|
-
|
232
|
+
|
233
|
+
- `append`, `prepend`
|
182
234
|
|
183
235
|
#### Dir
|
184
|
-
|
236
|
+
|
237
|
+
- `children`, `each_child`
|
185
238
|
|
186
239
|
#### Enumerable
|
187
|
-
|
240
|
+
|
241
|
+
- `any?`, `all?`, `none?`, `one?` (with pattern argument)
|
188
242
|
|
189
243
|
#### Hash
|
190
|
-
|
191
|
-
|
244
|
+
|
245
|
+
- `slice`
|
246
|
+
- `transform_keys`
|
192
247
|
|
193
248
|
#### Integer
|
194
|
-
|
195
|
-
|
249
|
+
|
250
|
+
- `sqrt`
|
251
|
+
- `allbits?`, `anybits?` and `nobits?`
|
196
252
|
|
197
253
|
#### Kernel
|
198
|
-
|
254
|
+
|
255
|
+
- `yield_self`
|
199
256
|
|
200
257
|
#### Module
|
201
|
-
|
202
|
-
|
203
|
-
|
258
|
+
|
259
|
+
- `attr`, `attr_accessor`, `attr_reader`, `attr_writer` (now public)
|
260
|
+
- `define_method`, `alias_method`, `undef_method`, `remove_method` (now
|
261
|
+
public)
|
204
262
|
|
205
263
|
#### String
|
206
|
-
|
207
|
-
|
208
|
-
|
264
|
+
|
265
|
+
- `delete_prefix`, `delete_prefix!`
|
266
|
+
- `delete_suffix`, `delete_suffix!`
|
267
|
+
- `undump`
|
209
268
|
|
210
269
|
#### Struct
|
211
|
-
|
270
|
+
|
271
|
+
- `new` (with `keyword_init: true`)
|
212
272
|
|
213
273
|
## Ruby 2.4 backports
|
214
274
|
|
215
275
|
#### Comparable
|
216
|
-
|
276
|
+
|
277
|
+
- `clamp`
|
217
278
|
|
218
279
|
#### Enumerable
|
219
|
-
|
220
|
-
|
280
|
+
|
281
|
+
- `sum`
|
282
|
+
- `uniq`
|
221
283
|
|
222
284
|
#### Hash
|
223
|
-
|
224
|
-
|
285
|
+
|
286
|
+
- `compact`, `compact!`
|
287
|
+
- `transform_values`, `transform_values!`
|
225
288
|
|
226
289
|
#### Queue
|
227
|
-
|
290
|
+
|
291
|
+
- `close`, `closed?`
|
228
292
|
|
229
293
|
#### Regexp
|
230
|
-
|
294
|
+
|
295
|
+
- `match?`
|
231
296
|
|
232
297
|
#### String
|
233
|
-
|
234
|
-
|
298
|
+
|
299
|
+
- `match?`
|
300
|
+
- `unpack1`
|
235
301
|
|
236
302
|
#### FalseClass, Fixnum, Bignum, Float, NilClass, TrueClass
|
237
|
-
|
303
|
+
|
304
|
+
- `dup`
|
238
305
|
|
239
306
|
## Ruby 2.3 backports
|
240
307
|
|
241
308
|
#### Array
|
242
|
-
|
243
|
-
|
309
|
+
|
310
|
+
- `bsearch_index`
|
311
|
+
- `dig`
|
244
312
|
|
245
313
|
#### Enumerable
|
246
|
-
|
247
|
-
|
314
|
+
|
315
|
+
- `chunk_while`
|
316
|
+
- `grep_v`
|
248
317
|
|
249
318
|
#### Hash
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
319
|
+
|
320
|
+
- `dig`
|
321
|
+
- `fetch_values`
|
322
|
+
- `to_proc`
|
323
|
+
- <=, <, >=, >
|
254
324
|
|
255
325
|
#### Numeric
|
256
|
-
|
257
|
-
|
326
|
+
|
327
|
+
- `negative?`
|
328
|
+
- `positive?`
|
258
329
|
|
259
330
|
#### String
|
260
|
-
|
331
|
+
|
332
|
+
- unary + and -
|
261
333
|
|
262
334
|
#### Struct
|
263
|
-
|
335
|
+
|
336
|
+
- `dig`
|
264
337
|
|
265
338
|
## Ruby 2.2 backports
|
266
339
|
|
267
340
|
#### Enumerable
|
268
|
-
|
269
|
-
|
341
|
+
|
342
|
+
- `slice_after`
|
343
|
+
- `slice_when`
|
270
344
|
|
271
345
|
#### Float
|
272
|
-
|
273
|
-
|
346
|
+
|
347
|
+
- `prev_float`
|
348
|
+
- `next_float`
|
274
349
|
|
275
350
|
#### Kernel
|
276
|
-
|
351
|
+
|
352
|
+
- `itself`
|
277
353
|
|
278
354
|
#### Method
|
279
|
-
|
280
|
-
|
355
|
+
|
356
|
+
- `curry`
|
357
|
+
- `super_method`
|
281
358
|
|
282
359
|
#### String
|
283
|
-
|
284
|
-
|
285
|
-
|
360
|
+
|
361
|
+
- `unicode_normalize`
|
362
|
+
- `unicode_normalize!`
|
363
|
+
- `unicode_normalize?`
|
286
364
|
|
287
365
|
## Ruby 2.1 backports
|
288
366
|
|
289
367
|
#### Array
|
290
|
-
|
368
|
+
|
369
|
+
- `to_h`
|
291
370
|
|
292
371
|
#### Bignum
|
293
|
-
|
372
|
+
|
373
|
+
- `bit_length`
|
294
374
|
|
295
375
|
#### Enumerable
|
296
|
-
|
376
|
+
|
377
|
+
- `to_h`
|
297
378
|
|
298
379
|
#### Fixnum
|
299
|
-
|
380
|
+
|
381
|
+
- `bit_length`
|
300
382
|
|
301
383
|
#### Module
|
302
|
-
|
384
|
+
|
385
|
+
- `include` (now public)
|
386
|
+
- `singleton_class?`
|
303
387
|
|
304
388
|
## Ruby 2.0 backports
|
305
389
|
|
306
390
|
#### Array
|
307
|
-
|
391
|
+
|
392
|
+
- `bsearch`
|
308
393
|
|
309
394
|
#### Enumerable
|
310
|
-
|
395
|
+
|
396
|
+
- `lazy`
|
311
397
|
|
312
398
|
#### Enumerator::Lazy
|
313
|
-
|
399
|
+
|
400
|
+
- all methods
|
314
401
|
|
315
402
|
#### Hash
|
316
|
-
|
317
|
-
|
403
|
+
|
404
|
+
- `default_proc=` (with nil argument)
|
405
|
+
- `to_h`
|
318
406
|
|
319
407
|
#### `nil.to_h`
|
320
408
|
|
321
409
|
#### Range
|
322
|
-
|
410
|
+
|
411
|
+
- `bsearch`
|
323
412
|
|
324
413
|
#### Struct
|
325
|
-
|
414
|
+
|
415
|
+
- `to_h`
|
326
416
|
|
327
417
|
## Ruby 1.9.3 backports
|
328
418
|
|
329
419
|
#### File
|
330
|
-
|
420
|
+
|
421
|
+
- `NULL`
|
331
422
|
|
332
423
|
#### IO
|
333
|
-
|
334
|
-
|
424
|
+
|
425
|
+
- `advise` (acts as a noop)
|
426
|
+
- `write`, `binwrite`
|
335
427
|
|
336
428
|
#### String
|
337
|
-
|
338
|
-
|
429
|
+
|
430
|
+
- `byteslice`
|
431
|
+
- `prepend`
|
339
432
|
|
340
433
|
## Ruby 1.9.2 backports
|
341
434
|
|
342
435
|
#### Array
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
436
|
+
|
437
|
+
- `rotate, rotate!`
|
438
|
+
- `keep_if, select!`
|
439
|
+
- `product` (with block)
|
440
|
+
- `repeated_combination`, `repeated_permutation`
|
441
|
+
- `sort_by!`
|
442
|
+
- `uniq, uniq!` (with block)
|
349
443
|
|
350
444
|
#### Complex
|
351
|
-
|
445
|
+
|
446
|
+
- `to_r`
|
352
447
|
|
353
448
|
#### Dir
|
354
|
-
|
449
|
+
|
450
|
+
- `home`
|
355
451
|
|
356
452
|
#### Enumerable
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
453
|
+
|
454
|
+
- `chunk`
|
455
|
+
- `flat_map`, `collect_concat`
|
456
|
+
- `join`
|
457
|
+
- `slice_before`
|
361
458
|
|
362
459
|
#### Float::INFINITY, NAN
|
363
460
|
|
364
461
|
#### Hash
|
365
|
-
|
462
|
+
|
463
|
+
- `keep_if`, `select!`
|
366
464
|
|
367
465
|
#### Object
|
368
|
-
|
466
|
+
|
467
|
+
- `singleton_class`
|
369
468
|
|
370
469
|
#### Random (new class)
|
371
470
|
|
372
|
-
|
471
|
+
_Note_: The methods of `Random` can't be required individually; the class
|
373
472
|
can only be required whole with `require 'backports/1.9.2/random'`.
|
374
473
|
|
375
474
|
## Ruby 1.9.1 backports
|
376
475
|
|
377
476
|
Additionally, the following Ruby 1.9 features have been backported:
|
477
|
+
|
378
478
|
#### Array
|
379
|
-
|
380
|
-
|
479
|
+
|
480
|
+
- `try_convert`
|
481
|
+
- `sample`
|
381
482
|
|
382
483
|
#### Enumerable
|
383
|
-
|
384
|
-
|
484
|
+
|
485
|
+
- `each_with_object`
|
486
|
+
- `each_with_index` (with arguments)
|
385
487
|
|
386
488
|
#### Enumerator
|
387
|
-
|
489
|
+
|
490
|
+
- `new` (with block)
|
388
491
|
|
389
492
|
#### File
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
493
|
+
|
494
|
+
- `binread`
|
495
|
+
- `to_path`
|
496
|
+
- All class methods accepting filenames will accept files or anything
|
497
|
+
with a `#to_path` method.
|
498
|
+
- `File.open` accepts an options hash.
|
395
499
|
|
396
500
|
#### Float
|
397
|
-
|
501
|
+
|
502
|
+
- `round`
|
398
503
|
|
399
504
|
#### Hash
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
505
|
+
|
506
|
+
- `assoc`, `rassoc`
|
507
|
+
- `key`
|
508
|
+
- `try_convert`
|
509
|
+
- `default_proc=`
|
404
510
|
|
405
511
|
#### Integer
|
406
|
-
|
407
|
-
|
512
|
+
|
513
|
+
- `magnitude`
|
514
|
+
- `round`
|
408
515
|
|
409
516
|
#### IO
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
517
|
+
|
518
|
+
- `bin_read`
|
519
|
+
- `try_convert`
|
520
|
+
- `ungetbyte`
|
521
|
+
- `IO.open` accepts an options hash.
|
414
522
|
|
415
523
|
#### Kernel
|
416
|
-
|
524
|
+
|
525
|
+
- `require_relative`
|
417
526
|
|
418
527
|
#### Math
|
419
|
-
|
420
|
-
|
528
|
+
|
529
|
+
- `log` (with base)
|
530
|
+
- `log2`
|
421
531
|
|
422
532
|
#### Numeric
|
423
|
-
|
533
|
+
|
534
|
+
- `round`
|
424
535
|
|
425
536
|
#### Object
|
426
|
-
|
427
|
-
|
428
|
-
|
537
|
+
|
538
|
+
- `define_singleton_method`
|
539
|
+
- `public_method`
|
540
|
+
- `public_send`
|
429
541
|
|
430
542
|
#### Proc
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
543
|
+
|
544
|
+
- `yield`
|
545
|
+
- `lambda?`
|
546
|
+
- `curry`
|
547
|
+
- `===`
|
435
548
|
|
436
549
|
#### Range
|
437
|
-
|
550
|
+
|
551
|
+
- `cover?`
|
438
552
|
|
439
553
|
#### Regexp
|
440
|
-
|
554
|
+
|
555
|
+
- `try_convert`
|
441
556
|
|
442
557
|
#### String
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
558
|
+
|
559
|
+
- `ascii_only?`
|
560
|
+
- `chr`
|
561
|
+
- `clear`
|
562
|
+
- `codepoints`, `each_codepoint`
|
563
|
+
- `get_byte`, `set_byte`
|
564
|
+
- `ord`
|
565
|
+
- `try_convert`
|
450
566
|
|
451
567
|
`Enumerator` can be accessed directly (instead of `Enumerable::Enumerator`)
|
452
568
|
|
453
|
-
To include
|
454
|
-
"backports/1.9.1"`.
|
569
|
+
To include _only_ these backports and those of the 1.8 line, `require "backports/1.9.1"`.
|
455
570
|
|
456
571
|
Moreover, a pretty good imitation of `BasicObject` is available, but since it
|
457
572
|
is only an imitation, it must be required explicitly:
|
@@ -465,8 +580,11 @@ Complete Ruby 1.8.7 backporting (core language). Refer to the official list of
|
|
465
580
|
backports!
|
466
581
|
|
467
582
|
Only exceptions:
|
583
|
+
|
468
584
|
#### String#gsub (the form returning an enumerator)
|
469
|
-
|
585
|
+
|
586
|
+
#### GC.stress= (not implemented)
|
587
|
+
|
470
588
|
#### Array#choice (removed in 1.9, use 1.9.1's Array#sample instead)
|
471
589
|
|
472
590
|
## Libraries
|
@@ -478,7 +596,9 @@ The backports would be automatically used after requiring 'backports/std_lib' bu
|
|
478
596
|
The following libraries are up to date with Ruby 1.9.3:
|
479
597
|
|
480
598
|
#### Matrix
|
599
|
+
|
481
600
|
#### Prime
|
601
|
+
|
482
602
|
#### Set
|
483
603
|
|
484
604
|
The following library is to date with Ruby 2.0.0:
|
@@ -489,6 +609,7 @@ I am aware of the following backport gem, which probably won't make it into
|
|
489
609
|
this gem:
|
490
610
|
|
491
611
|
#### Net::SMTP for Ruby 1.8.6:
|
612
|
+
|
492
613
|
[smtp_tls](http://seattlerb.rubyforge.org/smtp_tls/)
|
493
614
|
|
494
615
|
Requiring backports for a given version of Ruby will also load
|
@@ -501,13 +622,16 @@ but could be useful in some projects. It is possible to request such
|
|
501
622
|
incompatible changes. Backports currently supports the following:
|
502
623
|
|
503
624
|
#### Hash
|
504
|
-
|
625
|
+
|
626
|
+
- `select` (returns a Hash instead of an Array)
|
505
627
|
|
506
628
|
#### Enumerable / Array
|
507
|
-
|
629
|
+
|
630
|
+
- `map` (returns an enumerator when called without a block)
|
508
631
|
|
509
632
|
#### String
|
510
|
-
|
633
|
+
|
634
|
+
- `length`, `size` (for UTF-8 support)
|
511
635
|
|
512
636
|
These must be imported in addition to the backports gem, for example:
|
513
637
|
|
@@ -519,8 +643,11 @@ These must be imported in addition to the backports gem, for example:
|
|
519
643
|
Thanks for the bug reports and patches, in particular the repeat offenders:
|
520
644
|
|
521
645
|
#### Arto Bendiken ( [bendiken](http://github.com/bendiken) )
|
646
|
+
|
522
647
|
#### Konstantin Haase ( [rkh](https://github.com/rkh) )
|
648
|
+
|
523
649
|
#### Roger Pack ( [rdp](http://github.com/rdp) )
|
650
|
+
|
524
651
|
#### Victor Shepelev ( [zverok](http://github.com/zverok) )
|
525
652
|
|
526
653
|
## Contributing
|
@@ -546,5 +673,4 @@ Failures that are acceptable are added the to `tags` file.
|
|
546
673
|
LICENSE file.
|
547
674
|
|
548
675
|
Author
|
549
|
-
:
|
550
|
-
|
676
|
+
: Marc-André Lafortune
|
@@ -4,4 +4,11 @@ class Dir
|
|
4
4
|
return to_enum(__method__, *args) unless block_given?
|
5
5
|
foreach(*args) { |f| yield f unless Backports::EXCLUDED_CHILDREN.include? f }
|
6
6
|
end
|
7
|
+
|
8
|
+
def each_child(&block)
|
9
|
+
return to_enum(__method__) unless block_given?
|
10
|
+
|
11
|
+
Dir.each_child(path, &block)
|
12
|
+
self
|
13
|
+
end
|
7
14
|
end unless Dir.respond_to? :each_child
|
File without changes
|
@@ -1,10 +1,11 @@
|
|
1
|
-
require 'backports/1.9.1/enumerable/each_with_object' unless Enumerable.method_defined? :each_with_object
|
2
|
-
|
3
1
|
unless Enumerable.method_defined? :tally
|
4
2
|
module Enumerable
|
5
3
|
def tally
|
4
|
+
h = {}
|
6
5
|
# NB: By spec, tally should return default-less hash
|
7
|
-
|
6
|
+
each_entry { |item| h[item] = h.fetch(item, 0) + 1 }
|
7
|
+
|
8
|
+
h
|
8
9
|
end
|
9
10
|
end
|
10
11
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
unless Array.method_defined? :intersect?
|
2
|
+
require 'backports/tools/arguments'
|
3
|
+
|
4
|
+
class Array
|
5
|
+
def intersect?(array)
|
6
|
+
array = Backports.coerce_to_ary(array)
|
7
|
+
|
8
|
+
if size < array.size
|
9
|
+
smaller = self
|
10
|
+
else
|
11
|
+
smaller, array = array, self
|
12
|
+
end
|
13
|
+
(array & smaller).size > 0
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
unless Class.method_defined? :subclasses
|
2
|
+
require 'backports/2.1.0/module/singleton_class'
|
3
|
+
|
4
|
+
class Class
|
5
|
+
def subclasses
|
6
|
+
ObjectSpace.each_object(singleton_class).reject do |klass|
|
7
|
+
klass.superclass != self || klass.singleton_class?
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
unless ([].tally({}) rescue false)
|
2
|
+
require 'backports/tools/arguments'
|
3
|
+
require 'backports/2.7.0/enumerable/tally'
|
4
|
+
require 'backports/tools/alias_method_chain'
|
5
|
+
|
6
|
+
module Enumerable
|
7
|
+
def tally_with_hash_argument(h = ::Backports::Undefined)
|
8
|
+
return tally_without_hash_argument if h.equal? ::Backports::Undefined
|
9
|
+
|
10
|
+
h = ::Backports.coerce_to_hash(h)
|
11
|
+
|
12
|
+
each_entry { |item| h[item] = h.fetch(item, 0) + 1 }
|
13
|
+
|
14
|
+
h
|
15
|
+
end
|
16
|
+
::Backports.alias_method_chain self, :tally, :hash_argument
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
unless (File.dirname("", 0) rescue false)
|
2
|
+
require 'backports/tools/alias_method_chain'
|
3
|
+
|
4
|
+
class File
|
5
|
+
def self.dirname_with_depth(path, depth = 1)
|
6
|
+
return dirname_without_depth(path) if depth == 1
|
7
|
+
|
8
|
+
raise ArgumentError, "negative depth #{depth}" if depth < 0
|
9
|
+
|
10
|
+
depth.times { path = dirname_without_depth(path) }
|
11
|
+
|
12
|
+
path
|
13
|
+
end
|
14
|
+
Backports.alias_method_chain singleton_class, :dirname, :depth
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'backports/3.1.0'
|
data/lib/backports/latest.rb
CHANGED
data/lib/backports/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module Backports
|
2
|
-
VERSION = "3.
|
2
|
+
VERSION = "3.22.0" unless Backports.constants.include? :VERSION # the guard is against a redefinition warning that happens on Travis
|
3
3
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: backports
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.22.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marc-André Lafortune
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Essential backports that enable many of the nice features of Ruby for
|
14
14
|
earlier versions.
|
@@ -391,6 +391,7 @@ files:
|
|
391
391
|
- lib/backports/2.1.0/fixnum/bit_length.rb
|
392
392
|
- lib/backports/2.1.0/module.rb
|
393
393
|
- lib/backports/2.1.0/module/include.rb
|
394
|
+
- lib/backports/2.1.0/module/singleton_class.rb
|
394
395
|
- lib/backports/2.1.rb
|
395
396
|
- lib/backports/2.2.0.rb
|
396
397
|
- lib/backports/2.2.0/enumerable.rb
|
@@ -524,7 +525,7 @@ files:
|
|
524
525
|
- lib/backports/2.7.0/comparable.rb
|
525
526
|
- lib/backports/2.7.0/comparable/clamp.rb
|
526
527
|
- lib/backports/2.7.0/complex.rb
|
527
|
-
- lib/backports/2.7.0/complex/
|
528
|
+
- lib/backports/2.7.0/complex/comparison.rb
|
528
529
|
- lib/backports/2.7.0/enumerable.rb
|
529
530
|
- lib/backports/2.7.0/enumerable/filter_map.rb
|
530
531
|
- lib/backports/2.7.0/enumerable/tally.rb
|
@@ -543,6 +544,25 @@ files:
|
|
543
544
|
- lib/backports/3.0.0/symbol.rb
|
544
545
|
- lib/backports/3.0.0/symbol/name.rb
|
545
546
|
- lib/backports/3.0.rb
|
547
|
+
- lib/backports/3.1.0.rb
|
548
|
+
- lib/backports/3.1.0/array.rb
|
549
|
+
- lib/backports/3.1.0/array/intersect.rb
|
550
|
+
- lib/backports/3.1.0/class.rb
|
551
|
+
- lib/backports/3.1.0/class/descendants.rb
|
552
|
+
- lib/backports/3.1.0/class/subclasses.rb
|
553
|
+
- lib/backports/3.1.0/enumerable.rb
|
554
|
+
- lib/backports/3.1.0/enumerable/compact.rb
|
555
|
+
- lib/backports/3.1.0/enumerable/tally.rb
|
556
|
+
- lib/backports/3.1.0/file.rb
|
557
|
+
- lib/backports/3.1.0/file/dirname.rb
|
558
|
+
- lib/backports/3.1.0/integer.rb
|
559
|
+
- lib/backports/3.1.0/integer/try_convert.rb
|
560
|
+
- lib/backports/3.1.0/match_data.rb
|
561
|
+
- lib/backports/3.1.0/match_data/match.rb
|
562
|
+
- lib/backports/3.1.0/match_data/match_length.rb
|
563
|
+
- lib/backports/3.1.0/struct.rb
|
564
|
+
- lib/backports/3.1.0/struct/keyword_init.rb
|
565
|
+
- lib/backports/3.1.rb
|
546
566
|
- lib/backports/basic_object.rb
|
547
567
|
- lib/backports/force/array_map.rb
|
548
568
|
- lib/backports/force/enumerable_map.rb
|
@@ -605,7 +625,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
605
625
|
- !ruby/object:Gem::Version
|
606
626
|
version: '0'
|
607
627
|
requirements: []
|
608
|
-
rubygems_version: 3.
|
628
|
+
rubygems_version: 3.1.4
|
609
629
|
signing_key:
|
610
630
|
specification_version: 4
|
611
631
|
summary: Backports of Ruby features for older Ruby.
|