code_ownership 2.1.0 → 2.1.1

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 (227) hide show
  1. checksums.yaml +4 -4
  2. data/Cargo.lock +8 -14
  3. data/ext/cargo-vendor/magnus-0.8.2/.cargo-checksum.json +1 -0
  4. data/ext/cargo-vendor/magnus-0.8.2/.cargo_vcs_info.json +6 -0
  5. data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/CHANGELOG.md +66 -1
  6. data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/Cargo.lock +243 -9
  7. data/ext/cargo-vendor/magnus-0.8.2/Cargo.toml +277 -0
  8. data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/Cargo.toml.orig +11 -6
  9. data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/README.md +75 -23
  10. data/ext/cargo-vendor/magnus-0.8.2/build.rs +15 -0
  11. data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/examples/complete_object/test/temperature_test.rb +4 -4
  12. data/ext/cargo-vendor/magnus-0.8.2/examples/inheritance.rs +66 -0
  13. data/ext/cargo-vendor/magnus-0.8.2/examples/mut_point.rs +116 -0
  14. data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/api.rs +4 -3
  15. data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/class.rs +9 -7
  16. data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/encoding.rs +5 -5
  17. data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/error.rs +12 -3
  18. data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/fiber.rs +5 -5
  19. data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/gc.rs +3 -3
  20. data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/integer.rs +134 -0
  21. data/ext/cargo-vendor/magnus-0.8.2/src/io.rs +230 -0
  22. data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/lib.rs +53 -54
  23. data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/macros.rs +2 -2
  24. data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/method.rs +14 -100
  25. data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/module.rs +1 -1
  26. data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/mutex.rs +1 -1
  27. data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/r_array.rs +2 -2
  28. data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/r_bignum.rs +100 -3
  29. data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/r_hash.rs +63 -1
  30. data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/r_string.rs +31 -231
  31. data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/r_typed_data.rs +6 -9
  32. data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/rb_sys.rs +4 -4
  33. data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/scan_args.rs +3 -3
  34. data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/thread.rs +16 -10
  35. data/ext/cargo-vendor/magnus-0.8.2/src/time.rs +462 -0
  36. data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/try_convert.rs +64 -2
  37. data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/typed_data.rs +113 -11
  38. data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/value/flonum.rs +1 -1
  39. data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/value.rs +83 -6
  40. data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/test +1 -1
  41. data/ext/cargo-vendor/magnus-0.8.2/tests/hash.rs +44 -0
  42. data/ext/cargo-vendor/magnus-0.8.2/tests/io.rs +62 -0
  43. data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/return_iter.rs +1 -1
  44. data/ext/cargo-vendor/magnus-0.8.2/tests/string.rs +23 -0
  45. data/ext/cargo-vendor/magnus-0.8.2/tests/time.rs +71 -0
  46. data/ext/cargo-vendor/magnus-macros-0.8.0/.cargo-checksum.json +1 -0
  47. data/ext/cargo-vendor/magnus-macros-0.8.0/.cargo_vcs_info.json +6 -0
  48. data/ext/cargo-vendor/magnus-macros-0.8.0/Cargo.lock +47 -0
  49. data/ext/cargo-vendor/{magnus-macros-0.6.0 → magnus-macros-0.8.0}/Cargo.toml +10 -1
  50. data/ext/cargo-vendor/{magnus-macros-0.6.0 → magnus-macros-0.8.0}/Cargo.toml.orig +1 -1
  51. data/ext/cargo-vendor/magnus-macros-0.8.0/src/lib.rs +545 -0
  52. data/ext/cargo-vendor/{magnus-macros-0.6.0 → magnus-macros-0.8.0}/src/typed_data.rs +3 -3
  53. data/ext/cargo-vendor/{magnus-macros-0.6.0 → magnus-macros-0.8.0}/src/util.rs +1 -1
  54. data/ext/cargo-vendor/serde_magnus-0.10.0/.cargo-checksum.json +1 -0
  55. data/ext/cargo-vendor/serde_magnus-0.10.0/.cargo_vcs_info.json +6 -0
  56. data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/Cargo.lock +77 -75
  57. data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/Cargo.toml +3 -3
  58. data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/Cargo.toml.orig +7 -4
  59. data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/README.md +8 -5
  60. data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/src/de/array_deserializer.rs +12 -8
  61. data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/src/de/array_enumerator.rs +12 -7
  62. data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/src/de/deserializer.rs +21 -18
  63. data/ext/cargo-vendor/serde_magnus-0.10.0/src/de/enum_deserializer.rs +35 -0
  64. data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/src/de/hash_deserializer.rs +18 -11
  65. data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/src/de/mod.rs +76 -76
  66. data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/src/de/variant_deserializer.rs +10 -9
  67. data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/src/error.rs +10 -4
  68. data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/src/lib.rs +6 -5
  69. data/ext/cargo-vendor/serde_magnus-0.10.0/src/ser/enums.rs +11 -0
  70. data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/src/ser/map_serializer.rs +11 -12
  71. data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/src/ser/mod.rs +53 -50
  72. data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/src/ser/seq_serializer.rs +11 -10
  73. data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/src/ser/serializer.rs +50 -34
  74. data/ext/cargo-vendor/serde_magnus-0.10.0/src/ser/struct_serializer.rs +40 -0
  75. data/ext/cargo-vendor/serde_magnus-0.10.0/src/ser/struct_variant_serializer.rs +45 -0
  76. data/ext/cargo-vendor/serde_magnus-0.10.0/src/ser/tuple_variant_serializer.rs +38 -0
  77. data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/tests/deserializing_arrays.rs +3 -3
  78. data/ext/cargo-vendor/serde_magnus-0.10.0/tests/deserializing_booleans.rs +15 -0
  79. data/ext/cargo-vendor/serde_magnus-0.10.0/tests/deserializing_enums.rs +39 -0
  80. data/ext/cargo-vendor/serde_magnus-0.10.0/tests/deserializing_floats.rs +12 -0
  81. data/ext/cargo-vendor/serde_magnus-0.10.0/tests/deserializing_integers.rs +18 -0
  82. data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/tests/deserializing_maps.rs +3 -2
  83. data/ext/cargo-vendor/serde_magnus-0.10.0/tests/deserializing_options.rs +15 -0
  84. data/ext/cargo-vendor/serde_magnus-0.10.0/tests/deserializing_results.rs +17 -0
  85. data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/tests/deserializing_strings.rs +7 -7
  86. data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/tests/deserializing_structs.rs +9 -9
  87. data/ext/cargo-vendor/serde_magnus-0.10.0/tests/deserializing_tuples.rs +27 -0
  88. data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/tests/deserializing_vecs.rs +3 -3
  89. data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/tests/serializing_arrays.rs +3 -3
  90. data/ext/cargo-vendor/serde_magnus-0.10.0/tests/serializing_booleans.rs +15 -0
  91. data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/tests/serializing_enums.rs +9 -7
  92. data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/tests/serializing_floats.rs +2 -2
  93. data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/tests/serializing_integers.rs +4 -4
  94. data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/tests/serializing_maps.rs +3 -2
  95. data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/tests/serializing_options.rs +3 -3
  96. data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/tests/serializing_results.rs +5 -4
  97. data/ext/cargo-vendor/serde_magnus-0.10.0/tests/serializing_strings.rs +30 -0
  98. data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/tests/serializing_structs.rs +15 -7
  99. data/ext/cargo-vendor/serde_magnus-0.10.0/tests/serializing_tuples.rs +35 -0
  100. data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/tests/serializing_vecs.rs +3 -3
  101. data/ext/code_ownership/Cargo.toml +2 -2
  102. data/ext/code_ownership/extconf.rb +2 -1
  103. data/ext/code_ownership/src/lib.rs +16 -16
  104. data/lib/code_ownership/cli.rb +1 -0
  105. data/lib/code_ownership/private/file_path_finder.rb +3 -7
  106. data/lib/code_ownership/private/file_path_team_cache.rb +5 -9
  107. data/lib/code_ownership/private/for_file_output_builder.rb +0 -1
  108. data/lib/code_ownership/private/team_finder.rb +8 -14
  109. data/lib/code_ownership/version.rb +2 -2
  110. data/lib/code_ownership.rb +12 -17
  111. metadata +182 -186
  112. data/ext/cargo-vendor/magnus-0.7.1/.cargo-checksum.json +0 -1
  113. data/ext/cargo-vendor/magnus-0.7.1/.cargo_vcs_info.json +0 -6
  114. data/ext/cargo-vendor/magnus-0.7.1/Cargo.toml +0 -95
  115. data/ext/cargo-vendor/magnus-0.7.1/build.rs +0 -5
  116. data/ext/cargo-vendor/magnus-0.7.1/examples/mut_point.rs +0 -60
  117. data/ext/cargo-vendor/magnus-0.7.1/src/time.rs +0 -190
  118. data/ext/cargo-vendor/magnus-0.7.1/tests/hash.rs +0 -25
  119. data/ext/cargo-vendor/magnus-0.7.1/tests/string.rs +0 -13
  120. data/ext/cargo-vendor/magnus-macros-0.6.0/.cargo-checksum.json +0 -1
  121. data/ext/cargo-vendor/magnus-macros-0.6.0/.cargo_vcs_info.json +0 -6
  122. data/ext/cargo-vendor/magnus-macros-0.6.0/src/lib.rs +0 -401
  123. data/ext/cargo-vendor/rb-sys-env-0.1.2/.cargo-checksum.json +0 -1
  124. data/ext/cargo-vendor/rb-sys-env-0.1.2/.cargo_vcs_info.json +0 -6
  125. data/ext/cargo-vendor/rb-sys-env-0.1.2/Cargo.toml +0 -25
  126. data/ext/cargo-vendor/rb-sys-env-0.1.2/Cargo.toml.orig +0 -14
  127. data/ext/cargo-vendor/rb-sys-env-0.1.2/LICENSE-APACHE +0 -190
  128. data/ext/cargo-vendor/rb-sys-env-0.1.2/LICENSE-MIT +0 -21
  129. data/ext/cargo-vendor/rb-sys-env-0.1.2/readme.md +0 -119
  130. data/ext/cargo-vendor/rb-sys-env-0.1.2/src/defines.rs +0 -37
  131. data/ext/cargo-vendor/rb-sys-env-0.1.2/src/lib.rs +0 -180
  132. data/ext/cargo-vendor/rb-sys-env-0.1.2/src/rb_env.rs +0 -110
  133. data/ext/cargo-vendor/rb-sys-env-0.1.2/src/ruby_version.rs +0 -163
  134. data/ext/cargo-vendor/rb-sys-env-0.1.2/src/utils.rs +0 -6
  135. data/ext/cargo-vendor/serde_magnus-0.9.0/.cargo-checksum.json +0 -1
  136. data/ext/cargo-vendor/serde_magnus-0.9.0/.cargo_vcs_info.json +0 -6
  137. data/ext/cargo-vendor/serde_magnus-0.9.0/src/de/enum_deserializer.rs +0 -30
  138. data/ext/cargo-vendor/serde_magnus-0.9.0/src/ser/enums.rs +0 -11
  139. data/ext/cargo-vendor/serde_magnus-0.9.0/src/ser/struct_serializer.rs +0 -36
  140. data/ext/cargo-vendor/serde_magnus-0.9.0/src/ser/struct_variant_serializer.rs +0 -37
  141. data/ext/cargo-vendor/serde_magnus-0.9.0/src/ser/tuple_variant_serializer.rs +0 -33
  142. data/ext/cargo-vendor/serde_magnus-0.9.0/tests/deserializing_booleans.rs +0 -18
  143. data/ext/cargo-vendor/serde_magnus-0.9.0/tests/deserializing_enums.rs +0 -39
  144. data/ext/cargo-vendor/serde_magnus-0.9.0/tests/deserializing_floats.rs +0 -12
  145. data/ext/cargo-vendor/serde_magnus-0.9.0/tests/deserializing_integers.rs +0 -18
  146. data/ext/cargo-vendor/serde_magnus-0.9.0/tests/deserializing_options.rs +0 -15
  147. data/ext/cargo-vendor/serde_magnus-0.9.0/tests/deserializing_results.rs +0 -17
  148. data/ext/cargo-vendor/serde_magnus-0.9.0/tests/deserializing_tuples.rs +0 -31
  149. data/ext/cargo-vendor/serde_magnus-0.9.0/tests/serializing_booleans.rs +0 -15
  150. data/ext/cargo-vendor/serde_magnus-0.9.0/tests/serializing_strings.rs +0 -30
  151. data/ext/cargo-vendor/serde_magnus-0.9.0/tests/serializing_tuples.rs +0 -27
  152. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/.cargo/config.toml +0 -0
  153. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/Gemfile +0 -0
  154. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/LICENSE +0 -0
  155. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/examples/complete_object/Rakefile +0 -0
  156. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/examples/complete_object/lib/temperature.rb +0 -0
  157. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/examples/custom_exception_ruby/Rakefile +0 -0
  158. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/examples/custom_exception_ruby/lib/ahriman/error.rb +0 -0
  159. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/examples/custom_exception_ruby/lib/ahriman.rb +0 -0
  160. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/examples/custom_exception_ruby/test/error_test.rb +0 -0
  161. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/examples/custom_exception_rust/Rakefile +0 -0
  162. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/examples/custom_exception_rust/lib/ahriman.rb +0 -0
  163. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/examples/custom_exception_rust/test/error_test.rb +0 -0
  164. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/examples/fibonacci.rs +0 -0
  165. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/examples/hello_world.rs +0 -0
  166. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/examples/point.rs +0 -0
  167. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/examples/rust_blank/Rakefile +0 -0
  168. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/examples/rust_blank/lib/rust_blank.rb +0 -0
  169. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/examples/rust_blank/test/bench.rb +0 -0
  170. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/examples/rust_blank/test/blank_test.rb +0 -0
  171. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/block.rs +0 -0
  172. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/embed.rs +0 -0
  173. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/enumerator.rs +0 -0
  174. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/exception.rs +0 -0
  175. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/float.rs +0 -0
  176. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/into_value.rs +0 -0
  177. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/numeric.rs +0 -0
  178. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/object.rs +0 -0
  179. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/process.rs +0 -0
  180. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/r_complex.rs +0 -0
  181. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/r_file.rs +0 -0
  182. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/r_float.rs +0 -0
  183. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/r_match.rs +0 -0
  184. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/r_object.rs +0 -0
  185. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/r_rational.rs +0 -0
  186. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/r_regexp.rs +0 -0
  187. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/r_struct.rs +0 -0
  188. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/range.rs +0 -0
  189. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/symbol.rs +0 -0
  190. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/allocate_before_init.rs +0 -0
  191. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/array_slice.rs +0 -0
  192. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/block_call.rs +0 -0
  193. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/bytes.rs +0 -0
  194. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/call_proc.rs +0 -0
  195. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/classname.rs +0 -0
  196. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/clone.rs +0 -0
  197. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/codepoints.rs +0 -0
  198. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/debug_exception.rs +0 -0
  199. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/encoding_capable.rs +0 -0
  200. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/enumerator.rs +0 -0
  201. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/enumeratorize.rs +0 -0
  202. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/float_convert_from_value.rs +0 -0
  203. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/float_convert_to_value.rs +0 -0
  204. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/fmt.rs +0 -0
  205. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/freeze.rs +0 -0
  206. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/integer_convert_to_value.rs +0 -0
  207. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/integer_traits.rs +0 -0
  208. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/ivar.rs +0 -0
  209. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/lazy_id.rs +0 -0
  210. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/make_proc.rs +0 -0
  211. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/proc_new.rs +0 -0
  212. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/range.rs +0 -0
  213. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/return_custom_error.rs +0 -0
  214. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/scan_args.rs +0 -0
  215. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/str.rs +0 -0
  216. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/struct.rs +0 -0
  217. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/symbol.rs +0 -0
  218. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/try_convert_array.rs +0 -0
  219. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/tuple_to_array.rs +0 -0
  220. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/typed_data.rs +0 -0
  221. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/typed_data_obj.rs +0 -0
  222. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/typed_data_subclass.rs +0 -0
  223. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/typed_data_subclass_from_ruby.rs +0 -0
  224. /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/yield.rs +0 -0
  225. /data/ext/cargo-vendor/{magnus-macros-0.6.0 → magnus-macros-0.8.0}/LICENSE +0 -0
  226. /data/ext/cargo-vendor/{magnus-macros-0.6.0 → magnus-macros-0.8.0}/src/init.rs +0 -0
  227. /data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/LICENSE +0 -0
