backports 3.20.2 → 3.23.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.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +401 -304
  3. data/Gemfile +1 -1
  4. data/README.md +288 -158
  5. data/lib/backports/2.1.0/module/singleton_class.rb +8 -0
  6. data/lib/backports/2.3.0/struct/dig.rb +2 -0
  7. data/lib/backports/2.4.0/string/unpack1.rb +7 -0
  8. data/lib/backports/2.5.0/dir/children.rb +4 -0
  9. data/lib/backports/2.5.0/dir/each_child.rb +7 -0
  10. data/lib/backports/2.7.0/complex/{comparision.rb → comparison.rb} +0 -0
  11. data/lib/backports/2.7.0/enumerable/tally.rb +4 -3
  12. data/lib/backports/2.7.0/symbol/end_with.rb +9 -0
  13. data/lib/backports/2.7.0/symbol.rb +3 -0
  14. data/lib/backports/3.0.0/symbol/name.rb +16 -6
  15. data/lib/backports/3.1.0/array/intersect.rb +16 -0
  16. data/lib/backports/3.1.0/array.rb +3 -0
  17. data/lib/backports/3.1.0/class/descendants.rb +11 -0
  18. data/lib/backports/3.1.0/class/subclasses.rb +11 -0
  19. data/lib/backports/3.1.0/class.rb +3 -0
  20. data/lib/backports/3.1.0/enumerable/compact.rb +5 -0
  21. data/lib/backports/3.1.0/enumerable/tally.rb +18 -0
  22. data/lib/backports/3.1.0/enumerable.rb +3 -0
  23. data/lib/backports/3.1.0/file/dirname.rb +16 -0
  24. data/lib/backports/3.1.0/file.rb +3 -0
  25. data/lib/backports/3.1.0/integer/try_convert.rb +7 -0
  26. data/lib/backports/3.1.0/integer.rb +3 -0
  27. data/lib/backports/3.1.0/match_data/match.rb +5 -0
  28. data/lib/backports/3.1.0/match_data/match_length.rb +6 -0
  29. data/lib/backports/3.1.0/match_data.rb +3 -0
  30. data/lib/backports/3.1.0/struct/keyword_init.rb +5 -0
  31. data/lib/backports/3.1.0/struct.rb +3 -0
  32. data/lib/backports/3.1.0.rb +3 -0
  33. data/lib/backports/3.1.rb +1 -0
  34. data/lib/backports/latest.rb +1 -1
  35. data/lib/backports/ractor/cloner.rb +13 -4
  36. data/lib/backports/version.rb +1 -1
  37. metadata +27 -4
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.0 while
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.0.0's standards:
41
+ For example, to bring any version of Ruby mostly up to Ruby 3.1.0's standards:
42
42
 
43
- require 'backports/3.0.0'
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.0.0 (for all versions of Ruby)!
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
- *Note*: For production / public gems, it is highly recommended you only require
51
+ _Note_: For production / public gems, it is highly recommended you only require
52
52
  the backports you need explicitly.
53
53
 
54
- *Note*: Although I am a Ruby committer, this gem is a personal project and is
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,349 +109,467 @@ 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
- - `except`
148
+
149
+ - `except`
115
150
 
116
151
  #### Hash
117
- - `except`
118
- - `transform_keys`, `transform_keys!` (with hash argument)
152
+
153
+ - `except`
154
+ - `transform_keys`, `transform_keys!` (with hash argument)
119
155
 
120
156
  #### Ractor
121
- - All methods, with the caveats:
122
- - uses Ruby's `Thread` internally
123
- - will not raise some errors when `Ractor` would (in particular `Ractor::IsolationError`)
124
- - supported in Ruby 2.0+ only
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
- - `name`
164
+
165
+ - `name`
128
166
 
129
167
  ## Ruby 2.7 backports
130
168
 
131
169
  #### Array
132
- - `intersection`
170
+
171
+ - `intersection`
133
172
 
134
173
  #### Comparable
135
- - `clamp` (with range)
174
+
175
+ - `clamp` (with range)
136
176
 
137
177
  #### Complex
138
- - `<=>`
178
+
179
+ - `<=>`
139
180
 
140
181
  #### Enumerable
141
- - `filter_map`
142
- - `tally`
182
+
183
+ - `filter_map`
184
+ - `tally`
143
185
 
