unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] ruby: add all_tags method to Notmuch::Database
@ 2012-07-09 14:36 Peter Keen
  0 siblings, 0 replies; only message in thread
From: Peter Keen @ 2012-07-09 14:36 UTC (permalink / raw)
  To: notmuch

[-- Attachment #1: Type: text/plain, Size: 2169 bytes --]

The python bindings define a binding for the all_tags method on the
database, which is pretty handy. This commit adds the same binding to
the ruby bindings.
---
 bindings/ruby/database.c |   20 ++++++++++++++++++++
 bindings/ruby/defs.h     |    3 +++
 bindings/ruby/init.c     |    1 +
 3 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/bindings/ruby/database.c b/bindings/ruby/database.c
index e84f726..d5ba108 100644
--- a/bindings/ruby/database.c
+++ b/bindings/ruby/database.c
@@ -395,3 +395,23 @@ notmuch_rb_database_query_create (VALUE self, VALUE qstrv)

     return Data_Wrap_Struct (notmuch_rb_cQuery, NULL, NULL, query);
 }
+
+/*
+ * call-seq: DB.get_all_tags() => TAGS
+ *
+ * Retrieve all tags in the database.
+ */
+VALUE
+notmuch_rb_database_get_all_tags (VALUE self)
+{
+    notmuch_database_t *db;
+    notmuch_tags_t *tags;
+
+    Data_Get_Notmuch_Database (self, db);
+
+    tags = notmuch_database_get_all_tags (db);
+    if (!tags)
+        rb_raise (notmuch_rb_eMemoryError, "Out of memory");
+
+    return Data_Wrap_Struct (notmuch_rb_cTags, NULL, NULL, tags);
+}
diff --git a/bindings/ruby/defs.h b/bindings/ruby/defs.h
index fe81b3f..f1f7502 100644
--- a/bindings/ruby/defs.h
+++ b/bindings/ruby/defs.h
@@ -180,6 +180,9 @@ notmuch_rb_database_find_message_by_filename
(VALUE self, VALUE pathv);
 VALUE
 notmuch_rb_database_query_create (VALUE self, VALUE qstrv);

+VALUE
+notmuch_rb_database_get_all_tags (VALUE self);
+
 /* directory.c */
 VALUE
 notmuch_rb_directory_destroy (VALUE self);
diff --git a/bindings/ruby/init.c b/bindings/ruby/init.c
index f4931d3..52561c7 100644
--- a/bindings/ruby/init.c
+++ b/bindings/ruby/init.c
@@ -230,6 +230,7 @@ Init_notmuch (void)
     rb_define_method (notmuch_rb_cDatabase, "find_message_by_filename",
 		      notmuch_rb_database_find_message_by_filename, 1); /* in database.c */
     rb_define_method (notmuch_rb_cDatabase, "query",
notmuch_rb_database_query_create, 1); /* in database.c */
+    rb_define_method (notmuch_rb_cDatabase, "all_tags",
notmuch_rb_database_get_all_tags, 0); /* in database.c */

     /*
      * Document-class: Notmuch::Directory
-- 
1.7.7.5 (Apple Git-26)

[-- Attachment #2: Type: text/html, Size: 2292 bytes --]

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2012-07-09 14:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-09 14:36 [PATCH] ruby: add all_tags method to Notmuch::Database Peter Keen

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).