backports 3.21.0 → 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 (35) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +401 -304
  3. data/Gemfile +1 -1
  4. data/README.md +288 -159
  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.5.0/dir/children.rb +4 -0
  8. data/lib/backports/2.5.0/dir/each_child.rb +7 -0
  9. data/lib/backports/2.7.0/complex/{comparision.rb → comparison.rb} +0 -0
  10. data/lib/backports/2.7.0/enumerable/tally.rb +4 -3
  11. data/lib/backports/2.7.0/symbol/end_with.rb +9 -0
  12. data/lib/backports/2.7.0/symbol.rb +3 -0
  13. data/lib/backports/3.0.0/symbol/name.rb +16 -6
  14. data/lib/backports/3.1.0/array/intersect.rb +16 -0
  15. data/lib/backports/3.1.0/array.rb +3 -0
  16. data/lib/backports/3.1.0/class/descendants.rb +11 -0
  17. data/lib/backports/3.1.0/class/subclasses.rb +11 -0
  18. data/lib/backports/3.1.0/class.rb +3 -0
  19. data/lib/backports/3.1.0/enumerable/compact.rb +5 -0
  20. data/lib/backports/3.1.0/enumerable/tally.rb +18 -0
  21. data/lib/backports/3.1.0/enumerable.rb +3 -0
  22. data/lib/backports/3.1.0/file/dirname.rb +16 -0
  23. data/lib/backports/3.1.0/file.rb +3 -0
  24. data/lib/backports/3.1.0/integer/try_convert.rb +7 -0
  25. data/lib/backports/3.1.0/integer.rb +3 -0
  26. data/lib/backports/3.1.0/match_data/match.rb +5 -0
  27. data/lib/backports/3.1.0/match_data/match_length.rb +6 -0
  28. data/lib/backports/3.1.0/match_data.rb +3 -0
  29. data/lib/backports/3.1.0/struct/keyword_init.rb +5 -0
  30. data/lib/backports/3.1.0/struct.rb +3 -0
  31. data/lib/backports/3.1.0.rb +3 -0
  32. data/lib/backports/3.1.rb +1 -0
  33. data/lib/backports/latest.rb +1 -1
  34. data/lib/backports/version.rb +1 -1
  35. metadata +26 -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,350 +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?`
234
- - `unpack1`
301
+
302
+ - `match?`
303
+ - `unpack1`
235
304
 
236
305
  #### FalseClass, Fixnum, Bignum, Float, NilClass, TrueClass
237
- - `dup`
306
+
307
+ - `dup`
238
308
 
239
309
  ## Ruby 2.3 backports
240
310
 
241
311
  #### Array
242
- - `bsearch_index`
243
- - `dig`
312
+
313
+ - `bsearch_index`
314
+ - `dig`
244
315
 
245
316
  #### Enumerable
246
- - `chunk_while`
247
- - `grep_v`
317
+
318
+ - `chunk_while`
319
+ - `grep_v`
248
320
 
249
321
  #### Hash
250
- - `dig`
251
- - `fetch_values`
252
- - `to_proc`
253
- - <=, <, >=, >
322
+
323
+ - `dig`
324
+ - `fetch_values`
325
+ - `to_proc`
326
+ - <=, <, >=, >
254
327
 
255
328
  #### Numeric
256
- - `negative?`
257
- - `positive?`
329
+
330
+ - `negative?`
331
+ - `positive?`
258
332
 
259
333
  #### String
260
- - unary + and -
334
+
335
+ - unary + and -
261
336
 
262
337
  #### Struct
263
- - `dig`
338
+
339
+ - `dig`
264
340
 
265
341
  ## Ruby 2.2 backports
266
342
 
267
343
  #### Enumerable
268
- - `slice_after`
269
- - `slice_when`
344
+
345
+ - `slice_after`
346
+ - `slice_when`
270
347
 
271
348
  #### Float
272
- - `prev_float`
273
- - `next_float`
349
+
350
+ - `prev_float`
351
+ - `next_float`
274
352
 
275
353
  #### Kernel
276
- - `itself`
354
+
355
+ - `itself`
277
356
 
278
357
  #### Method
279
- - `curry`
280
- - `super_method`
358
+
359
+ - `curry`
360
+ - `super_method`
281
361
 
282
362
  #### String
283
- - `unicode_normalize`
284
- - `unicode_normalize!`
285
- - `unicode_normalize?`
363
+
364
+ - `unicode_normalize`
365
+ - `unicode_normalize!`
366
+ - `unicode_normalize?`
286
367
 
287
368
  ## Ruby 2.1 backports
288
369
 
289
370
  #### Array
290
- - `to_h`
371
+
372
+ - `to_h`
291
373
 
292
374
  #### Bignum
293
- - `bit_length`
375
+
376
+ - `bit_length`
294
377
 
295
378
  #### Enumerable
296
- - `to_h`
379
+
380
+ - `to_h`
297
381
 
298
382
  #### Fixnum
299
- - `bit_length`
383
+
384
+ - `bit_length`
300
385
 
301
386
  #### Module
302
- - `include` (now public)
387
+
388
+ - `include` (now public)
389
+ - `singleton_class?`
303
390
 
304
391
  ## Ruby 2.0 backports
305
392
 
306
393
  #### Array
307
- - `bsearch`
394
+
395
+ - `bsearch`
308
396
 
309
397
  #### Enumerable
310
- - `lazy`
398
+
399
+ - `lazy`
311
400
 
312
401
  #### Enumerator::Lazy
313
- - all methods
402
+
403
+ - all methods
314
404
 
315
405
  #### Hash
316
- - `default_proc=` (with nil argument)
317
- - `to_h`
406
+
407
+ - `default_proc=` (with nil argument)
408
+ - `to_h`
318
409
 
319
410
  #### `nil.to_h`
320
411
 
321
412
  #### Range
322
- - `bsearch`
413
+
414
+ - `bsearch`
323
415
 
324
416
  #### Struct
325
- - `to_h`
417
+
418
+ - `to_h`
326
419
 
327
420
  ## Ruby 1.9.3 backports
328
421
 
329
422
  #### File
330
- - `NULL`
423
+
424
+ - `NULL`
331
425
 
332
426
  #### IO
333
- - `advise` (acts as a noop)
334
- - `write`, `binwrite`
427
+
428
+ - `advise` (acts as a noop)
429
+ - `write`, `binwrite`
335
430
 
336
431
  #### String
337
- - `byteslice`
338
- - `prepend`
432
+
433
+ - `byteslice`
434
+ - `prepend`
339
435
 
340
436
  ## Ruby 1.9.2 backports
341
437
 
342
438
  #### Array
343
- - `rotate, rotate!`
344
- - `keep_if, select!`
345
- - `product` (with block)
346
- - `repeated_combination`, `repeated_permutation`
347
- - `sort_by!`
348
- - `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)
349
446
 
