From acc8415d7109e8fb45bbfcd8cf545ebcf5b5d16a Mon Sep 17 00:00:00 2001 From: mms Date: Thu, 7 Nov 2024 14:57:41 +0100 Subject: init spike --- lib/some.rb | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 lib/some.rb (limited to 'lib/some.rb') diff --git a/lib/some.rb b/lib/some.rb new file mode 100644 index 0000000..7e1dbdb --- /dev/null +++ b/lib/some.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +require 'notmuch' +require 'pry' + +require_relative 'some/database' +require_relative 'some/message' +require_relative 'some/messages' +require_relative 'some/helpers' + +module Some + class Some + def initialize + @db = Database.new(path: '/home/mms/mail') + end + + def with_filter(filter_string) + db.query(filter_string).search_messages.each do |msg| + yield Message.new(msg: msg) + end + rescue StandardError => e + p e + end + + private + + attr_reader :db + end +end + +p Some::Messages.new + .filter(from: 'janek', tags: [1, 2]) + .or.filter(subject: 'a') + .query_string -- cgit v1.2.3