backports 3.15.0 → 3.24.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (505) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +846 -0
  3. data/Gemfile +6 -13
  4. data/README.md +706 -0
  5. data/SECURITY.md +5 -0
  6. data/backports.gemspec +6 -2
  7. data/lib/backports/1.8.7.rb +10 -2
  8. data/lib/backports/1.9.1.rb +6 -1
  9. data/lib/backports/1.9.2/stdlib/matrix.rb +5 -0
  10. data/lib/backports/1.9.2.rb +6 -1
  11. data/lib/backports/1.9.3.rb +6 -1
  12. data/lib/backports/2.0.0/range/size.rb +2 -0
  13. data/lib/backports/2.0.0.rb +7 -2
  14. data/lib/backports/2.1.0/module/singleton_class.rb +8 -0
  15. data/lib/backports/2.1.0.rb +2 -2
  16. data/lib/backports/2.2.0/enumerable/slice_after.rb +1 -1
  17. data/lib/backports/2.2.0/float/next_float.rb +1 -1
  18. data/lib/backports/2.2.0/float/prev_float.rb +1 -1
  19. data/lib/backports/2.2.0/method/super_method.rb +2 -2
  20. data/lib/backports/2.2.0/string/unicode_normalize.rb +3 -3
  21. data/lib/backports/2.2.0.rb +2 -2
  22. data/lib/backports/2.3.0/array/bsearch_index.rb +1 -1
  23. data/lib/backports/2.3.0/hash/lt.rb +1 -1
  24. data/lib/backports/2.3.0/hash/lte.rb +1 -1
  25. data/lib/backports/2.3.0/hash/to_proc.rb +1 -1
  26. data/lib/backports/2.3.0/queue/close.rb +48 -0
  27. data/lib/backports/2.3.0/string.rb +3 -0
  28. data/lib/backports/2.3.0/struct/dig.rb +3 -2
  29. data/lib/backports/2.3.0.rb +2 -2
  30. data/lib/backports/2.4.0/bignum/dup.rb +5 -0
  31. data/lib/backports/2.4.0/bignum.rb +3 -0
  32. data/lib/backports/2.4.0/enumerable/sum.rb +8 -4
  33. data/lib/backports/2.4.0/hash/transform_values.rb +2 -2
  34. data/lib/backports/2.4.0/string/unpack1.rb +7 -0
  35. data/lib/backports/2.4.0/true_class/dup.rb +0 -1
  36. data/lib/backports/2.4.0.rb +2 -2
  37. data/lib/backports/2.5.0/dir/children.rb +4 -0
  38. data/lib/backports/2.5.0/dir/each_child.rb +7 -0
  39. data/lib/backports/2.5.0/hash/transform_keys.rb +11 -4
  40. data/lib/backports/2.5.0/integer/sqrt.rb +2 -2
  41. data/lib/backports/2.5.0/module/alias_method.rb +0 -1
  42. data/lib/backports/2.5.0/string/undump.rb +5 -9
  43. data/lib/backports/2.5.0/struct/new.rb +1 -1
  44. data/lib/backports/2.5.0.rb +2 -2
  45. data/lib/backports/2.5.rb +1 -1
  46. data/lib/backports/2.6.0/array/difference.rb +7 -3
  47. data/lib/backports/2.6.0/enumerable/chain.rb +6 -1
  48. data/lib/backports/2.6.0/hash/to_h.rb +1 -1
  49. data/lib/backports/2.6.0/range/cover.rb +22 -0
  50. data/lib/backports/2.6.0/range.rb +3 -0
  51. data/lib/backports/2.6.0.rb +3 -3
  52. data/lib/backports/2.6.rb +1 -1
  53. data/lib/backports/2.7.0/array/intersection.rb +7 -0
  54. data/lib/backports/2.7.0/array.rb +3 -0
  55. data/lib/backports/2.7.0/comparable/clamp.rb +23 -0
  56. data/lib/backports/2.7.0/comparable.rb +3 -0
  57. data/lib/backports/2.7.0/complex/comparison.rb +13 -0
  58. data/lib/backports/2.7.0/complex.rb +3 -0
  59. data/lib/backports/2.7.0/enumerable/filter_map.rb +14 -0
  60. data/lib/backports/2.7.0/enumerable/tally.rb +11 -0
  61. data/lib/backports/2.7.0/enumerable.rb +3 -0
  62. data/lib/backports/2.7.0/enumerator/produce.rb +20 -0
  63. data/lib/backports/2.7.0/enumerator.rb +3 -0
  64. data/lib/backports/2.7.0/symbol/end_with.rb +9 -0
  65. data/lib/backports/2.7.0/symbol/start_with.rb +9 -0
  66. data/lib/backports/2.7.0/symbol.rb +3 -0
  67. data/lib/backports/2.7.0/time/ceil.rb +10 -0
  68. data/lib/backports/2.7.0/time/floor.rb +7 -0
  69. data/lib/backports/2.7.0.rb +3 -0
  70. data/lib/backports/2.7.rb +1 -0
  71. data/lib/backports/3.0.0/env/except.rb +10 -0
  72. data/lib/backports/3.0.0/env.rb +3 -0
  73. data/lib/backports/3.0.0/hash/except.rb +10 -0
  74. data/lib/backports/3.0.0/hash/transform_keys.rb +48 -0
  75. data/lib/backports/3.0.0/hash.rb +3 -0
  76. data/lib/backports/3.0.0/ractor.rb +19 -0
  77. data/lib/backports/3.0.0/symbol/name.rb +21 -0
  78. data/lib/backports/3.0.0/symbol.rb +3 -0
  79. data/lib/backports/3.0.0.rb +3 -0
  80. data/lib/backports/3.0.rb +1 -0
  81. data/lib/backports/3.1.0/array/intersect.rb +16 -0
  82. data/lib/backports/3.1.0/array.rb +3 -0
  83. data/lib/backports/3.1.0/class/subclasses.rb +11 -0
  84. data/lib/backports/3.1.0/enumerable/compact.rb +5 -0
  85. data/lib/backports/3.1.0/enumerable/tally.rb +18 -0
  86. data/lib/backports/3.1.0/enumerable.rb +3 -0
  87. data/lib/backports/3.1.0/file/dirname.rb +16 -0
  88. data/lib/backports/3.1.0/file.rb +3 -0
  89. data/lib/backports/3.1.0/integer/try_convert.rb +7 -0
  90. data/lib/backports/3.1.0/integer.rb +3 -0
  91. data/lib/backports/3.1.0/match_data/match.rb +5 -0
  92. data/lib/backports/3.1.0/match_data/match_length.rb +6 -0
  93. data/lib/backports/3.1.0/match_data.rb +3 -0
  94. data/lib/backports/3.1.0/struct/keyword_init.rb +5 -0
  95. data/lib/backports/3.1.0/struct.rb +3 -0
  96. data/lib/backports/3.1.0.rb +3 -0
  97. data/lib/backports/3.1.rb +1 -0
  98. data/lib/backports/3.2.0/class/attached_object.rb +10 -0
  99. data/lib/backports/3.2.0/class.rb +3 -0
  100. data/lib/backports/3.2.0/data.rb +144 -0
  101. data/lib/backports/3.2.0/enumerator/product.rb +64 -0
  102. data/lib/backports/3.2.0/enumerator.rb +3 -0
  103. data/lib/backports/3.2.0/hash/shift.rb +10 -0
  104. data/lib/backports/3.2.0/hash.rb +3 -0
  105. data/lib/backports/3.2.0/integer/ceildiv.rb +7 -0
  106. data/lib/backports/3.2.0/integer.rb +3 -0
  107. data/lib/backports/3.2.0/match_data/byteoffset.rb +12 -0
  108. data/lib/backports/3.2.0/match_data.rb +3 -0
  109. data/lib/backports/3.2.0.rb +3 -0
  110. data/lib/backports/3.2.rb +1 -0
  111. data/lib/backports/latest.rb +1 -1
  112. data/lib/backports/ractor/cloner.rb +103 -0
  113. data/lib/backports/ractor/errors.rb +20 -0
  114. data/lib/backports/ractor/filtered_queue.rb +205 -0
  115. data/lib/backports/ractor/queues.rb +66 -0
  116. data/lib/backports/ractor/ractor.rb +272 -0
  117. data/lib/backports/ractor/sharing.rb +97 -0
  118. data/lib/backports/rails/array.rb +4 -0
  119. data/lib/backports/rails/enumerable.rb +4 -0
  120. data/lib/backports/rails/hash.rb +4 -0
  121. data/lib/backports/rails/kernel.rb +4 -0
  122. data/lib/backports/rails/module.rb +4 -0
  123. data/lib/backports/rails/string.rb +4 -0
  124. data/lib/backports/std_lib.rb +3 -0
  125. data/lib/backports/tools/deprecation.rb +19 -0
  126. data/lib/backports/tools/require_relative_dir.rb +6 -1
  127. data/lib/backports/version.rb +1 -1
  128. data/lib/backports.rb +6 -0
  129. metadata +81 -488
  130. data/.document +0 -6
  131. data/.gitignore +0 -9
  132. data/.gitmodules +0 -6
  133. data/.irbrc +0 -3
  134. data/.travis.yml +0 -20
  135. data/CHANGELOG.rdoc +0 -479
  136. data/README.rdoc +0 -422
  137. data/Rakefile +0 -189
  138. data/default.mspec +0 -14
  139. data/frozen_old_spec/tags/1.8.6/core/argf/each_line_spec.rb +0 -6
  140. data/frozen_old_spec/tags/1.8.6/core/argf/each_spec.rb +0 -6
  141. data/frozen_old_spec/tags/1.8.6/core/argf/lines_spec.rb +0 -6
  142. data/frozen_old_spec/tags/1.8.6/core/array/append_spec.rb +0 -1
  143. data/frozen_old_spec/tags/1.8.6/core/array/collect_spec.rb +0 -7
  144. data/frozen_old_spec/tags/1.8.6/core/array/rotate_spec.rb +0 -2
  145. data/frozen_old_spec/tags/1.8.6/core/array/uniq_spec.rb +0 -3
  146. data/frozen_old_spec/tags/1.8.6/core/complex/to_r_spec.rb +0 -3
  147. data/frozen_old_spec/tags/1.8.6/core/enumerable/all_spec.rb +0 -1
  148. data/frozen_old_spec/tags/1.8.6/core/enumerable/any_spec.rb +0 -2
  149. data/frozen_old_spec/tags/1.8.6/core/enumerable/each_entry_spec.rb +0 -1
  150. data/frozen_old_spec/tags/1.8.6/core/enumerable/none_spec.rb +0 -1
  151. data/frozen_old_spec/tags/1.8.6/core/enumerable/one_spec.rb +0 -1
  152. data/frozen_old_spec/tags/1.8.6/core/enumerator/next_spec.rb +0 -1
  153. data/frozen_old_spec/tags/1.8.6/core/env/to_h_spec.rb +0 -2
  154. data/frozen_old_spec/tags/1.8.6/core/file/join_spec.rb +0 -3
  155. data/frozen_old_spec/tags/1.8.6/core/file/lchmod_spec.rb +0 -2
  156. data/frozen_old_spec/tags/1.8.6/core/file/new_spec.rb +0 -2
  157. data/frozen_old_spec/tags/1.8.6/core/file/open_spec.rb +0 -13
  158. data/frozen_old_spec/tags/1.8.6/core/file/to_path_spec.rb +0 -1
  159. data/frozen_old_spec/tags/1.8.6/core/fixnum/fdiv_spec.rb +0 -1
  160. data/frozen_old_spec/tags/1.8.6/core/gc/stress_spec.rb +0 -2
  161. data/frozen_old_spec/tags/1.8.6/core/hash/assoc_spec.rb +0 -1
  162. data/frozen_old_spec/tags/1.8.6/core/hash/constructor_spec.rb +0 -3
  163. data/frozen_old_spec/tags/1.8.6/core/hash/default_proc_spec.rb +0 -3
  164. data/frozen_old_spec/tags/1.8.6/core/hash/delete_if_spec.rb +0 -1
  165. data/frozen_old_spec/tags/1.8.6/core/hash/each_pair_spec.rb +0 -1
  166. data/frozen_old_spec/tags/1.8.6/core/hash/eql_spec.rb +0 -3
  167. data/frozen_old_spec/tags/1.8.6/core/hash/hash_spec.rb +0 -3
  168. data/frozen_old_spec/tags/1.8.6/core/hash/keep_if_spec.rb +0 -2
  169. data/frozen_old_spec/tags/1.8.6/core/hash/rassoc_spec.rb +0 -1
  170. data/frozen_old_spec/tags/1.8.6/core/hash/reject_spec.rb +0 -2
  171. data/frozen_old_spec/tags/1.8.6/core/hash/select_spec.rb +0 -8
  172. data/frozen_old_spec/tags/1.8.6/core/integer/round_spec.rb +0 -2
  173. data/frozen_old_spec/tags/1.8.6/core/io/binread_spec.rb +0 -7
  174. data/frozen_old_spec/tags/1.8.6/core/io/chars_spec.rb +0 -1
  175. data/frozen_old_spec/tags/1.8.6/core/io/each_char_spec.rb +0 -1
  176. data/frozen_old_spec/tags/1.8.6/core/io/lines_spec.rb +0 -1
  177. data/frozen_old_spec/tags/1.8.6/core/io/open_spec.rb +0 -24
  178. data/frozen_old_spec/tags/1.8.6/core/io/ungetbyte_spec.rb +0 -4
  179. data/frozen_old_spec/tags/1.8.6/core/io/write_spec.rb +0 -5
  180. data/frozen_old_spec/tags/1.8.6/core/kernel/__callee___spec.rb +0 -6
  181. data/frozen_old_spec/tags/1.8.6/core/kernel/__method___spec.rb +0 -1
  182. data/frozen_old_spec/tags/1.8.6/core/kernel/define_singleton_method_spec.rb +0 -2
  183. data/frozen_old_spec/tags/1.8.6/core/kernel/public_method_spec.rb +0 -2
  184. data/frozen_old_spec/tags/1.8.6/core/kernel/require_relative_spec.rb +0 -3
  185. data/frozen_old_spec/tags/1.8.6/core/math/log2_spec.rb +0 -6
  186. data/frozen_old_spec/tags/1.8.6/core/math/log_spec.rb +0 -3
  187. data/frozen_old_spec/tags/1.8.6/core/module/alias_method_spec.rb +0 -1
  188. data/frozen_old_spec/tags/1.8.6/core/module/attr_accessor_spec.rb +0 -2
  189. data/frozen_old_spec/tags/1.8.6/core/module/attr_reader_spec.rb +0 -2
  190. data/frozen_old_spec/tags/1.8.6/core/module/attr_spec.rb +0 -1
  191. data/frozen_old_spec/tags/1.8.6/core/module/attr_writer_spec.rb +0 -2
  192. data/frozen_old_spec/tags/1.8.6/core/module/class_exec_spec.rb +0 -2
  193. data/frozen_old_spec/tags/1.8.6/core/module/define_method_spec.rb +0 -1
  194. data/frozen_old_spec/tags/1.8.6/core/module/module_exec_spec.rb +0 -2
  195. data/frozen_old_spec/tags/1.8.6/core/module/remove_method_spec.rb +0 -1
  196. data/frozen_old_spec/tags/1.8.6/core/module/undef_method_spec.rb +0 -1
  197. data/frozen_old_spec/tags/1.8.6/core/nil/dup_spec.rb +0 -1
  198. data/frozen_old_spec/tags/1.8.6/core/numeric/step_spec.rb +0 -12
  199. data/frozen_old_spec/tags/1.8.6/core/proc/curry_spec.rb +0 -4
  200. data/frozen_old_spec/tags/1.8.6/core/range/step_spec.rb +0 -12
  201. data/frozen_old_spec/tags/1.8.6/core/string/getbyte_spec.rb +0 -6
  202. data/frozen_old_spec/tags/1.8.6/core/string/partition_spec.rb +0 -1
  203. data/frozen_old_spec/tags/1.8.6/core/string/prepend_spec.rb +0 -1
  204. data/frozen_old_spec/tags/1.8.6/core/string/rpartition_spec.rb +0 -1
  205. data/frozen_old_spec/tags/1.8.6/core/string/setbyte_spec.rb +0 -5
  206. data/frozen_old_spec/tags/1.8.6/core/string/upto_spec.rb +0 -1
  207. data/frozen_old_spec/tags/1.8.6/core/symbol/capitalize_spec.rb +0 -3
  208. data/frozen_old_spec/tags/1.8.6/core/symbol/comparison_spec.rb +0 -1
  209. data/frozen_old_spec/tags/1.8.6/core/symbol/downcase_spec.rb +0 -2
  210. data/frozen_old_spec/tags/1.8.6/core/symbol/element_reference_spec.rb +0 -4
  211. data/frozen_old_spec/tags/1.8.6/core/symbol/empty_spec.rb +0 -1
  212. data/frozen_old_spec/tags/1.8.6/core/symbol/match_spec.rb +0 -2
  213. data/frozen_old_spec/tags/1.8.6/core/symbol/swapcase_spec.rb +0 -2
  214. data/frozen_old_spec/tags/1.8.6/core/symbol/to_proc_spec.rb +0 -1
  215. data/frozen_old_spec/tags/1.8.6/core/symbol/upcase_spec.rb +0 -1
  216. data/frozen_old_spec/tags/1.8.7/core/array/append_spec.rb +0 -1
  217. data/frozen_old_spec/tags/1.8.7/core/array/keep_if_spec.rb +0 -2
  218. data/frozen_old_spec/tags/1.8.7/core/array/rotate_spec.rb +0 -2
  219. data/frozen_old_spec/tags/1.8.7/core/array/select_spec.rb +0 -2
  220. data/frozen_old_spec/tags/1.8.7/core/array/uniq_spec.rb +0 -3
  221. data/frozen_old_spec/tags/1.8.7/core/complex/to_r_spec.rb +0 -3
  222. data/frozen_old_spec/tags/1.8.7/core/enumerable/all_spec.rb +0 -1
  223. data/frozen_old_spec/tags/1.8.7/core/enumerable/any_spec.rb +0 -2
  224. data/frozen_old_spec/tags/1.8.7/core/enumerable/collect_concat_spec.rb +0 -1
  225. data/frozen_old_spec/tags/1.8.7/core/enumerable/flat_map_spec.rb +0 -1
  226. data/frozen_old_spec/tags/1.8.7/core/enumerable/none_spec.rb +0 -1
  227. data/frozen_old_spec/tags/1.8.7/core/enumerable/one_spec.rb +0 -1
  228. data/frozen_old_spec/tags/1.8.7/core/env/to_h_spec.rb +0 -2
  229. data/frozen_old_spec/tags/1.8.7/core/file/lchmod_spec.rb +0 -2
  230. data/frozen_old_spec/tags/1.8.7/core/file/new_spec.rb +0 -1
  231. data/frozen_old_spec/tags/1.8.7/core/file/open_spec.rb +0 -5
  232. data/frozen_old_spec/tags/1.8.7/core/file/readlink_spec.rb +0 -6
  233. data/frozen_old_spec/tags/1.8.7/core/file/to_path_spec.rb +0 -1
  234. data/frozen_old_spec/tags/1.8.7/core/hash/assoc_spec.rb +0 -1
  235. data/frozen_old_spec/tags/1.8.7/core/hash/default_proc_spec.rb +0 -3
  236. data/frozen_old_spec/tags/1.8.7/core/hash/keep_if_spec.rb +0 -2
  237. data/frozen_old_spec/tags/1.8.7/core/hash/merge_spec.rb +0 -3
  238. data/frozen_old_spec/tags/1.8.7/core/hash/rassoc_spec.rb +0 -1
  239. data/frozen_old_spec/tags/1.8.7/core/hash/select_spec.rb +0 -1
  240. data/frozen_old_spec/tags/1.8.7/core/hash/to_h_spec.rb +0 -1
  241. data/frozen_old_spec/tags/1.8.7/core/hash/update_spec.rb +0 -3
  242. data/frozen_old_spec/tags/1.8.7/core/integer/round_spec.rb +0 -2
  243. data/frozen_old_spec/tags/1.8.7/core/io/binread_spec.rb +0 -7
  244. data/frozen_old_spec/tags/1.8.7/core/io/open_spec.rb +0 -32
  245. data/frozen_old_spec/tags/1.8.7/core/io/ungetbyte_spec.rb +0 -4
  246. data/frozen_old_spec/tags/1.8.7/core/io/write_spec.rb +0 -5
  247. data/frozen_old_spec/tags/1.8.7/core/kernel/__callee___spec.rb +0 -6
  248. data/frozen_old_spec/tags/1.8.7/core/kernel/define_singleton_method_spec.rb +0 -2
  249. data/frozen_old_spec/tags/1.8.7/core/kernel/public_method_spec.rb +0 -1
  250. data/frozen_old_spec/tags/1.8.7/core/kernel/require_relative_spec.rb +0 -3
  251. data/frozen_old_spec/tags/1.8.7/core/math/log2_spec.rb +0 -6
  252. data/frozen_old_spec/tags/1.8.7/core/math/log_spec.rb +0 -3
  253. data/frozen_old_spec/tags/1.8.7/core/module/alias_method_spec.rb +0 -7
  254. data/frozen_old_spec/tags/1.8.7/core/module/attr_accessor_spec.rb +0 -2
  255. data/frozen_old_spec/tags/1.8.7/core/module/attr_reader_spec.rb +0 -2
  256. data/frozen_old_spec/tags/1.8.7/core/module/attr_spec.rb +0 -2
  257. data/frozen_old_spec/tags/1.8.7/core/module/attr_writer_spec.rb +0 -2
  258. data/frozen_old_spec/tags/1.8.7/core/module/define_method_spec.rb +0 -1
  259. data/frozen_old_spec/tags/1.8.7/core/module/include_spec.rb +0 -3
  260. data/frozen_old_spec/tags/1.8.7/core/module/remove_method_spec.rb +0 -3
  261. data/frozen_old_spec/tags/1.8.7/core/module/undef_method_spec.rb +0 -3
  262. data/frozen_old_spec/tags/1.8.7/core/nil/dup_spec.rb +0 -1
  263. data/frozen_old_spec/tags/1.8.7/core/proc/curry_spec.rb +0 -3
  264. data/frozen_old_spec/tags/1.8.7/core/proc/yield_spec.rb +0 -4
  265. data/frozen_old_spec/tags/1.8.7/core/range/size_spec.rb +0 -1
  266. data/frozen_old_spec/tags/1.8.7/core/string/getbyte_spec.rb +0 -5
  267. data/frozen_old_spec/tags/1.8.7/core/string/prepend_spec.rb +0 -1
  268. data/frozen_old_spec/tags/1.8.7/core/string/setbyte_spec.rb +0 -5
  269. data/frozen_old_spec/tags/1.8.7/core/struct/new_spec.rb +0 -3
  270. data/frozen_old_spec/tags/1.8.7/core/symbol/capitalize_spec.rb +0 -3
  271. data/frozen_old_spec/tags/1.8.7/core/symbol/comparison_spec.rb +0 -1
  272. data/frozen_old_spec/tags/1.8.7/core/symbol/downcase_spec.rb +0 -2
  273. data/frozen_old_spec/tags/1.8.7/core/symbol/element_reference_spec.rb +0 -4
  274. data/frozen_old_spec/tags/1.8.7/core/symbol/empty_spec.rb +0 -1
  275. data/frozen_old_spec/tags/1.8.7/core/symbol/match_spec.rb +0 -2
  276. data/frozen_old_spec/tags/1.8.7/core/symbol/swapcase_spec.rb +0 -2
  277. data/frozen_old_spec/tags/1.8.7/core/symbol/upcase_spec.rb +0 -1
  278. data/frozen_old_spec/tags/1.9.1/core/array/append_spec.rb +0 -1
  279. data/frozen_old_spec/tags/1.9.1/core/array/rotate_spec.rb +0 -1
  280. data/frozen_old_spec/tags/1.9.1/core/enumerable/all_spec.rb +0 -1
  281. data/frozen_old_spec/tags/1.9.1/core/enumerable/any_spec.rb +0 -2
  282. data/frozen_old_spec/tags/1.9.1/core/enumerable/none_spec.rb +0 -1
  283. data/frozen_old_spec/tags/1.9.1/core/enumerable/one_spec.rb +0 -1
  284. data/frozen_old_spec/tags/1.9.1/core/env/to_h_spec.rb +0 -2
  285. data/frozen_old_spec/tags/1.9.1/core/hash/default_proc_spec.rb +0 -1
  286. data/frozen_old_spec/tags/1.9.1/core/io/write_spec.rb +0 -2
  287. data/frozen_old_spec/tags/1.9.1/core/module/alias_method_spec.rb +0 -4
  288. data/frozen_old_spec/tags/1.9.1/core/module/attr_accessor_spec.rb +0 -2
  289. data/frozen_old_spec/tags/1.9.1/core/module/attr_reader_spec.rb +0 -2
  290. data/frozen_old_spec/tags/1.9.1/core/module/attr_spec.rb +0 -1
  291. data/frozen_old_spec/tags/1.9.1/core/module/attr_writer_spec.rb +0 -2
  292. data/frozen_old_spec/tags/1.9.1/core/module/define_method_spec.rb +0 -3
  293. data/frozen_old_spec/tags/1.9.1/core/module/remove_method_spec.rb +0 -1
  294. data/frozen_old_spec/tags/1.9.1/core/module/undef_method_spec.rb +0 -1
  295. data/frozen_old_spec/tags/1.9.1/core/nil/dup_spec.rb +0 -1
  296. data/frozen_old_spec/tags/1.9.2/core/array/append_spec.rb +0 -1
  297. data/frozen_old_spec/tags/1.9.2/core/enumerable/all_spec.rb +0 -1
  298. data/frozen_old_spec/tags/1.9.2/core/enumerable/any_spec.rb +0 -2
  299. data/frozen_old_spec/tags/1.9.2/core/enumerable/none_spec.rb +0 -1
  300. data/frozen_old_spec/tags/1.9.2/core/enumerable/one_spec.rb +0 -1
  301. data/frozen_old_spec/tags/1.9.2/core/io/write_spec.rb +0 -3
  302. data/frozen_old_spec/tags/1.9.2/core/module/alias_method_spec.rb +0 -4
  303. data/frozen_old_spec/tags/1.9.2/core/module/attr_accessor_spec.rb +0 -2
  304. data/frozen_old_spec/tags/1.9.2/core/module/attr_reader_spec.rb +0 -2
  305. data/frozen_old_spec/tags/1.9.2/core/module/attr_spec.rb +0 -1
  306. data/frozen_old_spec/tags/1.9.2/core/module/attr_writer_spec.rb +0 -2
  307. data/frozen_old_spec/tags/1.9.2/core/module/define_method_spec.rb +0 -3
  308. data/frozen_old_spec/tags/1.9.2/core/module/remove_method_spec.rb +0 -1
  309. data/frozen_old_spec/tags/1.9.2/core/module/undef_method_spec.rb +0 -1
  310. data/frozen_old_spec/tags/1.9.2/core/nil/dup_spec.rb +0 -1
  311. data/frozen_old_spec/tags/1.9.3/core/enumerable/any_spec.rb +0 -1
  312. data/frozen_old_spec/tags/1.9.3/core/module/alias_method_spec.rb +0 -4
  313. data/frozen_old_spec/tags/1.9.3/core/module/attr_accessor_spec.rb +0 -1
  314. data/frozen_old_spec/tags/1.9.3/core/module/attr_reader_spec.rb +0 -1
  315. data/frozen_old_spec/tags/1.9.3/core/module/attr_spec.rb +0 -1
  316. data/frozen_old_spec/tags/1.9.3/core/module/attr_writer_spec.rb +0 -1
  317. data/frozen_old_spec/tags/1.9.3/core/module/define_method_spec.rb +0 -3
  318. data/frozen_old_spec/tags/1.9.3/core/module/remove_method_spec.rb +0 -1
  319. data/frozen_old_spec/tags/1.9.3/core/module/undef_method_spec.rb +0 -1
  320. data/frozen_old_spec/tags/2.0.0/core/enumerable/any_spec.rb +0 -1
  321. data/frozen_old_spec/tags/2.0.0/core/module/alias_method_spec.rb +0 -1
  322. data/frozen_old_spec/tags/2.0.0/core/module/attr_accessor_spec.rb +0 -2
  323. data/frozen_old_spec/tags/2.0.0/core/module/attr_reader_spec.rb +0 -2
  324. data/frozen_old_spec/tags/2.0.0/core/module/attr_spec.rb +0 -1
  325. data/frozen_old_spec/tags/2.0.0/core/module/attr_writer_spec.rb +0 -2
  326. data/frozen_old_spec/tags/2.0.0/core/module/define_method_spec.rb +0 -2
  327. data/frozen_old_spec/tags/2.0.0/core/module/remove_method_spec.rb +0 -1
  328. data/frozen_old_spec/tags/2.0.0/core/module/undef_method_spec.rb +0 -1
  329. data/frozen_old_spec/tags/2.0.0/core/nil/dup_spec.rb +0 -1
  330. data/frozen_old_spec/tags/2.0.0/core/struct/new_spec.rb +0 -1
  331. data/frozen_old_spec/tags/2.1.0/core/enumerable/any_spec.rb +0 -1
  332. data/frozen_old_spec/tags/2.1.0/core/module/alias_method_spec.rb +0 -1
  333. data/frozen_old_spec/tags/2.1.0/core/module/attr_accessor_spec.rb +0 -2
  334. data/frozen_old_spec/tags/2.1.0/core/module/attr_reader_spec.rb +0 -2
  335. data/frozen_old_spec/tags/2.1.0/core/module/attr_spec.rb +0 -1
  336. data/frozen_old_spec/tags/2.1.0/core/module/attr_writer_spec.rb +0 -2
  337. data/frozen_old_spec/tags/2.1.0/core/module/define_method_spec.rb +0 -2
  338. data/frozen_old_spec/tags/2.1.0/core/module/remove_method_spec.rb +0 -1
  339. data/frozen_old_spec/tags/2.1.0/core/module/undef_method_spec.rb +0 -1
  340. data/frozen_old_spec/tags/2.1.0/core/nil/dup_spec.rb +0 -1
  341. data/frozen_old_spec/tags/2.1.0/core/struct/new_spec.rb +0 -1
  342. data/frozen_old_spec/tags/2.2.0/core/enumerable/any_spec.rb +0 -1
  343. data/frozen_old_spec/tags/2.2.0/core/module/alias_method_spec.rb +0 -1
  344. data/frozen_old_spec/tags/2.2.0/core/module/attr_accessor_spec.rb +0 -2
  345. data/frozen_old_spec/tags/2.2.0/core/module/attr_reader_spec.rb +0 -2
  346. data/frozen_old_spec/tags/2.2.0/core/module/attr_spec.rb +0 -1
  347. data/frozen_old_spec/tags/2.2.0/core/module/attr_writer_spec.rb +0 -2
  348. data/frozen_old_spec/tags/2.2.0/core/module/define_method_spec.rb +0 -1
  349. data/frozen_old_spec/tags/2.2.0/core/module/remove_method_spec.rb +0 -1
  350. data/frozen_old_spec/tags/2.2.0/core/module/undef_method_spec.rb +0 -1
  351. data/frozen_old_spec/tags/2.2.0/core/nil/dup_spec.rb +0 -1
  352. data/frozen_old_spec/tags/2.2.0/core/struct/new_spec.rb +0 -1
  353. data/frozen_old_spec/tags/2.3.0/core/enumerable/any_spec.rb +0 -1
  354. data/frozen_old_spec/tags/2.3.0/core/module/alias_method_spec.rb +0 -1
  355. data/frozen_old_spec/tags/2.3.0/core/module/attr_accessor_spec.rb +0 -2
  356. data/frozen_old_spec/tags/2.3.0/core/module/attr_reader_spec.rb +0 -2
  357. data/frozen_old_spec/tags/2.3.0/core/module/attr_spec.rb +0 -1
  358. data/frozen_old_spec/tags/2.3.0/core/module/attr_writer_spec.rb +0 -2
  359. data/frozen_old_spec/tags/2.3.0/core/module/define_method_spec.rb +0 -1
  360. data/frozen_old_spec/tags/2.3.0/core/module/remove_method_spec.rb +0 -1
  361. data/frozen_old_spec/tags/2.3.0/core/module/undef_method_spec.rb +0 -1
  362. data/frozen_old_spec/tags/2.3.0/core/nil/dup_spec.rb +0 -1
  363. data/frozen_old_spec/tags/2.3.0/core/struct/new_spec.rb +0 -1
  364. data/frozen_old_spec/tags/2.3.5/core/struct/new_spec.rb +0 -1
  365. data/frozen_old_spec/tags/2.4.0/core/enumerable/any_spec.rb +0 -1
  366. data/frozen_old_spec/tags/2.4.0/core/module/alias_method_spec.rb +0 -1
  367. data/frozen_old_spec/tags/2.4.0/core/module/attr_accessor_spec.rb +0 -2
  368. data/frozen_old_spec/tags/2.4.0/core/module/attr_reader_spec.rb +0 -2
  369. data/frozen_old_spec/tags/2.4.0/core/module/attr_spec.rb +0 -1
  370. data/frozen_old_spec/tags/2.4.0/core/module/attr_writer_spec.rb +0 -2
  371. data/frozen_old_spec/tags/2.4.0/core/module/define_method_spec.rb +0 -1
  372. data/frozen_old_spec/tags/2.4.0/core/module/remove_method_spec.rb +0 -1
  373. data/frozen_old_spec/tags/2.4.0/core/module/undef_method_spec.rb +0 -1
  374. data/frozen_old_spec/tags/2.4.0/core/nil/dup_spec.rb +0 -1
  375. data/frozen_old_spec/tags/2.4.0/core/struct/new_spec.rb +0 -1
  376. data/frozen_old_spec/tags/2.5.0/core/enumerable/any_spec.rb +0 -1
  377. data/frozen_old_spec/tags/2.5.0/core/module/alias_method_spec.rb +0 -1
  378. data/frozen_old_spec/tags/2.5.0/core/module/attr_accessor_spec.rb +0 -2
  379. data/frozen_old_spec/tags/2.5.0/core/module/attr_reader_spec.rb +0 -2
  380. data/frozen_old_spec/tags/2.5.0/core/module/attr_spec.rb +0 -1
  381. data/frozen_old_spec/tags/2.5.0/core/module/attr_writer_spec.rb +0 -2
  382. data/frozen_old_spec/tags/2.5.0/core/module/define_method_spec.rb +0 -1
  383. data/frozen_old_spec/tags/2.5.0/core/module/remove_method_spec.rb +0 -1
  384. data/frozen_old_spec/tags/2.5.0/core/module/undef_method_spec.rb +0 -1
  385. data/frozen_old_spec/tags/2.5.0/core/nil/dup_spec.rb +0 -1
  386. data/frozen_old_spec/tags/2.5.0/core/struct/new_spec.rb +0 -1
  387. data/set_version/1.8.7.rb +0 -1
  388. data/set_version/1.9.1.rb +0 -1
  389. data/set_version/1.9.2.rb +0 -1
  390. data/set_version/1.9.3.rb +0 -1
  391. data/set_version/2.0.0.rb +0 -1
  392. data/set_version/2.1.0.rb +0 -1
  393. data/set_version/2.2.0.rb +0 -1
  394. data/set_version/2.3.0.rb +0 -1
  395. data/set_version/2.4.0.rb +0 -1
  396. data/set_version/2.5.0.rb +0 -1
  397. data/set_version/2.6.0.rb +0 -1
  398. data/set_version/setter.rb +0 -22
  399. data/spec/tags/1.8.7/core/array/to_h_spec.rb +0 -3
  400. data/spec/tags/1.8.7/core/enumerable/to_h_spec.rb +0 -2
  401. data/spec/tags/1.8.7/core/module/attr_spec.rb +0 -1
  402. data/spec/tags/1.8.7/core/module/include_spec.rb +0 -1
  403. data/spec/tags/1.9.1/core/array/bsearch_index_spec.rb +0 -1
  404. data/spec/tags/1.9.1/core/array/rotate_spec.rb +0 -1
  405. data/spec/tags/1.9.1/core/dir/each_child_spec.rb +0 -1
  406. data/spec/tags/1.9.1/core/env/to_h_spec.rb +0 -2
  407. data/spec/tags/1.9.1/core/hash/default_proc_spec.rb +0 -1
  408. data/spec/tags/1.9.1/core/hash/slice_spec.rb +0 -1
  409. data/spec/tags/1.9.1/core/hash/transform_keys_spec.rb +0 -2
  410. data/spec/tags/1.9.1/core/hash/transform_values_spec.rb +0 -2
  411. data/spec/tags/1.9.1/core/io/write_spec.rb +0 -3
  412. data/spec/tags/1.9.1/core/kernel/yield_self_spec.rb +0 -1
  413. data/spec/tags/1.9.1/core/method/curry_spec.rb +0 -1
  414. data/spec/tags/1.9.1/core/module/alias_method_spec.rb +0 -3
  415. data/spec/tags/1.9.1/core/module/attr_accessor_spec.rb +0 -1
  416. data/spec/tags/1.9.1/core/module/attr_reader_spec.rb +0 -1
  417. data/spec/tags/1.9.1/core/module/attr_spec.rb +0 -1
  418. data/spec/tags/1.9.1/core/module/attr_writer_spec.rb +0 -1
  419. data/spec/tags/1.9.1/core/module/define_method_spec.rb +0 -7
  420. data/spec/tags/1.9.1/core/string/uplus_spec.rb +0 -1
  421. data/spec/tags/1.9.1/core/struct/new_spec.rb +0 -2
  422. data/spec/tags/1.9.2/core/array/bsearch_index_spec.rb +0 -1
  423. data/spec/tags/1.9.2/core/array/to_h_spec.rb +0 -3
  424. data/spec/tags/1.9.2/core/dir/each_child_spec.rb +0 -1
  425. data/spec/tags/1.9.2/core/enumerable/to_h_spec.rb +0 -2
  426. data/spec/tags/1.9.2/core/hash/slice_spec.rb +0 -1
  427. data/spec/tags/1.9.2/core/hash/to_h_spec.rb +0 -3
  428. data/spec/tags/1.9.2/core/hash/transform_keys_spec.rb +0 -2
  429. data/spec/tags/1.9.2/core/hash/transform_values_spec.rb +0 -2
  430. data/spec/tags/1.9.2/core/io/write_spec.rb +0 -3
  431. data/spec/tags/1.9.2/core/kernel/then_spec.rb +0 -1
  432. data/spec/tags/1.9.2/core/kernel/yield_self_spec.rb +0 -1
  433. data/spec/tags/1.9.2/core/method/curry_spec.rb +0 -1
  434. data/spec/tags/1.9.2/core/module/alias_method_spec.rb +0 -3
  435. data/spec/tags/1.9.2/core/module/attr_accessor_spec.rb +0 -1
  436. data/spec/tags/1.9.2/core/module/attr_reader_spec.rb +0 -1
  437. data/spec/tags/1.9.2/core/module/attr_writer_spec.rb +0 -1
  438. data/spec/tags/1.9.2/core/module/define_method_spec.rb +0 -7
  439. data/spec/tags/1.9.2/core/module/include_spec.rb +0 -1
  440. data/spec/tags/1.9.2/core/string/uplus_spec.rb +0 -1
  441. data/spec/tags/1.9.2/core/struct/new_spec.rb +0 -2
  442. data/spec/tags/1.9.3/core/array/bsearch_index_spec.rb +0 -1
  443. data/spec/tags/1.9.3/core/dir/each_child_spec.rb +0 -1
  444. data/spec/tags/1.9.3/core/hash/slice_spec.rb +0 -1
  445. data/spec/tags/1.9.3/core/hash/to_h_spec.rb +0 -3
  446. data/spec/tags/1.9.3/core/hash/transform_keys_spec.rb +0 -2
  447. data/spec/tags/1.9.3/core/hash/transform_values_spec.rb +0 -2
  448. data/spec/tags/1.9.3/core/io/write_spec.rb +0 -3
  449. data/spec/tags/1.9.3/core/kernel/yield_self_spec.rb +0 -1
  450. data/spec/tags/1.9.3/core/method/curry_spec.rb +0 -1
  451. data/spec/tags/1.9.3/core/module/alias_method_spec.rb +0 -3
  452. data/spec/tags/1.9.3/core/module/attr_accessor_spec.rb +0 -1
  453. data/spec/tags/1.9.3/core/module/attr_reader_spec.rb +0 -1
  454. data/spec/tags/1.9.3/core/module/attr_writer_spec.rb +0 -1
  455. data/spec/tags/1.9.3/core/module/define_method_spec.rb +0 -7
  456. data/spec/tags/1.9.3/core/module/include_spec.rb +0 -1
  457. data/spec/tags/1.9.3/core/string/uplus_spec.rb +0 -1
  458. data/spec/tags/1.9.3/core/struct/new_spec.rb +0 -2
  459. data/spec/tags/2.0.0/core/array/to_h_spec.rb +0 -3
  460. data/spec/tags/2.0.0/core/enumerable/to_h_spec.rb +0 -2
  461. data/spec/tags/2.0.0/core/hash/slice_spec.rb +0 -1
  462. data/spec/tags/2.0.0/core/hash/to_h_spec.rb +0 -3
  463. data/spec/tags/2.0.0/core/module/attr_accessor_spec.rb +0 -1
  464. data/spec/tags/2.0.0/core/module/attr_reader_spec.rb +0 -1
  465. data/spec/tags/2.0.0/core/module/attr_spec.rb +0 -1
  466. data/spec/tags/2.0.0/core/module/attr_writer_spec.rb +0 -1
  467. data/spec/tags/2.0.0/core/module/define_method_spec.rb +0 -4
  468. data/spec/tags/2.0.0/core/module/include_spec.rb +0 -1
  469. data/spec/tags/2.0.0/core/string/uplus_spec.rb +0 -1
  470. data/spec/tags/2.0.0/core/struct/new_spec.rb +0 -1
  471. data/spec/tags/2.1.0/core/array/union_spec.rb +0 -1
  472. data/spec/tags/2.1.0/core/hash/slice_spec.rb +0 -1
  473. data/spec/tags/2.1.0/core/hash/to_h_spec.rb +0 -1
  474. data/spec/tags/2.1.0/core/module/attr_accessor_spec.rb +0 -1
  475. data/spec/tags/2.1.0/core/module/attr_reader_spec.rb +0 -1
  476. data/spec/tags/2.1.0/core/module/attr_spec.rb +0 -1
  477. data/spec/tags/2.1.0/core/module/attr_writer_spec.rb +0 -1
  478. data/spec/tags/2.1.0/core/module/define_method_spec.rb +0 -4
  479. data/spec/tags/2.1.0/core/string/uplus_spec.rb +0 -1
  480. data/spec/tags/2.1.0/core/struct/new_spec.rb +0 -1
  481. data/spec/tags/2.2.0/core/hash/slice_spec.rb +0 -1
  482. data/spec/tags/2.2.0/core/hash/to_h_spec.rb +0 -1
  483. data/spec/tags/2.2.0/core/module/attr_accessor_spec.rb +0 -1
  484. data/spec/tags/2.2.0/core/module/attr_reader_spec.rb +0 -1
  485. data/spec/tags/2.2.0/core/module/attr_spec.rb +0 -1
  486. data/spec/tags/2.2.0/core/module/attr_writer_spec.rb +0 -1
  487. data/spec/tags/2.2.0/core/module/define_method_spec.rb +0 -4
  488. data/spec/tags/2.2.0/core/string/uplus_spec.rb +0 -1
  489. data/spec/tags/2.2.0/core/struct/new_spec.rb +0 -1
  490. data/spec/tags/2.3.0/core/hash/slice_spec.rb +0 -1
  491. data/spec/tags/2.3.0/core/hash/to_h_spec.rb +0 -1
  492. data/spec/tags/2.3.0/core/module/attr_spec.rb +0 -1
  493. data/spec/tags/2.3.0/core/string/uplus_spec.rb +0 -1
  494. data/spec/tags/2.3.0/core/struct/new_spec.rb +0 -1
  495. data/spec/tags/2.4.0/core/hash/slice_spec.rb +0 -1
  496. data/spec/tags/2.4.0/core/hash/to_h_spec.rb +0 -1
  497. data/spec/tags/2.4.0/core/module/attr_spec.rb +0 -1
  498. data/spec/tags/2.4.0/core/struct/new_spec.rb +0 -1
  499. data/spec/tags/2.5.0/core/hash/to_h_spec.rb +0 -1
  500. data/test/README +0 -2
  501. data/test/_backport_guards_test.rb +0 -148
  502. data/test/bit_length_test.rb +0 -11
  503. data/test/lazy_test.rb +0 -487
  504. data/test/socket_interaction_test.rb +0 -9
  505. data/test/test_helper.rb +0 -1
