1 Return-Path: <bremner@tethera.net>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by arlo.cworth.org (Postfix) with ESMTP id 3BBD76DE1348
\r
6 for <notmuch@notmuchmail.org>; Sun, 6 Mar 2016 03:56:43 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org
\r
11 X-Spam-Status: No, score=-0.034 tagged_above=-999 required=5
\r
12 tests=[AWL=-0.023, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01]
\r
14 Received: from arlo.cworth.org ([127.0.0.1])
\r
15 by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id zT9V4IXtKhI3 for <notmuch@notmuchmail.org>;
\r
17 Sun, 6 Mar 2016 03:56:40 -0800 (PST)
\r
18 Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197])
\r
19 by arlo.cworth.org (Postfix) with ESMTPS id AE3156DE021D
\r
20 for <notmuch@notmuchmail.org>; Sun, 6 Mar 2016 03:56:40 -0800 (PST)
\r
21 Received: from remotemail by fethera.tethera.net with local (Exim 4.84)
\r
22 (envelope-from <bremner@tethera.net>)
\r
23 id 1acXJD-0000tn-BY; Sun, 06 Mar 2016 06:57:15 -0500
\r
24 Received: (nullmailer pid 3486 invoked by uid 1000);
\r
25 Sun, 06 Mar 2016 11:56:35 -0000
\r
26 From: David Bremner <david@tethera.net>
\r
27 To: Ludovic LANGE <ll-notmuchmail@lange.nom.fr>, notmuch@notmuchmail.org
\r
28 Subject: [PATCH] ruby: add bindings for `notmuch_database_get_all_tags`
\r
29 Date: Sun, 6 Mar 2016 07:56:28 -0400
\r
30 Message-Id: <1457265388-3434-1-git-send-email-david@tethera.net>
\r
31 X-Mailer: git-send-email 2.7.0
\r
32 In-Reply-To: <1416167892-15686-1-git-send-email-ll-notmuchmail@lange.nom.fr>
\r
33 References: <1416167892-15686-1-git-send-email-ll-notmuchmail@lange.nom.fr>
\r
34 X-BeenThere: notmuch@notmuchmail.org
\r
35 X-Mailman-Version: 2.1.20
\r
37 List-Id: "Use and development of the notmuch mail system."
\r
38 <notmuch.notmuchmail.org>
\r
39 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,
\r
40 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
41 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>
\r
42 List-Post: <mailto:notmuch@notmuchmail.org>
\r
43 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
44 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,
\r
45 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
46 X-List-Received-Date: Sun, 06 Mar 2016 11:56:43 -0000
\r
48 From: Ludovic LANGE <ll-notmuchmail@lange.nom.fr>
\r
50 The Ruby bindings were missing a way to get all the tags of the
\r
51 database. Now you should be able to access this with the public
\r
52 instance method `all_tags` of your database object.
\r
55 notmuchdb = Notmuch::Database.new path, { :create => false,
\r
56 :mode => Notmuch::MODE_READ_ONLY }
\r
58 my_tags = notmuchdb.all_tags
\r
60 my_tags.each { |tag|
\r
66 Amended by db: improve error reporting, add test
\r
69 I'm not super happy with the "%s", but apparently the compiler is not smart enough to accept just "msg" there.
\r
72 bindings/ruby/database.c | 24 ++++++++++++++++++++++++
\r
73 bindings/ruby/defs.h | 3 +++
\r
74 bindings/ruby/init.c | 1 +
\r
75 test/T395-ruby.sh | 16 ++++++++++++++++
\r
76 5 files changed, 49 insertions(+)
\r
78 diff --git a/NEWS b/NEWS
\r
79 index 613fdfe..43dc5e0 100644
\r
83 Notmuch 0.22 (UNRELEASED)
\r
84 =========================
\r
89 +Add support for `notmuch_database_get_all_tags`
\r
94 diff --git a/bindings/ruby/database.c b/bindings/ruby/database.c
\r
95 index c03d701..6deda57 100644
\r
96 --- a/bindings/ruby/database.c
\r
97 +++ b/bindings/ruby/database.c
\r
98 @@ -375,6 +375,30 @@ notmuch_rb_database_find_message_by_filename (VALUE self, VALUE pathv)
\r
102 + * call-seq: DB.get_all_tags() => TAGS
\r
104 + * Returns a list of all tags found in the database.
\r
107 +notmuch_rb_database_get_all_tags (VALUE self)
\r
109 + notmuch_database_t *db;
\r
110 + notmuch_tags_t *tags;
\r
112 + Data_Get_Notmuch_Database (self, db);
\r
114 + tags = notmuch_database_get_all_tags (db);
\r
116 + const char *msg = notmuch_database_status_string (db);
\r
118 + msg = "Unknown notmuch error";
\r
120 + rb_raise (notmuch_rb_eBaseError, "%s", msg);
\r
122 + return Data_Wrap_Struct (notmuch_rb_cTags, NULL, NULL, tags);
\r
126 * call-seq: DB.query(query) => QUERY
\r
128 * Retrieve a query object for the query string 'query'
\r
129 diff --git a/bindings/ruby/defs.h b/bindings/ruby/defs.h
\r
130 index f4901a0..167250e 100644
\r
131 --- a/bindings/ruby/defs.h
\r
132 +++ b/bindings/ruby/defs.h
\r
133 @@ -178,6 +178,9 @@ VALUE
\r
134 notmuch_rb_database_find_message_by_filename (VALUE self, VALUE pathv);
\r
137 +notmuch_rb_database_get_all_tags (VALUE self);
\r
140 notmuch_rb_database_query_create (VALUE self, VALUE qstrv);
\r
143 diff --git a/bindings/ruby/init.c b/bindings/ruby/init.c
\r
144 index ab3f22d..865d6bf 100644
\r
145 --- a/bindings/ruby/init.c
\r
146 +++ b/bindings/ruby/init.c
\r
147 @@ -229,6 +229,7 @@ Init_notmuch (void)
\r
148 notmuch_rb_database_find_message, 1); /* in database.c */
\r
149 rb_define_method (notmuch_rb_cDatabase, "find_message_by_filename",
\r
150 notmuch_rb_database_find_message_by_filename, 1); /* in database.c */
\r
151 + rb_define_method (notmuch_rb_cDatabase, "all_tags", notmuch_rb_database_get_all_tags, 0); /* in database.c */
\r
152 rb_define_method (notmuch_rb_cDatabase, "query", notmuch_rb_database_query_create, 1); /* in database.c */
\r
155 diff --git a/test/T395-ruby.sh b/test/T395-ruby.sh
\r
156 index d5cade8..20e0691 100755
\r
157 --- a/test/T395-ruby.sh
\r
158 +++ b/test/T395-ruby.sh
\r
159 @@ -83,4 +83,20 @@ EOF
\r
160 notmuch count --output=threads tag:inbox > EXPECTED
\r
161 test_expect_equal_file OUTPUT EXPECTED
\r
163 +test_begin_subtest "get all tags"
\r
166 +$maildir = ENV['MAIL_DIR']
\r
167 +if not $maildir then
\r
168 + abort('environment variable MAIL_DIR must be set')
\r
170 +@db = Notmuch::Database.new($maildir)
\r
171 +@t = @db.all_tags()
\r
176 +notmuch search --output=tags '*' > EXPECTED
\r
177 +test_expect_equal_file OUTPUT EXPECTED
\r