Class: Calypso::YAMLParser
Overview
YAML parser library
Instance Attribute Summary
Attributes inherited from IParser
Instance Method Summary collapse
-
#initialize(file) ⇒ YAMLParser
constructor
Create a new YAML parser.
-
#parse ⇒ nil
Parse the configuration file.
Constructor Details
#initialize(file) ⇒ YAMLParser
Create a new YAML parser.
33 34 35 |
# File 'lib/calypso/yamlparser.rb', line 33 def initialize(file) super end |
Instance Method Details
#parse ⇒ nil
Parse the configuration file.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/calypso/yamlparser.rb', line 40 def parse obj = YAML.load_file(@file) hardware = Hash.new tests = Hash.new obj['hardware'].each do |key, value| hw = Calypso::Hardware.new(key, value['name'], value['cpu']) hardware[key] = hw end obj['unit-tests'].each do |key, value| hw = hardware[value['hardware']] port = value['port'] baud = value['baud'] serial = Calypso::SerialPortData.new(port, baud) tst = Calypso::UnitTest.new(value, serial, hw) tests[key] = tst hw.add_test tst end set_hardware(hardware) set_tests(tests) end |