@@ -18,8 +18,9 @@ use std::{
18
18
  #[cfg(ruby_gte_3_0)]
19
19
  use rb_sys::rbimpl_typeddata_flags::{self, RUBY_TYPED_FREE_IMMEDIATELY, RUBY_TYPED_WB_PROTECTED};
20
20
  use rb_sys::{
21
- self, rb_data_type_struct__bindgen_ty_1, rb_data_type_t, rb_obj_reveal,
22
- rb_singleton_class_attached, rb_singleton_class_clone, size_t, VALUE,
21
+ self, rb_data_type_struct__bindgen_ty_1, rb_data_type_t, rb_gc_writebarrier,
22
+ rb_gc_writebarrier_unprotect, rb_obj_reveal, rb_singleton_class_attached,
23
+ rb_singleton_class_clone, size_t, RTYPEDDATA_GET_DATA, VALUE,
23
24
  };
24
25
 
25
26
  #[cfg(ruby_lt_3_0)]
@@ -31,7 +32,7 @@ const RUBY_TYPED_WB_PROTECTED: u32 = rb_sys::ruby_fl_type::RUBY_FL_WB_PROTECTED
31
32
  use crate::{
32
33
  class::RClass,
33
34
  error::{bug_from_panic, Error},
34
- gc,
35
+ gc::{self, Mark},
35
36
  into_value::IntoValue,
36
37
  object::Object,
37
38
  r_typed_data::RTypedData,
@@ -134,12 +135,12 @@ where
134
135
  /// in your [`mark`](Self::mark) function, you must update them in this
135
136
  /// function using [`gc::Compactor::location`].
136
137
  ///
137
- /// Ruby values would be concidered moveable if marked with the
138
+ /// Ruby considers values are moveable if marked with the
138
139
  /// [`gc::Marker::mark_movable`] function. Other marking functions such as
139
140
  /// [`gc::Marker::mark`] will prevent values being moved.
140
141
  ///
141
142
  /// As it is only safe for this function to receive a shared `&self`
142
- /// reference, you must implement interior mutablility to be able to update
143
+ /// reference, you must implement interior mutability to be able to update
143
144
  /// values. This is very hard to do correctly, and it is recommended to
144
145
  /// simply avoid using [`gc::Marker::mark_movable`] and `compact`.
145
146
  ///
@@ -157,7 +158,7 @@ where
157
158
  ///
158
159
  /// # Safety
159
160
  ///
160
- /// `ptr` must be a vaild pointer to a `Box<Self>`, and must not be aliased
161
+ /// `ptr` must be a valid pointer to a `Box<Self>`, and must not be aliased
161
162
  /// This function will free the memory pointed to by `ptr`.
162
163
  ///
163
164
  /// This function must not panic.
@@ -172,7 +173,7 @@ where
172
173
  ///
173
174
  /// # Safety
174
175
  ///
175
- /// `ptr` must be a vaild pointer to a `Self`, and must not be aliased.
176
+ /// `ptr` must be a valid pointer to a `Self`, and must not be aliased.
176
177
  ///
177
178
  /// This function must not panic.
178
179
  #[doc(hidden)]
@@ -187,7 +188,7 @@ where
187
188
  ///
188
189
  /// # Safety
189
190
  ///
190
- /// `ptr` must be a vaild pointer to a `Self`.
191
+ /// `ptr` must be a valid pointer to a `Self`.
191
192
  ///
192
193
  /// This function must not panic.
193
194
  #[doc(hidden)]
@@ -202,7 +203,7 @@ where
202
203
  ///
203
204
  /// # Safety
204
205
  ///
205
- /// `ptr` must be a vaild pointer to a `Self`, and must not be aliased.
206
+ /// `ptr` must be a valid pointer to a `Self`, and must not be aliased.
206
207
  ///
207
208
  /// This function must not panic.
208
209
  #[doc(hidden)]
@@ -299,7 +300,14 @@ where
299
300
 
300
301
  /// Enable the 'write barrier protected' flag.
301
302
  ///
302
- /// You almost certainly don't want to enable this.
303
+ /// Types that contain Ruby values by default do not participate in
304
+ /// generational GC (they are scanned every GC). This flag asserts all
305
+ /// operations that write Ruby values to this type are protected with
306
+ /// write barriers (see [`Writebarrier::writebarrier`]) so this
307
+ /// type can participate in generational GC.
308
+ ///
309
+ /// The write barrier is hard to get right. Magnus recommends you do not use
310
+ /// this flag.
303
311
  pub const fn wb_protected(mut self) -> Self {
304
312
  self.wb_protected = true;
305
313
  self
@@ -840,7 +848,12 @@ where
840
848
  /// # Ruby::init(example).unwrap()
841
849
  /// ```
842
850
  fn deref(&self) -> &Self::Target {
843
- self.inner.get().unwrap()
851
+ // Since we've already validated the inner during `TryConvert` via `RTypedData::get`, we
852
+ // can skip the extra checks and libruby calls and just access the data directly.
853
+ unsafe {
854
+ let data_ptr = RTYPEDDATA_GET_DATA(self.inner.as_rb_value()) as *mut Self::Target;
855
+ &*data_ptr
856
+ }
844
857
  }
845
858
  }
846
859
 
@@ -914,6 +927,95 @@ where
914
927
  }
915
928
  }
