Module: StubRequests::URI
- Defined in:
- lib/stub_requests/uri.rb,
lib/stub_requests/uri/scheme.rb,
lib/stub_requests/uri/suffix.rb,
lib/stub_requests/uri/builder.rb,
lib/stub_requests/uri/validator.rb
Overview
Module URI organizes all gem logic regarding URI
Defined Under Namespace
Modules: Scheme, Suffix Classes: Builder, Validator
Constant Summary collapse
- ROUTE_PARAM =
Returns A pattern for matching route parameters
%r{/:(\w+)/?}.freeze
Class Method Summary collapse
-
.route_params(string) ⇒ Array<Symbol>
Extracts route parameters from a string.
-
.safe_join(host, path) ⇒ String
Safely joins two string without any extra ///.
Class Method Details
.route_params(string) ⇒ Array<Symbol>
Extracts route parameters from a string
28 29 30 |
# File 'lib/stub_requests/uri.rb', line 28 def self.route_params(string) string.scan(ROUTE_PARAM).flatten.map(&:to_sym) end |
.safe_join(host, path) ⇒ String
Safely joins two string without any extra ///
40 41 42 |
# File 'lib/stub_requests/uri.rb', line 40 def self.safe_join(host, path) [host.chomp("/"), path.sub(%r{\A/}, "")].join("/") end |