From b700c1bef89a67a64f1040fb6bb03c0320eefe91 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 29 Apr 2017 21:55:48 +0200 Subject: Rename database client files to put them in a `Client` module Will be modifying the class names in the next commit. Here we change the file names & locations of the database client files. The format changes thusly: _client.rb -> client/.rb This organisation feels cleaner to me. Wasn't liking the previous structure. --- lib/dbshell/client/database.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 lib/dbshell/client/database.rb (limited to 'lib/dbshell/client/database.rb') diff --git a/lib/dbshell/client/database.rb b/lib/dbshell/client/database.rb new file mode 100644 index 0000000..edea777 --- /dev/null +++ b/lib/dbshell/client/database.rb @@ -0,0 +1,24 @@ +require 'dbshell/sqlite3_client' +require 'dbshell/postgres_client' + +class DBShell::DatabaseClient + def self.handler(connection_params) + case connection_params['adapter'] + when 'sqlite3' + DBShell::Sqlite3Client + when 'postgresql' + DBShell::PostgresClient + else + raise DBShell::InvalidDatabaseAdapter + end + end + + def self.runshell(connection_params) + self + .handler(connection_params) + .runshell(connection_params) + end +end + + +class DBShell::InvalidDatabaseAdapter < StandardError; end -- cgit v1.2.3