From e5099a741bf5bc2cfb004efd52cadab4054af325 Mon Sep 17 00:00:00 2001 From: Peter Keen Date: Tue, 10 Jul 2012 07:36:48 +1700 Subject: [PATCH] [PATCH] ruby: add all_tags method to Notmuch::Database --- 7f/4f3ff90fbb86aa7a2c31fb5ffc5288e0518416 | 204 ++++++++++++++++++++++ 1 file changed, 204 insertions(+) create mode 100644 7f/4f3ff90fbb86aa7a2c31fb5ffc5288e0518416 diff --git a/7f/4f3ff90fbb86aa7a2c31fb5ffc5288e0518416 b/7f/4f3ff90fbb86aa7a2c31fb5ffc5288e0518416 new file mode 100644 index 000000000..5c293092a --- /dev/null +++ b/7f/4f3ff90fbb86aa7a2c31fb5ffc5288e0518416 @@ -0,0 +1,204 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 2F9AC431FBD + for ; Mon, 9 Jul 2012 07:36:51 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.698 +X-Spam-Level: +X-Spam-Status: No, score=-0.698 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, + HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 6fQfvPkki9Y7 for ; + Mon, 9 Jul 2012 07:36:50 -0700 (PDT) +Received: from mail-vb0-f53.google.com (mail-vb0-f53.google.com + [209.85.212.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 4F3A4431FAE + for ; Mon, 9 Jul 2012 07:36:50 -0700 (PDT) +Received: by vbbfc26 with SMTP id fc26so8658401vbb.26 + for ; Mon, 09 Jul 2012 07:36:48 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=mime-version:sender:date:x-google-sender-auth:message-id:subject + :from:to:content-type; + bh=1LnfHk8kfBSq7hDQKMyQtGYeYQhnsH3yc/Yk2gGLuEE=; + b=C91oXa8e101b/uFQbDbyQmNjhNm90UV+9dfQj29bC+P7As5Pf17cLCI9Abl8sceA9c + 5zGHkAYeMV99aF8dkbQl9OdSzf7DaabSVGWHKz9moztf0kJ6bF8pwafznJ5FAGNT4eZ5 + HJchO7ZO4GL2ABFPA9KrwMhpQ49i9o0AiBL0VbI1YGKuFVA8PrksOtLaVTFZ05Dam12/ + kkg8v/nxI5XYvbHuDwSpQd97y5/H/Bw6GnKMeQc+NyUcEA7DdkNl/ZptWN9wlAD8BR6K + XQmPnS46hbXW6M9QmeFXfjA+NO4+cMGKJ5p5EzoGGr8OkkXQTiLMCOw4hMZBqDB351Nw + +Pyw== +MIME-Version: 1.0 +Received: by 10.52.67.134 with SMTP id n6mr16253903vdt.23.1341844608230; Mon, + 09 Jul 2012 07:36:48 -0700 (PDT) +Sender: peter.keen@gmail.com +Received: by 10.52.169.40 with HTTP; Mon, 9 Jul 2012 07:36:48 -0700 (PDT) +Date: Mon, 9 Jul 2012 07:36:48 -0700 +X-Google-Sender-Auth: l_bqwIBvqIxkAzirus5IPYOnQ5U +Message-ID: + +Subject: [PATCH] ruby: add all_tags method to Notmuch::Database +From: Peter Keen +To: notmuch@notmuchmail.org +Content-Type: multipart/alternative; boundary=20cf307f334237a57404c4668b36 +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Mon, 09 Jul 2012 14:36:51 -0000 + +--20cf307f334237a57404c4668b36 +Content-Type: text/plain; charset=ISO-8859-1 + +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) + +--20cf307f334237a57404c4668b36 +Content-Type: text/html; charset=ISO-8859-1 + +
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)
+

+ +--20cf307f334237a57404c4668b36-- -- 2.26.2