144
186
  #### Enumerator
145
- - `produce` (class method)
187
+
188
+ - `produce` (class method)
189
+
190
+ #### Symbol
191
+ - `end_with?`
146
192
 
147
193
  #### Time
148
- - `floor`, `ceil`
194
+
195
+ - `floor`, `ceil`
149
196
 
150
197
  ## Ruby 2.6 backports
151
198
 
152
199
  #### Array
153
- - `difference`, `union`
154
- - `to_h` (with block)
200
+
201
+ - `difference`, `union`
202
+ - `to_h` (with block)
155
203
 
156
204
  #### Enumerable
157
- - `chain`
158
- - `to_h` (with block)
205
+
206
+ - `chain`
207
+ - `to_h` (with block)
159
208
 
160
209
  #### Enumerator::Chain (use Enumerable#chain)
161
210
 
162
211
  #### Hash
163
- - `merge`, `merge!`/`update` (with multiple arguments)
164
- - `to_h` (with block)
212
+
213
+ - `merge`, `merge!`/`update` (with multiple arguments)
214
+ - `to_h` (with block)
165
215
 
166
216
  #### Kernel
167
- - `then`
217
+
218
+ - `then`
168
219
 
169
220
  #### Method
170
- - `<<`, `>>`
221
+
222
+ - `<<`, `>>`
171
223
 
172
224
  #### Proc
173
- - `<<`, `>>`
225
+
226
+ - `<<`, `>>`
174
227
 
175
228
  #### Range
176
- - `cover?` (with `Range` argument)
229
+
230
+ - `cover?` (with `Range` argument)
177
231
 
178
232
  ## Ruby 2.5 backports
179
233
 
180
234
  #### Array
181
- - `append`, `prepend`
235
+
236
+ - `append`, `prepend`
182
237
 
183
238
  #### Dir
184
- - `children`, `each_child`
239
+
240
+ - `children`, `each_child`
185
241
 
186
242
  #### Enumerable
187
- - `any?`, `all?`, `none?`, `one?` (with pattern argument)
243
+
244
+ - `any?`, `all?`, `none?`, `one?` (with pattern argument)
188
245
 
189
246
  #### Hash
190
- - `slice`
191
- - `transform_keys`
247
+
248
+ - `slice`
249
+ - `transform_keys`
192
250
 
193
251
  #### Integer
194
- - `sqrt`
195
- - `allbits?`, `anybits?` and `nobits?`
252
+
253
+ - `sqrt`
254
+ - `allbits?`, `anybits?` and `nobits?`
196
255
 
197
256
  #### Kernel
198
- - `yield_self`
257
+
258
+ - `yield_self`
199
259
 
200
260
  #### Module
201
- - `attr`, `attr_accessor`, `attr_reader`, `attr_writer` (now public)
202
- - `define_method`, `alias_method`, `undef_method`, `remove_method` (now
203
- public)
261
+
262
+ - `attr`, `attr_accessor`, `attr_reader`, `attr_writer` (now public)
263
+ - `define_method`, `alias_method`, `undef_method`, `remove_method` (now
264
+ public)
204
265
 
205
266
  #### String
206
- - `delete_prefix`, `delete_prefix!`
207
- - `delete_suffix`, `delete_suffix!`
208
- - `undump`
267
+
268
+ - `delete_prefix`, `delete_prefix!`
269
+ - `delete_suffix`, `delete_suffix!`
270
+ - `undump`
209
271
 
210
272
  #### Struct
211
- - `new` (with `keyword_init: true`)
273
+
274
+ - `new` (with `keyword_init: true`)
212
275
 
213
276
  ## Ruby 2.4 backports
214
277
 
215
278
  #### Comparable
216
- - `clamp`
279
+
280
+ - `clamp`
217
281
 
218
282
  #### Enumerable
219
- - `sum`
220
- - `uniq`
283
+
284
+ - `sum`
285
+ - `uniq`
221
286
 
222
287
  #### Hash
223
- - `compact`, `compact!`
224
- - `transform_values`, `transform_values!`
288
+
289
+ - `compact`, `compact!`
290
+ - `transform_values`, `transform_values!`
225
291
 
226
292
  #### Queue
227
- - `close`, `closed?`
293
+
294
+ - `close`, `closed?`
228
295
 
229
296
  #### Regexp
