unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH 0/2] ruby: database open improvements
@ 2023-03-23  2:05 Felipe Contreras
  2023-03-23  2:05 ` [PATCH 1/2] ruby: use database_open_with_config Felipe Contreras
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Felipe Contreras @ 2023-03-23  2:05 UTC (permalink / raw)
  To: notmuch

Essentially we want to do notmuch_database_open_with_config() and load the
default database.

Felipe Contreras (2):
  ruby: use database_open_with_config
  ruby: database: make path arg optional

 bindings/ruby/database.c | 12 ++++++++----
 test/T395-ruby.sh        |  2 +-
 2 files changed, 9 insertions(+), 5 deletions(-)

-- 
2.39.2.13.g1fb56cf030

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] ruby: use database_open_with_config
  2023-03-23  2:05 [PATCH 0/2] ruby: database open improvements Felipe Contreras
@ 2023-03-23  2:05 ` Felipe Contreras
  2023-03-23  2:05 ` [PATCH 2/2] ruby: database: make path arg optional Felipe Contreras
  2023-03-31 11:07 ` [PATCH 0/2] ruby: database open improvements David Bremner
  2 siblings, 0 replies; 5+ messages in thread
From: Felipe Contreras @ 2023-03-23  2:05 UTC (permalink / raw)
  To: notmuch

Fixes warning:

  warning: ‘notmuch_database_open’ is deprecated: function deprecated as of libnotmuch 5.4

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 bindings/ruby/database.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bindings/ruby/database.c b/bindings/ruby/database.c
index 9c3dbd96..a78d508b 100644
--- a/bindings/ruby/database.c
+++ b/bindings/ruby/database.c
@@ -91,7 +91,7 @@ notmuch_rb_database_initialize (int argc, VALUE *argv, VALUE self)
     if (create)
 	ret = notmuch_database_create (path, &database);
     else
-	ret = notmuch_database_open (path, mode, &database);
+	ret = notmuch_database_open_with_config (path, mode, NULL, NULL, &database, NULL);
     notmuch_rb_status_raise (ret);
 
     DATA_PTR (self) = notmuch_rb_object_create (database, "notmuch_rb_database");
-- 
2.39.2.13.g1fb56cf030
\r

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] ruby: database: make path arg optional
  2023-03-23  2:05 [PATCH 0/2] ruby: database open improvements Felipe Contreras
  2023-03-23  2:05 ` [PATCH 1/2] ruby: use database_open_with_config Felipe Contreras
@ 2023-03-23  2:05 ` Felipe Contreras
  2023-03-31 11:07 ` [PATCH 0/2] ruby: database open improvements David Bremner
  2 siblings, 0 replies; 5+ messages in thread
From: Felipe Contreras @ 2023-03-23  2:05 UTC (permalink / raw)
  To: notmuch

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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] ruby: database open improvements
  2023-03-23  2:05 [PATCH 0/2] ruby: database open improvements Felipe Contreras
  2023-03-23  2:05 ` [PATCH 1/2] ruby: use database_open_with_config Felipe Contreras
  2023-03-23  2:05 ` [PATCH 2/2] ruby: database: make path arg optional Felipe Contreras
@ 2023-03-31 11:07 ` David Bremner
  2023-03-31 20:42   ` Felipe Contreras
  2 siblings, 1 reply; 5+ messages in thread
From: David Bremner @ 2023-03-31 11:07 UTC (permalink / raw)
  To: Felipe Contreras, notmuch

Felipe Contreras <felipe.contreras@gmail.com> writes:

> Essentially we want to do notmuch_database_open_with_config() and load the
> default database.
>

Applied to master. Thanks for this change, both are things I'd wanted to
fix.

d

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] ruby: database open improvements
  2023-03-31 11:07 ` [PATCH 0/2] ruby: database open improvements David Bremner
@ 2023-03-31 20:42   ` Felipe Contreras
  0 siblings, 0 replies; 5+ messages in thread
From: Felipe Contreras @ 2023-03-31 20:42 UTC (permalink / raw)
  To: David Bremner; +Cc: notmuch

On Fri, Mar 31, 2023 at 5:07 AM David Bremner <david@tethera.net> wrote:
>
> Felipe Contreras <felipe.contreras@gmail.com> writes:
>
> > Essentially we want to do notmuch_database_open_with_config() and load the
> > default database.
> >
>
> Applied to master. Thanks for this change, both are things I'd wanted to
> fix.

Good. Since you chose to pick this series, I just sent another patch I
have lying around to reorganize this initializer code.

Cheers.

-- 
Felipe Contreras\r

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-03-31 20:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-23  2:05 [PATCH 0/2] ruby: database open improvements Felipe Contreras
2023-03-23  2:05 ` [PATCH 1/2] ruby: use database_open_with_config Felipe Contreras
2023-03-23  2:05 ` [PATCH 2/2] ruby: database: make path arg optional Felipe Contreras
2023-03-31 11:07 ` [PATCH 0/2] ruby: database open improvements David Bremner
2023-03-31 20:42   ` Felipe Contreras

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).