Re: [PATCH 2/3] ruby: add directory.delete

2023-05-29 Thread David Bremner
Felipe Contreras  writes:

> Signed-off-by: Felipe Contreras 
> ---
>  bindings/ruby/defs.h  |  3 +++
>  bindings/ruby/directory.c | 19 +++
>  bindings/ruby/init.c  |  1 +
>  3 files changed, 23 insertions(+)
>
> diff --git a/bindings/ruby/defs.h b/bindings/ruby/defs.h
> index c4943681..3ef228b7 100644
> --- a/bindings/ruby/defs.h
> +++ b/bindings/ruby/defs.h
> @@ -227,6 +227,9 @@ notmuch_rb_directory_get_child_files (VALUE self);
>  VALUE
>  notmuch_rb_directory_get_child_directories (VALUE self);
>  
> +VALUE
> +notmuch_rb_directory_delete (VALUE self);
> +
>  /* filenames.c */
>  VALUE
>  notmuch_rb_filenames_destroy (VALUE self);
> diff --git a/bindings/ruby/directory.c b/bindings/ruby/directory.c
> index 910f0a99..2fb22c70 100644
> --- a/bindings/ruby/directory.c
> +++ b/bindings/ruby/directory.c
> @@ -108,3 +108,22 @@ notmuch_rb_directory_get_child_directories (VALUE self)
>  
>  return Data_Wrap_Notmuch_Object (notmuch_rb_cFileNames, 
> _rb_filenames_type, fnames);
>  }
> +
> +/*
> + * call-seq: DIR.delete => nil
> + *
> + * Delete directory from the database.
> + */
> +VALUE
> +notmuch_rb_directory_delete (VALUE self)
> +{
> +notmuch_directory_t *dir;
> +notmuch_status_t ret;
> +
> +Data_Get_Notmuch_Directory (self, dir);
> +
> +ret = notmuch_directory_delete (dir);
> +notmuch_rb_status_raise (ret);
> +
> +return Qnil;
> +}

I don't mind if tests come in later patches or in the patch that
introduces new API, but please add a test every time the ruby bindings
API grows.

d
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 2/3] ruby: add directory.delete

2023-03-31 Thread Felipe Contreras
Signed-off-by: Felipe Contreras 
---
 bindings/ruby/defs.h  |  3 +++
 bindings/ruby/directory.c | 19 +++
 bindings/ruby/init.c  |  1 +
 3 files changed, 23 insertions(+)

diff --git a/bindings/ruby/defs.h b/bindings/ruby/defs.h
index c4943681..3ef228b7 100644
--- a/bindings/ruby/defs.h
+++ b/bindings/ruby/defs.h
@@ -227,6 +227,9 @@ notmuch_rb_directory_get_child_files (VALUE self);
 VALUE
 notmuch_rb_directory_get_child_directories (VALUE self);
 
+VALUE
+notmuch_rb_directory_delete (VALUE self);
+
 /* filenames.c */
 VALUE
 notmuch_rb_filenames_destroy (VALUE self);
diff --git a/bindings/ruby/directory.c b/bindings/ruby/directory.c
index 910f0a99..2fb22c70 100644
--- a/bindings/ruby/directory.c
+++ b/bindings/ruby/directory.c
@@ -108,3 +108,22 @@ notmuch_rb_directory_get_child_directories (VALUE self)
 
 return Data_Wrap_Notmuch_Object (notmuch_rb_cFileNames, 
_rb_filenames_type, fnames);
 }
+
+/*
+ * call-seq: DIR.delete => nil
+ *
+ * Delete directory from the database.
+ */
+VALUE
+notmuch_rb_directory_delete (VALUE self)
+{
+notmuch_directory_t *dir;
+notmuch_status_t ret;
+
+Data_Get_Notmuch_Directory (self, dir);
+
+ret = notmuch_directory_delete (dir);
+notmuch_rb_status_raise (ret);
+
+return Qnil;
+}
diff --git a/bindings/ruby/init.c b/bindings/ruby/init.c
index c78242a0..625c6c4d 100644
--- a/bindings/ruby/init.c
+++ b/bindings/ruby/init.c
@@ -297,6 +297,7 @@ Init_notmuch (void)
 rb_define_method (notmuch_rb_cDirectory, "mtime=", 
notmuch_rb_directory_set_mtime, 1); /* in directory.c */
 rb_define_method (notmuch_rb_cDirectory, "child_files", 
notmuch_rb_directory_get_child_files, 0); /* in directory.c */
 rb_define_method (notmuch_rb_cDirectory, "child_directories", 
notmuch_rb_directory_get_child_directories, 0); /* in directory.c */
+rb_define_method (notmuch_rb_cDirectory, "delete", 
notmuch_rb_directory_delete, 0); /* in directory.c */
 
 /*
  * Document-class: Notmuch::FileNames
-- 
2.40.0

___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org