lib/phut/parser.rb in phut-0.6.2 vs lib/phut/parser.rb in phut-0.6.3

- old
+ new

@@ -4,45 +4,16 @@ module Phut # Configuration DSL parser. class Parser def initialize(logger = NullLogger.new) - @config = Configuration.new(logger) - @port_number = Hash.new(0) + @logger = logger end def parse(file) - Syntax.new(@config).instance_eval IO.read(file), file - connect_links_to_switches - connect_links_to_vhosts - @config - end - - private - - def connect_links_to_switches - @config.links.each do |each| - maybe_assign_network_device_to_vswitch each + Configuration.new(@logger).tap do |configuration| + Syntax.new(configuration).instance_eval IO.read(file), file + configuration.update_connections end - end - - def connect_links_to_vhosts - @config.vhosts.each do |each| - each.network_device = @config.find_network_device_by_name(each.name) - end - end - - def maybe_assign_network_device_to_vswitch(link) - @config.vswitches.each do |each| - switch_name = each.name - network_device = link.find_network_device_by_name(switch_name) - next unless network_device - network_device.port_number = new_port_number(switch_name) - each.network_devices << network_device - end - end - - def new_port_number(switch_name) - @port_number[switch_name] += 1 end end end