Module: WifiWand::Models::Helpers::SecurityTypeNormalizer
- Defined in:
- lib/wifi_wand/models/helpers/security_type_normalizer.rb
Class Method Summary collapse
-
.canonical_security_type_from(security_text) ⇒ Object
Normalizes a raw security descriptor string from OS tools to one of: "WPA3", "WPA2", "WPA", "WEP", "NONE", or nil (unknown/enterprise).
Class Method Details
.canonical_security_type_from(security_text) ⇒ Object
Normalizes a raw security descriptor string from OS tools to one of: "WPA3", "WPA2", "WPA", "WEP", "NONE", or nil (unknown/enterprise).
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/wifi_wand/models/helpers/security_type_normalizer.rb', line 9 def self.canonical_security_type_from(security_text) return nil if security_text.nil? text = security_text.to_s.strip return nil if text.empty? # Exclude enterprise/EAP networks which are not representable with PSK/WEP return nil if text.match?(/802\.?1x|enterprise/i) case text when /WPA3/i 'WPA3' when /WPA2/i 'WPA2' when /WPA1/i, /WPA(?!\d)/i 'WPA' when /WEP/i 'WEP' when /\bnone\b|spairport_security_mode_none/i, /\bowe\b/i 'NONE' end end |