class Mycmd::Client
Attributes
result[R]
Public Class Methods
method_missing(action, *args)
click to toggle source
Calls superclass method
# File lib/mycmd/client.rb, line 39 def method_missing(action, *args) client = self.new if client.respond_to? action client.send(action, *args) else super end end
new()
click to toggle source
# File lib/mycmd/client.rb, line 7 def initialize @configuration = Configuration.new @connection = @configuration.connect end
Public Instance Methods
command()
click to toggle source
# File lib/mycmd/client.rb, line 26 def command @configuration.to_hash.inject(["mysql"]) do |c,(k,v)| case k when :host then c << "-h#{v}" when :port then c << "-P#{v}" when :username then c << "-u#{v}" when :password then c << "-p#{v}" when :database then c << v end end.join(" ") end
execute_task(task)
click to toggle source
# File lib/mycmd/client.rb, line 17 def execute_task(task) @result = @connection.query(@configuration.tasks[task.to_s]) self end
print(header=true)
click to toggle source
# File lib/mycmd/client.rb, line 22 def print(header=true) Printer.new(@result, header).print end
query(sql)
click to toggle source
# File lib/mycmd/client.rb, line 12 def query(sql) @result = @connection.query(sql) self end