Sha256: 4f6b51bab4673a2dbc558bb21e37c4557e2408b44b293b564b8ba657838fc90e

Contents?: true

Size: 602 Bytes

Versions: 12

Compression:

Stored size: 602 Bytes

Contents

require "addressable/uri"

module WildcardMatchers
  module Matchers
    def is_uri(hash = {})
      IsUri.new(hash)
    end

    class IsUri < ::WildcardMatchers::WildcardMatcher
      protected
      def wildcard_match(actual)
        unless actual
          return errors.push "#{position}: expect URI but nil"
        end

        uri = ::Addressable::URI.parse(actual) # if actual is ::URI re-parse

        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

12 entries across 12 versions & 1 rubygems

Version Path
wildcard_matchers-0.9.2 lib/wildcard_matchers/matchers/is_uri.rb
wildcard_matchers-0.9.1 lib/wildcard_matchers/matchers/is_uri.rb
wildcard_matchers-0.9.0 lib/wildcard_matchers/matchers/is_uri.rb
wildcard_matchers-0.4.0 lib/wildcard_matchers/matchers/is_uri.rb
wildcard_matchers-0.3.1 lib/wildcard_matchers/matchers/is_uri.rb
wildcard_matchers-0.3.0 lib/wildcard_matchers/matchers/is_uri.rb
wildcard_matchers-0.2.1 lib/wildcard_matchers/matchers/is_uri.rb
wildcard_matchers-0.2.0 lib/wildcard_matchers/matchers/is_uri.rb
wildcard_matchers-0.1.8 lib/wildcard_matchers/matchers/is_uri.rb
wildcard_matchers-0.1.7 lib/wildcard_matchers/matchers/is_uri.rb
wildcard_matchers-0.1.6 lib/wildcard_matchers/matchers/is_uri.rb
wildcard_matchers-0.1.5 lib/wildcard_matchers/matchers/is_uri.rb