Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: replace yaml-rust with yaml-rust2 #555

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 64 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 25 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,27 @@ edition = "2018"
maintenance = { status = "actively-developed" }

[features]
default = ["toml", "json", "yaml", "ini", "ron", "json5", "convert-case", "async"]
default = [
"toml",
"json",
"yaml",
"ini",
"ron",
"json5",
"convert-case",
"async",
]
json = ["serde_json"]
yaml = ["yaml-rust"]
yaml = ["yaml-rust2"]
ini = ["rust-ini"]
json5 = ["json5_rs", "serde/derive"]
convert-case = ["convert_case"]
preserve_order = ["indexmap", "toml?/preserve_order", "serde_json?/preserve_order", "ron?/indexmap"]
preserve_order = [
"indexmap",
"toml?/preserve_order",
"serde_json?/preserve_order",
"ron?/indexmap",
]
async = ["async-trait"]

[dependencies]
Expand All @@ -32,7 +46,7 @@ nom = "7"
async-trait = { version = "0.1", optional = true }
toml = { version = "0.8", optional = true }
serde_json = { version = "1.0", optional = true }
yaml-rust = { version = "0.4", optional = true }
yaml-rust2 = { version = "0.8", optional = true }
rust-ini = { version = "0.20", optional = true }
ron = { version = "0.8", optional = true }
json5_rs = { version = "0.4", optional = true, package = "json5" }
Expand All @@ -44,7 +58,13 @@ pathdiff = "0.2"
serde_derive = "1.0"
float-cmp = "0.9"
chrono = { version = "0.4", features = ["serde"] }
tokio = { version = "1", features = ["rt-multi-thread", "macros", "fs", "io-util", "time"]}
tokio = { version = "1", features = [
"rt-multi-thread",
"macros",
"fs",
"io-util",
"time",
] }
warp = "0.3"
futures = "0.3"
reqwest = "0.11"
Expand Down
32 changes: 15 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@

[12-factor]: https://12factor.net/config

- Set defaults
- Set explicit values (to programmatically override)
- Read from [JSON], [TOML], [YAML], [INI], [RON], [JSON5] files
- Read from environment
- Loosely typed — Configuration values may be read in any supported type, as long as there exists a reasonable conversion
- Access nested fields using a formatted path — Uses a subset of JSONPath; currently supports the child ( `redis.port` ) and subscript operators ( `databases[0].name` )
- Set defaults
- Set explicit values (to programmatically override)
- Read from [JSON], [TOML], [YAML], [INI], [RON], [JSON5] files
- Read from environment
- Loosely typed — Configuration values may be read in any supported type, as long as there exists a reasonable conversion
- Access nested fields using a formatted path — Uses a subset of JSONPath; currently supports the child ( `redis.port` ) and subscript operators ( `databases[0].name` )

[JSON]: https://github.com/serde-rs/json
[TOML]: https://github.com/toml-lang/toml
[YAML]: https://github.com/chyh1990/yaml-rust
[YAML]: https://github.com/Ethiraric/yaml-rust2
[INI]: https://github.com/zonyitoo/rust-ini
[RON]: https://github.com/ron-rs/ron
[JSON5]: https://github.com/callum-oakley/json5-rs

Please note this library

- can not be used to write changed configuration values back to the configuration file(s)!
- Is case insensitive and all the keys are converted to lowercase internally
- can not be used to write changed configuration values back to the configuration file(s)!
- Is case insensitive and all the keys are converted to lowercase internally

## Usage

Expand All @@ -37,12 +37,12 @@ config = "0.14.0"

### Feature flags

- `ini` - Adds support for reading INI files
- `json` - Adds support for reading JSON files
- `yaml` - Adds support for reading YAML files
- `toml` - Adds support for reading TOML files
- `ron` - Adds support for reading RON files
- `json5` - Adds support for reading JSON5 files
- `ini` - Adds support for reading INI files
- `json` - Adds support for reading JSON files
- `yaml` - Adds support for reading YAML files
- `toml` - Adds support for reading TOML files
- `ron` - Adds support for reading RON files
- `json5` - Adds support for reading JSON5 files

### Support for custom formats

Expand All @@ -55,12 +55,10 @@ See [custom_file_format](https://github.com/mehcode/config-rs/tree/master/exampl
See the [documentation](https://docs.rs/config) or [examples](https://github.com/mehcode/config-rs/tree/master/examples) for
more usage information.


## MSRV

We currently support Rust 1.75.0 and newer.


## License

config-rs is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0).
Expand Down
2 changes: 1 addition & 1 deletion src/file/format/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub enum FileFormat {
#[cfg(feature = "json")]
Json,

/// YAML (parsed with yaml_rust)
/// YAML (parsed with yaml_rust2)
#[cfg(feature = "yaml")]
Yaml,

Expand Down
2 changes: 1 addition & 1 deletion src/file/format/yaml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::error::Error;
use std::fmt;
use std::mem;

use yaml_rust as yaml;
use yaml_rust2 as yaml;

use crate::format;
use crate::map::Map;
Expand Down
3 changes: 1 addition & 2 deletions tests/file_yaml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ fn test_error_parse() {
assert_eq!(
res.unwrap_err().to_string(),
format!(
"while parsing a block mapping, did not find expected key at \
line 2 column 1 in {}",
"simple key expect ':' at byte 21 line 3 column 1 in {}",
path_with_extension.display()
)
);
Expand Down
3 changes: 1 addition & 2 deletions tests/legacy/file_yaml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ fn test_error_parse() {
assert_eq!(
res.unwrap_err().to_string(),
format!(
"while parsing a block mapping, did not find expected key at \
line 2 column 1 in {}",
"simple key expect ':' at byte 21 line 3 column 1 in {}",
path_with_extension.display()
)
);
Expand Down