1- //! java-spaghetti.toml configuration file structures and parsing APIs.
1+ //! java-spaghetti.yaml configuration file structures and parsing APIs.
22
33use std:: path:: { Path , PathBuf } ;
44use std:: { fs, io} ;
@@ -135,18 +135,19 @@ pub struct Config {
135135}
136136
137137impl Config {
138- /// Read from I/O, under the assumption that it's in the "java-spaghetti.toml " file format.
139- /// `directory` is the directory that contained the `java-spaghetti.toml ` file, against which paths should be resolved.
138+ /// Read from I/O, under the assumption that it's in the "java-spaghetti.yaml " file format.
139+ /// `directory` is the directory that contained the `java-spaghetti.yaml ` file, against which paths should be resolved.
140140 pub fn read ( file : & mut impl io:: Read , dir : & Path ) -> io:: Result < Self > {
141141 let mut buffer = String :: new ( ) ;
142- file. read_to_string ( & mut buffer) ?; // Apparently toml can't stream.
142+ file. read_to_string ( & mut buffer) ?; // Apparently yaml can't stream.
143143 Self :: read_str ( & buffer[ ..] , dir)
144144 }
145145
146- /// Read from a memory buffer, under the assumption that it's in the "java-spaghetti.toml " file format.
147- /// `directory` is the directory that contained the `java-spaghetti.toml ` file, against which paths should be resolved.
146+ /// Read from a memory buffer, under the assumption that it's in the "java-spaghetti.yaml " file format.
147+ /// `directory` is the directory that contained the `java-spaghetti.yaml ` file, against which paths should be resolved.
148148 pub fn read_str ( buffer : & str , dir : & Path ) -> io:: Result < Self > {
149- let mut config: Config = toml:: from_str ( buffer) . map_err ( |e| io:: Error :: new ( io:: ErrorKind :: InvalidData , e) ) ?;
149+ let mut config: Config =
150+ serde_yaml:: from_str ( buffer) . map_err ( |e| io:: Error :: new ( io:: ErrorKind :: InvalidData , e) ) ?;
150151
151152 if config. rules . is_empty ( ) {
152153 config. rules . push ( Rule {
@@ -165,20 +166,20 @@ impl Config {
165166 Ok ( config)
166167 }
167168
168- /// Search the current directory - or failing that, it's ancestors - until we find "java-spaghetti.toml " or reach the
169+ /// Search the current directory - or failing that, it's ancestors - until we find "java-spaghetti.yaml " or reach the
169170 /// root of the filesystem and cannot continue.
170171 #[ allow( dead_code) ]
171172 pub fn from_current_directory ( ) -> io:: Result < Self > {
172173 Self :: from_directory ( std:: env:: current_dir ( ) ?. as_path ( ) )
173174 }
174175
175- /// Search the specified directory - or failing that, it's ancestors - until we find "java-spaghetti.toml " or reach the
176+ /// Search the specified directory - or failing that, it's ancestors - until we find "java-spaghetti.yaml " or reach the
176177 /// root of the filesystem and cannot continue.
177178 pub fn from_directory ( path : & Path ) -> io:: Result < Self > {
178179 let original = path;
179180 let mut path = path. to_owned ( ) ;
180181 loop {
181- path. push ( "java-spaghetti.toml " ) ;
182+ path. push ( "java-spaghetti.yaml " ) ;
182183 println ! ( "cargo:rerun-if-changed={}" , path. display( ) ) ;
183184 if path. exists ( ) {
184185 return Config :: read ( & mut fs:: File :: open ( & path) ?, path. parent ( ) . unwrap ( ) ) ;
@@ -187,7 +188,7 @@ impl Config {
187188 Err ( io:: Error :: new (
188189 io:: ErrorKind :: NotFound ,
189190 format ! (
190- "Failed to find java-spaghetti.toml in \" {}\" or any of it's parent directories." ,
191+ "Failed to find java-spaghetti.yaml in \" {}\" or any of it's parent directories." ,
191192 original. display( )
192193 ) ,
193194 ) ) ?;
0 commit comments