Sha256: 5b7fd3db958b29aaa269bd463202085e9cb74ed840ce02f4f4c2e158236b4701
Contents?: true
Size: 998 Bytes
Versions: 2
Compression:
Stored size: 998 Bytes
Contents
# -*- encoding : utf-8 -*- require 'hashie/mash' module Pacto class PactoRequest # FIXME: Need case insensitive header lookup, but case-sensitive storage attr_accessor :headers, :body, :method, :uri include BodyParsing def initialize(data) mash = Hashie::Mash.new data @headers = mash.headers.nil? ? {} : mash.headers @body = mash.body @method = mash[:method] @uri = mash.uri normalize end def to_hash { method: method, uri: uri, headers: headers, body: body } end def to_s string = Pacto::UI.colorize_method(method) string << " #{relative_uri}" string << " with body (#{raw_body.bytesize} bytes)" if raw_body string end def relative_uri uri.to_s.tap do |s| s.slice!(uri.normalized_site) end end def normalize @method = @method.to_s.downcase.to_sym @uri = @uri.normalize if @uri end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pacto-0.4.0.rc3 | lib/pacto/core/pacto_request.rb |
pacto-0.4.0.rc2 | lib/pacto/core/pacto_request.rb |