From 295407026c52216869a98dbed877a09edb801bc6 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 29 Apr 2017 19:24:54 +0200 Subject: Add `DBShell::Sqlite3Client` Much simpler `.build_command` than the Postgres version. Only building arguments now. Want to try out executing the subprocess command. Inspired of course by: https://github.com/django/django/blob/66150f7cf61bc09547fa98586790df596eff6d77/django/db/backends/sqlite3/client.py --- lib/dbshell/sqlite3_client.rb | 10 ++++++++++ spec/dbshell/sqlite3_client_spec.rb | 16 ++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 lib/dbshell/sqlite3_client.rb create mode 100644 spec/dbshell/sqlite3_client_spec.rb diff --git a/lib/dbshell/sqlite3_client.rb b/lib/dbshell/sqlite3_client.rb new file mode 100644 index 0000000..7e962d7 --- /dev/null +++ b/lib/dbshell/sqlite3_client.rb @@ -0,0 +1,10 @@ +class DBShell::Sqlite3Client + EXECUTABLE_NAME = 'sqlite3' + + def self.build_command(db_info) + args = [ + EXECUTABLE_NAME, + db_info['database'] + ] + end +end diff --git a/spec/dbshell/sqlite3_client_spec.rb b/spec/dbshell/sqlite3_client_spec.rb new file mode 100644 index 0000000..4922993 --- /dev/null +++ b/spec/dbshell/sqlite3_client_spec.rb @@ -0,0 +1,16 @@ +require 'minitest/autorun' +require 'dbshell/sqlite3_client' + +describe DBShell::Sqlite3Client do + describe ".build_command" do + it "builds basic arguments" do + DBShell::Sqlite3Client.build_command({ + 'adapter' => 'sqlite3', + 'database' => 'db/development.sqlite3' + }).must_equal([ + 'sqlite3', + 'db/development.sqlite3' + ]) + end + end +end -- cgit v1.2.3