Method: OpenC3::ConfigParser#parse_file
- Defined in:
- lib/openc3/config/config_parser.rb
#parse_file(filename, yield_non_keyword_lines = false, remove_quotes = true, run_erb = true, variables = {}) {|keyword, parameters| ... } ⇒ Object
Processes a file and yields |config| to the given block
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/openc3/config/config_parser.rb', line 197 def parse_file(filename, yield_non_keyword_lines = false, remove_quotes = true, run_erb = true, variables = {}, &) raise Error.new(self, "Configuration file #{filename} does not exist.") unless filename && File.exist?(filename) @filename = filename # Create a temp file where we write the ERB parsed output file = create_parsed_output_file(filename, run_erb, variables) size = file.stat.size.to_f # Callbacks for beginning of parsing @@message_callback.call("Parsing #{size} bytes of #{filename}") if @@message_callback @@progress_callback.call(0.0) if @@progress_callback begin # Loop through each line of the data parse_loop(file, yield_non_keyword_lines, remove_quotes, size, PARSING_REGEX, &) ensure file.close unless file.closed? end end |