Sha256: 12e572d73d51173c4dc9a6ef092a483bb0e308938cad12c9bbb085a37adce500
Contents?: true
Size: 989 Bytes
Versions: 2
Compression:
Stored size: 989 Bytes
Contents
# -*- encoding : utf-8 -*- module Pacto module RequestClause include Logger attr_reader :host attr_reader :http_method attr_reader :schema attr_reader :path attr_reader :headers attr_reader :params attr_reader :pattern def http_method=(method) normalize(method) end def uri(values = {}) values ||= {} uri_template = pattern.uri_template missing_keys = uri_template.keys.map(&:to_sym) - values.keys.map(&:to_sym) values[:scheme] = 'http' if missing_keys.delete(:scheme) values[:server] = 'localhost' if missing_keys.delete(:server) logger.warn "Missing keys for building a complete URL: #{missing_keys.inspect}" unless missing_keys.empty? Addressable::URI.heuristic_parse(uri_template.expand(values)).tap do |uri| uri.query_values = params unless params.nil? || params.empty? end end private def normalize(method) method.to_s.downcase.to_sym end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pacto-0.4.0.rc3 | lib/pacto/request_clause.rb |
pacto-0.4.0.rc2 | lib/pacto/request_clause.rb |