Sha256: eeb5c8c9e31d473d0e43dcca1cd653bb321070f10a3c7e5bc54050f66c700e75
Contents?: true
Size: 1.08 KB
Versions: 1
Compression:
Stored size: 1.08 KB
Contents
# -*- encoding : utf-8 -*- module Pacto class UriPattern class << self def for(request, strict = Pacto.configuration.strict_matchers) fix_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 ||= '{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 fix_deprecations(request) return if request.path.is_a? Addressable::Template return if request.path == (corrected_path = request.path.gsub(/\/:(\w+)/, '/{\\1}')) Pacto::UI.deprecation "Please change path #{request.path} to uri template: #{corrected_path}" request.path = Addressable::Template.new(corrected_path) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pacto-0.4.0.rc1 | lib/pacto/stubs/uri_pattern.rb |