From 0300df09fb3aa4f05cca754de10a828502bf0321 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Fri, 30 Sep 2016 12:11:54 -0700 Subject: [PATCH] guests/linux: Update constant name, freeze constant values --- plugins/guests/linux/cap/network_interfaces.rb | 6 +++--- .../plugins/guests/linux/cap/network_interfaces_test.rb | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/plugins/guests/linux/cap/network_interfaces.rb b/plugins/guests/linux/cap/network_interfaces.rb index ea7dc32da..6d3ce657c 100644 --- a/plugins/guests/linux/cap/network_interfaces.rb +++ b/plugins/guests/linux/cap/network_interfaces.rb @@ -5,7 +5,7 @@ module VagrantPlugins # Valid ethernet device prefix values. # eth - classic prefix # en - predictable interface names prefix - ETHERNET_PREFIX = ["eth", "en"] + POSSIBLE_ETHERNET_PREFIXES = ["eth".freeze, "en".freeze].freeze @@logger = Log4r::Logger.new("vagrant::guest::linux::network_interfaces") @@ -25,8 +25,8 @@ module VagrantPlugins # Break out integers from strings and sort the arrays to provide # a natural sort for the interface names ifaces = ifaces.map do |iface| - unless eth_prefix - eth_prefix = ETHERNET_PREFIX.detect do |prefix| + if eth_prefix.nil? + eth_prefix = POSSIBLE_ETHERNET_PREFIXES.detect do |prefix| iface.start_with?(prefix) end end diff --git a/test/unit/plugins/guests/linux/cap/network_interfaces_test.rb b/test/unit/plugins/guests/linux/cap/network_interfaces_test.rb index 139cebfdc..810606f2a 100644 --- a/test/unit/plugins/guests/linux/cap/network_interfaces_test.rb +++ b/test/unit/plugins/guests/linux/cap/network_interfaces_test.rb @@ -56,6 +56,5 @@ describe "VagrantPlugins::GuestLinux::Cap::NetworkInterfaces" do result = cap.network_interfaces(machine) expect(result).to eq(["enp0s3", "enp0s5", "enp0s8", "bridge0", "docker0"]) end - end end