230
- - `match?`
297
+
298
+ - `match?`
231
299
 
232
300
  #### String
233
- - `match?`
301
+
302
+ - `match?`
303
+ - `unpack1`
234
304
 
235
305
  #### FalseClass, Fixnum, Bignum, Float, NilClass, TrueClass
236
- - `dup`
306
+
307
+ - `dup`
237
308
 
238
309
  ## Ruby 2.3 backports
239
310
 
240
311
  #### Array
241
- - `bsearch_index`
242
- - `dig`
312
+
313
+ - `bsearch_index`
314
+ - `dig`
243
315
 
244
316
  #### Enumerable
245
- - `chunk_while`
246
- - `grep_v`
317
+
318
+ - `chunk_while`
319
+ - `grep_v`
247
320
 
248
321
  #### Hash
249
- - `dig`
250
- - `fetch_values`
251
- - `to_proc`
252
- - <=, <, >=, >
322
+
323
+ - `dig`
324
+ - `fetch_values`
325
+ - `to_proc`
326
+ - <=, <, >=, >
253
327
 
254
328
  #### Numeric
255
- - `negative?`
256
- - `positive?`
329
+
330
+ - `negative?`
331
+ - `positive?`
257
332
 
258
333
  #### String
259
- - unary + and -
334
+
335
+ - unary + and -
260
336
 
261
337
  #### Struct
262
- - `dig`
338
+
339
+ - `dig`
263
340
 
264
341
  ## Ruby 2.2 backports
265
342
 
266
343
  #### Enumerable
267
- - `slice_after`
268
- - `slice_when`
344
+
345
+ - `slice_after`
346
+ - `slice_when`
269
347
 
270
348
  #### Float
271
- - `prev_float`
272
- - `next_float`
349
+
350
+ - `prev_float`
351
+ - `next_float`
273
352
 
274
353
  #### Kernel
275
- - `itself`
354
+
355
+ - `itself`
276
356
 
277
357
  #### Method
278
- - `curry`
279
- - `super_method`
358
+
359
+ - `curry`
360
+ - `super_method`
280
361
 
281
362
  #### String
282
- - `unicode_normalize`
283
- - `unicode_normalize!`
284
- - `unicode_normalize?`
363
+
364
+ - `unicode_normalize`
365
+ - `unicode_normalize!`
366
+ - `unicode_normalize?`
285
367
 
286
368
  ## Ruby 2.1 backports
287
369
 
288
370
  #### Array
289
- - `to_h`
371
+
372
+ - `to_h`
290
373
 
291
374
  #### Bignum
292
- - `bit_length`
375
+
376
+ - `bit_length`
293
377
 
294
378
  #### Enumerable
295
- - `to_h`
379
+
380
+ - `to_h`
296
381
 
297
382
  #### Fixnum
298
- - `bit_length`
383
+
384
+ - `bit_length`
299
385
 
300
386
  #### Module
301
- - `include` (now public)
387
+
388
+ - `include` (now public)
389
+ - `singleton_class?`
302
390
 
303
391
  ## Ruby 2.0 backports
304
392
 
305
393
  #### Array
306
- - `bsearch`
394
+
395
+ - `bsearch`
307
396
 
308
397
  #### Enumerable
309
- - `lazy`
398
+
399
+ - `lazy`
310
400
 
311
401
  #### Enumerator::Lazy
312
- - all methods
402
+
403
+ - all methods
313
404
 
314
405
  #### Hash
315
- - `default_proc=` (with nil argument)
316
- - `to_h`
406
+
407
+ - `default_proc=` (with nil argument)
408
+ - `to_h`
317
409
 
318
410
  #### `nil.to_h`
319
411
 
320
412
  #### Range
321
- - `bsearch`
413
+
414
+ - `bsearch`
322
415
 
323
416
  #### Struct
324
- - `to_h`
417
+
418
+ - `to_h`
325
419
 
326
420
  ## Ruby 1.9.3 backports
327
421
 
328
422
  #### File
329
- - `NULL`
423
+
424
+ - `NULL`
330
425
 
331
426
  #### IO
332
- - `advise` (acts as a noop)
333
- - `write`, `binwrite`
427
+
428
+ - `advise` (acts as a noop)
429
+ - `write`, `binwrite`
334
430
 
335
431
  #### String
