Skip to content

Commit

Permalink
fix regexp matchers
Browse files Browse the repository at this point in the history
  • Loading branch information
calavera authored and mitchellh committed Mar 31, 2012
1 parent eb07788 commit 73b31b5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions lib/vagrant/driver/virtualbox_4_0.rb
Expand Up @@ -219,7 +219,7 @@ def read_forwarded_ports(uuid=nil, active_only=false)
end

# Parse out the forwarded port information
if matcher = line =~ /^Forwarding.+?="(.+?),.+?,.*?,(.+?),.*?,(.+?)"$/
if matcher = /^Forwarding.+?="(.+?),.+?,.*?,(.+?),.*?,(.+?)"$/.match(line)
result = [current_nic, matcher[1], matcher[2].to_i, matcher[3].to_i]
@logger.debug(" - #{result.inspect}")
results << result
Expand Down Expand Up @@ -331,19 +331,19 @@ def read_network_interfaces
nics = {}
info = execute("showvminfo", @uuid, "--machinereadable", :retryable => true)
info.split("\n").each do |line|
if matcher = line =~ /^nic(\d+)="(.+?)"$/
if matcher = /^nic(\d+)="(.+?)"$/.match(line)
adapter = matcher[1].to_i
type = matcher[2].to_sym

nics[adapter] ||= {}
nics[adapter][:type] = type
elsif matcher = line =~ /^hostonlyadapter(\d+)="(.+?)"$/
elsif matcher = /^hostonlyadapter(\d+)="(.+?)"$/.match(line)
adapter = matcher[1].to_i
network = matcher[2].to_s

nics[adapter] ||= {}
nics[adapter][:hostonly] = network
elsif matcher = line =~ /^bridgeadapter(\d+)="(.+?)"$/
elsif matcher = /^bridgeadapter(\d+)="(.+?)"$/.match(line)
adapter = matcher[1].to_i
network = matcher[2].to_s

Expand Down
8 changes: 4 additions & 4 deletions lib/vagrant/driver/virtualbox_4_1.rb
Expand Up @@ -219,7 +219,7 @@ def read_forwarded_ports(uuid=nil, active_only=false)
end

# Parse out the forwarded port information
if matcher = line =~ /^Forwarding.+?="(.+?),.+?,.*?,(.+?),.*?,(.+?)"$/
if matcher = /^Forwarding.+?="(.+?),.+?,.*?,(.+?),.*?,(.+?)"$/.match(line)
result = [current_nic, matcher[1], matcher[2].to_i, matcher[3].to_i]
@logger.debug(" - #{result.inspect}")
results << result
Expand Down Expand Up @@ -331,19 +331,19 @@ def read_network_interfaces
nics = {}
info = execute("showvminfo", @uuid, "--machinereadable", :retryable => true)
info.split("\n").each do |line|
if matcher = line =~ /^nic(\d+)="(.+?)"$/
if matcher = /^nic(\d+)="(.+?)"$/.match(line)
adapter = matcher[1].to_i
type = matcher[2].to_sym

nics[adapter] ||= {}
nics[adapter][:type] = type
elsif matcher = line =~ /^hostonlyadapter(\d+)="(.+?)"$/
elsif matcher = /^hostonlyadapter(\d+)="(.+?)"$/.match(line)
adapter = matcher[1].to_i
network = matcher[2].to_s

nics[adapter] ||= {}
nics[adapter][:hostonly] = network
elsif matcher = line =~ /^bridgeadapter(\d+)="(.+?)"$/
elsif matcher = /^bridgeadapter(\d+)="(.+?)"$/.match(line)
adapter = matcher[1].to_i
network = matcher[2].to_s

Expand Down

0 comments on commit 73b31b5

Please sign in to comment.