@@ -0,0 +1,13 @@
1
+ unless Complex.method_defined?(:<=>)
2
+ class Complex
3
+ def <=>(other)
4
+ return nil unless imaginary.zero?
5
+
6
+ if other.is_a?(Complex)
7
+ other.imaginary.zero? ? real <=> other.real : nil
8
+ else
9
+ real <=> other
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ require 'backports/tools/require_relative_dir'
2
+
3
+ Backports.require_relative_dir
@@ -0,0 +1,14 @@
1
+ require 'backports/1.9.1/enumerable/each_with_object' unless Enumerable.method_defined? :each_with_object
2
+
3
+ unless Enumerable.method_defined? :filter_map
4
+ module Enumerable
5
+ def filter_map
6
+ return to_enum(:filter_map) unless block_given?
7
+
8
+ each_with_object([]) do |item, res|
9
+ processed = yield(item)
10
+ res << processed if processed
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,11 @@
1
+ unless Enumerable.method_defined? :tally
2
+ module Enumerable
3
+ def tally
4
+ h = {}
5
+ # NB: By spec, tally should return default-less hash
6
+ each_entry { |item| h[item] = h.fetch(item, 0) + 1 }
7
+
8
+ h
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ require 'backports/tools/require_relative_dir'
2
+
3
+ Backports.require_relative_dir
@@ -0,0 +1,20 @@
1
+ Enumerator = Enumerable::Enumerator unless Object.const_defined? :Enumerator # For 1.8.x
2
+
3
+ unless Enumerator.respond_to?(:produce)
4
+ require 'backports/tools/arguments'
5
+
6
+ class Enumerator
7
+ def self.produce(initial = Backports::Undefined)
8
+ raise ArgumentError, 'no block given' unless block_given?
9
+
10
+ Enumerator.new do |y|
11
+ val = initial == Backports::Undefined ? yield() : initial
12
+
13
+ loop do
14
+ y << val
15
+ val = yield(val)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,3 @@
1
+ require 'backports/tools/require_relative_dir'
2
+
3
+ Backports.require_relative_dir
@@ -0,0 +1,9 @@
1
+ require 'backports/1.8.7/string/end_with' unless String.method_defined? :end_with?
2
+
3
+ unless Symbol.method_defined?(:end_with?)
4
+ class Symbol
5
+ def end_with?(*suffixes)
6
+ to_s.end_with?(*suffixes)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ require 'backports/1.8.7/string/start_with' unless String.method_defined? :end_with?
2
+
3
+ unless Symbol.method_defined?(:start_with?)
4
+ class Symbol
5
+ def start_with?(*suffixes)
6
+ to_s.start_with?(*suffixes)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ require 'backports/tools/require_relative_dir'
2
+
3
+ Backports.require_relative_dir
@@ -0,0 +1,10 @@
1
+ unless Time.method_defined?(:ceil)
2
+ class Time
3
+ def ceil(ndigits = 0)
4
+ # Imitate value.ceil(ndigits) which does not exist in Ruby < 2.4
5
+ sceil = (subsec * 10**ndigits).ceil.to_r / 10**ndigits
6
+ change = sceil - subsec
7
+ self + change
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ unless Time.method_defined?(:floor)
2
+ class Time
3
+ def floor(ndigits = 0)
4
+ self - subsec.modulo(10**-ndigits)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ # require this file to load all the backports up to Ruby 2.7
2
+ require 'backports/2.6.0'
3
+ Backports.require_relative_dir if RUBY_VERSION < '2.7'
@@ -0,0 +1 @@
1
+ require 'backports/2.7.0'
@@ -0,0 +1,10 @@
1
+ class << ENV
2
+ def except(*keys)
3
+ if keys.size > 4 && size > 4 # index if O(m*n) is big
4
+ h = {}
5
+ keys.each { |key| h[key] = true }
6
+ keys = h
7
+ end
8
+ reject { |key, _value| keys.include? key}
9
+ end
10
+ end unless ENV.respond_to? :except
@@ -0,0 +1,3 @@
1
+ require 'backports/tools/require_relative_dir'
2
+
3
+ Backports.require_relative_dir
@@ -0,0 +1,10 @@
1
+ class Hash
2
+ def except(*keys)
3
+ if keys.size > 4 && size > 4 # index if O(m*n) is big
4
+ h = {}
5
+ keys.each { |key| h[key] = true }
6
+ keys = h
7
+ end
8
+ reject { |key, _value| keys.include? key}
9
+ end
10
+ end unless Hash.method_defined? :except
@@ -0,0 +1,48 @@
1
+ class Hash
2
+ unless ({}.transform_keys(:x => 1) rescue false)
3
+ require 'backports/2.5.0/hash/transform_keys'
4
+ require 'backports/tools/alias_method_chain'
5
+
6
+ def transform_keys_with_hash_arg(hash = not_given = true, &block)
7
+ return to_enum(:transform_keys) { size } if not_given && !block
8
+
9
+ return transform_keys_without_hash_arg(&block) if not_given
10
+
11
+ h = {}
12
+ if block_given?
13
+ each do |key, value|
14
+ h[hash.fetch(key) { yield key }] = value
15
+ end
16
+ else
17
+ each do |key, value|
18
+ h[hash.fetch(key, key)] = value
19
+ end
20
+ end
21
+ h
22
+ end
23
+ Backports.alias_method_chain self, :transform_keys, :hash_arg
24
+
25
+ def transform_keys_with_hash_arg!(hash = not_given = true, &block)
26
+ return enum_for(:transform_keys!) { size } if not_given && !block
27
+
28
+ return transform_keys_without_hash_arg!(&block) if not_given
29
+
30
+ h = {}
31
+ begin
32
+ if block_given?
33
+ each do |key, value|
34
+ h[hash.fetch(key) { yield key }] = value
35
+ end
36
+ else
37
+ each do |key, value|
38
+ h[hash.fetch(key, key)] = value
39
+ end
40
+ end
41
+ ensure
42
+ replace(h)
43
+ end
44
+ self
45
+ end
46
+ Backports.alias_method_chain self, :transform_keys!, :hash_arg
47
+ end
48
+ end
@@ -0,0 +1,3 @@
1
+ require 'backports/tools/require_relative_dir'
2
+
3
+ Backports.require_relative_dir
@@ -0,0 +1,19 @@
1
+ if RUBY_VERSION < '2'
2
+ warn 'Ractor not backported to Ruby 1.x'
3
+ elsif defined?(Ractor.current)
4
+ # all good
5
+ else
6
+ # Cloner:
7
+ require_relative '../2.4.0/hash/transform_values'
8
+ require_relative '../2.5.0/hash/transform_keys'
9
+ # Queues & FilteredQueue
10
+ require_relative '../2.3.0/queue/close'
11
+
12
+ class Ractor
13
+ end
14
+
15
+ module Backports
16
+ Ractor = ::Ractor
17
+ end
18
+ require_relative '../ractor/ractor'
19
+ end
@@ -0,0 +1,21 @@
1
+ unless Symbol.method_defined? :name
2
+ if ((ObjectSpace::WeakMap.new[:test] = :test) rescue false)
3
+ # WeakMaps accept symbols only in Ruby 2.7+
4
+ def Backports.symbol_names
5
+ @symbol_names ||= ObjectSpace::WeakMap.new
6
+ end
7
+
8
+ class Symbol
9
+ def name
10
+ Backports.symbol_names[self] ||= to_s.freeze
11
+ end
12
+ end
13
+ else
14
+ # For earlier Rubies, we can't pool their strings
15
+ class Symbol
16
+ def name
17
+ to_s.freeze
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ require 'backports/tools/require_relative_dir'
2
+
3
+ Backports.require_relative_dir
@@ -0,0 +1,3 @@
1
+ # require this file to load all the backports up to Ruby 3.0
2
+ require 'backports/2.7.0'
3
+ Backports.require_relative_dir if RUBY_VERSION < '3.0'
@@ -0,0 +1 @@
1
+ require 'backports/3.0.0'
@@ -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,3 @@
1
+ require 'backports/tools/require_relative_dir'
2
+
3
+ Backports.require_relative_dir
@@ -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,5 @@
1
+ module Enumerable
2
+ def compact
3
+ reject { |elem| nil == elem }
4
+ end
5
+ end unless Enumerable.method_defined? :compact
@@ -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,3 @@
1
+ require 'backports/tools/require_relative_dir'
2
+
3
+ Backports.require_relative_dir
@@ -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,3 @@
1
+ require 'backports/tools/require_relative_dir'
2
+
3
+ Backports.require_relative_dir
@@ -0,0 +1,7 @@
1
+ class Integer
2
+ require 'backports/tools/arguments'
3
+
4
+ def self.try_convert(obj)
5
+ ::Backports.try_convert(obj, ::Integer, :to_int)
6
+ end
7
+ end unless Integer.respond_to? :try_convert
@@ -0,0 +1,3 @@
1
+ require 'backports/tools/require_relative_dir'
2
+
3
+ Backports.require_relative_dir
@@ -0,0 +1,5 @@
1
+ class MatchData
2
+ def match(index)
3
+ self[index]
4
+ end
5
+ end unless MatchData.method_defined? :match
@@ -0,0 +1,6 @@
1
+ class MatchData
2
+ def match_length(index)
3
+ m = self[index]
4
+ m && m.length
5
+ end
6
+ end unless MatchData.method_defined? :match_length
@@ -0,0 +1,3 @@
1
+ require 'backports/tools/require_relative_dir'
2
+
3
+ Backports.require_relative_dir
@@ -0,0 +1,5 @@
1
+ unless Struct.respond_to?(:keyword_init?)
2
+ def Struct.keyword_init?
3
+ new(1) && false rescue true
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ require 'backports/tools/require_relative_dir'
2
+
3
+ Backports.require_relative_dir
@@ -0,0 +1,3 @@
1
+ # require this file to load all the backports up to Ruby 3.0
2
+ require 'backports/3.0.0'
3
+ Backports.require_relative_dir if RUBY_VERSION < '3.1'
@@ -0,0 +1 @@
1
+ require 'backports/3.1.0'
@@ -0,0 +1,10 @@
1
+ unless Class.method_defined? :attached_object
2
+ require 'backports/2.1.0/module/singleton_class'
3
+
4
+ class Class
5
+ def attached_object
6
+ raise TypeError, "`#{self}' is not a singleton class" unless singleton_class?
7
+ ObjectSpace.each_object(self).first
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ require 'backports/tools/require_relative_dir'
2
+
3
+ Backports.require_relative_dir
@@ -0,0 +1,144 @@
1
+ original_verbosity = $VERBOSE
2
+ $VERBOSE = nil
3
+ if defined?(::Data) && !::Data.respond_to?(:define)
4
+ Object.send(:remove_const, :Data)
5
+ end
6
+ class ::Data
7
+ end
8
+
9
+ module Backports
10
+ Data = ::Data
11
+ end
12
+ $VERBOSE = original_verbosity
13
+
14
+ unless ::Backports::Data.respond_to?(:define)
15
+ require "backports/2.7.0/symbol/end_with"
16
+ require "backports/2.5.0/module/define_method"
17
+
18
+ class ::Backports::Data
19
+ def deconstruct
20
+ @__members__.values
21
+ end
22
+
23
+ def deconstruct_keys(keys_or_nil)
24
+ return @__members__ unless keys_or_nil
25
+
26
+ raise TypeError, "Expected symbols" unless keys_or_nil.is_a?(Array) && keys_or_nil.all? {|s| s.is_a?(Symbol)}
27
+ @__members__.slice(*keys_or_nil)
28
+ end
29
+
30
+ def self.define(*members, &block)
31
+ members.each do |m|
32
+ raise TypeError, "#{m} is not a Symbol" unless m.is_a?(Symbol) || m.is_a?(String)
33
+ raise ArgumentError, "invalid data member: #{m}" if m.end_with?("=")
34
+ end
35
+ members = members.map(&:to_sym)
36
+ raise ArgumentError, "duplicate members" if members.uniq!
37
+
38
+ klass = instance_eval <<-"end_define", __FILE__, __LINE__ + 1
39
+ Class.new(::Backports::Data) do # Class.new(::Data) do
40
+ def self.members # def self.members
41
+ #{members.inspect} # [:a_member, :another_member]
42
+ end # end
43
+ end # end
44
+ end_define
45
+
46
+ members.each do |m|
47
+ klass.define_method(m) { @__members__[m]}
48
+ end
49
+
50
+ class << klass
51
+ def new(*values, **named_values)
52
+ if named_values.empty?
53
+ if values.size > members.size
54
+ raise ArgumentError, "wrong number of arguments (given #{values.size}, expected 0..#{members.size})"
55
+ end
56
+ super(**members.first(values.size).zip(values).to_h)
57
+ else
58
+ unless values.empty?
59
+ raise ArgumentError, "wrong number of arguments (given #{values.size}, expected 0)"
60
+ end
61
+ super(**named_values)
62
+ end
63
+ end
64
+ undef :define
65
+ end
66
+
67
+ klass.class_eval(&block) if block
68
+
69
+ klass
70
+ end
71
+
72
+ def eql?(other)
73
+ return false unless other.instance_of?(self.class)
74
+
75
+ @__members__.eql?(other.to_h)
76
+ end
77
+
78
+ def ==(other)
79
+ return false unless other.instance_of?(self.class)
80
+
81
+ @__members__ == other.to_h
82
+ end
83
+
84
+ def hash
85
+ @__members__.hash
86
+ end
87
+
88
+ def initialize(**named_values)
89
+ given = named_values.keys
90
+ missing = members - given
91
+ unless missing.empty?
92
+ missing = missing.map(&:inspect).join(", ")
93
+ raise ArgumentError, "missing keywords: #{missing}"
94
+ end
95
+ if members.size < given.size
96
+ extra = (given - members).map(&:inspect).join(", ")
97
+ raise ArgumentError, "unknown keywords: #{extra}"
98
+ end
99
+ @__members__ = named_values.freeze
100
+ freeze
101
+ end
102
+
103
+ # Why is `initialize_copy` specialized in MRI and not just `initialize_dup`?
104
+ # Let's follow the pattern anyways
105
+ def initialize_copy(other)
106
+ @__members__ = other.to_h
107
+ freeze
108
+ end
109
+
110
+ def inspect
111
+ data = @__members__.map {|k, v| "#{k}=#{v.inspect}"}.join(", ")
112
+ space = data != "" && self.class.name ? " " : ""
113
+ "#<data #{self.class.name}#{space}#{data}>"
114
+ end
115
+
116
+ def marshal_dump
117
+ @__members__
118
+ end
119
+
120
+ def marshal_load(members)
121
+ @__members__ = members
122
+ freeze
123
+ end
124
+
125
+ # class method defined in `define`
126
+ def members
127
+ self.class.members
128
+ end
129
+
130
+ class << self
131
+ private :new
132
+ end
133
+
134
+ def to_h(&block)
135
+ @__members__.to_h(&block)
136
+ end
137
+
138
+ def with(**update)
139
+ return self if update.empty?
140
+
141
+ self.class.new(**@__members__.merge(update))
142
+ end
143
+ end
144
+ end
@@ -0,0 +1,64 @@
1
+ unless Enumerator.method_defined? :product
2
+ if RUBY_VERSION >= '2.7'
3
+ instance_eval <<-EOT, __FILE__, __LINE__ + 1
4
+ def Enumerator.product(*enums, **nil, &block)
5
+ Enumerator::Product.new(*enums).each(&block)
6
+ end
7
+ EOT
8
+ else
9
+ def Enumerator.product(*enums, &block)
10
+ Enumerator::Product.new(*enums).each(&block)
11
+ end
12
+ end
13
+
14
+ class Enumerator::Product < Enumerator
15
+ if RUBY_VERSION >= '2.7'
16
+ module_eval <<-EOT, __FILE__, __LINE__ + 1
17
+ def initialize(*enums, **nil)
18
+ @__enums = enums
19
+ end
20
+ EOT
21
+ else
22
+ # rubocop:disable Lint/MissingSuper
23
+ def initialize(*enums)
24
+ @__enums = enums
25
+ end
26
+ # rubocop:enable Lint/MissingSuper
27
+ end
28
+
29
+ def each(&block)
30
+ return self unless block
31
+ __execute(block, [], @__enums)
32
+ end
33
+
34
+ def __execute(block, values, enums)
35
+ if enums.empty?
36
+ block.yield values
37
+ else
38
+ enum, *enums = enums
39
+ enum.each do |val|
40
+ __execute(block, [*values, val], enums)
41
+ end
42
+ end
43
+ nil
44
+ end
45
+ private :__execute
46
+
47
+ def size
48
+ total_size = 1
49
+ @__enums.each do |enum|
50
+ size = enum.size
51
+ return size if size == nil || size == Float::INFINITY
52
+ total_size *= size
53
+ end
54
+ total_size
55
+ end
56
+
57
+ def rewind
58
+ @__enums.reverse_each do |enum|
59
+ enum.rewind if enum.respond_to?(:rewind)
60
+ end
61
+ self
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,3 @@
1
+ require 'backports/tools/require_relative_dir'
2
+
3
+ Backports.require_relative_dir
@@ -0,0 +1,10 @@
1
+ if Hash.new(42).shift
2
+ require 'backports/tools/alias_method_chain'
3
+
4
+ class Hash
5
+ def shift_with_correct_behaviour_when_empty
6
+ shift_without_correct_behaviour_when_empty unless empty?
7
+ end
8
+ Backports.alias_method_chain self, :shift, :correct_behaviour_when_empty
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ require 'backports/tools/require_relative_dir'
2
+
3
+ Backports.require_relative_dir