Skip to content

Commit 0f19155

Browse files
committed
Replace serde_yaml with serde_json
`serde_yaml` was deprecated more than a year ago. See https://github.com/dtolnay/serde-yaml Didn't find a nice replacement that is also typed. So why not just convert it to json?
1 parent b7d1879 commit 0f19155

File tree

4 files changed

+15
-38
lines changed

4 files changed

+15
-38
lines changed

rakelib/cargo.rake

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ namespace :cargo do
33

44
desc "Build and test the Rust packages"
55
task build: [:templates] do
6+
require "json"
7+
require "yaml"
8+
69
gemspec = Gem::Specification.load("prism.gemspec")
710

811
prism_sys_dir = Pathname(File.expand_path(File.join(__dir__, "../rust", "ruby-prism-sys")))
@@ -18,7 +21,11 @@ namespace :cargo do
1821

1922
rm_rf(prism_dir.join("vendor"))
2023
mkdir_p(prism_vendor_dir)
21-
cp(File.expand_path("../config.yml", __dir__), prism_vendor_dir.join("config.yml"))
24+
25+
# This used `serde_yaml` previously, which is now deprecated. Convert it to json
26+
# so that `serde_json` can be used instead, keeping it strongly typed.
27+
config_yaml = YAML.load_file(File.expand_path("../config.yml", __dir__))
28+
File.write(prism_vendor_dir.join("config.json"), JSON.dump(config_yaml))
2229

2330
# Align the Cargo.toml version with the gemspec version
2431
CRATES.each do |crate|

rust/Cargo.lock

Lines changed: 4 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/ruby-prism/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ include = ["src/", "build.rs", "Cargo.toml", "Cargo.lock", "vendor"]
2323

2424
[build-dependencies]
2525
serde = { version = "1.0", features = ["derive"] }
26-
serde_yaml = "0.9"
26+
serde_json = "1.0"
2727

2828
[dependencies]
2929
ruby-prism-sys = { version = "1.6.0", path = "../ruby-prism-sys" }

rust/ruby-prism/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,12 @@ struct Config {
117117
///
118118
fn main() -> Result<(), Box<dyn std::error::Error>> {
119119
let prism_dir = format!("prism-{}", env!("CARGO_PKG_VERSION"));
120-
let config_path = Path::new(env!("CARGO_MANIFEST_DIR")).join("vendor").join(prism_dir).join("config.yml");
120+
let config_path = Path::new(env!("CARGO_MANIFEST_DIR")).join("vendor").join(prism_dir).join("config.json");
121121

122122
let config_file = std::fs::File::open(&config_path)?;
123123
println!("cargo:rerun-if-changed={}", config_path.to_str().unwrap());
124124

125-
let config: Config = serde_yaml::from_reader(config_file)?;
125+
let config: Config = serde_json::from_reader(config_file)?;
126126
write_bindings(&config)?;
127127

128128
Ok(())

0 commit comments

Comments
 (0)