336
- - `byteslice`
337
- - `prepend`
432
+
433
+ - `byteslice`
434
+ - `prepend`
338
435
 
339
436
  ## Ruby 1.9.2 backports
340
437
 
341
438
  #### Array
342
- - `rotate, rotate!`
343
- - `keep_if, select!`
344
- - `product` (with block)
345
- - `repeated_combination`, `repeated_permutation`
346
- - `sort_by!`
347
- - `uniq, uniq!` (with block)
439
+
440
+ - `rotate, rotate!`
441
+ - `keep_if, select!`
442
+ - `product` (with block)
443
+ - `repeated_combination`, `repeated_permutation`
444
+ - `sort_by!`
445
+ - `uniq, uniq!` (with block)
348
446
 
349
447
  #### Complex
350
- - `to_r`
448
+
449
+ - `to_r`
351
450
 
352
451
  #### Dir
353
- - `home`
452
+
453
+ - `home`
354
454
 
355
455
  #### Enumerable
356
- - `chunk`
357
- - `flat_map`, `collect_concat`
358
- - `join`
359
- - `slice_before`
456
+
457
+ - `chunk`
458
+ - `flat_map`, `collect_concat`
459
+ - `join`
460
+ - `slice_before`
360
461
 
361
462
  #### Float::INFINITY, NAN
362
463
 
363
464
  #### Hash
364
- - `keep_if`, `select!`
465
+
466
+ - `keep_if`, `select!`
365
467
 
366
468
  #### Object
367
- - `singleton_class`
469
+
470
+ - `singleton_class`
368
471
 
369
472
  #### Random (new class)
370
473
 
371
- *Note*: The methods of `Random` can't be required individually; the class
474
+ _Note_: The methods of `Random` can't be required individually; the class
372
475
  can only be required whole with `require 'backports/1.9.2/random'`.
373
476
 
374
477
  ## Ruby 1.9.1 backports
375
478
 
376
479
  Additionally, the following Ruby 1.9 features have been backported:
480
+
377
481
  #### Array
378
- - `try_convert`
379
- - `sample`
482
+
483
+ - `try_convert`
484
+ - `sample`
380
485
 
381
486
  #### Enumerable
382
- - `each_with_object`
383
- - `each_with_index` (with arguments)
487
+
488
+ - `each_with_object`
489
+ - `each_with_index` (with arguments)
384
490
 
385
491
  #### Enumerator
386
- - `new` (with block)
492
+
493
+ - `new` (with block)
387
494
 
388
495
  #### File
389
- - `binread`
390
- - `to_path`
391
- - All class methods accepting filenames will accept files or anything
392
- with a `#to_path` method.
393
- - `File.open` accepts an options hash.
496
+
497
+ - `binread`
498
+ - `to_path`
499
+ - All class methods accepting filenames will accept files or anything
500
+ with a `#to_path` method.
501
+ - `File.open` accepts an options hash.
394
502
 
395
503
  #### Float
396
- - `round`
504
+
505
+ - `round`
397
506
 
398
507
  #### Hash
399
- - `assoc`, `rassoc`
400
- - `key`
401
- - `try_convert`
402
- - `default_proc=`
508
+
509
+ - `assoc`, `rassoc`
510
+ - `key`
511
+ - `try_convert`
512
+ - `default_proc=`
403
513
 
404
514
  #### Integer
405
- - `magnitude`
406
- - `round`
515
+
516
+ - `magnitude`
517
+ - `round`
407
518
 
408
519
  #### IO
409
- - `bin_read`
410
- - `try_convert`
411
- - `ungetbyte`
412
- - `IO.open` accepts an options hash.
520
+
521
+ - `bin_read`
522
+ - `try_convert`
523
+ - `ungetbyte`
524
+ - `IO.open` accepts an options hash.
413
525
 
414
526
  #### Kernel
415
- - `require_relative`
527
+
528
+ - `require_relative`
416
529
 
417
530
  #### Math
418
- - `log` (with base)
419
- - `log2`
531
+
532
+ - `log` (with base)
533
+ - `log2`
420
534
 
421
535
  #### Numeric
422
- - `round`
536
+
537
+ - `round`
423
538
 
424
539
  #### Object
425
- - `define_singleton_method`
426
- - `public_method`
427
- - `public_send`
540
+
541
+ - `define_singleton_method`
542
+ - `public_method`
543
+ - `public_send`
428
544
 
