unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH 0/4] Update Ruby bindings
@ 2011-01-10 14:39 Ali Polatel
  2011-01-10 14:39 ` [PATCH 1/4] ruby: Add wrappers for query_get_s{ort,tring} Ali Polatel
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Ali Polatel @ 2011-01-10 14:39 UTC (permalink / raw)
  To: notmuch

Hello all,

This patchset updates Ruby bindings to cover all the recent
functionality of the notmuch library.

Ali Polatel (4):
  ruby: Add wrappers for query_get_s{ort,tring}
  ruby: Add wrappers for maildir sync. interface
  ruby: Add wrapper for message_get_filenames
  ruby: Add generated files to gitignore

 .gitignore              |    4 +++
 bindings/ruby/defs.h    |   15 ++++++++++++
 bindings/ruby/init.c    |    5 ++++
 bindings/ruby/message.c |   56 +++++++++++++++++++++++++++++++++++++++++++++++
 bindings/ruby/query.c   |   30 +++++++++++++++++++++++++
 5 files changed, 110 insertions(+), 0 deletions(-)

-- 
1.7.3.5

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/4] ruby: Add wrappers for query_get_s{ort,tring}
  2011-01-10 14:39 [PATCH 0/4] Update Ruby bindings Ali Polatel
@ 2011-01-10 14:39 ` Ali Polatel
  2011-01-10 14:39 ` [PATCH 2/4] ruby: Add wrappers for maildir sync. interface Ali Polatel
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Ali Polatel @ 2011-01-10 14:39 UTC (permalink / raw)
  To: notmuch

New wrappers:
notmuch_query_get_sort(): QUERY.sort
notmuch_query_get_query_string(): QUERY.to_s
---
 bindings/ruby/defs.h  |    6 ++++++
 bindings/ruby/init.c  |    2 ++
 bindings/ruby/query.c |   30 ++++++++++++++++++++++++++++++
 3 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/bindings/ruby/defs.h b/bindings/ruby/defs.h
index b1be5a3..db53096 100644
--- a/bindings/ruby/defs.h
+++ b/bindings/ruby/defs.h
@@ -190,9 +190,15 @@ VALUE
 notmuch_rb_query_destroy(VALUE self);
 
 VALUE
+notmuch_rb_query_get_sort(VALUE self);
+
+VALUE
 notmuch_rb_query_set_sort(VALUE self, VALUE sortv);
 
 VALUE
+notmuch_rb_query_get_string(VALUE self);
+
+VALUE
 notmuch_rb_query_search_threads(VALUE self);
 
 VALUE
diff --git a/bindings/ruby/init.c b/bindings/ruby/init.c
index e19b035..63ab205 100644
--- a/bindings/ruby/init.c
+++ b/bindings/ruby/init.c
@@ -224,7 +224,9 @@ Init_notmuch(void)
     notmuch_rb_cQuery = rb_define_class_under(mod, "Query", rb_cData);
     rb_undef_method(notmuch_rb_cQuery, "initialize");
     rb_define_method(notmuch_rb_cQuery, "destroy", notmuch_rb_query_destroy, 0);
+    rb_define_method(notmuch_rb_cQuery, "sort", notmuch_rb_query_get_sort, 0);
     rb_define_method(notmuch_rb_cQuery, "sort=", notmuch_rb_query_set_sort, 1);
+    rb_define_method(notmuch_rb_cQuery, "to_s", notmuch_rb_query_get_string, 0);
     rb_define_method(notmuch_rb_cQuery, "search_threads", notmuch_rb_query_search_threads, 0);
     rb_define_method(notmuch_rb_cQuery, "search_messages", notmuch_rb_query_search_messages, 0);
 
diff --git a/bindings/ruby/query.c b/bindings/ruby/query.c
index c5b8a4c..ef9e1a0 100644
--- a/bindings/ruby/query.c
+++ b/bindings/ruby/query.c
@@ -39,6 +39,21 @@ notmuch_rb_query_destroy(VALUE self)
 }
 
 /*
+ * call-seq: QUERY.sort => fixnum
+ *
+ * Get sort type of the +QUERY+
+ */
+VALUE
+notmuch_rb_query_get_sort(VALUE self)
+{
+    notmuch_query_t *query;
+
+    Data_Get_Notmuch_Query(self, query);
+
+    return FIX2INT(notmuch_query_get_sort(query));
+}
+
+/*
  * call-seq: QUERY.sort=(fixnum) => nil
  *
  * Set sort type of the +QUERY+
@@ -59,6 +74,21 @@ notmuch_rb_query_set_sort(VALUE self, VALUE sortv)
 }
 
 /*
+ * call-seq: QUERY.to_s => string
+ *
+ * Get query string of the +QUERY+
+ */
+VALUE
+notmuch_rb_query_get_string(VALUE self)
+{
+    notmuch_query_t *query;
+
+    Data_Get_Notmuch_Query(self, query);
+
+    return rb_str_new2(notmuch_query_get_query_string(query));
+}
+
+/*
  * call-seq: QUERY.search_threads => THREADS
  *
  * Search for threads
-- 
1.7.3.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/4] ruby: Add wrappers for maildir sync. interface
  2011-01-10 14:39 [PATCH 0/4] Update Ruby bindings Ali Polatel
  2011-01-10 14:39 ` [PATCH 1/4] ruby: Add wrappers for query_get_s{ort,tring} Ali Polatel
