diff options
author | Teddy Wing | 2017-04-29 22:21:01 +0200 |
---|---|---|
committer | Teddy Wing | 2017-04-29 22:21:01 +0200 |
commit | 46b019abd520870ab159b60c03c45675f64dd88a (patch) | |
tree | 7204226a8129cf40a4723c9def1a4e01c6e663fb /lib/dbshell/client/postgres.rb | |
parent | 6f4057392857313355769de7fea293b5e50f0779 (diff) | |
download | dbshell-rails-46b019abd520870ab159b60c03c45675f64dd88a.tar.bz2 |
Rename database client classes
Update our class names to reflect the new file structure introduced in
b700c1bef89a67a64f1040fb6bb03c0320eefe91.
Use the
module DBShell
module Client
end
end
syntax intead of `DBShell::Client` so that we don't have to define the
`Client` module in a separate file and require it. Otherwise we'd get an
error:
lib/dbshell/client/sqlite3.rb:1:in `<top (required)>': uninitialized constant DBShell::Client (NameError)
Diffstat (limited to 'lib/dbshell/client/postgres.rb')
-rw-r--r-- | lib/dbshell/client/postgres.rb | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/lib/dbshell/client/postgres.rb b/lib/dbshell/client/postgres.rb index 1c1c663..0e33843 100644 --- a/lib/dbshell/client/postgres.rb +++ b/lib/dbshell/client/postgres.rb @@ -1,23 +1,27 @@ -class DBShell::PostgresClient - EXECUTABLE_NAME = 'psql' +module DBShell + module Client + class Postgres + EXECUTABLE_NAME = 'psql' - def self.runshell(db_info) - args = self.build_command(db_info) - exec(*args) - end + def self.runshell(db_info) + args = self.build_command(db_info) + exec(*args) + end - def self.build_command(db_info) - args = [EXECUTABLE_NAME] + def self.build_command(db_info) + args = [EXECUTABLE_NAME] - host = db_info['host'] - port = db_info['port'] - db_name = db_info['database'] - user = db_info['username'] - password = db_info['password'] + host = db_info['host'] + port = db_info['port'] + db_name = db_info['database'] + user = db_info['username'] + password = db_info['password'] - args.push('-U', user) if user - args.push('-h', host) if host - args.push('-p', port) if port - args.push(db_name) + args.push('-U', user) if user + args.push('-h', host) if host + args.push('-p', port) if port + args.push(db_name) + end + end end end |