made MONGODB_URI_MATCHER regular expression in uri_parser.rb easier to interpret by breaking it into parts

This commit is contained in:
Tyler Brock 2011-12-20 11:27:40 -05:00
parent 63708a5f16
commit 1d22c75811
1 changed files with 13 additions and 1 deletions

View File

@ -20,8 +20,20 @@ module Mongo
class URIParser
DEFAULT_PORT = 27017
MONGODB_URI_MATCHER = /(([-.\w:]+):([^@,]+)@)?((?:(?:[-.\w]+)(?::(?:[\w]+))?,?)+)(\/([-\w]+))?/
USER_REGEX = /([-.\w:]+)/
PASS_REGEX = /([^@,]+)/
AUTH_REGEX = /(#{USER_REGEX}:#{PASS_REGEX}@)?/
HOST_REGEX = /(?:[-.\w]+)/
PORT_REGEX = /(?::(?:[\d]+))/
NODE_REGEX = /((?:#{HOST_REGEX}#{PORT_REGEX}?,?)+)/
PATH_REGEX = /(\/([-\w]+))?/
MONGODB_URI_MATCHER = /#{AUTH_REGEX}#{NODE_REGEX}#{PATH_REGEX}/
MONGODB_URI_SPEC = "mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/database]"
SPEC_ATTRS = [:nodes, :auths]
OPT_ATTRS = [:connect, :replicaset, :slaveok, :safe, :w, :wtimeout, :fsync]