Class: WebValve::ServiceUrlConverter
- Inherits:
-
Object
- Object
- WebValve::ServiceUrlConverter
- Defined in:
- lib/webvalve/service_url_converter.rb
Constant Summary collapse
- TOKEN_BOUNDARY_CHARS =
Regexp.escape('.:/?#@&=').freeze
- WILDCARD_SUBSTITUTION =
('[^' + TOKEN_BOUNDARY_CHARS + ']*').freeze
- URL_PREFIX_BOUNDARY =
('[' + TOKEN_BOUNDARY_CHARS + ']').freeze
- URL_SUFFIX_PATTERN =
('((' + URL_PREFIX_BOUNDARY + '|(?<=' + URL_PREFIX_BOUNDARY + ')).*)?\z').freeze
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(url:) ⇒ ServiceUrlConverter
constructor
A new instance of ServiceUrlConverter.
- #regexp ⇒ Object
Constructor Details
#initialize(url:) ⇒ ServiceUrlConverter
Returns a new instance of ServiceUrlConverter.
10 11 12 |
# File 'lib/webvalve/service_url_converter.rb', line 10 def initialize(url:) @url = url end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
8 9 10 |
# File 'lib/webvalve/service_url_converter.rb', line 8 def url @url end |
Instance Method Details
#regexp ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/webvalve/service_url_converter.rb', line 14 def regexp if url.is_a?(String) regexp_string = Regexp.escape(url) substituted_regexp_string = regexp_string.gsub('\*', WILDCARD_SUBSTITUTION) %r(\A#{substituted_regexp_string}#{URL_SUFFIX_PATTERN}) else url end end |