Sha256: ea42494da6b25cfd83c7bbe819dfe38fb13dbcc78febb51e2e0a2d7bd6bf1c54
Contents?: true
Size: 783 Bytes
Versions: 2
Compression:
Stored size: 783 Bytes
Contents
module WildcardMatchers module Matchers def is_uri(hash = {}) IsUri.new(hash) end class IsUri < ::WildcardMatchers::WildcardMatcher protected def wildcard_match(actual) unless actual errors.push "#{position}: expect uri but nil" return end uri = nil begin require "addressable/uri" uri = ::Addressable::URI.parse(actual) # if actual is ::URI re-parse rescue LoadError require "uri" uri = actual.is_a?(::URI) ? actual : ::URI.parse(actual) end expectation.each do |key, value| errors.push(*self.class.superclass.check_errors(uri.__send__(key), value, position + "[#{key.inspect}]")) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
wildcard_matchers-0.1.4 | lib/wildcard_matchers/matchers/is_uri.rb |
wildcard_matchers-0.1.3 | lib/wildcard_matchers/matchers/is_uri.rb |