Sha256: f50f16d8d30c3168c3c9aa0435f7cb88a9862888f614e2cfd2dc9cca1ef5eb7e
Contents?: true
Size: 1.05 KB
Versions: 2
Compression:
Stored size: 1.05 KB
Contents
# -*- encoding : utf-8 -*- module Pacto class UriPattern class << self def for(request, strict = Pacto.configuration.strict_matchers) fail_deprecations(request) build_template_uri_pattern(request, strict) end def build_template_uri_pattern(request, strict) path = request.path.respond_to?(:pattern) ? request.path.pattern : request.path host = request.host host ||= '{server}' scheme, host = host.split('://') if host.include?('://') scheme ||= '{scheme}' if strict Addressable::Template.new("#{scheme}://#{host}#{path}") else Addressable::Template.new("#{scheme}://#{host}#{path}{?anyvars*}") end end def fail_deprecations(request) return if request.path.is_a? Addressable::Template return if request.path == (corrected_path = request.path.gsub(/\/:(\w+)/, '/{\\1}')) fail "please change path #{request.path} to uri template: #{corrected_path} - old syntax no longer supported" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pacto-0.4.0.rc3 | lib/pacto/stubs/uri_pattern.rb |
pacto-0.4.0.rc2 | lib/pacto/stubs/uri_pattern.rb |