lib/mongo/functional/uri_parser.rb in mongo-1.10.0.rc0 vs lib/mongo/functional/uri_parser.rb in mongo-1.10.0.rc1
- old
+ new
@@ -40,13 +40,15 @@
}
OPT_ATTRS = [
:authmechanism,
:authsource,
+ :canonicalizehostname,
:connect,
:connecttimeoutms,
:fsync,
+ :gssapiservicename,
:journal,
:pool_size,
:readpreference,
:replicaset,
:safe,
@@ -57,75 +59,83 @@
:wtimeout,
:wtimeoutms
]
OPT_VALID = {
- :authmechanism => lambda { |arg| Mongo::Authentication.validate_mechanism(arg) },
- :authsource => lambda { |arg| arg.length > 0 },
- :connect => lambda { |arg| [ 'direct', 'replicaset', 'true', 'false', true, false ].include?(arg) },
- :connecttimeoutms => lambda { |arg| arg =~ /^\d+$/ },
- :fsync => lambda { |arg| ['true', 'false'].include?(arg) },
- :journal => lambda { |arg| ['true', 'false'].include?(arg) },
- :pool_size => lambda { |arg| arg.to_i > 0 },
- :readpreference => lambda { |arg| READ_PREFERENCES.keys.include?(arg) },
- :replicaset => lambda { |arg| arg.length > 0 },
- :safe => lambda { |arg| ['true', 'false'].include?(arg) },
- :slaveok => lambda { |arg| ['true', 'false'].include?(arg) },
- :sockettimeoutms => lambda { |arg| arg =~ /^\d+$/ },
- :ssl => lambda { |arg| ['true', 'false'].include?(arg) },
- :w => lambda { |arg| arg =~ /^\w+$/ },
- :wtimeout => lambda { |arg| arg =~ /^\d+$/ },
- :wtimeoutms => lambda { |arg| arg =~ /^\d+$/ }
+ :authmechanism => lambda { |arg| Mongo::Authentication.validate_mechanism(arg) },
+ :authsource => lambda { |arg| arg.length > 0 },
+ :canonicalizehostname => lambda { |arg| ['true', 'false'].include?(arg) },
+ :connect => lambda { |arg| [ 'direct', 'replicaset', 'true', 'false', true, false ].include?(arg) },
+ :connecttimeoutms => lambda { |arg| arg =~ /^\d+$/ },
+ :fsync => lambda { |arg| ['true', 'false'].include?(arg) },
+ :gssapiservicename => lambda { |arg| arg.length > 0 },
+ :journal => lambda { |arg| ['true', 'false'].include?(arg) },
+ :pool_size => lambda { |arg| arg.to_i > 0 },
+ :readpreference => lambda { |arg| READ_PREFERENCES.keys.include?(arg) },
+ :replicaset => lambda { |arg| arg.length > 0 },
+ :safe => lambda { |arg| ['true', 'false'].include?(arg) },
+ :slaveok => lambda { |arg| ['true', 'false'].include?(arg) },
+ :sockettimeoutms => lambda { |arg| arg =~ /^\d+$/ },
+ :ssl => lambda { |arg| ['true', 'false'].include?(arg) },
+ :w => lambda { |arg| arg =~ /^\w+$/ },
+ :wtimeout => lambda { |arg| arg =~ /^\d+$/ },
+ :wtimeoutms => lambda { |arg| arg =~ /^\d+$/ }
}
OPT_ERR = {
- :authmechanism => "must be one of #{Mongo::Authentication::MECHANISMS.join(', ')}",
- :authsource => "must be a string containing the name of the database being used for authentication",
- :connect => "must be 'direct', 'replicaset', 'true', or 'false'",
- :connecttimeoutms => "must be an integer specifying milliseconds",
- :fsync => "must be 'true' or 'false'",
- :journal => "must be 'true' or 'false'",
- :pool_size => "must be an integer greater than zero",
- :readpreference => "must be on of #{READ_PREFERENCES.keys.map(&:inspect).join(",")}",
- :replicaset => "must be a string containing the name of the replica set to connect to",
- :safe => "must be 'true' or 'false'",
- :slaveok => "must be 'true' or 'false'",
- :settimeoutms => "must be an integer specifying milliseconds",
- :ssl => "must be 'true' or 'false'",
- :w => "must be an integer indicating number of nodes to replicate to or a string " +
- "specifying that replication is required to the majority or nodes with a " +
- "particilar getLastErrorMode.",
- :wtimeout => "must be an integer specifying milliseconds",
- :wtimeoutms => "must be an integer specifying milliseconds"
+ :authmechanism => "must be one of #{Mongo::Authentication::MECHANISMS.join(', ')}",
+ :authsource => "must be a string containing the name of the database being used for authentication",
+ :canonicalizehostname => "must be 'true' or 'false'",
+ :connect => "must be 'direct', 'replicaset', 'true', or 'false'",
+ :connecttimeoutms => "must be an integer specifying milliseconds",
+ :fsync => "must be 'true' or 'false'",
+ :gssapiservicename => "must be a string containing the name of the GSSAPI service",
+ :journal => "must be 'true' or 'false'",
+ :pool_size => "must be an integer greater than zero",
+ :readpreference => "must be on of #{READ_PREFERENCES.keys.map(&:inspect).join(",")}",
+ :replicaset => "must be a string containing the name of the replica set to connect to",
+ :safe => "must be 'true' or 'false'",
+ :slaveok => "must be 'true' or 'false'",
+ :settimeoutms => "must be an integer specifying milliseconds",
+ :ssl => "must be 'true' or 'false'",
+ :w => "must be an integer indicating number of nodes to replicate to or a string " +
+ "specifying that replication is required to the majority or nodes with a " +
+ "particilar getLastErrorMode.",
+ :wtimeout => "must be an integer specifying milliseconds",
+ :wtimeoutms => "must be an integer specifying milliseconds"
}
OPT_CONV = {
- :authmechanism => lambda { |arg| arg.upcase },
- :authsource => lambda { |arg| arg },
- :connect => lambda { |arg| arg == 'false' ? false : arg }, # convert 'false' to FalseClass
- :connecttimeoutms => lambda { |arg| arg.to_f / 1000 }, # stored as seconds
- :fsync => lambda { |arg| arg == 'true' ? true : false },
- :journal => lambda { |arg| arg == 'true' ? true : false },
- :pool_size => lambda { |arg| arg.to_i },
- :readpreference => lambda { |arg| READ_PREFERENCES[arg] },
- :replicaset => lambda { |arg| arg },
- :safe => lambda { |arg| arg == 'true' ? true : false },
- :slaveok => lambda { |arg| arg == 'true' ? true : false },
- :sockettimeoutms => lambda { |arg| arg.to_f / 1000 }, # stored as seconds
- :ssl => lambda { |arg| arg == 'true' ? true : false },
- :w => lambda { |arg| Mongo::Support.is_i?(arg) ? arg.to_i : arg.to_sym },
- :wtimeout => lambda { |arg| arg.to_i },
- :wtimeoutms => lambda { |arg| arg.to_i }
+ :authmechanism => lambda { |arg| arg.upcase },
+ :authsource => lambda { |arg| arg },
+ :canonicalizehostname => lambda { |arg| arg == 'true' ? true : false },
+ :connect => lambda { |arg| arg == 'false' ? false : arg }, # convert 'false' to FalseClass
+ :connecttimeoutms => lambda { |arg| arg.to_f / 1000 }, # stored as seconds
+ :fsync => lambda { |arg| arg == 'true' ? true : false },
+ :gssapiservicename => lambda { |arg| arg },
+ :journal => lambda { |arg| arg == 'true' ? true : false },
+ :pool_size => lambda { |arg| arg.to_i },
+ :readpreference => lambda { |arg| READ_PREFERENCES[arg] },
+ :replicaset => lambda { |arg| arg },
+ :safe => lambda { |arg| arg == 'true' ? true : false },
+ :slaveok => lambda { |arg| arg == 'true' ? true : false },
+ :sockettimeoutms => lambda { |arg| arg.to_f / 1000 }, # stored as seconds
+ :ssl => lambda { |arg| arg == 'true' ? true : false },
+ :w => lambda { |arg| Mongo::Support.is_i?(arg) ? arg.to_i : arg.to_sym },
+ :wtimeout => lambda { |arg| arg.to_i },
+ :wtimeoutms => lambda { |arg| arg.to_i }
}
attr_reader :auths,
:authmechanism,
:authsource,
+ :canonicalizehostname,
:connect,
:connecttimeoutms,
:db_name,
:fsync,
+ :gssapiservicename,
:journal,
:nodes,
:pool_size,
:readpreference,
:replicaset,
@@ -316,9 +326,11 @@
:username => URI.unescape(username),
:password => password ? URI.unescape(password) : nil,
:source => @authsource,
:mechanism => @authmechanism
})
+ auth[:extra] = @canonicalizehostname ? { :canonicalize_host_name => @canonicalizehostname } : {}
+ auth[:extra].merge!(:gssapi_service_name => @gssapiservicename) if @gssapiservicename
@auths << auth
end
end
# This method uses the lambdas defined in OPT_VALID and OPT_CONV to validate