Class: Vito::Connection
- Inherits:
-
Object
- Object
- Vito::Connection
- Defined in:
- lib/vito/connection.rb
Instance Method Summary collapse
-
#initialize(type, args = {}) ⇒ Connection
constructor
A new instance of Connection.
- #query(command) ⇒ Object
- #run(command) ⇒ Object
Constructor Details
#initialize(type, args = {}) ⇒ Connection
Returns a new instance of Connection.
5 6 7 8 9 10 |
# File 'lib/vito/connection.rb', line 5 def initialize(type, args = {}) @options = {} @options[:command] = args[:command] @options[:verbose] = args[:verbose] || false @options[:silent] = args[:silent] || false end |
Instance Method Details
#query(command) ⇒ Object
12 13 14 15 |
# File 'lib/vito/connection.rb', line 12 def query(command) command = final_command(command) execute_command(command) end |
#run(command) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/vito/connection.rb', line 17 def run(command) command = final_command(command) Log.write("* Executing: #{command}") unless silent? output = execute_command(command) Log.write(output.result, verbose?) unless output.success? Log.raise "An error occurred. Here's the stacktrace:" Log.raise output.result Log.raise "" raise "Error." end output end |