From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id eDW5L79v22D1QQAAgWs5BA (envelope-from ) for ; Tue, 29 Jun 2021 21:08:47 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id WGpTK79v22CyYgAAbx9fmQ (envelope-from ) for ; Tue, 29 Jun 2021 19:08:47 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [144.217.243.247]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id D0A8932C4F for ; Tue, 29 Jun 2021 21:08:46 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id B9C2A290AD; Tue, 29 Jun 2021 15:08:41 -0400 (EDT) Received: from mail-oi1-x22c.google.com (mail-oi1-x22c.google.com [IPv6:2607:f8b0:4864:20::22c]) by mail.notmuchmail.org (Postfix) with ESMTPS id AC8B6290A2 for ; Tue, 29 Jun 2021 15:08:38 -0400 (EDT) Received: by mail-oi1-x22c.google.com with SMTP id t3so4519022oic.5 for ; Tue, 29 Jun 2021 12:08:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=BfYdEtbFgbr/je2+i39crh3mEkzKtbnPf6kzCq3+KEo=; b=YekDGSdX4OSHSymWM22tHxxGYvwrVmEA7Unmh/xYuiOvnCWHbaRPCYnCub/thmtwTe lFhMyVwRO2VKI1+HiWSzyqHOk/JPY9Wg+FmL64ZEO4gCX85UyzaIRWVa0/7Eop14sUaj rIC+j0p+2qvykJ3Yo8eRTbQjnCWCRagCCZpHpPfn2yTk/Yi86d4cIzycHZ/96FbaXVSs 88Y4Cjz1eFdGd35UroX+f7g1cRSA16+0KGPd46cLks9rjM3Y7E/5D9/BiIFpq5yJ/eAP enxLaCa4eTtmVMQMy+N3AQqQsigw+PVzrRo4hhoqiS6RknYq7Zssz0LqZoHb8vCkMyU0 eaOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=BfYdEtbFgbr/je2+i39crh3mEkzKtbnPf6kzCq3+KEo=; b=gmGW+ItmRYetaY5uJxZbVfGi4DsafkQHRebzFpUSMGul5INmIexCbvusxjOBR0i/gV usMNdWZ5DATOdLw+u3WbtqzYZXrvStVxmuLeUxNR4nTWID6CwYu2rE0lMT0H93Fdyx0U QQhCtkQTjSRpRhGfD2zuYutN4Khi9Ssdl8EUc/Vxx5iKQ9Gs82+ylnplHzvSWuKDlsGY 1MkxFYzAod/cIoWKX1UrkPgfZJZe1opYRPvuvVu+gyPoKhIUDNVwjPVNOkOKquLfShtQ za4TMrH/WklfqcxW+czJk8uvsDxTrJiY0H3XKdOqy6ILQ6HjypnVpIB0YP+lgJxo+o/W So6w== X-Gm-Message-State: AOAM531uIS/k5qN528fRdfJc5JWz86G9LwriYxeb0zqUahS7tuy6OlpS Hs+y5M3mZfXjdiWvVJ3jiQs/747HpXJEHQ== X-Google-Smtp-Source: ABdhPJzNofFM/kf8Bgd+aHnB7cq62kKSUEW+NdAZgBs3PJm/GoF/KNf6kBNBJXSNBK6ybMWpMpkWKg== X-Received: by 2002:a54:4713:: with SMTP id k19mr293513oik.86.1624993717551; Tue, 29 Jun 2021 12:08:37 -0700 (PDT) Received: from localhost (fixed-187-189-165-231.totalplay.net. [187.189.165.231]) by smtp.gmail.com with ESMTPSA id r1sm4385227oth.19.2021.06.29.12.08.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Jun 2021 12:08:37 -0700 (PDT) From: Felipe Contreras To: notmuch@notmuchmail.org Cc: David Bremner , Felipe Contreras Subject: [PATCH v2 0/3] ruby: add latest config API Date: Tue, 29 Jun 2021 14:08:32 -0500 Message-Id: <20210629190835.19381-1-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Message-ID-Hash: WMM2E4ZC6RAGXFZGE3UMUESXPXJD6KK6 X-Message-ID-Hash: WMM2E4ZC6RAGXFZGE3UMUESXPXJD6KK6 X-MailFrom: felipe.contreras@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1624993727; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=pTPyBzVWNLlqO2Fou5y9cfXMzoGTiooQLRDz4B56F2Y=; b=irL9a4Pwu/usPpj794KAh++SUTcnhYxdtx1hL41ZRTk8ud9wcSSpglejNt9rWi3joxx8tB nDClrel0S3/cMK4Xi+66dvdD/w0rUnVCQgxxSIgPKI7FLXGGpPAIYNmRQ3iP9eFqBTB7L7 MbaTcc3oFrhUmAQPPDV15A4l5QOGCXiummiTTSYPykcgfUFOJeeEq32ST7FbHAB5v4Dg5m OeOXNH76dFqNdxJzNySLErqq9TfCeKSkzHTWoTo3P4euM1EtyteGmZM0KRq6LPiCZkq7Bk 3/QPrwJHF0WhtJKCUNltoyKUQlUnvNc+rg3r/PUaONkLxEGRAQX0FlbflqtxDg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1624993727; a=rsa-sha256; cv=none; b=WICVESwIHdOdOudLy0R5z39r7RbOu4wVuP4ZOvRW/LXJp455++LyP0B/OqF01uKpJrNyBX u2CaiPvKDOLgI2ZWnyenHBX3VuPrQFpYLNd1WvCbzcw2wfQIhM+MIaT6xMzCxb7j8Qtl2R IdFOof1b56Df5X2R4j573M0kytR41c1cJV2pcECCijkKscG9pvGv4OrAymc0JU8eq4xNg0 9F31wAh/f+ntxTGbK+cBkufegx2eHDgH1fnz7EiUWaxStnrdI6MLA7lkYJuQ6X2pRdfjNC lxJ1y/8ra2qJHksfhSyuXP23rN427a57D4D2CxCR3Dnm3b46ZjpdMRuwxW/74Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20161025 header.b=YekDGSdX; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -0.97 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20161025 header.b=YekDGSdX; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: D0A8932C4F X-Spam-Score: -0.97 X-Migadu-Scanner: scn1.migadu.com X-TUID: +Grt2K0h59QV Currently the simplest way to open the notmuch database properly a client must do: $config = IO.popen(%w[notmuch config list]) do |io| io.each(chomp: true).map { |e| e.split('=') }.to_h end $db_name = config['database.path'] $db = Notmuch::Database.new($db_name) While this works and it's not too overly complicated, the notmuch API already has much better constucts. This patch series allows the user to simply do: $db = Notmuch::Database.open_with_config $config = $db.config.to_h And much more. Since v1 this is rebased on top of master to resolve conflicts, and a minor style update to one test. Felipe Contreras (3): ruby: add new Database.open_with_config ruby: add db.config ruby: make db.config return an enumerator bindings/ruby/database.c | 95 ++++++++++++++++++++++++++++++++++++++++ bindings/ruby/defs.h | 10 +++++ bindings/ruby/init.c | 2 + test/T395-ruby.sh | 14 ++++++ 4 files changed, 121 insertions(+) Range-diff against v1: 1: 0d63249e = 1: beba4602 ruby: add new Database.open_with_config 2: 41bae8f2 ! 2: 92a36061 ruby: add db.config @@ Commit message Signed-off-by: Felipe Contreras ## bindings/ruby/database.c ## -@@ bindings/ruby/database.c: notmuch_rb_database_query_create (VALUE self, VALUE qstrv) +@@ bindings/ruby/database.c: notmuch_rb_database_query_create (int argc, VALUE *argv, VALUE self) return Data_Wrap_Notmuch_Object (notmuch_rb_cQuery, ¬much_rb_query_type, query); } @@ bindings/ruby/defs.h: extern ID ID_db_mode; extern const rb_data_type_t notmuch_rb_database_type; @@ bindings/ruby/defs.h: notmuch_rb_database_get_all_tags (VALUE self); VALUE - notmuch_rb_database_query_create (VALUE self, VALUE qstrv); + notmuch_rb_database_query_create (int argc, VALUE *argv, VALUE self); +VALUE +notmuch_rb_database_config (int argc, VALUE *argv, VALUE self); @@ bindings/ruby/init.c @@ bindings/ruby/init.c: Init_notmuch (void) notmuch_rb_database_find_message_by_filename, 1); /* in database.c */ rb_define_method (notmuch_rb_cDatabase, "all_tags", notmuch_rb_database_get_all_tags, 0); /* in database.c */ - rb_define_method (notmuch_rb_cDatabase, "query", notmuch_rb_database_query_create, 1); /* in database.c */ + rb_define_method (notmuch_rb_cDatabase, "query", notmuch_rb_database_query_create, -1); /* in database.c */ + rb_define_method (notmuch_rb_cDatabase, "config", notmuch_rb_database_config, -1); /* in database.c */ /* @@ test/T395-ruby.sh: test_ruby < EXPECTED +test_ruby <<"EOF" -+config_db = Notmuch::Database.open_with_config -+config_db.config { |e| puts '%s=%s' % e } ++Notmuch::Database.open_with_config do |db| ++ db.config { |e| puts '%s=%s' % e } ++end +EOF + test_done 3: e6880180 = 3: 4efe195f ruby: make db.config return an enumerator -- 2.32.0