Class: DDSL::Parser
- Inherits:
-
Object
- Object
- DDSL::Parser
- Defined in:
- lib/ddsl/parser.rb
Defined Under Namespace
Classes: UnsupportedFileFormatError
Instance Method Summary collapse
-
#parse(file_path) ⇒ Hash
Parse configuration file in given path.
Instance Method Details
#parse(file_path) ⇒ Hash
Parse configuration file in given path
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ddsl/parser.rb', line 18 def parse(file_path) format = File.extname(file_path) parsed_config = case format when '.json' JSON.parse(File.read(file_path)) when '.yml' YAML.load_file(file_path) else raise UnsupportedFileFormatError, "format #{format} is unsupported" end DDSL::SchemaParser.new.parse!(parsed_config) end |