summaryrefslogtreecommitdiff
path: root/bindings/ruby
AgeCommit message (Collapse)Author
2023-05-29ruby: db: reorganize initializerFelipe Contreras
In order to make it more extensible. No functional changes. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2023-05-25ruby: query: fix get sortFelipe Contreras
The order was wrong, right now `query.sort` doesn't return a number. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2023-04-12ruby: remove FileNames objectFelipe Contreras
Not used anymore now that we return an array of strings directly. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2023-04-12ruby: filenames: return string array directlyFelipe Contreras
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2023-04-12ruby: add filenames helperFelipe Contreras
Right now it doesn't do much, but it will help for further reorganization. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2023-04-02ruby: remove Tags objectFelipe Contreras
Not used anymore now that we return an array of strings directly. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2023-04-02ruby: tags: return string array directlyFelipe Contreras
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2023-04-02ruby: add tags helperFelipe Contreras
Right now it doesn't do much, but it will help for further reorganization. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2023-03-31ruby: database: make path arg optionalFelipe Contreras
It can be automatically loaded from the configuration now. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2023-03-31ruby: use database_open_with_configFelipe Contreras
Fixes warning: warning: ‘notmuch_database_open’ is deprecated: function deprecated as of libnotmuch 5.4 Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-08-03ruby: cleanup object_destroy()Felipe Contreras
It was assumed the destructor of notmuch_rb_database_type did return a notmuch_status_t because that's what notmuch_database_close returns, and that value was checked by notmuch_rb_database_close in order to decide if to raise an exception. It turns out notmuch_database_destroy was called instead, so nothing was returned (void). All the destroy functions are void, and that's what we want. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-08-02ruby: split database close and destroyFelipe Contreras
Mirrors the C API: 7864350c (Split notmuch_database_close into two functions, 2012-04-25). Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-07-18ruby: enable garbage collection using tallocFelipe Contreras
We basically steal all the objects from their notmuch parents, therefore they are completely under Ruby's gc control. The order at which these objects are freed does not matter any more, because destroying the database does not destroy all the children objects, since they belong to Ruby now. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-07-18ruby: create an actual wrapper structFelipe Contreras
Currently Ruby data points directly to a notmuch object (e.g. notmuch_database_t), since we don't need any extra data that is fine. However, in the next commit we will need extra data, therefore we create a new struct notmuch_rb_object_t wrapper which contains nothing but a pointer to the current pointer (e.g. notmuch_database_t). This struct is tied to the Ruby object, and is freed when the Ruby object is freed by the garbage collector. We do nothing with this wrapper, so no functionality should be changed. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-06-27ruby: add keyword arguments to db.queryFelipe Contreras
That way we don't need pass them to the query object ourselves. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-05-23ruby: use notmuch_exclude_t enumFelipe Contreras
It exists since 2013, let's allow it to be used in Ruby. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-05-17ruby: new notmuch_rb_object_destroy() helperFelipe Contreras
The struct used to store the types (rb_data_type_t) contains a "data" field where we can store whatever we want. I use that field to store a pointer to the corresponding destroy function. For example notmuch_rb_database_type contains a pointer to notmuch_database_destroy. I cast that pointer as a notmuch_status_t (func*)(void *) and call that function passing the internal object (e.g. notmuch_database_t). Using the rb_data_type_t data we can call the correct notmuch destroy function. Therefore this: ret = ((notmuch_status_t (*)(void *)) type->data) (nm_object); Is effectively the same as this: ret = notmuch_database_destroy (database); The advantage of doing it this way is that much less code is necesary since each rb_data_type_t has the corresponding destroy function stored in it. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-05-17ruby: add all data typesFelipe Contreras
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-05-17ruby: move towards more modern RTypedDataFelipe Contreras
Virtually the whole ruby core moved from RData to RTypeData, let's do so ourselves too. Basically the information typically passed through Data_Wrap_Struct is now stored in a struct rb_data_type_t (mark and free functions). This has the advantage that more information can be easily added, like the name of the type, a custom data ponter, and more. Data_Wrap_Struct is replaced with TypedData_Wrap_Struct, and the information is stored in a struct rb_data_type_t, rather than passed as arguments. Check_Type is replaced with Check_TypedStruct, which is a wrapper for rb_check_typeddata (with casts). #define Check_TypedStruct(v, t) \ rb_check_typeddata(RBIMPL_CAST((VALUE)(v)), (t)) We can use rb_check_typeddata directly, just like we use rb_data_object_get directly. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-05-17ruby: create Data_Wrap_Notmuch_Object helperFelipe Contreras
This makes the code more maintainable and will help in further patches. No functional changes. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-05-17ruby: add unlikely hintFelipe Contreras
The error path is very unlikely. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-05-17ruby: fetch class name in case of errorFelipe Contreras
There is not much point in complicating the code for error messages that can be easily constructed. Before: database closed (RuntimeError) After: Notmuch::Database object destroyed (RuntimeError) Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-05-17ruby: simplify data get helperFelipe Contreras
Data_Get_Struct is nothing but a macro that calls rb_data_object_get with a cast (unnecessary in C). #define Data_Get_Struct(obj, type, sval) \ ((sval) = RBIMPL_CAST((type*)rb_data_object_get(obj))) We can use rb_data_object_get directly, and this way we don't need to pass the type, which is unnecessary information. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-05-12ruby: improve general data get helperFelipe Contreras
There's no need to do Check_Type, Data_Get_Struct calls rb_data_object_get(), which already does that. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-05-12ruby: improve all Data_Get_Notmuch_* helpersFelipe Contreras
There's no need to repeat the same code over and over. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-05-12ruby: add missing Data_Get_Notmuch helpersFelipe Contreras
Apparently commit 5c9e3855 (ruby: Don't barf if an object is destroyed more than once, 2010-05-26) missed these two. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-04-18ruby: fix ruby 3.1 warningsFelipe Contreras
init.c:214:5: warning: ‘rb_cData’ is deprecated: by: rb_cObject. Will be removed in 3.1. [-Wdeprecated-declarations] Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2020-07-18bindings/ruby: replacy use of deprecated notmuch_message_get_flagDavid Bremner
Depending on the flag, this actually can return an errror, so raise a ruby exception if so.
2017-08-23database: add n_d_index_file (deprecates n_d_add_message)Daniel Kahn Gillmor
We need a way to pass parameters to the indexing functionality on the first index, not just on reindexing. The obvious place is in notmuch_database_add_message. But since modifying the argument list would break both API and ABI, we needed a new name. I considered notmuch_database_add_message_with_params(), but the functionality we're talking about doesn't always add a message. It tries to index a specific file, possibly adding a message, but possibly doing other things, like adding terms to an existing message, or failing to deal with message objects entirely (e.g. because the file didn't contain a message). So i chose the function name notmuch_database_index_file. I confess i'm a little concerned about confusing future notmuch developers with the new name, since we already have a private _notmuch_message_index_file function, and the two do rather different things. But i think the added clarity for people linking against the future libnotmuch and the capacity for using index parameters makes this a worthwhile tradeoff. (that said, if anyone has another name that they strongly prefer, i'd be happy to go with it) This changeset also adjusts the tests so that we test whether the new, preferred function returns bad values (since the deprecated function just calls the new one). We can keep the deprecated n_d_add_message function around as long as we like, but at the next place where we're forced to break API or ABI we can probably choose to drop the name relatively safely. NOTE: there is probably more cleanup to do in the ruby and go bindings to complete the deprecation directly. I don't know those languages well enough to attempt a fix; i don't know how to test them; and i don't know the culture around those languages about API additions or deprecations.
2017-08-18Use rooted paths in .gitignore filesVladimir Panteleev
A leading / in paths in a .gitignore file matches the beginning of the path, meaning that for patterns without slashes, git will match files only in the current directory as opposed to in any subdirectory. Prefix relevant paths with / in .gitignore files, to prevent accidentally ignoring files in subdirectories and possibly slightly improve the performance of "git status".
2017-03-22lib: replace deprecated n_q_count_threads with status returning versionDavid Bremner
This function was deprecated in notmuch 0.21. We re-use the name for a status returning version, and deprecate the _st name.
2017-03-22lib: replace deprecated n_q_count_messages with status returning versionDavid Bremner
This function was deprecated in notmuch 0.21. We re-use the name for a status returning version, and deprecate the _st name. One or two remaining uses of the (removed) non-status returning version fixed at the same time
2017-03-22lib: replace deprecated n_q_search_messages with status returning versionDavid Bremner
This function was deprecated in notmuch 0.21. We re-use the name for a status returning version, and deprecate the _st name.
2017-03-22lib: replace n_query_search_threads with status returning versionDavid Bremner
This function was deprecated in notmuch 0.21. We finally remove the deprecated API, and rename the status returning version to the simpler name. The status returning is kept as a deprecated alias.
2017-03-12fix out of tree buildTomi Ollila
In addition to use ${srcdir} and deliver ${NOTMUCH_SRCDIR} where needed, source from ruby bindings had to be copied to the out-of-tree target directory -- if the source files in source directory were referenced in build and there were also built object files there, those could have been considered as target files (and then not found when attempting to create bindings/ruby/notmuch.so).
2016-06-05Use https instead of http where possibleDaniel Kahn Gillmor
Many of the external links found in the notmuch source can be resolved using https instead of http. This changeset addresses as many as i could find, without touching the e-mail corpus or expected outputs found in tests.
2016-05-19ruby: add bindings for `notmuch_database_get_all_tags`Ludovic LANGE
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! Amended by db: improve error reporting, add test
2015-10-05ruby: use new query_search APIDavid Bremner
These changes should not be too surprising for users because the routines were already potentially throwing exceptions.
2015-10-05ruby: use new count APIDavid Bremner
This change of replacing ignoring errors with exceptions is intended, and indeed one of the main motivations for the libnotmuch API changes.
2015-06-14build/ruby: use notmuch configure script values for shared libDavid Bremner
This is supposed to help build on systems like MacOS with different conventions for naming shared libraries. We have already computed the relevant names, so doing it again in ruby seems like a bad idea.
2015-06-13lib, ruby: make use of -Wl,--no-undefined configurableDavid Bremner
In particular this is supposed to help build on systems (presumably using a non-gnu ld) where this flag is not available.
2015-06-12build: integrate building ruby bindings into notmuch build processDavid Bremner
Because ruby generates a Makefile, we have to use recursive make. Because mkmf.rb hardcodes the name Makefile, put our Makefile{.local} in the parent directory.
2015-01-01bindings/ruby: gitignore *.oDavid Bremner
2014-09-16ruby: handle return status of database closePeter Wang
Throw an exception if notmuch_database_destroy fails.
2014-05-18ruby: Add wrapper for notmuch_query_count_threadsWael M. Nasreddine
2014-02-21ruby bindings message: docstring typoGaute Hope
2013-05-23ruby: use in-tree notmuch libraryFelipe Contreras
Currently it simply finds any library available, and if notmuch is installed in the system, it would give priority to that library. Let's implement our own helper functions to link directly to the local library, and give priority to the local header file. Also, add an option to properly check if there are missing symbols. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2013-05-23ruby: fix missing symbol UINT2FIX()Felipe Contreras
It has never existed in Ruby (maybe JRuby). Fortunately the symbols are loaded lazily, so nobody would notice unless they try 'query::count_messages'. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2013-02-18ruby: Add bindings for notmuch_thread_get_messagesAustin Clements
2012-06-29ruby: extern linkage portability improvementTomi Ollila
Some C compilers are stricter when it comes to (tentative) definition of a variable -- in those compilers introducing variable without 'extern' keyword always allocates new 'storage' to the variable and linking all these modules fails due to duplicate symbols. This is reimplementation of Charlie Allom's patch: id:"1336481467-66356-1-git-send-email-charlie@mediasp.com", written originally by Ali Polatel. This version has more accurate commit message.