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.
- checksums.yaml +4 -4
- data/Cargo.lock +8 -14
- data/ext/cargo-vendor/magnus-0.8.2/.cargo-checksum.json +1 -0
- data/ext/cargo-vendor/magnus-0.8.2/.cargo_vcs_info.json +6 -0
- data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/CHANGELOG.md +66 -1
- data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/Cargo.lock +243 -9
- data/ext/cargo-vendor/magnus-0.8.2/Cargo.toml +277 -0
- data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/Cargo.toml.orig +11 -6
- data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/README.md +75 -23
- data/ext/cargo-vendor/magnus-0.8.2/build.rs +15 -0
- data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/examples/complete_object/test/temperature_test.rb +4 -4
- data/ext/cargo-vendor/magnus-0.8.2/examples/inheritance.rs +66 -0
- data/ext/cargo-vendor/magnus-0.8.2/examples/mut_point.rs +116 -0
- data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/api.rs +4 -3
- data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/class.rs +9 -7
- data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/encoding.rs +5 -5
- data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/error.rs +12 -3
- data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/fiber.rs +5 -5
- data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/gc.rs +3 -3
- data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/integer.rs +134 -0
- data/ext/cargo-vendor/magnus-0.8.2/src/io.rs +230 -0
- data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/lib.rs +53 -54
- data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/macros.rs +2 -2
- data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/method.rs +14 -100
- data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/module.rs +1 -1
- data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/mutex.rs +1 -1
- data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/r_array.rs +2 -2
- data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/r_bignum.rs +100 -3
- data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/r_hash.rs +63 -1
- data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/r_string.rs +31 -231
- data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/r_typed_data.rs +6 -9
- data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/rb_sys.rs +4 -4
- data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/scan_args.rs +3 -3
- data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/thread.rs +16 -10
- data/ext/cargo-vendor/magnus-0.8.2/src/time.rs +462 -0
- data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/try_convert.rs +64 -2
- data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/typed_data.rs +113 -11
- data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/value/flonum.rs +1 -1
- data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/value.rs +83 -6
- data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/test +1 -1
- data/ext/cargo-vendor/magnus-0.8.2/tests/hash.rs +44 -0
- data/ext/cargo-vendor/magnus-0.8.2/tests/io.rs +62 -0
- data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/return_iter.rs +1 -1
- data/ext/cargo-vendor/magnus-0.8.2/tests/string.rs +23 -0
- data/ext/cargo-vendor/magnus-0.8.2/tests/time.rs +71 -0
- data/ext/cargo-vendor/magnus-macros-0.8.0/.cargo-checksum.json +1 -0
- data/ext/cargo-vendor/magnus-macros-0.8.0/.cargo_vcs_info.json +6 -0
- data/ext/cargo-vendor/magnus-macros-0.8.0/Cargo.lock +47 -0
- data/ext/cargo-vendor/{magnus-macros-0.6.0 → magnus-macros-0.8.0}/Cargo.toml +10 -1
- data/ext/cargo-vendor/{magnus-macros-0.6.0 → magnus-macros-0.8.0}/Cargo.toml.orig +1 -1
- data/ext/cargo-vendor/magnus-macros-0.8.0/src/lib.rs +545 -0
- data/ext/cargo-vendor/{magnus-macros-0.6.0 → magnus-macros-0.8.0}/src/typed_data.rs +3 -3
- data/ext/cargo-vendor/{magnus-macros-0.6.0 → magnus-macros-0.8.0}/src/util.rs +1 -1
- data/ext/cargo-vendor/serde_magnus-0.10.0/.cargo-checksum.json +1 -0
- data/ext/cargo-vendor/serde_magnus-0.10.0/.cargo_vcs_info.json +6 -0
- data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/Cargo.lock +77 -75
- data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/Cargo.toml +3 -3
- data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/Cargo.toml.orig +7 -4
- data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/README.md +8 -5
- data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/src/de/array_deserializer.rs +12 -8
- data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/src/de/array_enumerator.rs +12 -7
- data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/src/de/deserializer.rs +21 -18
- data/ext/cargo-vendor/serde_magnus-0.10.0/src/de/enum_deserializer.rs +35 -0
- data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/src/de/hash_deserializer.rs +18 -11
- data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/src/de/mod.rs +76 -76
- data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/src/de/variant_deserializer.rs +10 -9
- data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/src/error.rs +10 -4
- data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/src/lib.rs +6 -5
- data/ext/cargo-vendor/serde_magnus-0.10.0/src/ser/enums.rs +11 -0
- data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/src/ser/map_serializer.rs +11 -12
- data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/src/ser/mod.rs +53 -50
- data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/src/ser/seq_serializer.rs +11 -10
- data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/src/ser/serializer.rs +50 -34
- data/ext/cargo-vendor/serde_magnus-0.10.0/src/ser/struct_serializer.rs +40 -0
- data/ext/cargo-vendor/serde_magnus-0.10.0/src/ser/struct_variant_serializer.rs +45 -0
- data/ext/cargo-vendor/serde_magnus-0.10.0/src/ser/tuple_variant_serializer.rs +38 -0
- data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/tests/deserializing_arrays.rs +3 -3
- data/ext/cargo-vendor/serde_magnus-0.10.0/tests/deserializing_booleans.rs +15 -0
- data/ext/cargo-vendor/serde_magnus-0.10.0/tests/deserializing_enums.rs +39 -0
- data/ext/cargo-vendor/serde_magnus-0.10.0/tests/deserializing_floats.rs +12 -0
- data/ext/cargo-vendor/serde_magnus-0.10.0/tests/deserializing_integers.rs +18 -0
- data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/tests/deserializing_maps.rs +3 -2
- data/ext/cargo-vendor/serde_magnus-0.10.0/tests/deserializing_options.rs +15 -0
- data/ext/cargo-vendor/serde_magnus-0.10.0/tests/deserializing_results.rs +17 -0
- data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/tests/deserializing_strings.rs +7 -7
- data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/tests/deserializing_structs.rs +9 -9
- data/ext/cargo-vendor/serde_magnus-0.10.0/tests/deserializing_tuples.rs +27 -0
- data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/tests/deserializing_vecs.rs +3 -3
- data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/tests/serializing_arrays.rs +3 -3
- data/ext/cargo-vendor/serde_magnus-0.10.0/tests/serializing_booleans.rs +15 -0
- data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/tests/serializing_enums.rs +9 -7
- data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/tests/serializing_floats.rs +2 -2
- data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/tests/serializing_integers.rs +4 -4
- data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/tests/serializing_maps.rs +3 -2
- data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/tests/serializing_options.rs +3 -3
- data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/tests/serializing_results.rs +5 -4
- data/ext/cargo-vendor/serde_magnus-0.10.0/tests/serializing_strings.rs +30 -0
- data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/tests/serializing_structs.rs +15 -7
- data/ext/cargo-vendor/serde_magnus-0.10.0/tests/serializing_tuples.rs +35 -0
- data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/tests/serializing_vecs.rs +3 -3
- data/ext/code_ownership/Cargo.toml +2 -2
- data/ext/code_ownership/extconf.rb +2 -1
- data/ext/code_ownership/src/lib.rs +16 -16
- data/lib/code_ownership/cli.rb +1 -0
- data/lib/code_ownership/private/file_path_finder.rb +3 -7
- data/lib/code_ownership/private/file_path_team_cache.rb +5 -9
- data/lib/code_ownership/private/for_file_output_builder.rb +0 -1
- data/lib/code_ownership/private/team_finder.rb +8 -14
- data/lib/code_ownership/version.rb +2 -2
- data/lib/code_ownership.rb +12 -17
- metadata +182 -186
- data/ext/cargo-vendor/magnus-0.7.1/.cargo-checksum.json +0 -1
- data/ext/cargo-vendor/magnus-0.7.1/.cargo_vcs_info.json +0 -6
- data/ext/cargo-vendor/magnus-0.7.1/Cargo.toml +0 -95
- data/ext/cargo-vendor/magnus-0.7.1/build.rs +0 -5
- data/ext/cargo-vendor/magnus-0.7.1/examples/mut_point.rs +0 -60
- data/ext/cargo-vendor/magnus-0.7.1/src/time.rs +0 -190
- data/ext/cargo-vendor/magnus-0.7.1/tests/hash.rs +0 -25
- data/ext/cargo-vendor/magnus-0.7.1/tests/string.rs +0 -13
- data/ext/cargo-vendor/magnus-macros-0.6.0/.cargo-checksum.json +0 -1
- data/ext/cargo-vendor/magnus-macros-0.6.0/.cargo_vcs_info.json +0 -6
- data/ext/cargo-vendor/magnus-macros-0.6.0/src/lib.rs +0 -401
- data/ext/cargo-vendor/rb-sys-env-0.1.2/.cargo-checksum.json +0 -1
- data/ext/cargo-vendor/rb-sys-env-0.1.2/.cargo_vcs_info.json +0 -6
- data/ext/cargo-vendor/rb-sys-env-0.1.2/Cargo.toml +0 -25
- data/ext/cargo-vendor/rb-sys-env-0.1.2/Cargo.toml.orig +0 -14
- data/ext/cargo-vendor/rb-sys-env-0.1.2/LICENSE-APACHE +0 -190
- data/ext/cargo-vendor/rb-sys-env-0.1.2/LICENSE-MIT +0 -21
- data/ext/cargo-vendor/rb-sys-env-0.1.2/readme.md +0 -119
- data/ext/cargo-vendor/rb-sys-env-0.1.2/src/defines.rs +0 -37
- data/ext/cargo-vendor/rb-sys-env-0.1.2/src/lib.rs +0 -180
- data/ext/cargo-vendor/rb-sys-env-0.1.2/src/rb_env.rs +0 -110
- data/ext/cargo-vendor/rb-sys-env-0.1.2/src/ruby_version.rs +0 -163
- data/ext/cargo-vendor/rb-sys-env-0.1.2/src/utils.rs +0 -6
- data/ext/cargo-vendor/serde_magnus-0.9.0/.cargo-checksum.json +0 -1
- data/ext/cargo-vendor/serde_magnus-0.9.0/.cargo_vcs_info.json +0 -6
- data/ext/cargo-vendor/serde_magnus-0.9.0/src/de/enum_deserializer.rs +0 -30
- data/ext/cargo-vendor/serde_magnus-0.9.0/src/ser/enums.rs +0 -11
- data/ext/cargo-vendor/serde_magnus-0.9.0/src/ser/struct_serializer.rs +0 -36
- data/ext/cargo-vendor/serde_magnus-0.9.0/src/ser/struct_variant_serializer.rs +0 -37
- data/ext/cargo-vendor/serde_magnus-0.9.0/src/ser/tuple_variant_serializer.rs +0 -33
- data/ext/cargo-vendor/serde_magnus-0.9.0/tests/deserializing_booleans.rs +0 -18
- data/ext/cargo-vendor/serde_magnus-0.9.0/tests/deserializing_enums.rs +0 -39
- data/ext/cargo-vendor/serde_magnus-0.9.0/tests/deserializing_floats.rs +0 -12
- data/ext/cargo-vendor/serde_magnus-0.9.0/tests/deserializing_integers.rs +0 -18
- data/ext/cargo-vendor/serde_magnus-0.9.0/tests/deserializing_options.rs +0 -15
- data/ext/cargo-vendor/serde_magnus-0.9.0/tests/deserializing_results.rs +0 -17
- data/ext/cargo-vendor/serde_magnus-0.9.0/tests/deserializing_tuples.rs +0 -31
- data/ext/cargo-vendor/serde_magnus-0.9.0/tests/serializing_booleans.rs +0 -15
- data/ext/cargo-vendor/serde_magnus-0.9.0/tests/serializing_strings.rs +0 -30
- data/ext/cargo-vendor/serde_magnus-0.9.0/tests/serializing_tuples.rs +0 -27
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/.cargo/config.toml +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/Gemfile +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/LICENSE +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/examples/complete_object/Rakefile +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/examples/complete_object/lib/temperature.rb +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/examples/custom_exception_ruby/Rakefile +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/examples/custom_exception_ruby/lib/ahriman/error.rb +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/examples/custom_exception_ruby/lib/ahriman.rb +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/examples/custom_exception_ruby/test/error_test.rb +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/examples/custom_exception_rust/Rakefile +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/examples/custom_exception_rust/lib/ahriman.rb +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/examples/custom_exception_rust/test/error_test.rb +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/examples/fibonacci.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/examples/hello_world.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/examples/point.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/examples/rust_blank/Rakefile +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/examples/rust_blank/lib/rust_blank.rb +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/examples/rust_blank/test/bench.rb +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/examples/rust_blank/test/blank_test.rb +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/block.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/embed.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/enumerator.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/exception.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/float.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/into_value.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/numeric.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/object.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/process.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/r_complex.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/r_file.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/r_float.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/r_match.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/r_object.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/r_rational.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/r_regexp.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/r_struct.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/range.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/src/symbol.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/allocate_before_init.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/array_slice.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/block_call.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/bytes.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/call_proc.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/classname.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/clone.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/codepoints.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/debug_exception.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/encoding_capable.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/enumerator.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/enumeratorize.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/float_convert_from_value.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/float_convert_to_value.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/fmt.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/freeze.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/integer_convert_to_value.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/integer_traits.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/ivar.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/lazy_id.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/make_proc.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/proc_new.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/range.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/return_custom_error.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/scan_args.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/str.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/struct.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/symbol.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/try_convert_array.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/tuple_to_array.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/typed_data.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/typed_data_obj.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/typed_data_subclass.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/typed_data_subclass_from_ruby.rs +0 -0
- /data/ext/cargo-vendor/{magnus-0.7.1 → magnus-0.8.2}/tests/yield.rs +0 -0
- /data/ext/cargo-vendor/{magnus-macros-0.6.0 → magnus-macros-0.8.0}/LICENSE +0 -0
- /data/ext/cargo-vendor/{magnus-macros-0.6.0 → magnus-macros-0.8.0}/src/init.rs +0 -0
- /data/ext/cargo-vendor/{serde_magnus-0.9.0 → serde_magnus-0.10.0}/LICENSE +0 -0
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
|
|
2
|
+
#
|
|
3
|
+
# When uploading crates to the registry Cargo will automatically
|
|
4
|
+
# "normalize" Cargo.toml files for maximal compatibility
|
|
5
|
+
# with all versions of Cargo and also rewrite `path` dependencies
|
|
6
|
+
# to registry (e.g., crates.io) dependencies.
|
|
7
|
+
#
|
|
8
|
+
# If you are reading this file be aware that the original Cargo.toml
|
|
9
|
+
# will likely look very different (and much more reasonable).
|
|
10
|
+
# See Cargo.toml.orig for the original contents.
|
|
11
|
+
|
|
12
|
+
[package]
|
|
13
|
+
edition = "2021"
|
|
14
|
+
name = "magnus"
|
|
15
|
+
version = "0.8.2"
|
|
16
|
+
build = "build.rs"
|
|
17
|
+
exclude = [
|
|
18
|
+
".github",
|
|
19
|
+
".gitignore",
|
|
20
|
+
]
|
|
21
|
+
autolib = false
|
|
22
|
+
autobins = false
|
|
23
|
+
autoexamples = false
|
|
24
|
+
autotests = false
|
|
25
|
+
autobenches = false
|
|
26
|
+
description = "High level Ruby bindings. Write Ruby extension gems in Rust, or call Ruby code from a Rust binary."
|
|
27
|
+
homepage = "https://github.com/matsadler/magnus"
|
|
28
|
+
documentation = "https://docs.rs/magnus/"
|
|
29
|
+
readme = "README.md"
|
|
30
|
+
keywords = [
|
|
31
|
+
"ruby",
|
|
32
|
+
"rubygem",
|
|
33
|
+
"extension",
|
|
34
|
+
"gem",
|
|
35
|
+
]
|
|
36
|
+
categories = [
|
|
37
|
+
"api-bindings",
|
|
38
|
+
"development-tools::ffi",
|
|
39
|
+
]
|
|
40
|
+
license = "MIT"
|
|
41
|
+
repository = "https://github.com/matsadler/magnus"
|
|
42
|
+
|
|
43
|
+
[package.metadata.docs.rs]
|
|
44
|
+
all-features = true
|
|
45
|
+
rustdoc-args = [
|
|
46
|
+
"--cfg",
|
|
47
|
+
"docsrs",
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
[features]
|
|
51
|
+
bytes = ["dep:bytes"]
|
|
52
|
+
chrono = ["dep:chrono"]
|
|
53
|
+
default = ["io"]
|
|
54
|
+
embed = ["rb-sys/link-ruby"]
|
|
55
|
+
io = []
|
|
56
|
+
old-api = []
|
|
57
|
+
rb-sys = []
|
|
58
|
+
|
|
59
|
+
[lib]
|
|
60
|
+
name = "magnus"
|
|
61
|
+
path = "src/lib.rs"
|
|
62
|
+
doc-scrape-examples = false
|
|
63
|
+
|
|
64
|
+
[[example]]
|
|
65
|
+
name = "fibonacci"
|
|
66
|
+
path = "examples/fibonacci.rs"
|
|
67
|
+
doc-scrape-examples = false
|
|
68
|
+
|
|
69
|
+
[[example]]
|
|
70
|
+
name = "hello_world"
|
|
71
|
+
path = "examples/hello_world.rs"
|
|
72
|
+
doc-scrape-examples = false
|
|
73
|
+
|
|
74
|
+
[[example]]
|
|
75
|
+
name = "inheritance"
|
|
76
|
+
path = "examples/inheritance.rs"
|
|
77
|
+
|
|
78
|
+
[[example]]
|
|
79
|
+
name = "mut_point"
|
|
80
|
+
path = "examples/mut_point.rs"
|
|
81
|
+
doc-scrape-examples = false
|
|
82
|
+
|
|
83
|
+
[[example]]
|
|
84
|
+
name = "point"
|
|
85
|
+
path = "examples/point.rs"
|
|
86
|
+
doc-scrape-examples = false
|
|
87
|
+
|
|
88
|
+
[[test]]
|
|
89
|
+
name = "allocate_before_init"
|
|
90
|
+
path = "tests/allocate_before_init.rs"
|
|
91
|
+
|
|
92
|
+
[[test]]
|
|
93
|
+
name = "array_slice"
|
|
94
|
+
path = "tests/array_slice.rs"
|
|
95
|
+
|
|
96
|
+
[[test]]
|
|
97
|
+
name = "block_call"
|
|
98
|
+
path = "tests/block_call.rs"
|
|
99
|
+
|
|
100
|
+
[[test]]
|
|
101
|
+
name = "bytes"
|
|
102
|
+
path = "tests/bytes.rs"
|
|
103
|
+
|
|
104
|
+
[[test]]
|
|
105
|
+
name = "call_proc"
|
|
106
|
+
path = "tests/call_proc.rs"
|
|
107
|
+
|
|
108
|
+
[[test]]
|
|
109
|
+
name = "classname"
|
|
110
|
+
path = "tests/classname.rs"
|
|
111
|
+
|
|
112
|
+
[[test]]
|
|
113
|
+
name = "clone"
|
|
114
|
+
path = "tests/clone.rs"
|
|
115
|
+
|
|
116
|
+
[[test]]
|
|
117
|
+
name = "codepoints"
|
|
118
|
+
path = "tests/codepoints.rs"
|
|
119
|
+
|
|
120
|
+
[[test]]
|
|
121
|
+
name = "debug_exception"
|
|
122
|
+
path = "tests/debug_exception.rs"
|
|
123
|
+
|
|
124
|
+
[[test]]
|
|
125
|
+
name = "encoding_capable"
|
|
126
|
+
path = "tests/encoding_capable.rs"
|
|
127
|
+
|
|
128
|
+
[[test]]
|
|
129
|
+
name = "enumerator"
|
|
130
|
+
path = "tests/enumerator.rs"
|
|
131
|
+
|
|
132
|
+
[[test]]
|
|
133
|
+
name = "enumeratorize"
|
|
134
|
+
path = "tests/enumeratorize.rs"
|
|
135
|
+
|
|
136
|
+
[[test]]
|
|
137
|
+
name = "float_convert_from_value"
|
|
138
|
+
path = "tests/float_convert_from_value.rs"
|
|
139
|
+
|
|
140
|
+
[[test]]
|
|
141
|
+
name = "float_convert_to_value"
|
|
142
|
+
path = "tests/float_convert_to_value.rs"
|
|
143
|
+
|
|
144
|
+
[[test]]
|
|
145
|
+
name = "fmt"
|
|
146
|
+
path = "tests/fmt.rs"
|
|
147
|
+
|
|
148
|
+
[[test]]
|
|
149
|
+
name = "freeze"
|
|
150
|
+
path = "tests/freeze.rs"
|
|
151
|
+
|
|
152
|
+
[[test]]
|
|
153
|
+
name = "hash"
|
|
154
|
+
path = "tests/hash.rs"
|
|
155
|
+
|
|
156
|
+
[[test]]
|
|
157
|
+
name = "integer_convert_to_value"
|
|
158
|
+
path = "tests/integer_convert_to_value.rs"
|
|
159
|
+
|
|
160
|
+
[[test]]
|
|
161
|
+
name = "integer_traits"
|
|
162
|
+
path = "tests/integer_traits.rs"
|
|
163
|
+
|
|
164
|
+
[[test]]
|
|
165
|
+
name = "io"
|
|
166
|
+
path = "tests/io.rs"
|
|
167
|
+
|
|
168
|
+
[[test]]
|
|
169
|
+
name = "ivar"
|
|
170
|
+
path = "tests/ivar.rs"
|
|
171
|
+
|
|
172
|
+
[[test]]
|
|
173
|
+
name = "lazy_id"
|
|
174
|
+
path = "tests/lazy_id.rs"
|
|
175
|
+
|
|
176
|
+
[[test]]
|
|
177
|
+
name = "make_proc"
|
|
178
|
+
path = "tests/make_proc.rs"
|
|
179
|
+
|
|
180
|
+
[[test]]
|
|
181
|
+
name = "proc_new"
|
|
182
|
+
path = "tests/proc_new.rs"
|
|
183
|
+
|
|
184
|
+
[[test]]
|
|
185
|
+
name = "range"
|
|
186
|
+
path = "tests/range.rs"
|
|
187
|
+
|
|
188
|
+
[[test]]
|
|
189
|
+
name = "return_custom_error"
|
|
190
|
+
path = "tests/return_custom_error.rs"
|
|
191
|
+
|
|
192
|
+
[[test]]
|
|
193
|
+
name = "return_iter"
|
|
194
|
+
path = "tests/return_iter.rs"
|
|
195
|
+
|
|
196
|
+
[[test]]
|
|
197
|
+
name = "scan_args"
|
|
198
|
+
path = "tests/scan_args.rs"
|
|
199
|
+
|
|
200
|
+
[[test]]
|
|
201
|
+
name = "str"
|
|
202
|
+
path = "tests/str.rs"
|
|
203
|
+
|
|
204
|
+
[[test]]
|
|
205
|
+
name = "string"
|
|
206
|
+
path = "tests/string.rs"
|
|
207
|
+
|
|
208
|
+
[[test]]
|
|
209
|
+
name = "struct"
|
|
210
|
+
path = "tests/struct.rs"
|
|
211
|
+
|
|
212
|
+
[[test]]
|
|
213
|
+
name = "symbol"
|
|
214
|
+
path = "tests/symbol.rs"
|
|
215
|
+
|
|
216
|
+
[[test]]
|
|
217
|
+
name = "time"
|
|
218
|
+
path = "tests/time.rs"
|
|
219
|
+
|
|
220
|
+
[[test]]
|
|
221
|
+
name = "try_convert_array"
|
|
222
|
+
path = "tests/try_convert_array.rs"
|
|
223
|
+
|
|
224
|
+
[[test]]
|
|
225
|
+
name = "tuple_to_array"
|
|
226
|
+
path = "tests/tuple_to_array.rs"
|
|
227
|
+
|
|
228
|
+
[[test]]
|
|
229
|
+
name = "typed_data"
|
|
230
|
+
path = "tests/typed_data.rs"
|
|
231
|
+
|
|
232
|
+
[[test]]
|
|
233
|
+
name = "typed_data_obj"
|
|
234
|
+
path = "tests/typed_data_obj.rs"
|
|
235
|
+
|
|
236
|
+
[[test]]
|
|
237
|
+
name = "typed_data_subclass"
|
|
238
|
+
path = "tests/typed_data_subclass.rs"
|
|
239
|
+
|
|
240
|
+
[[test]]
|
|
241
|
+
name = "typed_data_subclass_from_ruby"
|
|
242
|
+
path = "tests/typed_data_subclass_from_ruby.rs"
|
|
243
|
+
|
|
244
|
+
[[test]]
|
|
245
|
+
name = "yield"
|
|
246
|
+
path = "tests/yield.rs"
|
|
247
|
+
|
|
248
|
+
[dependencies.bytes]
|
|
249
|
+
version = "1"
|
|
250
|
+
optional = true
|
|
251
|
+
|
|
252
|
+
[dependencies.chrono]
|
|
253
|
+
version = "0.4.38"
|
|
254
|
+
optional = true
|
|
255
|
+
|
|
256
|
+
[dependencies.magnus-macros]
|
|
257
|
+
version = "0.8.0"
|
|
258
|
+
|
|
259
|
+
[dependencies.rb-sys]
|
|
260
|
+
version = ">=0.9.113"
|
|
261
|
+
features = [
|
|
262
|
+
"bindgen-rbimpls",
|
|
263
|
+
"bindgen-deprecated-types",
|
|
264
|
+
"stable-api",
|
|
265
|
+
]
|
|
266
|
+
default-features = false
|
|
267
|
+
|
|
268
|
+
[dependencies.seq-macro]
|
|
269
|
+
version = "0.3"
|
|
270
|
+
|
|
271
|
+
[dev-dependencies.rb-sys]
|
|
272
|
+
version = "0.9.113"
|
|
273
|
+
features = ["stable-api-compiled-fallback"]
|
|
274
|
+
default-features = false
|
|
275
|
+
|
|
276
|
+
[build-dependencies.rb-sys-env]
|
|
277
|
+
version = "0.2.2"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "magnus"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.8.2"
|
|
4
4
|
edition = "2021"
|
|
5
5
|
description = "High level Ruby bindings. Write Ruby extension gems in Rust, or call Ruby code from a Rust binary."
|
|
6
6
|
keywords = ["ruby", "rubygem", "extension", "gem"]
|
|
@@ -21,16 +21,19 @@ exclude = [
|
|
|
21
21
|
]
|
|
22
22
|
|
|
23
23
|
[features]
|
|
24
|
-
default = ["
|
|
24
|
+
default = ["io"]
|
|
25
25
|
bytes = ["dep:bytes"]
|
|
26
|
+
chrono = ["dep:chrono"]
|
|
26
27
|
embed = ["rb-sys/link-ruby"]
|
|
27
28
|
old-api = []
|
|
28
29
|
rb-sys = []
|
|
30
|
+
io = []
|
|
29
31
|
|
|
30
32
|
[dependencies]
|
|
31
33
|
bytes = { version = "1", optional = true }
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
chrono = { version = "0.4.38", optional = true }
|
|
35
|
+
magnus-macros = { version = "0.8.0", path = "magnus-macros" }
|
|
36
|
+
rb-sys = { version = ">=0.9.113", default-features = false, features = [
|
|
34
37
|
"bindgen-rbimpls",
|
|
35
38
|
"bindgen-deprecated-types",
|
|
36
39
|
"stable-api",
|
|
@@ -42,13 +45,15 @@ magnus = { path = ".", default-features = false, features = [
|
|
|
42
45
|
"embed",
|
|
43
46
|
"rb-sys",
|
|
44
47
|
"bytes",
|
|
48
|
+
"chrono",
|
|
49
|
+
"io",
|
|
45
50
|
] }
|
|
46
|
-
rb-sys = { version = "0.9", default-features = false, features = [
|
|
51
|
+
rb-sys = { version = "0.9.113", default-features = false, features = [
|
|
47
52
|
"stable-api-compiled-fallback",
|
|
48
53
|
] }
|
|
49
54
|
|
|
50
55
|
[build-dependencies]
|
|
51
|
-
rb-sys-env = "0.
|
|
56
|
+
rb-sys-env = "0.2.2"
|
|
52
57
|
|
|
53
58
|
[lib]
|
|
54
59
|
doc-scrape-examples = false
|
|
@@ -82,13 +82,24 @@ make sure the return type is `magnus::Value`.
|
|
|
82
82
|
|
|
83
83
|
### Wrapping Rust Types in Ruby Objects
|
|
84
84
|
|
|
85
|
-
Rust structs and enums
|
|
86
|
-
to Ruby.
|
|
85
|
+
Magnus allows you to wrap Rust structs and enums as Ruby objects, enabling seamless interaction between Rust and Ruby. This functionality is ideal for exposing Rust logic to Ruby modules.
|
|
87
86
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
87
|
+
Use one of the following approaches to expose a Rust type to Ruby:
|
|
88
|
+
|
|
89
|
+
* A convenience macro [`#[magnus::wrap]`][magnus-wrap].
|
|
90
|
+
* More customised approach by implementing the [`magnus::TypedData`] trait.
|
|
91
|
+
|
|
92
|
+
[magnus-wrap]: https://docs.rs/magnus/latest/magnus/attr.wrap.html
|
|
93
|
+
[`magnus::TypedData`]: https://docs.rs/magnus/latest/magnus/derive.TypedData.html
|
|
94
|
+
|
|
95
|
+
Then this Rust type can be:
|
|
96
|
+
|
|
97
|
+
* Returned to Ruby as a wrapped object.
|
|
98
|
+
* Passed back to Rust and automatically unwrapped to a native Rust reference.
|
|
99
|
+
|
|
100
|
+
#### Basic Usage
|
|
101
|
+
|
|
102
|
+
Here’s how you can wrap a simple Rust struct and expose its methods to Ruby:
|
|
92
103
|
|
|
93
104
|
```rust
|
|
94
105
|
use magnus::{function, method, prelude::*, Error, Ruby};
|
|
@@ -128,16 +139,20 @@ fn init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
128
139
|
}
|
|
129
140
|
```
|
|
130
141
|
|
|
131
|
-
|
|
142
|
+
#### Handling Mutability
|
|
143
|
+
|
|
144
|
+
Because Ruby's GC manages the memory where your Rust type is stored, Magnus can't bind functions with mutable references. To allow mutable fields in wrapped Rust structs, you can use the newtype pattern with `RefCell`:
|
|
132
145
|
|
|
133
146
|
```rust
|
|
147
|
+
use std::cell::RefCell;
|
|
148
|
+
|
|
134
149
|
struct Point {
|
|
135
150
|
x: isize,
|
|
136
151
|
y: isize,
|
|
137
152
|
}
|
|
138
153
|
|
|
139
154
|
#[magnus::wrap(class = "Point")]
|
|
140
|
-
struct MutPoint(
|
|
155
|
+
struct MutPoint(RefCell<Point>);
|
|
141
156
|
|
|
142
157
|
impl MutPoint {
|
|
143
158
|
fn set_x(&self, i: isize) {
|
|
@@ -146,8 +161,17 @@ impl MutPoint {
|
|
|
146
161
|
}
|
|
147
162
|
```
|
|
148
163
|
|
|
149
|
-
|
|
150
|
-
|
|
164
|
+
See [`examples/mut_point.rs`] for the complete example.
|
|
165
|
+
|
|
166
|
+
[`examples/mut_point.rs`]: https://github.com/matsadler/magnus/blob/main/examples/mut_point.rs
|
|
167
|
+
|
|
168
|
+
#### Supporting Subclassing
|
|
169
|
+
|
|
170
|
+
To enable Ruby subclassing for wrapped Rust types, the type must:
|
|
171
|
+
|
|
172
|
+
* Implement the `Default` trait.
|
|
173
|
+
* Define an allocator.
|
|
174
|
+
* Define an initialiser.
|
|
151
175
|
|
|
152
176
|
``` rust
|
|
153
177
|
#[derive(Default)]
|
|
@@ -177,6 +201,26 @@ fn init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
177
201
|
}
|
|
178
202
|
```
|
|
179
203
|
|
|
204
|
+
#### Error Handling
|
|
205
|
+
|
|
206
|
+
Use `magnus::Error` to propagate errors to Ruby from Rust:
|
|
207
|
+
|
|
208
|
+
```rust
|
|
209
|
+
#[magnus::wrap(class = "Point")]
|
|
210
|
+
struct MutPoint(RefCell<Point>);
|
|
211
|
+
|
|
212
|
+
impl MutPoint {
|
|
213
|
+
fn add_x(ruby: &Ruby, rb_self: &Self, val: isize) -> Result<isize, Error> {
|
|
214
|
+
if let Some(sum) = rb_self.0.borrow().x.checked_add(val) {
|
|
215
|
+
rb_self.0.borrow_mut().x = sum;
|
|
216
|
+
Ok(sum)
|
|
217
|
+
} else {
|
|
218
|
+
return Err(Error::new(ruby.exception_range_error(), "result out of range"));
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
180
224
|
## Getting Started
|
|
181
225
|
|
|
182
226
|
### Writing an extension gem (calling Rust from Ruby)
|
|
@@ -191,7 +235,7 @@ setting the `crate-type` attribute in your `Cargo.toml`.
|
|
|
191
235
|
crate-type = ["cdylib"]
|
|
192
236
|
|
|
193
237
|
[dependencies]
|
|
194
|
-
magnus = "0.
|
|
238
|
+
magnus = "0.8"
|
|
195
239
|
```
|
|
196
240
|
|
|
197
241
|
When Ruby loads your extension it calls an 'init' function defined in your
|
|
@@ -246,7 +290,7 @@ require "rb_sys/mkmf"
|
|
|
246
290
|
create_rust_makefile("my_example_gem/my_example_gem")
|
|
247
291
|
```
|
|
248
292
|
|
|
249
|
-
See the [`rust_blank`] example for examples
|
|
293
|
+
See the [`rust_blank`] example for examples of `extconf.rb` and `Rakefile`.
|
|
250
294
|
Running `rake compile` will place the extension at
|
|
251
295
|
`lib/my_example_gem/my_example_gem.so` (or `.bundle` on macOS), which you'd
|
|
252
296
|
load from Ruby like so:
|
|
@@ -274,7 +318,7 @@ To call Ruby from a Rust program, enable the `embed` feature:
|
|
|
274
318
|
|
|
275
319
|
```toml
|
|
276
320
|
[dependencies]
|
|
277
|
-
magnus = { version = "0.
|
|
321
|
+
magnus = { version = "0.8", features = ["embed"] }
|
|
278
322
|
```
|
|
279
323
|
|
|
280
324
|
This enables linking to Ruby and gives access to the `embed` module.
|
|
@@ -319,7 +363,7 @@ See `magnus::TryConvert` for more details.
|
|
|
319
363
|
| `i8`,`i16`,`i32`,`i64`,`isize`, `magnus::Integer` | `Integer`, `#to_int` |
|
|
320
364
|
| `u8`,`u16`,`u32`,`u64`,`usize` | `Integer`, `#to_int` |
|
|
321
365
|
| `f32`,`f64`, `magnus::Float` | `Float`, `Numeric` |
|
|
322
|
-
| `String`, `PathBuf`, `char`, `magnus::RString`, `bytes::Bytes
|
|
366
|
+
| `String`, `PathBuf`, `char`, `magnus::RString`, `bytes::Bytes`‡ | `String`, `#to_str` |
|
|
323
367
|
| `magnus::Symbol` | `Symbol`, `#to_sym` |
|
|
324
368
|
| `bool` | any object |
|
|
325
369
|
| `magnus::Range` | `Range` |
|
|
@@ -329,17 +373,19 @@ See `magnus::TryConvert` for more details.
|
|
|
329
373
|
| `[T; N]` | `[T]`, `#to_ary` |
|
|
330
374
|
| `magnus::RArray` | `Array`, `#to_ary` |
|
|
331
375
|
| `magnus::RHash` | `Hash`, `#to_hash` |
|
|
332
|
-
| `std::time::SystemTime`, `magnus::Time`
|
|
376
|
+
| `std::time::SystemTime`, `magnus::Time`, `chrono::DateTime<T>`§ | `Time` |
|
|
333
377
|
| `magnus::Value` | any object |
|
|
334
378
|
| `Vec<T>`\* | `[T]`, `#to_ary` |
|
|
335
379
|
| `HashMap<K, V>`\* | `{K => V}`, `#to_hash` |
|
|
336
|
-
| `&T`, `typed_data::Obj<T>` where `T: TypedData
|
|
380
|
+
| `&T`, `typed_data::Obj<T>` where `T: TypedData`† | instance of `<T as TypedData>::class()` |
|
|
337
381
|
|
|
338
382
|
\* when converting to `Vec` and `HashMap` the types of `T`/`K`,`V` must be native Rust types.
|
|
339
383
|
|
|
340
|
-
|
|
384
|
+
† see the `wrap` macro.
|
|
385
|
+
|
|
386
|
+
‡ when the `bytes` feature is enabled
|
|
341
387
|
|
|
342
|
-
|
|
388
|
+
§ when the `chrono` feature is enabled; `T` can be `Utc` or `FixedOffset`.
|
|
343
389
|
|
|
344
390
|
### Rust returning / passing values to Ruby
|
|
345
391
|
|
|
@@ -360,9 +406,9 @@ and `magnus::ArgList` for some additional details.
|
|
|
360
406
|
| `(T, U)`, `(T, U, V)`, etc, `[T; N]`, `Vec<T>` | `Array` |
|
|
361
407
|
| `HashMap<K, V>` | `Hash` |
|
|
362
408
|
| `std::time::SystemTime` | `Time` |
|
|
363
|
-
| `T`, `typed_data::Obj<T>` where `T: TypedData
|
|
409
|
+
| `T`, `typed_data::Obj<T>` where `T: TypedData`\* | instance of `<T as TypedData>::class()` |
|
|
364
410
|
|
|
365
|
-
|
|
411
|
+
\* see the `wrap` macro.
|
|
366
412
|
|
|
367
413
|
### Conversions via Serde
|
|
368
414
|
|
|
@@ -432,7 +478,7 @@ use `unsafe`.
|
|
|
432
478
|
|
|
433
479
|
## Compatibility
|
|
434
480
|
|
|
435
|
-
Ruby versions 3.0, 3.1, 3.2, and 3.
|
|
481
|
+
Ruby versions 3.0, 3.1, 3.2, 3.3 and 3.4 are fully supported.
|
|
436
482
|
|
|
437
483
|
Magnus currently works with, and is still tested against, Ruby 2.7, but as this
|
|
438
484
|
version of the language is no longer supported by the Ruby developers it is not
|
|
@@ -441,7 +487,7 @@ recommended and future support in Magnus is not guaranteed.
|
|
|
441
487
|
Ruby bindings will be generated at compile time, this may require libclang to
|
|
442
488
|
be installed.
|
|
443
489
|
|
|
444
|
-
The
|
|
490
|
+
The minimum supported Rust version is currently Rust 1.65.
|
|
445
491
|
|
|
446
492
|
Support for statically linking Ruby is provided via the lower-level [rb-sys]
|
|
447
493
|
crate, and can be enabled by adding the following to your `Cargo.toml`:
|
|
@@ -479,6 +525,10 @@ deserialisation of Rust to Ruby data structures and vice versa.
|
|
|
479
525
|
|
|
480
526
|
* [`halton`](https://github.com/matsadler/halton-rb) a Ruby gem providing a
|
|
481
527
|
highly optimised method for generating Halton sequences.
|
|
528
|
+
* [`optify`](https://github.com/juharris/optify) a Ruby gem to
|
|
529
|
+
simplify using configuration files to manage options for experiments.
|
|
530
|
+
It has a GitHub action to publish the gem for different architectures to RubyGems
|
|
531
|
+
with a RBI file for type hints.
|
|
482
532
|
|
|
483
533
|
Please open a [pull request](https://github.com/matsadler/magnus/pulls) if
|
|
484
534
|
you'd like your project listed here.
|
|
@@ -512,4 +562,6 @@ library turns out better for you.
|
|
|
512
562
|
|
|
513
563
|
## License
|
|
514
564
|
|
|
515
|
-
This project is licensed under the MIT license, see LICENSE.
|
|
565
|
+
This project is licensed under the MIT license, see [LICENSE].
|
|
566
|
+
|
|
567
|
+
[LICENSE]: https://github.com/matsadler/magnus/blob/main/LICENSE
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
2
|
+
// add these here to silence warnings until rb_sys_env is updated
|
|
3
|
+
println!("cargo:rustc-check-cfg=cfg(ruby_use_flonum)");
|
|
4
|
+
println!("cargo:rustc-check-cfg=cfg(ruby_lt_3_0)");
|
|
5
|
+
println!("cargo:rustc-check-cfg=cfg(ruby_gte_3_0)");
|
|
6
|
+
println!("cargo:rustc-check-cfg=cfg(ruby_gte_3_1)");
|
|
7
|
+
println!("cargo:rustc-check-cfg=cfg(ruby_lt_3_2)");
|
|
8
|
+
println!("cargo:rustc-check-cfg=cfg(ruby_gte_3_2)");
|
|
9
|
+
println!("cargo:rustc-check-cfg=cfg(ruby_lt_3_3)");
|
|
10
|
+
println!("cargo:rustc-check-cfg=cfg(ruby_gte_3_3)");
|
|
11
|
+
|
|
12
|
+
let _ = rb_sys_env::activate()?;
|
|
13
|
+
|
|
14
|
+
Ok(())
|
|
15
|
+
}
|
|
@@ -31,14 +31,14 @@ class TemperatureTest < Test::Unit::TestCase
|
|
|
31
31
|
|
|
32
32
|
def test_dup
|
|
33
33
|
temp = Temperature.new(celsius: 19.5)
|
|
34
|
-
def temp.
|
|
34
|
+
def temp.singleton_method_example
|
|
35
35
|
end
|
|
36
36
|
copy = temp.dup
|
|
37
37
|
|
|
38
38
|
assert { temp.object_id != copy.object_id }
|
|
39
39
|
assert { temp == copy }
|
|
40
40
|
assert { !copy.frozen? }
|
|
41
|
-
assert { !copy.respond_to?(:
|
|
41
|
+
assert { !copy.respond_to?(:singleton_method_example)}
|
|
42
42
|
|
|
43
43
|
temp2 = Temperature.new(celsius: 19.5)
|
|
44
44
|
temp2.freeze
|
|
@@ -48,14 +48,14 @@ class TemperatureTest < Test::Unit::TestCase
|
|
|
48
48
|
|
|
49
49
|
def test_clone
|
|
50
50
|
temp = Temperature.new(celsius: 19.5)
|
|
51
|
-
def temp.
|
|
51
|
+
def temp.singleton_method_example
|
|
52
52
|
end
|
|
53
53
|
copy = temp.clone
|
|
54
54
|
|
|
55
55
|
assert { temp.object_id != copy.object_id }
|
|
56
56
|
assert { temp == copy }
|
|
57
57
|
assert { !copy.frozen? }
|
|
58
|
-
assert { copy.respond_to?(:
|
|
58
|
+
assert { copy.respond_to?(:singleton_method_example)}
|
|
59
59
|
|
|
60
60
|
temp2 = Temperature.new(celsius: 19.5)
|
|
61
61
|
temp2.freeze
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
use magnus::{function, method, prelude::*};
|
|
2
|
+
|
|
3
|
+
/// Building on top of `wrap`, we can rely on Rust's enum to dispatch based on enum variants.
|
|
4
|
+
/// Magnus will transform the types between Ruby and Rust.
|
|
5
|
+
#[magnus::wrap(class = "Shape")]
|
|
6
|
+
enum Shape {
|
|
7
|
+
#[magnus(class = "Circle")]
|
|
8
|
+
Circle { radius: f64 },
|
|
9
|
+
#[magnus(class = "Rectangle")]
|
|
10
|
+
Rectangle { x: f64, y: f64 },
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
impl Shape {
|
|
14
|
+
fn new_circle(radius: f64) -> Self {
|
|
15
|
+
Self::Circle { radius }
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
fn new_rectangle(x: f64, y: f64) -> Self {
|
|
19
|
+
Self::Rectangle { x, y }
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
fn area(&self) -> f64 {
|
|
23
|
+
match self {
|
|
24
|
+
Shape::Circle { radius } => std::f64::consts::PI * radius * radius,
|
|
25
|
+
Shape::Rectangle { x, y } => x * y,
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
fn print_area(s: &Shape) {
|
|
31
|
+
println!("{}", s.area());
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
fn main() -> Result<(), String> {
|
|
35
|
+
// Normal Rust code
|
|
36
|
+
let a = Shape::Circle { radius: 10.0 };
|
|
37
|
+
let b = Shape::Rectangle { x: 10.0, y: 2.0 };
|
|
38
|
+
print_area(&a);
|
|
39
|
+
print_area(&b);
|
|
40
|
+
|
|
41
|
+
// magnus binding running in Ruby
|
|
42
|
+
magnus::Ruby::init(|ruby| {
|
|
43
|
+
let shape_class = ruby.define_class("Shape", ruby.class_object())?;
|
|
44
|
+
shape_class.undef_default_alloc_func();
|
|
45
|
+
|
|
46
|
+
// inherit from Shape
|
|
47
|
+
let circle_class = ruby.define_class("Circle", shape_class)?;
|
|
48
|
+
circle_class.define_singleton_method("new", function!(Shape::new_circle, 1))?;
|
|
49
|
+
circle_class.define_method("area", method!(Shape::area, 0))?;
|
|
50
|
+
|
|
51
|
+
let rectangle_class = ruby.define_class("Rectangle", shape_class)?;
|
|
52
|
+
rectangle_class.define_singleton_method("new", function!(Shape::new_rectangle, 2))?;
|
|
53
|
+
rectangle_class.define_method("area", method!(Shape::area, 0))?;
|
|
54
|
+
|
|
55
|
+
let d: f64 = ruby.eval(
|
|
56
|
+
"a = Circle.new(10.0)
|
|
57
|
+
b = Rectangle.new(10.0, 2.0)
|
|
58
|
+
difference = a.area - b.area
|
|
59
|
+
puts \"The difference of the area between the circle and the rectangle is #{difference}.\"
|
|
60
|
+
difference",
|
|
61
|
+
)?;
|
|
62
|
+
|
|
63
|
+
println!("{}", d);
|
|
64
|
+
Ok(())
|
|
65
|
+
})
|
|
66
|
+
}
|