module StubRequests::URI

Module URI organizes all gem logic regarding URI

@author Mikael Henriksson <mikael@zoolutions.se> @since 0.1.2

Module URI organizes all gem logic regarding URI

@author Mikael Henriksson <mikael@zoolutions.se>

Module URI organizes all gem logic regarding URI

@author Mikael Henriksson <mikael@zoolutions.se>

Module URI organizes all gem logic regarding URI

@author Mikael Henriksson <mikael@zoolutions.se>

Module URI organizes all gem logic regarding URI

@author Mikael Henriksson <mikael@zoolutions.se>

Constants

ROUTE_PARAM

@return [Regexp] A pattern for matching route parameters

Public Class Methods

route_params(string) click to toggle source

Extracts route parameters from a string

@param [String] string a regular string to scan for route parameters

@return [Array<Symbol>] an array with all route parameter keys

# 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) click to toggle source

Safely joins two string without any extra ///

@param [String] host the host of the URI @param [String] path the path of the URI

@return [String] the full URI

# File lib/stub_requests/uri.rb, line 40
def self.safe_join(host, path)
  [host.chomp("/"), path.sub(%r{\A/}, "")].join("/")
end