@ 2011-01-10 14:39 ` Ali Polatel
  2011-01-10 14:39 ` [PATCH 3/4] ruby: Add wrapper for message_get_filenames Ali Polatel
  2011-01-10 14:39 ` [PATCH 4/4] ruby: Add generated files to gitignore Ali Polatel
  3 siblings, 0 replies; 7+ messages in thread
From: Ali Polatel @ 2011-01-10 14:39 UTC (permalink / raw)
  To: notmuch

New wrappers:
notmuch_message_maildir_flags_to_tags(): MESSAGE.maildir_flags_to_tags
notmuch_message_tags_to_maildir_flags(): MESSAGE.tags_to_maildir_flags
---
 bindings/ruby/defs.h    |    6 ++++++
 bindings/ruby/init.c    |    2 ++
 bindings/ruby/message.c |   38 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/bindings/ruby/defs.h b/bindings/ruby/defs.h
index db53096..1f52988 100644
--- a/bindings/ruby/defs.h
+++ b/bindings/ruby/defs.h
@@ -293,6 +293,12 @@ VALUE
 notmuch_rb_message_remove_all_tags(VALUE self);
 
 VALUE
+notmuch_rb_message_maildir_flags_to_tags(VALUE self);
+
+VALUE
+notmuch_rb_message_tags_to_maildir_flags(VALUE self);
+
+VALUE
 notmuch_rb_message_freeze(VALUE self);
 
 VALUE
diff --git a/bindings/ruby/init.c b/bindings/ruby/init.c
index 63ab205..4a63ba0 100644
--- a/bindings/ruby/init.c
+++ b/bindings/ruby/init.c
@@ -273,6 +273,8 @@ Init_notmuch(void)
     rb_define_alias(notmuch_rb_cMessage, "<<", "add_tag");
     rb_define_method(notmuch_rb_cMessage, "remove_tag", notmuch_rb_message_remove_tag, 1);
     rb_define_method(notmuch_rb_cMessage, "remove_all_tags", notmuch_rb_message_remove_all_tags, 0);
+    rb_define_method(notmuch_rb_cMessage, "maildir_flags_to_tags", notmuch_rb_message_maildir_flags_to_tags, 0);
+    rb_define_method(notmuch_rb_cMessage, "tags_to_maildir_flags", notmuch_rb_message_tags_to_maildir_flags, 0);
     rb_define_method(notmuch_rb_cMessage, "freeze", notmuch_rb_message_freeze, 0);
     rb_define_method(notmuch_rb_cMessage, "thaw", notmuch_rb_message_thaw, 0);
 
diff --git a/bindings/ruby/message.c b/bindings/ruby/message.c
index f97e1a4..1b2c01e 100644
--- a/bindings/ruby/message.c
+++ b/bindings/ruby/message.c
@@ -284,6 +284,44 @@ notmuch_rb_message_remove_all_tags(VALUE self)
 }
 
 /*
+ * call-seq: MESSAGE.maildir_flags_to_tags => true
+ *
+ * Add/remove tags according to maildir flags in the message filename(s)
+ */
+VALUE
+notmuch_rb_message_maildir_flags_to_tags(VALUE self)
+{
+    notmuch_status_t ret;
+    notmuch_message_t *message;
+
+    Data_Get_Notmuch_Message(self, message);
+
+    ret = notmuch_message_maildir_flags_to_tags(message);
+    notmuch_rb_status_raise(ret);
+
+    return Qtrue;
+}
+
+/*
+ * call-seq: MESSAGE.tags_to_maildir_flags => true
+ *
+ * Rename message filename(s) to encode tags as maildir flags
+ */
+VALUE
+notmuch_rb_message_tags_to_maildir_flags(VALUE self)
+{
+    notmuch_status_t ret;
+    notmuch_message_t *message;
+
+    Data_Get_Notmuch_Message(self, message);
+
+    ret = notmuch_message_tags_to_maildir_flags(message);
+    notmuch_rb_status_raise(ret);
+
+    return Qtrue;
+}
+
+/*
  * call-seq: MESSAGE.freeze => true
  *
  * Freeze the 'message'
-- 
1.7.3.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/4] ruby: Add wrapper for message_get_filenames
  2011-01-10 14:39 [PATCH 0/4] Update Ruby bindings Ali Polatel
  2011-01-10 14:39 ` [PATCH 1/4] ruby: Add wrappers for query_get_s{ort,tring} Ali Polatel
  2011-01-10 14:39 ` [PATCH 2/4] ruby: Add wrappers for maildir sync. interface Ali Polatel
@ 2011-01-10 14:39 ` Ali Polatel
  2011-01-10 14:39 ` [PATCH 4/4] ruby: Add generated files to gitignore Ali Polatel
  3 siblings, 0 replies; 7+ messages in thread
From: Ali Polatel @ 2011-01-10 14:39 UTC (permalink / raw)
  To: notmuch

---
 bindings/ruby/defs.h    |    3 +++
 bindings/ruby/init.c    |    1 +
 bindings/ruby/message.c |   18 ++++++++++++++++++
 3 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/bindings/ruby/defs.h b/bindings/ruby/defs.h
index 1f52988..f00afef 100644
--- a/bindings/ruby/defs.h
+++ b/bindings/ruby/defs.h
@@ -269,6 +269,9 @@ VALUE
 notmuch_rb_message_get_filename(VALUE self);
 
 VALUE
+notmuch_rb_message_get_filenames(VALUE self);
+
+VALUE
 notmuch_rb_message_get_flag(VALUE self, VALUE flagv);
 
 VALUE
diff --git a/bindings/ruby/init.c b/bindings/ruby/init.c
index 4a63ba0..aa09c8d 100644
--- a/bindings/ruby/init.c
+++ b/bindings/ruby/init.c
@@ -263,6 +263,7 @@ Init_notmuch(void)
     rb_define_method(notmuch_rb_cMessage, "thread_id", notmuch_rb_message_get_thread_id, 0);
     rb_define_method(notmuch_rb_cMessage, "replies", notmuch_rb_message_get_replies, 0);
     rb_define_method(notmuch_rb_cMessage, "filename", notmuch_rb_message_get_filename, 0);
+    rb_define_method(notmuch_rb_cMessage, "filenames", notmuch_rb_message_get_filenames, 0);
     rb_define_method(notmuch_rb_cMessage, "get_flag", notmuch_rb_message_get_flag, 1);
     rb_define_method(notmuch_rb_cMessage, "set_flag", notmuch_rb_message_set_flag, 2);
     rb_define_method(notmuch_rb_cMessage, "date", notmuch_rb_message_get_date, 0);
diff --git a/bindings/ruby/message.c b/bindings/ruby/message.c
index 1b2c01e..49dbace 100644
--- a/bindings/ruby/message.c
+++ b/bindings/ruby/message.c
@@ -111,6 +111,24 @@ notmuch_rb_message_get_filename(VALUE self)
 }
 
 /*
+ * call-seq: MESSAGE.filanames => FILENAMES
+ *
+ * Get all filenames for the email corresponding to MESSAGE.
+ */
+VALUE
+notmuch_rb_message_get_filenames(VALUE self)
+{
+    notmuch_filenames_t *fnames;
+    notmuch_message_t *message;
+
+    Data_Get_Notmuch_Message(self, message);
+
+    fnames = notmuch_message_get_filenames(message);
+
+    return Data_Wrap_Struct(notmuch_rb_cFileNames, NULL, NULL, fnames);
+}
+
+/*
  * call-seq: MESSAGE.get_flag(flag) => true or false
  *
  * Get a value of a flag for the email corresponding to 'message'
-- 
1.7.3.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/4] ruby: Add generated files to gitignore
  2011-01-10 14:39 [PATCH 0/4] Update Ruby bindings Ali Polatel
                   ` (2 preceding siblings ...)
  2011-01-10 14:39 ` [PATCH 3/4] ruby: Add wrapper for message_get_filenames Ali Polatel
@ 2011-01-10 14:39 ` Ali Polatel
  2011-01-31 22:48   ` Thomas Schwinge
  3 siblings, 1 reply; 7+ messages in thread
From: Ali Polatel @ 2011-01-10 14:39 UTC (permalink / raw)
  To: notmuch

---
 .gitignore |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore
index 217440d..9786d4d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,3 +13,7 @@ libnotmuch.so*
 .*.swp
 *.elc
 releases
+
+bindings/ruby/mkmf.log
+bindings/ruby/notmuch.so
+bindings/ruby/Makefile
-- 
1.7.3.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 4/4] ruby: Add generated files to gitignore
  2011-01-10 14:39 ` [PATCH 4/4] ruby: Add generated files to gitignore Ali Polatel
