Class: DeployMongo::MongoShell
- Inherits:
-
Object
- Object
- DeployMongo::MongoShell
- Defined in:
- lib/deploy_mongo/mongo_shell.rb
Instance Method Summary collapse
- #execute(command) ⇒ Object
-
#initialize(database, mongo_shell_path) ⇒ MongoShell
constructor
A new instance of MongoShell.
Constructor Details
#initialize(database, mongo_shell_path) ⇒ MongoShell
Returns a new instance of MongoShell.
4 5 6 7 |
# File 'lib/deploy_mongo/mongo_shell.rb', line 4 def initialize(database,mongo_shell_path) @database = database @mongo_shell_path = mongo_shell_path end |
Instance Method Details
#execute(command) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/deploy_mongo/mongo_shell.rb', line 9 def execute(command) command = command.gsub("'","''") mongo_command = "#{@mongo_shell_path} #{@database} --eval '#{command}'" #puts mongo_command `#{mongo_command}` raise "error" if ($?.to_i != 0) end |