429
545
  #### Proc
430
- - `yield`
431
- - `lambda?`
432
- - `curry`
433
- - `===`
546
+
547
+ - `yield`
548
+ - `lambda?`
549
+ - `curry`
550
+ - `===`
434
551
 
435
552
  #### Range
436
- - `cover?`
553
+
554
+ - `cover?`
437
555
 
438
556
  #### Regexp
439
- - `try_convert`
557
+
558
+ - `try_convert`
440
559
 
441
560
  #### String
442
- - `ascii_only?`
443
- - `chr`
444
- - `clear`
445
- - `codepoints`, `each_codepoint`
446
- - `get_byte`, `set_byte`
447
- - `ord`
448
- - `try_convert`
561
+
562
+ - `ascii_only?`
563
+ - `chr`
564
+ - `clear`
565
+ - `codepoints`, `each_codepoint`
566
+ - `get_byte`, `set_byte`
567
+ - `ord`
568
+ - `try_convert`
449
569
 
450
570
  `Enumerator` can be accessed directly (instead of `Enumerable::Enumerator`)
451
571
 
452
- To include *only* these backports and those of the 1.8 line, `require
453
- "backports/1.9.1"`.
572
+ To include _only_ these backports and those of the 1.8 line, `require "backports/1.9.1"`.
454
573
 
455
574
  Moreover, a pretty good imitation of `BasicObject` is available, but since it
456
575
  is only an imitation, it must be required explicitly:
@@ -464,8 +583,11 @@ Complete Ruby 1.8.7 backporting (core language). Refer to the official list of
464
583
  backports!
465
584
 
466
585
  Only exceptions:
586
+
467
587
  #### String#gsub (the form returning an enumerator)
468
- #### GC.stress= (not implemented)
588
+
589
+ #### GC.stress= (not implemented)
590
+
469
591
  #### Array#choice (removed in 1.9, use 1.9.1's Array#sample instead)
470
592
 
471
593
  ## Libraries
@@ -477,7 +599,9 @@ The backports would be automatically used after requiring 'backports/std_lib' bu
477
599
  The following libraries are up to date with Ruby 1.9.3:
478
600
 
479
601
  #### Matrix
602
+
480
603
  #### Prime
604
+
481
605
  #### Set
482
606
 
483
607
  The following library is to date with Ruby 2.0.0:
@@ -488,6 +612,7 @@ I am aware of the following backport gem, which probably won't make it into
488
612
  this gem:
489
613
 
490
614
  #### Net::SMTP for Ruby 1.8.6:
615
+
491
616
  [smtp_tls](http://seattlerb.rubyforge.org/smtp_tls/)
492
617
 
493
618
  Requiring backports for a given version of Ruby will also load
@@ -500,13 +625,16 @@ but could be useful in some projects. It is possible to request such
500
625
  incompatible changes. Backports currently supports the following:
501
626
 
502
627
  #### Hash
503
- - `select` (returns a Hash instead of an Array)
628
+
629
+ - `select` (returns a Hash instead of an Array)
504
630
 
505
631
  #### Enumerable / Array
506
- - `map` (returns an enumerator when called without a block)
632
+
633
+ - `map` (returns an enumerator when called without a block)
507
634
 
508
635
  #### String
509
- - `length`, `size` (for UTF-8 support)
636
+
637
+ - `length`, `size` (for UTF-8 support)
510
638
 
511
639
  These must be imported in addition to the backports gem, for example:
512
640
 
@@ -518,8 +646,11 @@ These must be imported in addition to the backports gem, for example:
518
646
  Thanks for the bug reports and patches, in particular the repeat offenders:
519
647
 
520
648
  #### Arto Bendiken ( [bendiken](http://github.com/bendiken) )
649
+
521
650
  #### Konstantin Haase ( [rkh](https://github.com/rkh) )
651
+
522
652
  #### Roger Pack ( [rdp](http://github.com/rdp) )
653
+
523
654
  #### Victor Shepelev ( [zverok](http://github.com/zverok) )
524
655
 
525
656
  ## Contributing
@@ -545,5 +676,4 @@ Failures that are acceptable are added the to `tags` file.
545
676
  LICENSE file.
546
677
 
547
678
  Author
548
- : Marc-André Lafortune
549
-
679
+ : Marc-André Lafortune