Class: AllowHostNormalizer Private
- Inherits:
-
Object
- Object
- AllowHostNormalizer
- Defined in:
- lib/spm_version_updates/allow_host_normalizer.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Normalizes user-provided allow-host entries into hostnames.
Constant Summary collapse
- MALFORMED_SCHEME_PATTERN =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
%r{\A[a-z][a-z0-9+\-.]*//}i
Class Method Summary collapse
- .configured_entries(entries) ⇒ Object private
- .normalize(entry) ⇒ Object private
Instance Method Summary collapse
-
#initialize(entry) ⇒ AllowHostNormalizer
constructor
private
A new instance of AllowHostNormalizer.
- #normalize ⇒ Object private
Constructor Details
#initialize(entry) ⇒ AllowHostNormalizer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of AllowHostNormalizer.
22 23 24 |
# File 'lib/spm_version_updates/allow_host_normalizer.rb', line 22 def initialize(entry) @raw = entry.to_s.strip end |
Class Method Details
.configured_entries(entries) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
15 16 17 18 19 20 |
# File 'lib/spm_version_updates/allow_host_normalizer.rb', line 15 def self.configured_entries(entries) Array(entries).filter_map { |entry| value = entry.to_s.strip value unless value.empty? } end |
.normalize(entry) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
11 12 13 |
# File 'lib/spm_version_updates/allow_host_normalizer.rb', line 11 def self.normalize(entry) new(entry).normalize end |
Instance Method Details
#normalize ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
26 27 28 29 30 31 32 33 |
# File 'lib/spm_version_updates/allow_host_normalizer.rb', line 26 def normalize return nil if raw.empty? return parsed if parsed && !malformed_scheme? return fallback if fallback.match?(GitHostNormalizer::HOST_PATTERN) warn_unparseable nil end |