[PATCH 2/2] ruby: database: make path arg optional

Subject: [PATCH 2/2] ruby: database: make path arg optional

Date: Wed, 22 Mar 2023 20:05:23 -0600

To: notmuch@notmuchmail.org

Cc:

From: Felipe Contreras


It can be automatically loaded from the configuration now.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 bindings/ruby/database.c | 10 +++++++---
 test/T395-ruby.sh        |  2 +-
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/bindings/ruby/database.c b/bindings/ruby/database.c
index a78d508b..b6de1254 100644
--- a/bindings/ruby/database.c
+++ b/bindings/ruby/database.c
@@ -59,10 +59,14 @@ notmuch_rb_database_initialize (int argc, VALUE *argv, VALUE self)
     notmuch_status_t ret;
 
     /* Check arguments */
-    rb_scan_args (argc, argv, "11", &pathv, &hashv);
+    rb_scan_args (argc, argv, "02", &pathv, &hashv);
 
-    SafeStringValue (pathv);
-    path = RSTRING_PTR (pathv);
+    if (!NIL_P (pathv)) {
+	SafeStringValue (pathv);
+	path = RSTRING_PTR (pathv);
+    } else {
+	path = NULL;
+    }
 
     if (!NIL_P (hashv)) {
 	Check_Type (hashv, T_HASH);
diff --git a/test/T395-ruby.sh b/test/T395-ruby.sh
index e828efed..c066c842 100755
--- a/test/T395-ruby.sh
+++ b/test/T395-ruby.sh
@@ -12,7 +12,7 @@ test_ruby() {
     (
 	cat <<-EOF
 	require 'notmuch'
-	db = Notmuch::Database.new('$MAIL_DIR')
+	db = Notmuch::Database.new()
 	EOF
 	cat
     ) | $NOTMUCH_RUBY -I "$NOTMUCH_BUILDDIR/bindings/ruby"> OUTPUT
-- 
2.39.2.13.g1fb56cf030

_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: