aboutsummaryrefslogtreecommitdiff
path: root/lib/some
diff options
context:
space:
mode:
Diffstat (limited to 'lib/some')
l---------lib/some/.#messages.rb1
-rw-r--r--lib/some/database.rb15
-rw-r--r--lib/some/helpers.rb13
-rw-r--r--lib/some/message.rb23
-rw-r--r--lib/some/messages.rb39
5 files changed, 91 insertions, 0 deletions
diff --git a/lib/some/.#messages.rb b/lib/some/.#messages.rb
new file mode 120000
index 0000000..b1e8e06
--- /dev/null
+++ b/lib/some/.#messages.rb
@@ -0,0 +1 @@
+mms@voyager.local.90786:1730615032 \ No newline at end of file
diff --git a/lib/some/database.rb b/lib/some/database.rb
new file mode 100644
index 0000000..5595a41
--- /dev/null
+++ b/lib/some/database.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+module Some
+ class Database
+ attr_reader :db
+
+ def initialize(path:)
+ @db = ::Notmuch::Database.new(path)
+ end
+
+ def query(query)
+ db.query(query)
+ end
+ end
+end
diff --git a/lib/some/helpers.rb b/lib/some/helpers.rb
new file mode 100644
index 0000000..5842f73
--- /dev/null
+++ b/lib/some/helpers.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+module Some
+ module Helpers
+ def header_name_from_dsl(method_name)
+ method_name
+ .to_s
+ .split('_')
+ .map(&:capitalize)
+ .join('-')
+ end
+ end
+end
diff --git a/lib/some/message.rb b/lib/some/message.rb
new file mode 100644
index 0000000..47e397e
--- /dev/null
+++ b/lib/some/message.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+module Some
+ class Message
+ attr_reader :message
+
+ def initialize(msg:)
+ @message = msg
+ end
+
+ def method_missing(method_name, *_args)
+ handle_get(Helpers.header_name_from_dsl(method_name))
+ end
+
+ def handle_get(header_name)
+ message.header(header_name) if message.header(header_name)
+ end
+
+ def tags
+ @message.tags
+ end
+ end
+end
diff --git a/lib/some/messages.rb b/lib/some/messages.rb
new file mode 100644
index 0000000..2f89d2b
--- /dev/null
+++ b/lib/some/messages.rb
@@ -0,0 +1,39 @@
+# frozen_string_literal: true
+
+module Some
+ class Messages
+ AND_CONJUCTION = :and
+ OR_CONJUCTION = :or
+ DEFAULT_CONJUCTION = AND_CONJUCTION
+
+ attr_reader :query, :current_conjuction
+
+ def initialize
+ @query = []
+ @current_conjuction = AND_CONJUCTION
+ end
+
+ def or
+ @current_conjuction = OR_CONJUCTION
+ self
+ end
+
+ def filter(params)
+ query << params.map do |key, value|
+ unless value.is_a? Array
+ [current_conjuction, key, value.to_sym]
+ else
+
+ [current_conjuction,
+ value.map { |subarg| [OR_CONJUCTION, key, subarg] }]
+ end
+ end
+
+ self
+ end
+
+ def query_string
+
+ end
+ end
+end