916
929
 
930
+ /// A trait for types that can be used with the `rb_gc_writebarrier` API.
931
+ pub trait Writebarrier: ReprValue {
932
+ /// Inform Ruby that `self` contains a reference to `new`.
933
+ ///
934
+ /// If you have a Rust type that contains Ruby values, and itself is
935
+ /// wrapped as a Ruby object, and you choose to enable the `wb_protected`
936
+ /// flag so that it can participate in generational GC then all operations
937
+ /// that add a Ruby value to your data type must call this function.
938
+ ///
939
+ /// The write barrier is hard to get right. Magnus recommends you do not
940
+ /// enable the `wb_protected` flag, and thus you don't need to use this function.
941
+ ///
942
+ /// # Examples
943
+ ///
944
+ /// ```
945
+ /// use std::cell::RefCell;
946
+ ///
947
+ /// use magnus::{
948
+ /// function, gc, method,
949
+ /// prelude::*,
950
+ /// typed_data::{Obj, Writebarrier},
951
+ /// value::Opaque,
952
+ /// DataTypeFunctions, Error, Ruby, TypedData, Value,
953
+ /// };
954
+ ///
955
+ /// #[derive(TypedData)]
956
+ /// #[magnus(class = "MyVec", free_immediately, mark, wb_protected)]
957
+ /// struct MyVec {
958
+ /// values: RefCell<Vec<Opaque<Value>>>,
959
+ /// }
960
+ ///
961
+ /// impl DataTypeFunctions for MyVec {
962
+ /// fn mark(&self, marker: &gc::Marker) {
963
+ /// marker.mark_slice(self.values.borrow().as_slice());
964
+ /// }
965
+ /// }
966
+ ///
967
+ /// impl MyVec {
968
+ /// fn new() -> Self {
969
+ /// Self {
970
+ /// values: RefCell::new(Vec::new()),
971
+ /// }
972
+ /// }
973
+ ///
974
+ /// fn push(ruby: &Ruby, rb_self: Obj<Self>, val: Value) -> Obj<Self> {
975
+ /// rb_self.values.borrow_mut().push(val.into());
976
+ /// rb_self.writebarrier(rb_self);
977
+ /// rb_self
978
+ /// }
979
+ /// }
980
+ ///
981
+ /// fn example(ruby: &Ruby) -> Result<(), Error> {
982
+ /// let class = ruby.define_class("MyVec", ruby.class_object())?;
983
+ /// class.define_singleton_method("new", function!(MyVec::new, 0))?;
984
+ /// class.define_method("push", method!(MyVec::push, 1))?;
985
+ ///
986
+ /// let _: Value = ruby.eval(
987
+ /// r#"
988
+ /// vec = MyVec.new
989
+ /// vec.push("test")
990
+ /// vec.push("example")
991
+ /// "#,
992
+ /// )?;
993
+ ///
994
+ /// Ok(())
995
+ /// }
996
+ /// # Ruby::init(example).unwrap();
997
+ /// ```
998
+ fn writebarrier<T>(&self, young: T)
999
+ where
1000
+ T: Mark,
1001
+ {
1002
+ unsafe { rb_gc_writebarrier(self.as_rb_value(), young.raw()) };
1003
+ }
1004
+
1005
+ /// Opts `self` out of generational GC / write barrier protection.
1006
+ ///
1007
+ /// After calling this function `self` will not participate in generational
1008
+ /// GC and will always be scanned during a GC.
1009
+ /// See [`RTypedData::writebarrier`].
1010
+ fn writebarrier_unprotect<T, U>(&self) {
1011
+ unsafe { rb_gc_writebarrier_unprotect(self.as_rb_value()) };
1012
+ }
1013
+ }
1014
+
1015
+ impl Writebarrier for RTypedData {}
1016
+
1017
+ impl<T> Writebarrier for Obj<T> where T: TypedData {}
1018
+
917
1019
  /// Trait for a Ruby-compatible `#hash` method.
