Sha256: ae704b5b3d18c32399cf3443d144636339088ee2fe1fd0ebefacaae8f94d7811
Contents?: true
Size: 1.07 KB
Versions: 8
Compression:
Stored size: 1.07 KB
Contents
require 'uri' require 'mongo' module Low module Mongo # The `Util` module provides some handy static Mongo helper methods. module Util # Given a `string`, return all the mongdb URIs contained therein. def self.extract_mongodb_uris(string) URI.extract(string, 'mongodb') end def self.sync_from_remote(local_database_or_mongo, remote) # If a Mongo::Local is specified, local = local_database_or_mongo.is_a?(Mongo::Local) ? # use it, local_database_or_mongo : # otherwise, assume that it is a database name and build one. Mongo::Local.new(local_database_or_mongo) # Extract host and port from the remote URI, match = remote.uri.match(URI.regexp('mongodb')) remote_host = match[4] remote_port = match[5] # and copy the database. local.connection.copy_database( remote.database, local.database, "#{remote_host}:#{remote_port}", remote.username, remote.password ) end end end end
Version data entries
8 entries across 8 versions & 1 rubygems