350
447
  #### Complex
351
- - `to_r`
448
+
449
+ - `to_r`
352
450
 
353
451
  #### Dir
354
- - `home`
452
+
453
+ - `home`
355
454
 
356
455
  #### Enumerable
357
- - `chunk`
358
- - `flat_map`, `collect_concat`
359
- - `join`
360
- - `slice_before`
456
+
457
+ - `chunk`
458
+ - `flat_map`, `collect_concat`
459
+ - `join`
460
+ - `slice_before`
361
461
 
362
462
  #### Float::INFINITY, NAN
363
463
 
364
464
  #### Hash
365
- - `keep_if`, `select!`
465
+
466
+ - `keep_if`, `select!`
366
467
 
367
468
  #### Object
368
- - `singleton_class`
469
+
470
+ - `singleton_class`
369
471
 
370
472
  #### Random (new class)
371
473
 
372
- *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
373
475
  can only be required whole with `require 'backports/1.9.2/random'`.
374
476
 
375
477
  ## Ruby 1.9.1 backports
376
478
 
377
479
  Additionally, the following Ruby 1.9 features have been backported:
480
+
378
481
  #### Array
379
- - `try_convert`
380
- - `sample`
482
+
483
+ - `try_convert`
484
+ - `sample`
381
485
 
382
486
  #### Enumerable
383
- - `each_with_object`
384
- - `each_with_index` (with arguments)
487
+
488
+ - `each_with_object`
489
+ - `each_with_index` (with arguments)
385
490
 
386
491
  #### Enumerator
387
- - `new` (with block)
492
+
493
+ - `new` (with block)
388
494
 
389
495
  #### File