@ 2011-01-31 22:48   ` Thomas Schwinge
  2011-02-02 23:42     ` Ali Polatel
  0 siblings, 1 reply; 7+ messages in thread
From: Thomas Schwinge @ 2011-01-31 22:48 UTC (permalink / raw)
  To: Ali Polatel, notmuch

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

Hallo!

On Mon, 10 Jan 2011 16:39:28 +0200, Ali Polatel <alip@exherbo.org> wrote:
> --- a/.gitignore
> +++ b/.gitignore
> @@ -13,3 +13,7 @@ libnotmuch.so*
>  .*.swp
>  *.elc
>  releases
> +
> +bindings/ruby/mkmf.log
> +bindings/ruby/notmuch.so
> +bindings/ruby/Makefile

These should rather be put into bindings/ruby/.gitignore, I'd say.


Grüße,
 Thomas

[-- Attachment #2: Type: application/pgp-signature, Size: 489 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 4/4] ruby: Add generated files to gitignore
  2011-01-31 22:48   ` Thomas Schwinge
@ 2011-02-02 23:42     ` Ali Polatel
  0 siblings, 0 replies; 7+ messages in thread
From: Ali Polatel @ 2011-02-02 23:42 UTC (permalink / raw)
  To: Thomas Schwinge, notmuch

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

On Mon, 31 Jan 2011 23:48:57 +0100, Thomas Schwinge <thomas@schwinge.name> wrote:
> Hallo!
> 
> On Mon, 10 Jan 2011 16:39:28 +0200, Ali Polatel <alip@exherbo.org> wrote:
> > --- a/.gitignore
> > +++ b/.gitignore
> > @@ -13,3 +13,7 @@ libnotmuch.so*
> >  .*.swp
> >  *.elc
> >  releases
> > +
> > +bindings/ruby/mkmf.log
> > +bindings/ruby/notmuch.so
> > +bindings/ruby/Makefile
> 
> These should rather be put into bindings/ruby/.gitignore, I'd say.

Good idea!
Just pushed ca69ce2397c0bb9b0e590a80b898ab4d544448bb

> 
> Grüße,
>  Thomas

-- 
Regards,
Ali Polatel

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-02-02 23:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-10 14:39 [PATCH 0/4] Update Ruby bindings Ali Polatel
2011-01-10 14:39 ` [PATCH 1/4] ruby: Add wrappers for query_get_s{ort,tring} Ali Polatel
2011-01-10 14:39 ` [PATCH 2/4] ruby: Add wrappers for maildir sync. interface Ali Polatel
2011-01-10 14:39 ` [PATCH 3/4] ruby: Add wrapper for message_get_filenames Ali Polatel
2011-01-10 14:39 ` [PATCH 4/4] ruby: Add generated files to gitignore Ali Polatel
2011-01-31 22:48   ` Thomas Schwinge
2011-02-02 23:42     ` Ali Polatel

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