lib/arql/app.rb in arql-0.1.2 vs lib/arql/app.rb in arql-0.1.3
- old
+ new
@@ -1,9 +1,20 @@
require 'net/ssh/gateway'
module Arql
class App
+
+ class << self
+ def config
+ @@effective_config
+ end
+
+ def local_ssh_proxy_port
+ @@local_ssh_proxy_port
+ end
+ end
+
def initialize(options)
@options = options
Connection.open(connect_options)
@definition = Definition.new
end
@@ -19,15 +30,15 @@
connect_conf
end
def start_ssh_proxy!
ssh_config = effective_config[:ssh]
- @ssh_gateway = Net::SSH::Gateway.new(ssh_config[:host], ssh_config[:user])
- @local_ssh_proxy_port = @ssh_gateway.open(effective_config[:host], effective_config[:port], ssh_config[:local_port])
+ @ssh_gateway = Net::SSH::Gateway.new(ssh_config[:host], ssh_config[:user], ssh_config.slice(:port, :password).symbolize_keys)
+ @@local_ssh_proxy_port = @ssh_gateway.open(effective_config[:host], effective_config[:port], ssh_config[:local_port])
{
host: '127.0.0.1',
- port: @local_ssh_proxy_port
+ port: @@local_ssh_proxy_port
}
end
def config
@config ||= YAML.load(IO.read(@options.config_file)).with_indifferent_access
@@ -36,10 +47,10 @@
def selected_config
config[@options.env]
end
def effective_config
- @effective_config ||= selected_config.merge(@options.to_h)
+ @@effective_config ||= selected_config.deep_merge(@options.to_h)
end
def run!
show_sql if should_show_sql?
write_sql if should_write_sql?