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 5601F431FC3 for ; Sun, 16 Nov 2014 12:36:18 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_NONE=-0.0001] 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 wdeNssfuSH4N for ; Sun, 16 Nov 2014 12:36:10 -0800 (PST) X-Greylist: delayed 1205 seconds by postgrey-1.32 at olra; Sun, 16 Nov 2014 12:36:10 PST Received: from mo68.mail-out.ovh.net (4.mo68.mail-out.ovh.net [46.105.59.63]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 7D9CA431FCB for ; Sun, 16 Nov 2014 12:36:10 -0800 (PST) Received: from mail432.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo68.mail-out.ovh.net (Postfix) with SMTP id 5F9E1FFB07F for ; Sun, 16 Nov 2014 20:58:15 +0100 (CET) Received: from b0.ovh.net (HELO queueout) (213.186.33.50) by b0.ovh.net with SMTP; 16 Nov 2014 21:58:15 +0200 Received: from 112.248.broadband7.iol.cz (HELO snek) (llange@agisvoyages.com@88.102.248.112) by ns0.ovh.net with SMTP; 16 Nov 2014 21:58:14 +0200 From: Ludovic LANGE To: notmuch@notmuchmail.org Subject: [PATCH] ruby: add bindings for `notmuch_database_get_all_tags` Date: Sun, 16 Nov 2014 20:58:12 +0100 Message-Id: <1416167892-15686-1-git-send-email-ll-notmuchmail@lange.nom.fr> X-Mailer: git-send-email 1.8.0 X-Ovh-Tracer-Id: 132293241084504854 X-Ovh-Remote: 88.102.248.112 (112.248.broadband7.iol.cz) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-OVH-SPAMSTATE: OK X-OVH-SPAMSCORE: 0 X-OVH-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeejhedrjeekucetufdoteggodetrfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecu X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeejhedrjeekucetufdoteggodetrfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecu X-Mailman-Approved-At: Mon, 17 Nov 2014 01:37:28 -0800 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: Sun, 16 Nov 2014 20:36:18 -0000 The Ruby bindings were missing a way to get all the tags of the database. Now you should be able to access this with the public instance method `all_tags` of your database object. Example of use: notmuchdb = Notmuch::Database.new path, { :create => false, :mode => Notmuch::MODE_READ_ONLY } my_tags = notmuchdb.all_tags my_tags.each { |tag| print tag } my_tags.destroy! --- NEWS | 9 +++++++++ bindings/ruby/database.c | 20 ++++++++++++++++++++ bindings/ruby/defs.h | 3 +++ bindings/ruby/init.c | 1 + 4 files changed, 33 insertions(+) diff --git a/NEWS b/NEWS index 44e8d05..bcd368f 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,12 @@ +Notmuch X.XX (201X-XX-XX) +========================= + +Ruby Bindings +------------- + +Add support for `notmuch_database_get_all_tags` + + Notmuch 0.19 (2014-11-14) ========================= diff --git a/bindings/ruby/database.c b/bindings/ruby/database.c index c03d701..dd36ca8 100644 --- a/bindings/ruby/database.c +++ b/bindings/ruby/database.c @@ -375,6 +375,26 @@ notmuch_rb_database_find_message_by_filename (VALUE self, VALUE pathv) } /* + * call-seq: DB.get_all_tags() => TAGS + * + * Returns a list of all tags found 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); +} + +/* * call-seq: DB.query(query) => QUERY * * Retrieve a query object for the query string 'query' diff --git a/bindings/ruby/defs.h b/bindings/ruby/defs.h index f4901a0..167250e 100644 --- a/bindings/ruby/defs.h +++ b/bindings/ruby/defs.h @@ -178,6 +178,9 @@ VALUE notmuch_rb_database_find_message_by_filename (VALUE self, VALUE pathv); VALUE +notmuch_rb_database_get_all_tags (VALUE self); + +VALUE notmuch_rb_database_query_create (VALUE self, VALUE qstrv); /* directory.c */ diff --git a/bindings/ruby/init.c b/bindings/ruby/init.c index ab3f22d..865d6bf 100644 --- a/bindings/ruby/init.c +++ b/bindings/ruby/init.c @@ -229,6 +229,7 @@ Init_notmuch (void) notmuch_rb_database_find_message, 1); /* in database.c */ 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, "all_tags", notmuch_rb_database_get_all_tags, 0); /* in database.c */ rb_define_method (notmuch_rb_cDatabase, "query", notmuch_rb_database_query_create, 1); /* in database.c */ /* -- 1.8.0