918
1020
  ///
919
1021
  /// Automatically implemented for any type implementing [`std::hash::Hash`].
@@ -90,7 +90,7 @@ impl Flonum {
90
90
  #[inline]
91
91
  pub(crate) fn from_f64_impl(d: f64) -> Option<Self> {
92
92
  let v = d.to_bits();
93
- let bits = v >> 60 & 0x7;
93
+ let bits = (v >> 60) & 0x7;
94
94
  if v != 0x3000000000000000 && bits.wrapping_sub(3) & !0x01 == 0 {
95
95
  return Some(unsafe { Self::from_rb_value_unchecked(v.rotate_left(3) & !0x01 | 0x02) });
96
96
  } else if v == 0 {
@@ -130,6 +130,15 @@ impl IntoValue for i64 {
130
130
 
131
131
  unsafe impl IntoValueFromNative for i64 {}
132
132
 
133
+ impl IntoValue for i128 {
134
+ #[inline]
135
+ fn into_value_with(self, handle: &Ruby) -> Value {
136
+ handle.integer_from_i128(self).into_value_with(handle)
137
+ }
138
+ }
139
+
140
+ unsafe impl IntoValueFromNative for i128 {}
141
+
133
142
  impl IntoValue for isize {
134
143
  #[inline]
135
144
  fn into_value_with(self, handle: &Ruby) -> Value {
@@ -175,6 +184,15 @@ impl IntoValue for u64 {
175
184
 
176
185
  unsafe impl IntoValueFromNative for u64 {}
177
186
 
187
+ impl IntoValue for u128 {
188
+ #[inline]
189
+ fn into_value_with(self, handle: &Ruby) -> Value {
190
+ handle.integer_from_u128(self).into_value_with(handle)
191
+ }
192
+ }
193
+
194
+ unsafe impl IntoValueFromNative for u128 {}
195
+
178
196
  impl IntoValue for usize {
179
197
  #[inline]
180
198
  fn into_value_with(self, handle: &Ruby) -> Value {
@@ -758,7 +776,7 @@ pub(crate) mod private {
758
776
  /// Ruby may modify or free the memory backing the returned
759
777
  /// str, the caller must ensure this does not happen.
760
778
  #[allow(clippy::wrong_self_convention)]
761
- unsafe fn to_s_infallible(&self) -> Cow<str> {
779
+ unsafe fn to_s_infallible(&self) -> Cow<'_, str> {
762
780
  match self.as_value_ref().to_s() {
763
781
  Ok(v) => v,
764
782
  Err(_) => Cow::Owned(
@@ -1437,7 +1455,7 @@ pub trait ReprValue: private::ReprValue {
1437
1455
 
1438
1456
  /// Check if `self` responds to the given Ruby method.
1439
1457
  ///
1440
- /// The `include_private` agument controls whether `self`'s private methods
1458
+ /// The `include_private` argument controls whether `self`'s private methods
1441
1459
  /// are checked. If `false` they are not, if `true` they are.
1442
1460
  ///
1443
1461
  /// See also [`Value::check_funcall`].
@@ -1452,8 +1470,8 @@ pub trait ReprValue: private::ReprValue {
1452
1470
  /// assert!(s.respond_to("to_str", false)?);
1453
1471
  /// assert!(!s.respond_to("puts", false)?);
1454
1472
  /// assert!(s.respond_to("puts", true)?);
1455
- /// assert!(!s.respond_to("non_existant", false)?);
1456
- /// assert!(!s.respond_to("non_existant", true)?);
1473
+ /// assert!(!s.respond_to("non_existent", false)?);
1474
+ /// assert!(!s.respond_to("non_existent", true)?);
1457
1475
  ///
1458
1476
  /// Ok(())
1459
1477
  /// }
@@ -1530,7 +1548,7 @@ pub trait ReprValue: private::ReprValue {
1530
1548
  /// # Ruby::init(example).unwrap()
1531
1549
  /// ```
1532
1550
  #[allow(clippy::wrong_self_convention)]
1533
- unsafe fn to_s(&self) -> Result<Cow<str>, Error> {
1551
+ unsafe fn to_s(&self) -> Result<Cow<'_, str>, Error> {
1534
1552
  if let Some(s) = RString::ref_from_value(self.as_value_ref()) {
1535
1553
  if s.is_utf8_compatible_encoding() {
1536
1554
  return s.as_str().map(Cow::Borrowed);
@@ -1596,7 +1614,7 @@ pub trait ReprValue: private::ReprValue {
1596
1614
  /// }
1597
1615
  /// # Ruby::init(example).unwrap()
1598
1616
  /// ```
1599
- unsafe fn classname(&self) -> Cow<str> {
1617
+ unsafe fn classname(&self) -> Cow<'_, str> {
1600
1618
  let ptr = rb_obj_classname(self.as_rb_value());
1601
1619
  let cstr = CStr::from_ptr(ptr);
1602
1620
  cstr.to_string_lossy()
@@ -2594,6 +2612,35 @@ impl Fixnum {
2594
2612
  self.to_isize() as i64
2595
2613
  }
2596
2614
 
2615
+ /// Convert `self` to an `i128`. This is infallible as `i128` can represent a
2616
+ /// larger range than `Fixnum`.
2617
+ ///
2618
+ /// # Examples
2619
+ ///
2620
+ /// ```
2621
+ /// use magnus::{Error, Fixnum, Ruby};
2622
+ ///
2623
+ /// fn example(ruby: &Ruby) -> Result<(), Error> {
2624
+ /// # #[cfg(not(windows))]
2625
+ /// assert_eq!(
2626
+ /// ruby.eval::<Fixnum>("4611686018427387903")?.to_i128(),
2627
+ /// 4611686018427387903
2628
+ /// );
2629
+ /// # #[cfg(not(windows))]
2630
+ /// assert_eq!(
2631
+ /// ruby.eval::<Fixnum>("-4611686018427387904")?.to_i128(),
2632
+ /// -4611686018427387904
2633
+ /// );
2634
+ ///
2635
+ /// Ok(())
2636
+ /// }
2637
+ /// # Ruby::init(example).unwrap()
2638
+ /// ```
2639
+ #[inline]
2640
+ pub fn to_i128(self) -> i128 {
2641
+ self.to_isize() as i128
2642
+ }
2643
+
2597
2644
  /// Convert `self` to an `isize`. Returns `Err` if `self` is out of range
2598
2645
  /// for `isize`.
2599
2646
  ///
@@ -2764,6 +2811,36 @@ impl Fixnum {
2764
2811
  Ok(self.to_isize() as u64)
2765
2812
  }
2766
2813
 
2814
+ /// Convert `self` to a `u128`. Returns `Err` if `self` is negative.
2815
+ ///
2816
+ /// # Examples
2817
+ ///
2818
+ /// ```
2819
+ /// use magnus::{Error, Fixnum, Ruby};
2820
+ ///
2821
+ /// fn example(ruby: &Ruby) -> Result<(), Error> {
2822
+ /// # #[cfg(not(windows))]
2823
+ /// assert_eq!(
2824
+ /// ruby.eval::<Fixnum>("4611686018427387903")?.to_u128()?,
2825
+ /// 4611686018427387903
2826
+ /// );
2827
+ /// assert!(ruby.eval::<Fixnum>("-1")?.to_u128().is_err());
2828
+ ///
2829
+ /// Ok(())
2830
+ /// }
2831
+ /// # Ruby::init(example).unwrap()
2832
+ /// ```
2833
+ #[inline]
2834
+ pub fn to_u128(self) -> Result<u128, Error> {
2835
+ if self.is_negative() {
2836
+ return Err(Error::new(
2837
+ Ruby::get_with(self).exception_range_error(),
2838
+ "can't convert negative integer to unsigned",
2839
+ ));
2840
+ }
2841
+ Ok(self.to_isize() as u128)
2842
+ }
2843
+
2767
2844
  /// Convert `self` to a `usize`. Returns `Err` if `self` is negative or out
2768
2845
  /// of range for `usize`.
2769
2846
  ///
@@ -7,7 +7,7 @@ for VERSION in $RUBY_VERSIONS; do
7
7
  eval "$(rbenv init - sh)"
8
8
  rbenv shell $VERSION
9
9
  printf "testing Ruby $VERSION..."
10
- if OUTPUT=$(env RUBY="$(rbenv which ruby)" cargo +1.61 test --workspace 2>&1); then
10
+ if OUTPUT=$(env RUBY="$(rbenv which ruby)" cargo +1.65 test --workspace 2>&1); then
11
11
  echo ✅
12
12
  else
13
13
  ERRORS="$ERRORS\n\n\n$VERSION\n\n$OUTPUT"
@@ -0,0 +1,44 @@
1
+ use std::collections::{BTreeMap, HashMap};
2
+
3
+ #[test]
4
+ fn it_converts_maps() {
5
+ let ruby = unsafe { magnus::embed::init() };
6
+
7
+ let map: HashMap<String, u8> = ruby
8
+ .eval(r#"{"foo" => 1, "bar" => 2, "baz" => 3}"#)
9
+ .unwrap();
10
+
11
+ let mut expected = HashMap::new();
12
+ expected.insert("foo".to_owned(), 1);
13
+ expected.insert("bar".to_owned(), 2);
14
+ expected.insert("baz".to_owned(), 3);
15
+ assert_eq!(expected, map);
16
+
17
+ let mut map = HashMap::new();
18
+ map.insert("test", (0, 0.5));
19
+ map.insert("example", (1, 3.75));
20
+ magnus::rb_assert!(
21
+ ruby,
22
+ r#"map == {"test" => [0, 0.5], "example" => [1, 3.75]}"#,
23
+ map
24
+ );
25
+
26
+ let map: BTreeMap<String, u8> = ruby
27
+ .eval(r#"{"foo" => 1, "bar" => 2, "baz" => 3}"#)
28
+ .unwrap();
29
+
30
+ let mut expected = BTreeMap::new();
31
+ expected.insert("foo".to_owned(), 1);
32
+ expected.insert("bar".to_owned(), 2);
33
+ expected.insert("baz".to_owned(), 3);
34
+ assert_eq!(expected, map);
35
+
36
+ let mut map = BTreeMap::new();
37
+ map.insert("test", (0, 0.5));
38
+ map.insert("example", (1, 3.75));
39
+ magnus::rb_assert!(
40
+ ruby,
41
+ r#"map == {"test" => [0, 0.5], "example" => [1, 3.75]}"#,
42
+ map
43
+ );
44
+ }
@@ -0,0 +1,62 @@
1
+ use magnus::{
2
+ encoding::Index, io::*, value::ReprValue, Error, Fixnum, IntoValue, Module, Ruby, TryConvert,
3
+ };
4
+
5
+ #[test]
6
+ fn test_io_all() {
7
+ magnus::Ruby::init(|ruby| {
8
+ test_io_extract_modeenc_extracts_open_flags(ruby)?;
9
+ test_io_extract_modeenc_extracts_fmode_flags(ruby)?;
10
+ test_io_extract_modeenc_extracts_io_encoding(ruby)?;
11
+ Ok(())
12
+ })
13
+ .unwrap();
14
+ }
15
+
16
+ fn run_io_extract_modeenc(
17
+ ruby: &Ruby,
18
+ mode: &str,
19
+ ) -> Result<(OpenFlags, FMode, IoEncoding), Error> {
20
+ let mut mode = ruby.str_new(mode).into_value_with(&ruby);
21
+ let mut permission = ruby.qnil().into_value_with(&ruby);
22
+ let kwargs = ruby.hash_new();
23
+ let _ = kwargs.aset(ruby.to_symbol("encoding"), "GBK:UTF-8"); // follows "extern:intern". read more on `IO::new`
24
+ ruby.io_extract_modeenc(&mut mode, &mut permission, &kwargs)
25
+ }
26
+
27
+ fn test_io_extract_modeenc_extracts_open_flags(ruby: &Ruby) -> Result<(), Error> {
28
+ let (open_flags, _, _) = run_io_extract_modeenc(&ruby, "a")?;
29
+
30
+ let file_class = ruby.class_file();
31
+ let append_flag = file_class.const_get::<_, Fixnum>("APPEND")?.to_i32()?;
32
+
33
+ assert!(open_flags.contains(append_flag));
34
+ Ok(())
35
+ }
36
+
37
+ fn test_io_extract_modeenc_extracts_fmode_flags(ruby: &Ruby) -> Result<(), Error> {
38
+ let (_, fmode_flags, _) = run_io_extract_modeenc(&ruby, "a")?;
39
+
40
+ assert!(fmode_flags.contains(FMode::APPEND));
41
+ assert!(fmode_flags.contains(FMode::READ_WRITE));
42
+ assert!(fmode_flags.contains(FMode::CREATE));
43
+
44
+ Ok(())
45
+ }
46
+
47
+ fn test_io_extract_modeenc_extracts_io_encoding(ruby: &Ruby) -> Result<(), Error> {
48
+ let (_, _, io_encoding) = run_io_extract_modeenc(&ruby, "a")?;
49
+
50
+ assert!(io_encoding.internal.is_some());
51
+ assert!(io_encoding.external.is_some());
52
+
53
+ let internal_index = Index::from(io_encoding.internal.unwrap());
54
+ let external_index = Index::from(io_encoding.external.unwrap());
55
+ let utf_8 = ruby.utf8_encindex();
56
+ let gbk = Index::try_convert(ruby.str_new("GBK").as_value())?;
57
+
58
+ assert!(internal_index == utf_8, "Internal encoding is not UTF-8");
59
+ assert!(external_index == gbk, "External encoding is not GBK");
60
+
61
+ Ok(())
62
+ }
@@ -2,7 +2,7 @@ use magnus::{block::Yield, eval, method, prelude::*, rb_assert, Ruby, Value};
2
2
 
3
3
  fn count_to_3(ruby: &Ruby, rb_self: Value) -> Yield<impl Iterator<Item = u8>> {
4
4
  if ruby.block_given() {
5
- Yield::Iter((1..=3).into_iter())
5
+ Yield::Iter(1..=3)
6
6
  } else {
7
7
  Yield::Enumerator(rb_self.enumeratorize("count_to_3", ()))
8
8
  }
@@ -0,0 +1,23 @@
1
+ use magnus::{prelude::*, Value};
2
+
3
+ #[test]
4
+ fn it_converts_to_utf8_string() {
5
+ let ruby = unsafe { magnus::embed::init() };
6
+
7
+ let val: Value = ruby
8
+ .eval(r#""caf\xE9".force_encoding("ISO-8859-1")"#)
9
+ .unwrap();
10
+ let s = String::try_convert(val).unwrap();
11
+
12
+ assert_eq!("café", s);
13
+
14
+ let val: Value = magnus::eval!(r#""\xFF\xFF""#).unwrap();
15
+ let err = String::try_convert(val).unwrap_err();
16
+
17
+ let expected_error = "invalid byte sequence in UTF-8";
18
+ assert!(
19
+ err.to_string().contains(expected_error),
20
+ "Expected \"{}\" to contain \"{expected_error}\" but it didn't",
21
+ err.to_string()
22
+ );
23
+ }
@@ -0,0 +1,71 @@
1
+ use std::time::SystemTime;
2
+
3
+ use magnus::{rb_assert, Error, Ruby};
4
+
5
+ #[test]
6
+ fn test_all() {
7
+ magnus::Ruby::init(|ruby| {
8
+ test_supports_system_time(ruby)?;
9
+ #[cfg(feature = "chrono")]
10
+ test_supports_chrono(ruby)?;
11
+ Ok(())
12
+ })
13
+ .unwrap();
14
+ }
15
+
16
+ fn test_supports_system_time(ruby: &Ruby) -> Result<(), Error> {
17
+ let t = ruby.eval::<SystemTime>("Time.new(1971)").unwrap();
18
+ rb_assert!(ruby, "t.year == 1971", t);
19
+
20
+ let t = ruby.eval::<SystemTime>("Time.new(1960)").unwrap();
21
+ rb_assert!(ruby, "t.year == 1960", t);
22
+
23
+ Ok(())
24
+ }
25
+
26
+ fn test_supports_chrono(ruby: &Ruby) -> Result<(), Error> {
27
+ use chrono::{DateTime, Datelike, FixedOffset, Utc};
28
+
29
+ let t = ruby.eval::<DateTime<Utc>>("Time.at(0, 10, :nsec)").unwrap();
30
+ assert_eq!(t.year(), 1970);
31
+ assert_eq!(t.month(), 1);
32
+ assert_eq!(t.day(), 1);
33
+ assert_eq!(t.timestamp_subsec_nanos(), 10);
34
+
35
+ let dt = ruby
36
+ .eval::<DateTime<Utc>>(r#"Time.new(1971, 1, 1, 2, 2, 2.0000001, "Z")"#)
37
+ .unwrap();
38
+ assert_eq!(&dt.to_rfc3339(), "1971-01-01T02:02:02.000000099+00:00");
39
+ rb_assert!(ruby, "dt.utc?", dt);
40
+ rb_assert!(ruby, "dt.utc_offset == 0", dt);
41
+
42
+ let dt = ruby
43
+ .eval::<DateTime<Utc>>(r#"Time.new(1950, 1, 1, 0, 0, 0, "Z")"#)
44
+ .unwrap();
45
+ assert_eq!(&dt.to_rfc3339(), "1950-01-01T00:00:00+00:00");
46
+
47
+ let dt = ruby
48
+ .eval::<DateTime<Utc>>(r#"Time.new(1971, 1, 1, 2, 2, 2.0000001, "-07:00")"#)
49
+ .unwrap();
50
+ assert_eq!(&dt.to_rfc3339(), "1971-01-01T09:02:02.000000099+00:00");
51
+
52
+ let dt = ruby
53
+ .eval::<DateTime<FixedOffset>>(
54
+ r#"Time.new(2022, 5, 31, 9, 8, 123456789/1000000000r, "-07:00")"#,
55
+ )
56
+ .unwrap();
57
+ assert_eq!(&dt.to_rfc3339(), "2022-05-31T09:08:00.123456789-07:00");
58
+ rb_assert!(ruby, "!dt.utc?", dt);
59
+ rb_assert!(ruby, "dt.utc_offset == -25200", dt);
60
+
61
+ let dt = ruby
62
+ .eval::<DateTime<FixedOffset>>(
63
+ r#"Time.new(2022, 5, 31, 9, 8, 123456789/1000000000r, "+05:30")"#,
64
+ )
65
+ .unwrap();
66
+ assert_eq!(&dt.to_rfc3339(), "2022-05-31T09:08:00.123456789+05:30");
67
+ rb_assert!(ruby, "!dt.utc?", dt);
68
+ rb_assert!(ruby, "dt.utc_offset == 19800", dt);
69
+
70
+ Ok(())
71
+ }
@@ -0,0 +1 @@
1
+ {"files":{".cargo_vcs_info.json":"3799c49c0a41fefcee2b738bc923889af371a49341656d66801347a258ae4dc1","Cargo.lock":"2d7d7ea1ed593ad0699d570db1f655f3af4e0b355291c4eba02d60a1bdf2358c","Cargo.toml":"15867dafbc2b17bfdbfc4bca82a976f7a18533aa718b64a199fe17811f0757b2","Cargo.toml.orig":"7de5dc395d511e7519fa96ff211015802b02ba17d6ba6a79e30af7c8b1794eb0","LICENSE":"79e69d34457af5881b9b7410144cac786098fd86f242a98f419aa8abd1b0578a","src/init.rs":"c0204a41d747889cfd6723f4f3bf4aa2f9f868c288738d29cc6229de4260debf","src/lib.rs":"ee63e82cfc6c9d9ea9e338244f979d7059665d272e8339f414c4e652c07b0b76","src/typed_data.rs":"e44f4ba8d82f4d2a2377158b1815a0a4b09c3ab547b580ffa95b7f521ee572b8","src/util.rs":"f72750d079f31600d4bfa3dd8022550f63e1625e3cf184756f629ab5af69d241"},"package":"47607461fd8e1513cb4f2076c197d8092d921a1ea75bd08af97398f593751892"}
@@ -0,0 +1,6 @@
1
+ {
2
+ "git": {
3
+ "sha1": "108c87edff240ad930070b83b8801fcc0851c676"
4
+ },
5
+ "path_in_vcs": "magnus-macros"
6
+ }
@@ -0,0 +1,47 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ version = 3
4
+
5
+ [[package]]
6
+ name = "magnus-macros"
7
+ version = "0.8.0"
8
+ dependencies = [
9
+ "proc-macro2",
10
+ "quote",
11
+ "syn",
12
+ ]
13
+
14
+ [[package]]
15
+ name = "proc-macro2"
16
+ version = "1.0.66"
17
+ source = "registry+https://github.com/rust-lang/crates.io-index"
18
+ checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9"
19
+ dependencies = [
20
+ "unicode-ident",
21
+ ]
22
+
23
+ [[package]]
24
+ name = "quote"
25
+ version = "1.0.32"
26
+ source = "registry+https://github.com/rust-lang/crates.io-index"
27
+ checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965"
28
+ dependencies = [
29
+ "proc-macro2",
30
+ ]
31
+
32
+ [[package]]
33
+ name = "syn"
34
+ version = "2.0.28"
35
+ source = "registry+https://github.com/rust-lang/crates.io-index"
36
+ checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567"
37
+ dependencies = [
38
+ "proc-macro2",
39
+ "quote",
40
+ "unicode-ident",
41
+ ]
42
+
43
+ [[package]]
44
+ name = "unicode-ident"
45
+ version = "1.0.11"
46
+ source = "registry+https://github.com/rust-lang/crates.io-index"
47
+ checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c"
@@ -12,13 +12,22 @@
12
12
  [package]
13
13
  edition = "2021"
14
14
  name = "magnus-macros"
15
- version = "0.6.0"
15
+ version = "0.8.0"
16
+ build = false
17
+ autolib = false
18
+ autobins = false
19
+ autoexamples = false
20
+ autotests = false
21
+ autobenches = false
16
22
  description = "Derive and proc macros for magnus"
17
23
  homepage = "https://github.com/matsadler/magnus"
24
+ readme = false
18
25
  license = "MIT"
19
26
  repository = "https://github.com/matsadler/magnus"
20
27
 
21
28
  [lib]
29
+ name = "magnus_macros"
30
+ path = "src/lib.rs"
22
31
  proc-macro = true
23
32
 
24
33
  [dependencies.proc-macro2]
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "magnus-macros"
3
- version = "0.6.0"
3
+ version = "0.8.0"
4
4
  edition = "2021"
5
5
  description = "Derive and proc macros for magnus"
6
6
  repository = "https://github.com/matsadler/magnus"