390
- - `binread`
391
- - `to_path`
392
- - All class methods accepting filenames will accept files or anything
393
- with a `#to_path` method.
394
- - `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.
395
502
 
396
503
  #### Float
397
- - `round`
504
+
505
+ - `round`
398
506
 
399
507
  #### Hash
400
- - `assoc`, `rassoc`
401
- - `key`
402
- - `try_convert`
403
- - `default_proc=`
508
+
509
+ - `assoc`, `rassoc`
510
+ - `key`
511
+ - `try_convert`
512
+ - `default_proc=`
404
513
 
405
514
  #### Integer
406
- - `magnitude`
407
- - `round`
515
+
516
+ - `magnitude`
517
+ - `round`
408
518
 
409
519
  #### IO
410
- - `bin_read`
411
- - `try_convert`
412
- - `ungetbyte`
413
- - `IO.open` accepts an options hash.
520
+
521
+ - `bin_read`
522
+ - `try_convert`
523
+ - `ungetbyte`
524
+ - `IO.open` accepts an options hash.
414
525
 
415
526
  #### Kernel
416
- - `require_relative`
527
+
528
+ - `require_relative`
417
529
 
418
530
  #### Math
419
- - `log` (with base)
420
- - `log2`
531
+
532
+ - `log` (with base)
533
+ - `log2`
421
534
 
422
535
  #### Numeric
423
- - `round`
536
+
537
+ - `round`
424
538
 
425
539
  #### Object
426
- - `define_singleton_method`
427
- - `public_method`
428
- - `public_send`
540
+
541
+ - `define_singleton_method`
542
+ - `public_method`
543
+ - `public_send`
429
544
 
430
545
  #### Proc
431
- - `yield`
432
- - `lambda?`
433
- - `curry`
434
- - `===`
546
+
547
+ - `yield`
548
+ - `lambda?`
549
+ - `curry`
550
+ - `===`
435
551
 
436
552
  #### Range
437
- - `cover?`
553
+
554
+ - `cover?`
438
555
 
439
556
  #### Regexp
440
- - `try_convert`
557
+
558
+ - `try_convert`
441
559
 
442
560
  #### String
443
- - `ascii_only?`
444
- - `chr`
445
- - `clear`
446
- - `codepoints`, `each_codepoint`
447
- - `get_byte`, `set_byte`
448
- - `ord`
449
- - `try_convert`
561
+
562
+ - `ascii_only?`
563
+ - `chr`
564
+ - `clear`
565
+ - `codepoints`, `each_codepoint`
566
+ - `get_byte`, `set_byte`
567
+ - `ord`
568
+ - `try_convert`
450
569
 
451
570
  `Enumerator` can be accessed directly (instead of `Enumerable::Enumerator`)
452
571
 
453
- To include *only* these backports and those of the 1.8 line, `require
454
- "backports/1.9.1"`.
572
+ To include _only_ these backports and those of the 1.8 line, `require "backports/1.9.1"`.
455
573
 
456
574
  Moreover, a pretty good imitation of `BasicObject` is available, but since it
457
575
  is only an imitation, it must be required explicitly:
@@ -465,8 +583,11 @@ Complete Ruby 1.8.7 backporting (core language). Refer to the official list of
465
583
  backports!
466
584
 
467
585
  Only exceptions:
586
+
468
587
  #### String#gsub (the form returning an enumerator)
469
- #### GC.stress= (not implemented)
588
+
589
+ #### GC.stress= (not implemented)
590
+
470
591
  #### Array#choice (removed in 1.9, use 1.9.1's Array#sample instead)
471
592
 
472
593
  ## Libraries
@@ -478,7 +599,9 @@ The backports would be automatically used after requiring 'backports/std_lib' bu
478
599
  The following libraries are up to date with Ruby 1.9.3:
479
600
 
480
601
  #### Matrix
602
+
481
603
  #### Prime
604
+
482
605
  #### Set
483
606
 
484
607
  The following library is to date with Ruby 2.0.0:
@@ -489,6 +612,7 @@ I am aware of the following backport gem, which probably won't make it into
489
612
  this gem:
490
613
 
491
614
  #### Net::SMTP for Ruby 1.8.6:
615
+
492
616
  [smtp_tls](http://seattlerb.rubyforge.org/smtp_tls/)
493
617
 
494
618
  Requiring backports for a given version of Ruby will also load
@@ -501,13 +625,16 @@ but could be useful in some projects. It is possible to request such
501
625
  incompatible changes. Backports currently supports the following:
502
626
 
503
627
  #### Hash
504
- - `select` (returns a Hash instead of an Array)
628
+
629
+ - `select` (returns a Hash instead of an Array)
505
630
 
506
631
  #### Enumerable / Array
507
- - `map` (returns an enumerator when called without a block)
632
+
633
+ - `map` (returns an enumerator when called without a block)
508
634
 
509
635
  #### String
510
- - `length`, `size` (for UTF-8 support)
636
+
637
+ - `length`, `size` (for UTF-8 support)
511
638
 
512
639
  These must be imported in addition to the backports gem, for example:
513
640
 
@@ -519,8 +646,11 @@ These must be imported in addition to the backports gem, for example:
519
646
  Thanks for the bug reports and patches, in particular the repeat offenders:
520
647
 
521
648
  #### Arto Bendiken ( [bendiken](http://github.com/bendiken) )
649
+
522
650
  #### Konstantin Haase ( [rkh](https://github.com/rkh) )
651
+
523
652
  #### Roger Pack ( [rdp](http://github.com/rdp) )
653
+
524
654
  #### Victor Shepelev ( [zverok](http://github.com/zverok) )
525
655
 
526
656
  ## Contributing
@@ -546,5 +676,4 @@ Failures that are acceptable are added the to `tags` file.
546
676
  LICENSE file.
547
677
 
548
678
  Author
549
- : Marc-André Lafortune
550
-
679
+ : Marc-André Lafortune