From 4152e1bc20fa2803186740c76579b495f4c77fb6 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Wed, 22 Mar 2023 20:05:23 -0600 Subject: [PATCH] ruby: database: make path arg optional It can be automatically loaded from the configuration now. Signed-off-by: Felipe Contreras --- 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