From 98b6d1ba27fa2a2e1434e1fecd3479a2b4903fe7 Mon Sep 17 00:00:00 2001 From: dakkar Date: Thu, 16 Mar 2017 17:45:56 +0000 Subject: Dzil-build release 1.0.0 (from 9f1fc6d on master) --- .gitignore | 14 - .gitmodules | 6 - .proverc | 2 - Changes | 2 - LICENSE | 379 ++++++++++++++++++++++++++++ MANIFEST | 53 ++++ META.json | 89 +++++++ META.yml | 55 ++++ Makefile.PL | 105 ++++++++ dist.ini | 86 ------- docs/presentation/css | 1 - docs/presentation/css2 | 1 - docs/presentation/highlight.js | 1 - docs/presentation/js | 1 - docs/presentation/lib | 1 - docs/presentation/plugin | 1 - docs/presentation/reveal.js | 1 - docs/presentation/sietima.html | 221 ---------------- lib/Sietima.pm | 311 +++++++++++++---------- lib/Sietima/CmdLine.pm | 156 +++++++----- lib/Sietima/MailStore.pm | 52 +++- lib/Sietima/MailStore/FS.pm | 210 ++++++++------- lib/Sietima/Message.pm | 113 +++++---- lib/Sietima/Policy.pm | 50 +++- lib/Sietima/Role/AvoidDups.pm | 64 +++-- lib/Sietima/Role/Debounce.pm | 58 +++-- lib/Sietima/Role/Headers.pm | 113 ++++++--- lib/Sietima/Role/ManualSubscription.pm | 62 +++-- lib/Sietima/Role/NoMail.pm | 48 +++- lib/Sietima/Role/ReplyTo.pm | 136 ++++++---- lib/Sietima/Role/SubjectTag.pm | 73 ++++-- lib/Sietima/Role/SubscriberOnly.pm | 98 ++++--- lib/Sietima/Role/SubscriberOnly/Drop.pm | 43 +++- lib/Sietima/Role/SubscriberOnly/Moderate.pm | 256 ++++++++++--------- lib/Sietima/Role/WithMailStore.pm | 48 +++- lib/Sietima/Role/WithOwner.pm | 67 +++-- lib/Sietima/Role/WithPostAddress.pm | 60 +++-- lib/Sietima/Runner.pm | 50 +++- lib/Sietima/Subscriber.pm | 128 ++++++---- lib/Sietima/Types.pm | 145 ++++++----- t/author-critic.t | 20 ++ t/author-no-tabs.t | 60 +++++ t/author-pod-coverage.t | 15 ++ t/author-pod-syntax.t | 15 ++ weaver.ini | 41 --- 45 files changed, 2263 insertions(+), 1248 deletions(-) delete mode 100644 .gitignore delete mode 100644 .gitmodules delete mode 100644 .proverc create mode 100644 LICENSE create mode 100644 MANIFEST create mode 100644 META.json create mode 100644 META.yml create mode 100644 Makefile.PL delete mode 100644 dist.ini delete mode 120000 docs/presentation/css delete mode 120000 docs/presentation/css2 delete mode 160000 docs/presentation/highlight.js delete mode 120000 docs/presentation/js delete mode 120000 docs/presentation/lib delete mode 120000 docs/presentation/plugin delete mode 160000 docs/presentation/reveal.js delete mode 100644 docs/presentation/sietima.html create mode 100644 t/author-critic.t create mode 100644 t/author-no-tabs.t create mode 100644 t/author-pod-coverage.t create mode 100644 t/author-pod-syntax.t delete mode 100644 weaver.ini diff --git a/.gitignore b/.gitignore deleted file mode 100644 index f713c58..0000000 --- a/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -blib -pm_to_blib -*.sw? -Makefile -Makefile.old -MANIFEST.bak -*.tar.gz -/inc/ -/META.* -/MYMETA.* -.prove -*~ -/.build/ -/Sietima-* diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 7020267..0000000 --- a/.gitmodules +++ /dev/null @@ -1,6 +0,0 @@ -[submodule "docs/presentation/reveal.js"] - path = docs/presentation/reveal.js - url = git@github.com:hakimel/reveal.js.git -[submodule "docs/presentation/highlight.js"] - path = docs/presentation/highlight.js - url = git@github.com:isagalaev/highlight.js.git diff --git a/.proverc b/.proverc deleted file mode 100644 index ad83f73..0000000 --- a/.proverc +++ /dev/null @@ -1,2 +0,0 @@ ---lib ---recurse diff --git a/Changes b/Changes index 28179cc..521defd 100644 --- a/Changes +++ b/Changes @@ -1,4 +1,2 @@ -{{$NEXT}} - 1.0.0 2017-03-16 17:45:48+00:00 Europe/London - first release diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..eff077f --- /dev/null +++ b/LICENSE @@ -0,0 +1,379 @@ +This software is copyright (c) 2017 by Gianni Ceccarelli . + +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. + +Terms of the Perl programming language system itself + +a) the GNU General Public License as published by the Free + Software Foundation; either version 1, or (at your option) any + later version, or +b) the "Artistic License" + +--- The GNU General Public License, Version 1, February 1989 --- + +This software is Copyright (c) 2017 by Gianni Ceccarelli . + +This is free software, licensed under: + + The GNU General Public License, Version 1, February 1989 + + GNU GENERAL PUBLIC LICENSE + Version 1, February 1989 + + Copyright (C) 1989 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The license agreements of most software companies try to keep users +at the mercy of those companies. By contrast, our General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. The +General Public License applies to the Free Software Foundation's +software and to any other program whose authors commit to using it. +You can use it for your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Specifically, the General Public License is designed to make +sure that you have the freedom to give away or sell copies of free +software, that you receive source code or can get it if you want it, +that you can change the software or use pieces of it in new free +programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of a such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must tell them their rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any program or other work which +contains a notice placed by the copyright holder saying it may be +distributed under the terms of this General Public License. The +"Program", below, refers to any such program or work, and a "work based +on the Program" means either the Program or any work containing the +Program or a portion of it, either verbatim or with modifications. Each +licensee is addressed as "you". + + 1. You may copy and distribute verbatim copies of the Program's source +code as you receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice and +disclaimer of warranty; keep intact all the notices that refer to this +General Public License and to the absence of any warranty; and give any +other recipients of the Program a copy of this General Public License +along with the Program. You may charge a fee for the physical act of +transferring a copy. + + 2. You may modify your copy or copies of the Program or any portion of +it, and copy and distribute such modifications under the terms of Paragraph +1 above, provided that you also do the following: + + a) cause the modified files to carry prominent notices stating that + you changed the files and the date of any change; and + + b) cause the whole of any work that you distribute or publish, that + in whole or in part contains the Program or any part thereof, either + with or without modifications, to be licensed at no charge to all + third parties under the terms of this General Public License (except + that you may choose to grant warranty protection to some or all + third parties, at your option). + + c) If the modified program normally reads commands interactively when + run, you must cause it, when started running for such interactive use + in the simplest and most usual way, to print or display an + announcement including an appropriate copyright notice and a notice + that there is no warranty (or else, saying that you provide a + warranty) and that users may redistribute the program under these + conditions, and telling the user how to view a copy of this General + Public License. + + d) You may charge a fee for the physical act of transferring a + copy, and you may at your option offer warranty protection in + exchange for a fee. + +Mere aggregation of another independent work with the Program (or its +derivative) on a volume of a storage or distribution medium does not bring +the other work under the scope of these terms. + + 3. You may copy and distribute the Program (or a portion or derivative of +it, under Paragraph 2) in object code or executable form under the terms of +Paragraphs 1 and 2 above provided that you also do one of the following: + + a) accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of + Paragraphs 1 and 2 above; or, + + b) accompany it with a written offer, valid for at least three + years, to give any third party free (except for a nominal charge + for the cost of distribution) a complete machine-readable copy of the + corresponding source code, to be distributed under the terms of + Paragraphs 1 and 2 above; or, + + c) accompany it with the information you received as to where the + corresponding source code may be obtained. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form alone.) + +Source code for a work means the preferred form of the work for making +modifications to it. For an executable file, complete source code means +all the source code for all modules it contains; but, as a special +exception, it need not include source code for modules which are standard +libraries that accompany the operating system on which the executable +file runs, or for standard header files or definitions files that +accompany that operating system. + + 4. You may not copy, modify, sublicense, distribute or transfer the +Program except as expressly provided under this General Public License. +Any attempt otherwise to copy, modify, sublicense, distribute or transfer +the Program is void, and will automatically terminate your rights to use +the Program under this License. However, parties who have received +copies, or rights to use copies, from you under this General Public +License will not have their licenses terminated so long as such parties +remain in full compliance. + + 5. By copying, distributing or modifying the Program (or any work based +on the Program) you indicate your acceptance of this license to do so, +and all its terms and conditions. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the original +licensor to copy, distribute or modify the Program subject to these +terms and conditions. You may not impose any further restrictions on the +recipients' exercise of the rights granted herein. + + 7. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of the license which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +the license, you may choose any version ever published by the Free Software +Foundation. + + 8. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to humanity, the best way to achieve this is to make it +free software which everyone can redistribute and change under these +terms. + + To do so, attach the following notices to the program. It is safest to +attach them to the start of each source file to most effectively convey +the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19xx name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the +appropriate parts of the General Public License. Of course, the +commands you use may be called something other than `show w' and `show +c'; they could even be mouse-clicks or menu items--whatever suits your +program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + program `Gnomovision' (a program to direct compilers to make passes + at assemblers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +That's all there is to it! + + +--- The Artistic License 1.0 --- + +This software is Copyright (c) 2017 by Gianni Ceccarelli . + +This is free software, licensed under: + + The Artistic License 1.0 + +The Artistic License + +Preamble + +The intent of this document is to state the conditions under which a Package +may be copied, such that the Copyright Holder maintains some semblance of +artistic control over the development of the package, while giving the users of +the package the right to use and distribute the Package in a more-or-less +customary fashion, plus the right to make reasonable modifications. + +Definitions: + + - "Package" refers to the collection of files distributed by the Copyright + Holder, and derivatives of that collection of files created through + textual modification. + - "Standard Version" refers to such a Package if it has not been modified, + or has been modified in accordance with the wishes of the Copyright + Holder. + - "Copyright Holder" is whoever is named in the copyright or copyrights for + the package. + - "You" is you, if you're thinking about copying or distributing this Package. + - "Reasonable copying fee" is whatever you can justify on the basis of media + cost, duplication charges, time of people involved, and so on. (You will + not be required to justify it to the Copyright Holder, but only to the + computing community at large as a market that must bear the fee.) + - "Freely Available" means that no fee is charged for the item itself, though + there may be fees involved in handling the item. It also means that + recipients of the item may redistribute it under the same conditions they + received it. + +1. You may make and give away verbatim copies of the source form of the +Standard Version of this Package without restriction, provided that you +duplicate all of the original copyright notices and associated disclaimers. + +2. You may apply bug fixes, portability fixes and other modifications derived +from the Public Domain or from the Copyright Holder. A Package modified in such +a way shall still be considered the Standard Version. + +3. You may otherwise modify your copy of this Package in any way, provided that +you insert a prominent notice in each changed file stating how and when you +changed that file, and provided that you do at least ONE of the following: + + a) place your modifications in the Public Domain or otherwise make them + Freely Available, such as by posting said modifications to Usenet or an + equivalent medium, or placing the modifications on a major archive site + such as ftp.uu.net, or by allowing the Copyright Holder to include your + modifications in the Standard Version of the Package. + + b) use the modified Package only within your corporation or organization. + + c) rename any non-standard executables so the names do not conflict with + standard executables, which must also be provided, and provide a separate + manual page for each non-standard executable that clearly documents how it + differs from the Standard Version. + + d) make other distribution arrangements with the Copyright Holder. + +4. You may distribute the programs of this Package in object code or executable +form, provided that you do at least ONE of the following: + + a) distribute a Standard Version of the executables and library files, + together with instructions (in the manual page or equivalent) on where to + get the Standard Version. + + b) accompany the distribution with the machine-readable source of the Package + with your modifications. + + c) accompany any non-standard executables with their corresponding Standard + Version executables, giving the non-standard executables non-standard + names, and clearly documenting the differences in manual pages (or + equivalent), together with instructions on where to get the Standard + Version. + + d) make other distribution arrangements with the Copyright Holder. + +5. You may charge a reasonable copying fee for any distribution of this +Package. You may charge any fee you choose for support of this Package. You +may not charge a fee for this Package itself. However, you may distribute this +Package in aggregate with other (possibly commercial) programs as part of a +larger (possibly commercial) software distribution provided that you do not +advertise this Package as a product of your own. + +6. The scripts and library files supplied as input to or produced as output +from the programs of this Package do not automatically fall under the copyright +of this Package, but belong to whomever generated them, and may be sold +commercially, and may be aggregated with this Package. + +7. C or perl subroutines supplied by you and linked into this Package shall not +be considered part of this Package. + +8. The name of the Copyright Holder may not be used to endorse or promote +products derived from this software without specific prior written permission. + +9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF +MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + +The End + diff --git a/MANIFEST b/MANIFEST new file mode 100644 index 0000000..85eb430 --- /dev/null +++ b/MANIFEST @@ -0,0 +1,53 @@ +# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.008. +Changes +LICENSE +MANIFEST +META.json +META.yml +Makefile.PL +TODO.md +example/sietima +lib/Sietima.pm +lib/Sietima/CmdLine.pm +lib/Sietima/MailStore.pm +lib/Sietima/MailStore/FS.pm +lib/Sietima/Message.pm +lib/Sietima/Policy.pm +lib/Sietima/Role/AvoidDups.pm +lib/Sietima/Role/Debounce.pm +lib/Sietima/Role/Headers.pm +lib/Sietima/Role/ManualSubscription.pm +lib/Sietima/Role/NoMail.pm +lib/Sietima/Role/ReplyTo.pm +lib/Sietima/Role/SubjectTag.pm +lib/Sietima/Role/SubscriberOnly.pm +lib/Sietima/Role/SubscriberOnly/Drop.pm +lib/Sietima/Role/SubscriberOnly/Moderate.pm +lib/Sietima/Role/WithMailStore.pm +lib/Sietima/Role/WithOwner.pm +lib/Sietima/Role/WithPostAddress.pm +lib/Sietima/Runner.pm +lib/Sietima/Subscriber.pm +lib/Sietima/Types.pm +perlcritic.rc +t/author-critic.t +t/author-no-tabs.t +t/author-pod-coverage.t +t/author-pod-syntax.t +t/lib/Test/Sietima.pm +t/lib/Test/Sietima/MailStore.pm +t/tests/sietima.t +t/tests/sietima/cmdline.t +t/tests/sietima/mailstore.t +t/tests/sietima/message.t +t/tests/sietima/multi-role/debounce-moderate.t +t/tests/sietima/role/avoid-dups.t +t/tests/sietima/role/debounce.t +t/tests/sietima/role/headers.t +t/tests/sietima/role/manualsubscription.t +t/tests/sietima/role/nomail.t +t/tests/sietima/role/replyto.t +t/tests/sietima/role/subject-tag.t +t/tests/sietima/role/subscriberonly/drop.t +t/tests/sietima/role/subscriberonly/moderate.t +t/tests/sietima/subscriber.t diff --git a/META.json b/META.json new file mode 100644 index 0000000..59442b8 --- /dev/null +++ b/META.json @@ -0,0 +1,89 @@ +{ + "abstract" : "minimal mailing list manager", + "author" : [ + "Gianni Ceccarelli " + ], + "dynamic_config" : 0, + "generated_by" : "Dist::Zilla version 6.008, CPAN::Meta::Converter version 2.150005", + "license" : [ + "perl_5" + ], + "meta-spec" : { + "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", + "version" : 2 + }, + "name" : "Sietima", + "no_index" : { + "directory" : [ + "t/lib" + ] + }, + "prereqs" : { + "configure" : { + "requires" : { + "ExtUtils::MakeMaker" : "0" + } + }, + "develop" : { + "requires" : { + "Pod::Coverage::TrustPod" : "0", + "Test::More" : "0.88", + "Test::NoTabs" : "0", + "Test::Pod" : "1.41", + "Test::Pod::Coverage" : "1.08" + } + }, + "runtime" : { + "requires" : { + "App::Spec" : "0", + "App::Spec::Run" : "0", + "Digest::SHA" : "0", + "Email::Address" : "0", + "Email::MIME" : "0", + "Email::Sender" : "0", + "Email::Sender::Simple" : "0", + "Email::Stuffer" : "0", + "List::AllUtils" : "0", + "Moo" : "0", + "Moo::Role" : "0", + "MooX::Traits" : "0", + "Try::Tiny" : "0", + "Type::Library" : "0", + "Type::Params" : "0", + "Type::Utils" : "0", + "Types::Path::Tiny" : "0", + "Types::Standard" : "0", + "URI" : "0", + "experimental" : "0", + "feature" : "0", + "namespace::clean" : "0", + "perl" : "5.024", + "strict" : "0", + "warnings" : "0" + } + }, + "test" : { + "requires" : { + "Data::Printer" : "0", + "Email::Sender::Transport::Test" : "0", + "Import::Into" : "0", + "Path::Tiny" : "0", + "Test2::API" : "0", + "Test2::Bundle::Extended" : "0", + "lib" : "0" + } + } + }, + "release_status" : "stable", + "resources" : { + "homepage" : "https://www.thenautilus.net/SW/Sietima/", + "repository" : { + "type" : "git", + "url" : "https://www.thenautilus.net/cgit/Sietima", + "web" : "https://www.thenautilus.net/cgit/Sietima" + } + }, + "version" : "1.0.0", + "x_serialization_backend" : "Cpanel::JSON::XS version 3.0225" +} + diff --git a/META.yml b/META.yml new file mode 100644 index 0000000..326c8d5 --- /dev/null +++ b/META.yml @@ -0,0 +1,55 @@ +--- +abstract: 'minimal mailing list manager' +author: + - 'Gianni Ceccarelli ' +build_requires: + Data::Printer: '0' + Email::Sender::Transport::Test: '0' + Import::Into: '0' + Path::Tiny: '0' + Test2::API: '0' + Test2::Bundle::Extended: '0' + lib: '0' +configure_requires: + ExtUtils::MakeMaker: '0' +dynamic_config: 0 +generated_by: 'Dist::Zilla version 6.008, CPAN::Meta::Converter version 2.150005' +license: perl +meta-spec: + url: http://module-build.sourceforge.net/META-spec-v1.4.html + version: '1.4' +name: Sietima +no_index: + directory: + - t/lib +requires: + App::Spec: '0' + App::Spec::Run: '0' + Digest::SHA: '0' + Email::Address: '0' + Email::MIME: '0' + Email::Sender: '0' + Email::Sender::Simple: '0' + Email::Stuffer: '0' + List::AllUtils: '0' + Moo: '0' + Moo::Role: '0' + MooX::Traits: '0' + Try::Tiny: '0' + Type::Library: '0' + Type::Params: '0' + Type::Utils: '0' + Types::Path::Tiny: '0' + Types::Standard: '0' + URI: '0' + experimental: '0' + feature: '0' + namespace::clean: '0' + perl: '5.024' + strict: '0' + warnings: '0' +resources: + homepage: https://www.thenautilus.net/SW/Sietima/ + repository: https://www.thenautilus.net/cgit/Sietima +version: 1.0.0 +x_serialization_backend: 'YAML::Tiny version 1.70' diff --git a/Makefile.PL b/Makefile.PL new file mode 100644 index 0000000..3ba7a32 --- /dev/null +++ b/Makefile.PL @@ -0,0 +1,105 @@ +# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.008. +use strict; +use warnings; + +use 5.024; + +use ExtUtils::MakeMaker; + +my %WriteMakefileArgs = ( + "ABSTRACT" => "minimal mailing list manager", + "AUTHOR" => "Gianni Ceccarelli ", + "CONFIGURE_REQUIRES" => { + "ExtUtils::MakeMaker" => 0 + }, + "DISTNAME" => "Sietima", + "LICENSE" => "perl", + "MIN_PERL_VERSION" => "5.024", + "NAME" => "Sietima", + "PREREQ_PM" => { + "App::Spec" => 0, + "App::Spec::Run" => 0, + "Digest::SHA" => 0, + "Email::Address" => 0, + "Email::MIME" => 0, + "Email::Sender" => 0, + "Email::Sender::Simple" => 0, + "Email::Stuffer" => 0, + "List::AllUtils" => 0, + "Moo" => 0, + "Moo::Role" => 0, + "MooX::Traits" => 0, + "Try::Tiny" => 0, + "Type::Library" => 0, + "Type::Params" => 0, + "Type::Utils" => 0, + "Types::Path::Tiny" => 0, + "Types::Standard" => 0, + "URI" => 0, + "experimental" => 0, + "feature" => 0, + "namespace::clean" => 0, + "strict" => 0, + "warnings" => 0 + }, + "TEST_REQUIRES" => { + "Data::Printer" => 0, + "Email::Sender::Transport::Test" => 0, + "Import::Into" => 0, + "Path::Tiny" => 0, + "Test2::API" => 0, + "Test2::Bundle::Extended" => 0, + "lib" => 0 + }, + "VERSION" => "1.0.0", + "test" => { + "TESTS" => "t/*.t t/tests/*.t t/tests/sietima/*.t t/tests/sietima/multi-role/*.t t/tests/sietima/role/*.t t/tests/sietima/role/subscriberonly/*.t" + } +); + + +my %FallbackPrereqs = ( + "App::Spec" => 0, + "App::Spec::Run" => 0, + "Data::Printer" => 0, + "Digest::SHA" => 0, + "Email::Address" => 0, + "Email::MIME" => 0, + "Email::Sender" => 0, + "Email::Sender::Simple" => 0, + "Email::Sender::Transport::Test" => 0, + "Email::Stuffer" => 0, + "Import::Into" => 0, + "List::AllUtils" => 0, + "Moo" => 0, + "Moo::Role" => 0, + "MooX::Traits" => 0, + "Path::Tiny" => 0, + "Test2::API" => 0, + "Test2::Bundle::Extended" => 0, + "Try::Tiny" => 0, + "Type::Library" => 0, + "Type::Params" => 0, + "Type::Utils" => 0, + "Types::Path::Tiny" => 0, + "Types::Standard" => 0, + "URI" => 0, + "experimental" => 0, + "feature" => 0, + "lib" => 0, + "namespace::clean" => 0, + "strict" => 0, + "warnings" => 0 +); + + +unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { + delete $WriteMakefileArgs{TEST_REQUIRES}; + delete $WriteMakefileArgs{BUILD_REQUIRES}; + $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; +} + +delete $WriteMakefileArgs{CONFIGURE_REQUIRES} + unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; + +WriteMakefile(%WriteMakefileArgs); diff --git a/dist.ini b/dist.ini deleted file mode 100644 index a547eb5..0000000 --- a/dist.ini +++ /dev/null @@ -1,86 +0,0 @@ -name = Sietima -author = Gianni Ceccarelli -license = Perl_5 -copyright_holder = Gianni Ceccarelli -copyright_year = 2017 - -[GatherDir] -exclude_match = ~$ -exclude_filename = dist.ini -exclude_filename = weaver.ini -prune_directory = docs - -[PruneCruft] - -[PodWeaver] -; authordep Pod::Elemental::Transformer::List - -[Git::Check] -allow_dirty = dist.ini - -[Git::NextVersion] -first_version = 1.0.0 - -[CheckChangeLog] - -[NextRelease] - -[AutoPrereqs] - -[OurPkgVersion] - -[ManifestSkip] - -[Test::NoTabs] - -[Test::Perl::Critic] - -[PodCoverageTests] - -[PodSyntaxTests] - -[ExtraTests] - -[Repository] -repository=https://www.thenautilus.net/cgit/Sietima -web=https://www.thenautilus.net/cgit/Sietima - -[MetaResources] -homepage = https://www.thenautilus.net/SW/Sietima/ - -[MetaNoIndex] -directory = t/lib - -[MetaYAML] - -[MetaJSON] - -[ExecDir] -dir = scripts - -[ShareDir] - -[MakeMaker] - -[Manifest] - -[License] - -[TestRelease] - -[Git::Commit] - -[Git::CommitBuild] -branch = -release_branch = release/%b -release_message = Dzil-build release %v (from %h on %b) -multiple_inheritance = 1 - -[Git::Tag / master] -tag_format = v%v%t-dzilla - -[Git::Tag / release] -branch = release/master -tag_format = v%v%t - -[UploadToCPAN] diff --git a/docs/presentation/css b/docs/presentation/css deleted file mode 120000 index e95a0e7..0000000 --- a/docs/presentation/css +++ /dev/null @@ -1 +0,0 @@ -reveal.js/css \ No newline at end of file diff --git a/docs/presentation/css2 b/docs/presentation/css2 deleted file mode 120000 index 0ca84e4..0000000 --- a/docs/presentation/css2 +++ /dev/null @@ -1 +0,0 @@ -highlight.js/src/styles \ No newline at end of file diff --git a/docs/presentation/highlight.js b/docs/presentation/highlight.js deleted file mode 160000 index ac3f2db..0000000 --- a/docs/presentation/highlight.js +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ac3f2db5e434f6344d226d57d7e49290201696ca diff --git a/docs/presentation/js b/docs/presentation/js deleted file mode 120000 index ebce293..0000000 --- a/docs/presentation/js +++ /dev/null @@ -1 +0,0 @@ -reveal.js/js \ No newline at end of file diff --git a/docs/presentation/lib b/docs/presentation/lib deleted file mode 120000 index 892bcc7..0000000 --- a/docs/presentation/lib +++ /dev/null @@ -1 +0,0 @@ -reveal.js/lib \ No newline at end of file diff --git a/docs/presentation/plugin b/docs/presentation/plugin deleted file mode 120000 index 426257b..0000000 --- a/docs/presentation/plugin +++ /dev/null @@ -1 +0,0 @@ -reveal.js/plugin \ No newline at end of file diff --git a/docs/presentation/reveal.js b/docs/presentation/reveal.js deleted file mode 160000 index a349ff4..0000000 --- a/docs/presentation/reveal.js +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a349ff43c58c23f9c837b8ea9b5fc7d4761b8de3 diff --git a/docs/presentation/sietima.html b/docs/presentation/sietima.html deleted file mode 100644 index 6b82e72..0000000 --- a/docs/presentation/sietima.html +++ /dev/null @@ -1,221 +0,0 @@ - - - - - - - Sietima — a minimalist MLM - - -
-
-
-

Sietima — a minimalist MLM

-

Author: dakkar <dakkar@thenautilus.net>

-

Date: 2016-08-08

-
-
-

A bit of history

-
-

Siesta

- -
-
-

written in 2003

-
-
-

14 years ago

-
-
-

Class::DBI

-

no Moo

-

Perl 5.8

- -
-
-
-

Plugin style

-
-

simple base class

-

-sub handle_mail($self,$incoming_mail) {
- my (@outgoing_messages) = $self->munge_mail($incoming_mail);
- for my $outgoing_message (@outgoing_messages) {
-  $self->send_message($outgoing_message);
- }
- return;
-}
-            
-
-
-

provide all the needed extensions points

-

-sub munge_mail($self,$incoming_mail) {
- return Sietima::Message->new({
-  mail => $incoming_mail,
-  from => $self->return_path,
-  to => $self->subscribers_to_send_to($incoming_mail),
- });
-}
-            
-
-
-

but no more than that

-
-
-

traits / roles

-
    -
  • AvoidDups
  • -
  • Debounce
  • -
  • Headers
  • -
  • ManualSubscription
  • -
  • NoMail
  • -
  • ReplyTo
  • -
  • SubjectTag
  • -
  • SubscriberOnly::Drop
  • -
  • SubscriberOnly::Moderate
  • -
-
-
-

try to avoid cross-trait dependencies

-

«ReplyTo needs WithPostAddress» is fine

-

but «SubscriberOnly::Moderate should be added after Debounce» is not

-

sadly I couldn't avoid it, suggestions welcome

-
-
-
-

Driver

-
-

App::Spec

-
-
-

minimal spec in base class

-

-sub command_line_spec($self) {
- return {
-  name => 'sietima',
-  title => 'a simple mailing list manager',
-  subcommands => {
-   send => {
-    op => 'handle_mail_from_stdin',
-    summary => 'send email from STDIN',
-   },
-  },
- };
-}
-            
-
-
-

enriched by plugins

-

-around command_line_spec => sub ($orig,$self) {
- my $spec = $self->$orig();
-
- my $list_mail_ids = sub ($self,$runner,$args) {
-  $self->mail_store->retrieve_ids_by_tags('moderation');
- };
-
- my $with_mail_id = sub($cmd) { return (
-  summary => "$cmd the given mail, currently held for moderation",
-  parameters => [ {
-   name => 'mail-id', required => 1,
-   summary => "id of the mail to $cmd",
-   completion => { op => $list_mail_ids },
-  } ],
- ) };
-
- $spec->{subcommands}{'list-held'} = {
-  op => 'list_mails_in_moderation_queue',
-  summary => 'list all mails currently held for moderation',
- };
- $spec->{subcommands}{'show-held'} = {
-  op => 'show_mail_from_moderation_queue',
-  $with_mail_id->('show'),
- };
- $spec->{subcommands}{'resume-held'} = {
-  op => sub ($self,$runner,$args) {
-   $self->resume($runner->parameters->{'mail-id'});
-  },
-  $with_mail_id->('resume'),
- };
- $spec->{subcommands}{'drop-held'} = {
-  op => sub ($self,$runner,$args) {
-   $self->drop($runner->parameters->{'mail-id'});
-  },
-  $with_mail_id->('drop'),
- };
-
- return $spec;
-};
-            
-
-
-

-$ sietima-test <TAB>
-drop-held   -- drop the given mail, currently held for moderation
-help        -- Show command help
-list-held   -- list all mails currently held for moderation
-resume-held -- resume the given mail, currently held for moderation
-send        -- send email from STDIN
-show-held   -- show the given mail, currently held for moderation
-            
-
-
-

-$ sietima-test resume-held <TAB>
-0f0571203ef5ee2f786b7f7f2832093ed4c34fe8
-4d43ee7a2a17457606c07475b14054839fad9b7e
-            
-
-
-
-

Production ready!

-
-

all my lists now run with Sietima

-
-
-

coming soon to a CPAN near you

-
-
-
-

CPAN is awesome

-
-

Email::*, RJBS

-
-
-

Moo, MST + HAARG

-

Type::Tiny, TOBYINK

-
-
-

App::Spec, TINITA

-
-
-

Test2, EXODIST

-
-
-
-

Thank you

-
-
-
- - - - - diff --git a/lib/Sietima.pm b/lib/Sietima.pm index 98859ab..80cdf39 100644 --- a/lib/Sietima.pm +++ b/lib/Sietima.pm @@ -15,9 +15,131 @@ use Email::Address; use namespace::clean; with 'MooX::Traits'; -# VERSION +our $VERSION = '1.0.0'; # VERSION # ABSTRACT: minimal mailing list manager + +has return_path => ( + isa => Address, + is => 'ro', + required => 1, + coerce => AddressFromStr, +); + + +my $subscribers_array = ArrayRef[ + Subscriber->plus_coercions( + SubscriberFromAddress, + SubscriberFromStr, + SubscriberFromHashRef, + ) +]; +has subscribers => ( + isa => $subscribers_array, + is => 'lazy', + coerce => $subscribers_array->coercion, +); +sub _build_subscribers { +[] } + + +has transport => ( + isa => Transport, + is => 'lazy', +); +sub _build_transport { Email::Sender::Simple->default_transport } + + +sub handle_mail_from_stdin($self,@) { + my $mail_text = do { local $/; <> }; + # we're hoping that, since we probably got called from an MTA/MDA, + # STDIN contains a well-formed email message, addressed to us + my $incoming_mail = Email::MIME->new(\$mail_text); + return $self->handle_mail($incoming_mail); +} + + +sub handle_mail($self,$incoming_mail) { + state $check = compile(Object,EmailMIME); $check->(@_); + + my (@outgoing_messages) = $self->munge_mail($incoming_mail); + for my $outgoing_message (@outgoing_messages) { + $self->send_message($outgoing_message); + } + return; +} + + +sub subscribers_to_send_to($self,$incoming_mail) { + state $check = compile(Object,EmailMIME); $check->(@_); + + return $self->subscribers; +} + + +sub munge_mail($self,$incoming_mail) { + state $check = compile(Object,EmailMIME); $check->(@_); + + return Sietima::Message->new({ + mail => $incoming_mail, + from => $self->return_path, + to => $self->subscribers_to_send_to($incoming_mail), + }); +} + + +sub send_message($self,$outgoing_message) { + state $check = compile(Object,Message); $check->(@_); + + my $envelope = $outgoing_message->envelope; + if ($envelope->{to} && $envelope->{to}->@*) { + $self->transport->send( + $outgoing_message->mail, + $envelope, + ); + } + + return; +} + +sub _trait_namespace { 'Sietima::Role' } ## no critic(ProhibitUnusedPrivateSubroutines) + + +sub list_addresses($self) { + return +{ + return_path => $self->return_path, + }; +} + + +sub command_line_spec($self) { + return { + name => 'sietima', + title => 'a simple mailing list manager', + subcommands => { + send => { + op => 'handle_mail_from_stdin', + summary => 'send email from STDIN', + }, + }, + }; +} + +1; + +__END__ + +=pod + +=encoding UTF-8 + +=head1 NAME + +Sietima - minimal mailing list manager + +=head1 VERSION + +version 1.0.0 + =head1 SYNOPSIS use Sietima; @@ -44,51 +166,64 @@ consumes L<< C >> to simplify composing roles: These are the traits provided with the default distribution: -=for :list -= L<< C|Sietima::Role::AvoidDups >> +=over 4 + +=item L<< C|Sietima::Role::AvoidDups >> + prevents the sender from receiving copies of their own messages -= L<< C|Sietima::Role::Debounce >> + +=item L<< C|Sietima::Role::Debounce >> + avoids mail-loops using a C header -= L<< C|Sietima::Role::Headers >> + +=item L<< C|Sietima::Role::Headers >> + adds C headers to all outgoing messages -= L<< C|Sietima::Role::ManualSubscription >> + +=item L<< C|Sietima::Role::ManualSubscription >> + specifies that to (un)subscribe, people should write to the list owner -= L<< C|Sietima::Role::NoMail >> + +=item L<< C|Sietima::Role::NoMail >> + avoids sending messages to subscribers who don't want them -= L<< C|Sietima::Role::ReplyTo >> + +=item L<< C|Sietima::Role::ReplyTo >> + optionally sets the C header to the mailing list address -= L<< C|Sietima::Role::SubjectTag >> + +=item L<< C|Sietima::Role::SubjectTag >> + prepends a C<[tag]> to the subject header of outgoing messages that aren't already tagged -= L<< C|Sietima::Role::SubscriberOnly::Drop >> + +=item L<< C|Sietima::Role::SubscriberOnly::Drop >> + silently drops all messages coming from addresses not subscribed to the list -= L<< C|Sietima::Role::SubscriberOnly::Moderate >> + +=item L<< C|Sietima::Role::SubscriberOnly::Moderate >> + holds messages coming from addresses not subscribed to the list for moderation, and provides commands to manage the moderation queue +=back + The only "configuration mechanism" currently supported is to initialise a C object in your driver script, passing all the needed values to the constructor. L<< C >> is the recommended way of doing that: it adds command-line parsing capability to Sietima. -=attr C +=head1 ATTRIBUTES + +=head2 C A L<< C >> instance, coerced from string if necessary. This is the address that Sietima will send messages I. -=cut - -has return_path => ( - isa => Address, - is => 'ro', - required => 1, - coerce => AddressFromStr, -); - -=attr C +=head2 C An array-ref of L<< C >> objects, defaults to the empty array. @@ -104,38 +239,16 @@ roles use the other attributes (L<< C|Sietima::Role::NoMail C >> uses C via L<< C|Sietima::Subscriber/match >>) -=cut - -my $subscribers_array = ArrayRef[ - Subscriber->plus_coercions( - SubscriberFromAddress, - SubscriberFromStr, - SubscriberFromHashRef, - ) -]; -has subscribers => ( - isa => $subscribers_array, - is => 'lazy', - coerce => $subscribers_array->coercion, -); -sub _build_subscribers { +[] } - -=attr C +=head2 C A L<< C >> instance, which will be used to send messages. If not passed in, Sietima uses L<< C >>'s L<< C|Email::Sender::Simple/default_transport >>. -=cut - -has transport => ( - isa => Transport, - is => 'lazy', -); -sub _build_transport { Email::Sender::Simple->default_transport } +=head1 METHODS -=method C +=head2 C $sietima->handle_mail_from_stdin(); @@ -143,17 +256,7 @@ This is the main entry-point when Sietima is invoked from a MTA. It will parse a L<< C >> object out of the standard input, then pass it to L<< /C >> for processing. -=cut - -sub handle_mail_from_stdin($self,@) { - my $mail_text = do { local $/; <> }; - # we're hoping that, since we probably got called from an MTA/MDA, - # STDIN contains a well-formed email message, addressed to us - my $incoming_mail = Email::MIME->new(\$mail_text); - return $self->handle_mail($incoming_mail); -} - -=method C +=head2 C $sietima->handle_mail($email_mime); @@ -161,19 +264,7 @@ Main driver method: converts the given email message into a list of L<< C >> objects by calling L<< /C >>, then sends each of them by calling L<< /C >>. -=cut - -sub handle_mail($self,$incoming_mail) { - state $check = compile(Object,EmailMIME); $check->(@_); - - my (@outgoing_messages) = $self->munge_mail($incoming_mail); - for my $outgoing_message (@outgoing_messages) { - $self->send_message($outgoing_message); - } - return; -} - -=method C +=head2 C my $subscribers_aref = $sietima->subscribers_to_send_to($email_mime); @@ -185,15 +276,7 @@ In this base class, it just returns the value of the L<< C|Sietima::Role::AvoidDups >> modify this method to exclude some subscribers. -=cut - -sub subscribers_to_send_to($self,$incoming_mail) { - state $check = compile(Object,EmailMIME); $check->(@_); - - return $self->subscribers; -} - -=method C +=head2 C my @messages = $sietima->munge_mail($email_mime); @@ -207,19 +290,7 @@ email message. Roles such as L<< C|Sietima::Role::SubjectTag >> modify this method to alter the message. -=cut - -sub munge_mail($self,$incoming_mail) { - state $check = compile(Object,EmailMIME); $check->(@_); - - return Sietima::Message->new({ - mail => $incoming_mail, - from => $self->return_path, - to => $self->subscribers_to_send_to($incoming_mail), - }); -} - -=method C +=head2 C $sietima->send_message($sietima_message); @@ -227,25 +298,7 @@ Sends the given L<< C >> object via the L<< /C >>, but only if the message's L specifies some recipients. -=cut - -sub send_message($self,$outgoing_message) { - state $check = compile(Object,Message); $check->(@_); - - my $envelope = $outgoing_message->envelope; - if ($envelope->{to} && $envelope->{to}->@*) { - $self->transport->send( - $outgoing_message->mail, - $envelope, - ); - } - - return; -} - -sub _trait_namespace { 'Sietima::Role' } ## no critic(ProhibitUnusedPrivateSubroutines) - -=method C +=head2 C my $addresses_href = $sietima->list_addresses; @@ -258,15 +311,7 @@ use this method at all. The L<< C|Sietima::Role::Headers >> role uses this to populate the various C headers. -=cut - -sub list_addresses($self) { - return +{ - return_path => $self->return_path, - }; -} - -=method C +=head2 C my $app_spec_data = $sietima->command_line_spec; @@ -290,19 +335,15 @@ For example, in a C<.qmail> file: Roles can extend this to provide additional sub-commands and options. -=cut +=head1 AUTHOR -sub command_line_spec($self) { - return { - name => 'sietima', - title => 'a simple mailing list manager', - subcommands => { - send => { - op => 'handle_mail_from_stdin', - summary => 'send email from STDIN', - }, - }, - }; -} +Gianni Ceccarelli -1; +=head1 COPYRIGHT AND LICENSE + +This software is copyright (c) 2017 by Gianni Ceccarelli . + +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. + +=cut diff --git a/lib/Sietima/CmdLine.pm b/lib/Sietima/CmdLine.pm index 6c24834..e014d48 100644 --- a/lib/Sietima/CmdLine.pm +++ b/lib/Sietima/CmdLine.pm @@ -8,9 +8,79 @@ use App::Spec; use Sietima::Runner; use namespace::clean; -# VERSION +our $VERSION = '1.0.0'; # VERSION # ABSTRACT: run Sietima as a command-line application + +has sietima => ( + is => 'ro', + required => 1, + isa => SietimaObj, +); + + +has extra_spec => ( + is => 'ro', + isa => HashRef, + default => sub { +{} }, +); + + +sub BUILDARGS($class,@args) { + my $args = $class->next::method(@args); + $args->{sietima} //= do { + my $traits = delete $args->{traits} // []; + my $constructor_args = delete $args->{args} // {}; + Sietima->with_traits($traits->@*)->new($constructor_args); + }; + return $args; +} + + +has app_spec => ( + is => 'lazy', + init_arg => undef, +); + +sub _build_app_spec($self) { + my $spec_data = $self->sietima->command_line_spec(); + + return App::Spec->read({ + $spec_data->%*, + $self->extra_spec->%*, + }); +} + + +has runner => ( + is => 'lazy', + init_arg => undef, + handles => [qw(run)], +); + +sub _build_runner($self) { + return Sietima::Runner->new({ + spec => $self->app_spec, + cmd => $self->sietima, + }); +} + +1; + +__END__ + +=pod + +=encoding UTF-8 + +=head1 NAME + +Sietima::CmdLine - run Sietima as a command-line application + +=head1 VERSION + +version 1.0.0 + =head1 SYNOPSIS use Sietima::CmdLine; @@ -28,35 +98,23 @@ use namespace::clean; This class simplifies the creation of a L<< C >> object, and uses L<< C >> to provide a command-line interface to it. -=attr C +=head1 ATTRIBUTES + +=head2 C Required, an instance of L<< C >>. You can either construct it yourself, or use the L. -=cut - -has sietima => ( - is => 'ro', - required => 1, - isa => SietimaObj, -); - -=attr C +=head2 C Optional hashref. Used inside L<< /C >>. If you're not familiar with L<< C >>, you probably don't want to touch this. -=cut - -has extra_spec => ( - is => 'ro', - isa => HashRef, - default => sub { +{} }, -); +=head1 METHODS -=method C +=head2 C my $cmdline = Sietima::CmdLine->new({ sietima => Sietima->with_traits(qw(SubjectTag))->new({ @@ -78,21 +136,7 @@ The constructor. In alternative to passing a L<< C >> instance, you can pass C and C, and the instance will be built for you. The two calls above are equivalent. -=for Pod::Coverage BUILDARGS - -=cut - -sub BUILDARGS($class,@args) { - my $args = $class->next::method(@args); - $args->{sietima} //= do { - my $traits = delete $args->{traits} // []; - my $constructor_args = delete $args->{args} // {}; - Sietima->with_traits($traits->@*)->new($constructor_args); - }; - return $args; -} - -=method C +=head2 C Returns an instance of L<< C >>, built from the specification returned by calling L<< @@ -101,47 +145,29 @@ C|Sietima/command_line_spec >> on the L<< method, and the C attribute, are probably only interesting to people who are doing weird extensions. -=cut - -has app_spec => ( - is => 'lazy', - init_arg => undef, -); - -sub _build_app_spec($self) { - my $spec_data = $self->sietima->command_line_spec(); - - return App::Spec->read({ - $spec_data->%*, - $self->extra_spec->%*, - }); -} - -=method C +=head2 C Returns an instance of L<< C >>, built from the L<< /C >>. -=method C +=head2 C Delegates to the L<< /C >>'s L<< C|App::Spec::Run/run >> method. Parser the command line arguments from C<@ARGV> and executes the appropriate action. -=cut +=for Pod::Coverage BUILDARGS -has runner => ( - is => 'lazy', - init_arg => undef, - handles => [qw(run)], -); +=head1 AUTHOR -sub _build_runner($self) { - return Sietima::Runner->new({ - spec => $self->app_spec, - cmd => $self->sietima, - }); -} +Gianni Ceccarelli -1; +=head1 COPYRIGHT AND LICENSE + +This software is copyright (c) 2017 by Gianni Ceccarelli . + +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. + +=cut diff --git a/lib/Sietima/MailStore.pm b/lib/Sietima/MailStore.pm index 5e6fc7f..9ddec2c 100644 --- a/lib/Sietima/MailStore.pm +++ b/lib/Sietima/MailStore.pm @@ -3,15 +3,38 @@ use Moo::Role; use Sietima::Policy; use namespace::clean; -# VERSION +our $VERSION = '1.0.0'; # VERSION # ABSTRACT: interface for mail stores + +requires 'store', + 'retrieve_ids_by_tags','retrieve_by_tags','retrieve_by_id', + 'remove','clear'; + +1; + +__END__ + +=pod + +=encoding UTF-8 + +=head1 NAME + +Sietima::MailStore - interface for mail stores + +=head1 VERSION + +version 1.0.0 + =head1 DESCRIPTION This role defines the interface that all mail stores must adhere to. It does not provide any implementation. -=require C +=head1 REQUIRED METHODS + +=head2 C my $id = $ms->store($email_mime_object,@tags); @@ -21,7 +44,7 @@ tags (which must be strings). Must return a unique identifier for the stored message. It is acceptable if identical messages are indistinguishable by the storage. -=require C +=head2 C my $email_mime_object = $ms->retrieve_by_id($id); @@ -32,7 +55,7 @@ C >> object). If the message has been deleted, or the identifier is not recognised, this method must return C in scalar context. -=require C +=head2 C my @ids = $ms->retrieve_ids_by_tags(@tags)->@*; @@ -55,7 +78,7 @@ For example: $ms->retrieve_ids_by_tags('t1','t2') ==> [ $id3 ] $ms->retrieve_ids_by_tags('t3') ==> [ ] -=require C +=head2 C my @email_mime_objects = $ms->retrieve_by_tags(@tags)->@*; @@ -71,7 +94,7 @@ return an arrayref of hashrefs. For example: { id => $id1, mail => $msg1 }, ] -=require C +=head2 C $ms->remove($id); @@ -79,17 +102,22 @@ This method must remove the message corresponding to the given identifier from the persistent storage. Removing a non-existent message must succeed, and do nothing. -=require C +=head2 C $ms->clear(); This method must remove all messages from the persistent storage. Clearing an empty store must succeed, and do nothing. -=cut +=head1 AUTHOR -requires 'store', - 'retrieve_ids_by_tags','retrieve_by_tags','retrieve_by_id', - 'remove','clear'; +Gianni Ceccarelli -1; +=head1 COPYRIGHT AND LICENSE + +This software is copyright (c) 2017 by Gianni Ceccarelli . + +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. + +=cut diff --git a/lib/Sietima/MailStore/FS.pm b/lib/Sietima/MailStore/FS.pm index c429dfd..1c204b5 100644 --- a/lib/Sietima/MailStore/FS.pm +++ b/lib/Sietima/MailStore/FS.pm @@ -8,40 +8,12 @@ use Sietima::Types qw(EmailMIME TagName); use Digest::SHA qw(sha1_hex); use namespace::clean; -# VERSION +our $VERSION = '1.0.0'; # VERSION # ABSTRACT: filesystem-backed email store -=head1 SYNOPSIS - - my $store = Sietima::MailStore::FS->new({ root => '/tmp/my-store' }); - -=head1 DESCRIPTION - -This class implements the L<< C >> interface, -storing emails as files on disk. - -=cut with 'Sietima::MailStore'; -=attr C - -Required, a L<< C >> object that points to an existing -directory. Coercible from a string. - -It's a good idea for the directory to be readable and writable by the -user who will run the mailing list, and also by all users who will run -administrative commands (like those provided by L<< -C >>). A way to achieve that -is to have a group dedicated to list owners, and set the directory -group-writable and group-sticky, and owned by that group: - - # chgrp -R mailinglists /tmp/my-store - # chmod -R g+rwXs /tmp/my-store - -=for Pod::Coverage BUILD - -=cut has root => ( is => 'ro', @@ -59,18 +31,6 @@ sub BUILD($self,@) { return; } -=method C - - my $id = $store->store($email_mime_object,@tags); - -Stores the given email message inside the L, and -associates with the given tags. - -Returns a unique identifier for the stored message. If you store twice -the same message (or two messages that stringify identically), you'll -get the same identifier. - -=cut sub store($self,$mail,@tags) { state $check = compile(Object,EmailMIME,slurpy ArrayRef[TagName]);$check->(@_); @@ -85,18 +45,6 @@ sub store($self,$mail,@tags) { return $id; } -=method C - - my $email_mime_object = $store->retrieve_by_id($id); - -Given an identifier returned by L<< /C >>, this method returns -the email message. - -If the message has been deleted, or the identifier is not recognised, -this method returns C in scalar context, or an empty list in -list context. - -=cut sub retrieve_by_id($self,$id) { state $check = compile(Object,Str);$check->(@_); @@ -106,19 +54,6 @@ sub retrieve_by_id($self,$id) { return Email::MIME->new($msg_path->slurp_raw); } -=method C - - my @ids = $store->retrieve_ids_by_tags(@tags)->@*; - -Given a list of tags, this method returns an arrayref containing the -identifiers of all (and only) the messages that were stored associated -with (at least) all those tags. The order of the returned identifiers -is essentially random. - -If there are no messages associated with the given tags, this method -returns an empty arrayref. - -=cut sub _tagged_by($self,$tag) { my $tag_file = $self->_tagdir->child($tag); @@ -150,19 +85,6 @@ sub retrieve_ids_by_tags($self,@tags) { return \@ret; } -=method C - - my @email_mime_objects = $store->retrieve_by_tags(@tags)->@*; - -This method is similar to L<< /C >>, but it -returns an arrayref of hashrefs like: - - $store->retrieve_ids_by_tags('t1') ==> [ - { id => $id1, mail => $msg1 }, - { id => $id2, mail => $msg2 }, - ] - -=cut sub retrieve_by_tags($self,@tags) { state $check = compile(Object,slurpy ArrayRef[TagName]);$check->(@_); @@ -178,14 +100,6 @@ sub retrieve_by_tags($self,@tags) { return \@ret; } -=method C - - $store->remove($id); - -This method removes the message corresponding to the given identifier -from disk. Removing a non-existent message does nothing. - -=cut sub remove($self,$id) { state $check = compile(Object,Str);$check->(@_); @@ -198,19 +112,127 @@ sub remove($self,$id) { return; } -=method C + +sub clear($self) { + do { $self->$_->remove_tree;$self->$_->mkpath } for qw(_tagdir _msgdir); + return; +} + +1; + +__END__ + +=pod + +=encoding UTF-8 + +=head1 NAME + +Sietima::MailStore::FS - filesystem-backed email store + +=head1 VERSION + +version 1.0.0 + +=head1 SYNOPSIS + + my $store = Sietima::MailStore::FS->new({ root => '/tmp/my-store' }); + +=head1 DESCRIPTION + +This class implements the L<< C >> interface, +storing emails as files on disk. + +=head1 ATTRIBUTES + +=head2 C + +Required, a L<< C >> object that points to an existing +directory. Coercible from a string. + +It's a good idea for the directory to be readable and writable by the +user who will run the mailing list, and also by all users who will run +administrative commands (like those provided by L<< +C >>). A way to achieve that +is to have a group dedicated to list owners, and set the directory +group-writable and group-sticky, and owned by that group: + + # chgrp -R mailinglists /tmp/my-store + # chmod -R g+rwXs /tmp/my-store + +=head1 METHODS + +=head2 C + + my $id = $store->store($email_mime_object,@tags); + +Stores the given email message inside the L, and +associates with the given tags. + +Returns a unique identifier for the stored message. If you store twice +the same message (or two messages that stringify identically), you'll +get the same identifier. + +=head2 C + + my $email_mime_object = $store->retrieve_by_id($id); + +Given an identifier returned by L<< /C >>, this method returns +the email message. + +If the message has been deleted, or the identifier is not recognised, +this method returns C in scalar context, or an empty list in +list context. + +=head2 C + + my @ids = $store->retrieve_ids_by_tags(@tags)->@*; + +Given a list of tags, this method returns an arrayref containing the +identifiers of all (and only) the messages that were stored associated +with (at least) all those tags. The order of the returned identifiers +is essentially random. + +If there are no messages associated with the given tags, this method +returns an empty arrayref. + +=head2 C + + my @email_mime_objects = $store->retrieve_by_tags(@tags)->@*; + +This method is similar to L<< /C >>, but it +returns an arrayref of hashrefs like: + + $store->retrieve_ids_by_tags('t1') ==> [ + { id => $id1, mail => $msg1 }, + { id => $id2, mail => $msg2 }, + ] + +=head2 C + + $store->remove($id); + +This method removes the message corresponding to the given identifier +from disk. Removing a non-existent message does nothing. + +=head2 C $store->clear(); This method removes all messages from disk. Clearing as empty store does nothing. +=for Pod::Coverage BUILD -=cut +=head1 AUTHOR -sub clear($self) { - do { $self->$_->remove_tree;$self->$_->mkpath } for qw(_tagdir _msgdir); - return; -} +Gianni Ceccarelli -1; +=head1 COPYRIGHT AND LICENSE + +This software is copyright (c) 2017 by Gianni Ceccarelli . + +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. + +=cut diff --git a/lib/Sietima/Message.pm b/lib/Sietima/Message.pm index b0d82e6..d5d6268 100644 --- a/lib/Sietima/Message.pm +++ b/lib/Sietima/Message.pm @@ -10,9 +10,62 @@ use Sietima::Subscriber; use Email::MIME; use namespace::clean; -# VERSION +our $VERSION = '1.0.0'; # VERSION # ABSTRACT: an email message with an envelope + +has mail => ( + is => 'ro', + isa => EmailMIME, + required => 1, +); + + +has from => ( + is => 'ro', + isa => Address, + coerce => AddressFromStr, + required => 1, +); + + +my $subscriber_array = ArrayRef[ + Subscriber->plus_coercions( + SubscriberFromStr, + SubscriberFromAddress, + ) +]; +has to => ( + isa => $subscriber_array, + is => 'ro', + coerce => $subscriber_array->coercion, + required => 1, +); + + +sub envelope ($self) { + return { + from => $self->from, + to => [ map { $_->address } $self->to->@* ], + } +} + +1; + +__END__ + +=pod + +=encoding UTF-8 + +=head1 NAME + +Sietima::Message - an email message with an envelope + +=head1 VERSION + +version 1.0.0 + =head1 SYNOPSIS use Sietima::Message; @@ -34,67 +87,39 @@ C|Sietima/send_message >>. All attributes are read-only and required. -=attr C +=head2 C An L<< C >> object, representing the message. -=cut - -has mail => ( - is => 'ro', - isa => EmailMIME, - required => 1, -); - -=attr C +=head2 C An L<< C >> object, coercible from a string, representing the sender. -=cut - -has from => ( - is => 'ro', - isa => Address, - coerce => AddressFromStr, - required => 1, -); - -=attr C +=head2 C An arrayref of L<< C >> objects, each coercible from a string or an L<< C >> object, representing the recipients. -=cut - -my $subscriber_array = ArrayRef[ - Subscriber->plus_coercions( - SubscriberFromStr, - SubscriberFromAddress, - ) -]; -has to => ( - isa => $subscriber_array, - is => 'ro', - coerce => $subscriber_array->coercion, - required => 1, -); +=head1 METHODS -=method C +=head2 C my %envelope = $message->envelope->%*; Returns a hashref with envelope data, suitable for use with L<< C|Email::Sender::Transport/send >>. -=cut +=head1 AUTHOR -sub envelope ($self) { - return { - from => $self->from, - to => [ map { $_->address } $self->to->@* ], - } -} +Gianni Ceccarelli -1; +=head1 COPYRIGHT AND LICENSE + +This software is copyright (c) 2017 by Gianni Ceccarelli . + +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. + +=cut diff --git a/lib/Sietima/Policy.pm b/lib/Sietima/Policy.pm index 73af98e..853e0a4 100644 --- a/lib/Sietima/Policy.pm +++ b/lib/Sietima/Policy.pm @@ -5,9 +5,36 @@ use warnings; use feature ':5.24'; use experimental 'signatures'; -# VERSION +our $VERSION = '1.0.0'; # VERSION # ABSTRACT: pragma for Sietima modules + +sub import { + # These affect the currently compiling scope, + # so no need for import::into + strict->import; + warnings->import; + experimental->import('signatures'); + feature->import(':5.24'); + return; +} + +1; + +__END__ + +=pod + +=encoding UTF-8 + +=head1 NAME + +Sietima::Policy - pragma for Sietima modules + +=head1 VERSION + +version 1.0.0 + =head1 SYNOPSIS use 5.024; @@ -25,16 +52,15 @@ or just: This module imports the pragmas shown in the L. All Sietima modules use it. -=cut +=head1 AUTHOR -sub import { - # These affect the currently compiling scope, - # so no need for import::into - strict->import; - warnings->import; - experimental->import('signatures'); - feature->import(':5.24'); - return; -} +Gianni Ceccarelli -1; +=head1 COPYRIGHT AND LICENSE + +This software is copyright (c) 2017 by Gianni Ceccarelli . + +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. + +=cut diff --git a/lib/Sietima/Role/AvoidDups.pm b/lib/Sietima/Role/AvoidDups.pm index e0a5bae..2cef67a 100644 --- a/lib/Sietima/Role/AvoidDups.pm +++ b/lib/Sietima/Role/AvoidDups.pm @@ -4,26 +4,9 @@ use Sietima::Policy; use Email::Address; use namespace::clean; -# VERSION +our $VERSION = '1.0.0'; # VERSION # ABSTRACT: prevent people from receiving the same message multiple times -=head1 SYNOPSIS - - my $sietima = Sietima->with_traits('AvoidDups')->new(\%args); - -=head1 DESCRIPTION - -A L<< C >> list with this role applied will not send a -message to a subscriber, if that subscriber is already mentioned in -the C or C header fields, because they can be assumed to be -already receiving the message directly from the sender. - -=modif C - -Filters out subscribers that L the -addresses in the C or C headers of the incoming email. - -=cut around subscribers_to_send_to => sub ($orig,$self,$mail) { my @already_receiving = map { @@ -43,3 +26,48 @@ around subscribers_to_send_to => sub ($orig,$self,$mail) { }; 1; + +__END__ + +=pod + +=encoding UTF-8 + +=head1 NAME + +Sietima::Role::AvoidDups - prevent people from receiving the same message multiple times + +=head1 VERSION + +version 1.0.0 + +=head1 SYNOPSIS + + my $sietima = Sietima->with_traits('AvoidDups')->new(\%args); + +=head1 DESCRIPTION + +A L<< C >> list with this role applied will not send a +message to a subscriber, if that subscriber is already mentioned in +the C or C header fields, because they can be assumed to be +already receiving the message directly from the sender. + +=head1 MODIFIED METHODS + +=head2 C + +Filters out subscribers that L the +addresses in the C or C headers of the incoming email. + +=head1 AUTHOR + +Gianni Ceccarelli + +=head1 COPYRIGHT AND LICENSE + +This software is copyright (c) 2017 by Gianni Ceccarelli . + +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. + +=cut diff --git a/lib/Sietima/Role/Debounce.pm b/lib/Sietima/Role/Debounce.pm index e6bd087..3f362f5 100644 --- a/lib/Sietima/Role/Debounce.pm +++ b/lib/Sietima/Role/Debounce.pm @@ -3,9 +3,41 @@ use Moo::Role; use Sietima::Policy; use namespace::clean; -# VERSION +our $VERSION = '1.0.0'; # VERSION # ABSTRACT: avoid mail loops + +my $been_there = 'X-Been-There'; + +around munge_mail => sub ($orig,$self,$incoming_mail) { + my $return_path = $self->return_path->address; + if (my $there = $incoming_mail->header_str($been_there)) { + return if $there =~ m{\b\Q$return_path\E\b}; + } + + $incoming_mail->header_str_set( + $been_there => $return_path, + ); + + return $self->$orig($incoming_mail); +}; + +1; + +__END__ + +=pod + +=encoding UTF-8 + +=head1 NAME + +Sietima::Role::Debounce - avoid mail loops + +=head1 VERSION + +version 1.0.0 + =head1 SYNOPSIS my $sietima = Sietima->with_traits('Debounce')->new(\%args); @@ -18,28 +50,24 @@ have that same header. This prevents messages bounced by other services from being looped between the mailing list and those other services. -=modif C +=head1 MODIFIED METHODS + +=head2 C If the incoming email contains our C header, this method will return an empty list (essentially dropping the message). Otherwise, the header is added, and the email is processed normally. -=cut +=head1 AUTHOR -my $been_there = 'X-Been-There'; +Gianni Ceccarelli -around munge_mail => sub ($orig,$self,$incoming_mail) { - my $return_path = $self->return_path->address; - if (my $there = $incoming_mail->header_str($been_there)) { - return if $there =~ m{\b\Q$return_path\E\b}; - } +=head1 COPYRIGHT AND LICENSE - $incoming_mail->header_str_set( - $been_there => $return_path, - ); +This software is copyright (c) 2017 by Gianni Ceccarelli . - return $self->$orig($incoming_mail); -}; +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. -1; +=cut diff --git a/lib/Sietima/Role/Headers.pm b/lib/Sietima/Role/Headers.pm index a1aa566..1f11ecc 100644 --- a/lib/Sietima/Role/Headers.pm +++ b/lib/Sietima/Role/Headers.pm @@ -5,44 +5,9 @@ use Sietima::Policy; use Types::Standard qw(Str); use namespace::clean; -# VERSION +our $VERSION = '1.0.0'; # VERSION # ABSTRACT: adds standard list-related headers to messages -=head1 SYNOPSIS - - my $sietima = Sietima->with_traits('Headers')->new({ - %args, - name => $name_of_the_list, - }); - -=head1 DESCRIPTION - -A L<< C >> list with this role applied will add, to each -outgoing message, the set of headers defined in RFC 2919 and RFC 2369. - -This role uses the L<< C|Sietima/list_addresses >> -method to determine what headers to add. - -If the C attribute is set, a C header will be added, -with a value built out of the name and the C<< -$self->list_addresses->{return_path} >> value (which is normally the -same as the L<< C|Sietima/return_path >> attribute). - -Other C headers are built from the other values in the -C hashref. Those values can either be L<< -C >> objects (in which case the header will have a -C URI as value) or strings (which will be used literally for -the value of the header). - -=attr C - -Optional string, the name of the mailing list. If this attribute is -set, a C header will be added, with a value built out of the -name and the C<< $self->list_addresses->{return_path} >> value (which -is normally the same as the L<< C|Sietima/return_path >> -attribute). - -=cut has name => ( isa => Str, @@ -86,12 +51,6 @@ sub _add_headers_to($self,$message) { return; } -=modif C - -This method adds list-management headers to each message returned by -the original method. - -=cut around munge_mail => sub ($orig,$self,$mail) { my @messages = $self->$orig($mail); @@ -100,3 +59,73 @@ around munge_mail => sub ($orig,$self,$mail) { }; 1; + +__END__ + +=pod + +=encoding UTF-8 + +=head1 NAME + +Sietima::Role::Headers - adds standard list-related headers to messages + +=head1 VERSION + +version 1.0.0 + +=head1 SYNOPSIS + + my $sietima = Sietima->with_traits('Headers')->new({ + %args, + name => $name_of_the_list, + }); + +=head1 DESCRIPTION + +A L<< C >> list with this role applied will add, to each +outgoing message, the set of headers defined in RFC 2919 and RFC 2369. + +This role uses the L<< C|Sietima/list_addresses >> +method to determine what headers to add. + +If the C attribute is set, a C header will be added, +with a value built out of the name and the C<< +$self->list_addresses->{return_path} >> value (which is normally the +same as the L<< C|Sietima/return_path >> attribute). + +Other C headers are built from the other values in the +C hashref. Those values can either be L<< +C >> objects (in which case the header will have a +C URI as value) or strings (which will be used literally for +the value of the header). + +=head1 ATTRIBUTES + +=head2 C + +Optional string, the name of the mailing list. If this attribute is +set, a C header will be added, with a value built out of the +name and the C<< $self->list_addresses->{return_path} >> value (which +is normally the same as the L<< C|Sietima/return_path >> +attribute). + +=head1 MODIFIED METHODS + +=head2 C + +This method adds list-management headers to each message returned by +the original method. + +=head1 AUTHOR + +Gianni Ceccarelli + +=head1 COPYRIGHT AND LICENSE + +This software is copyright (c) 2017 by Gianni Ceccarelli . + +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. + +=cut diff --git a/lib/Sietima/Role/ManualSubscription.pm b/lib/Sietima/Role/ManualSubscription.pm index fd75f80..1023fa3 100644 --- a/lib/Sietima/Role/ManualSubscription.pm +++ b/lib/Sietima/Role/ManualSubscription.pm @@ -4,11 +4,44 @@ use Sietima::Policy; use URI; use namespace::clean; -# VERSION +our $VERSION = '1.0.0'; # VERSION # ABSTRACT: adds standard list-related headers to messages with 'Sietima::Role::WithOwner'; + +around list_addresses => sub($orig,$self) { + my $list_name = $self->name // 'the list'; + my $mail_owner_uri = URI->new($self->owner,'mailto'); + my $sub_uri = $mail_owner_uri->clone; + $sub_uri->query_form(subject => "Please add me to $list_name"); + my $unsub_uri = $mail_owner_uri->clone; + $unsub_uri->query_form(subject => "Please remove me from $list_name"); + + return +{ + $self->$orig->%*, + subscribe => $sub_uri, + unsubscribe => $unsub_uri, + }; +}; + + +1; + +__END__ + +=pod + +=encoding UTF-8 + +=head1 NAME + +Sietima::Role::ManualSubscription - adds standard list-related headers to messages + +=head1 VERSION + +version 1.0.0 + =head1 SYNOPSIS my $sietima = Sietima->with_traits( @@ -26,28 +59,23 @@ C|Sietima::Role::Headers >>) applied will add, to each outgoing message, headers specifying that to subscribe and unsubscribe, people sould email the list owner. -=modif C +=head1 MODIFIED METHODS + +=head2 C This method declares two "addresses", C and C. Both are C URLs for the list L, with different subjects. -=cut +=head1 AUTHOR -around list_addresses => sub($orig,$self) { - my $list_name = $self->name // 'the list'; - my $mail_owner_uri = URI->new($self->owner,'mailto'); - my $sub_uri = $mail_owner_uri->clone; - $sub_uri->query_form(subject => "Please add me to $list_name"); - my $unsub_uri = $mail_owner_uri->clone; - $unsub_uri->query_form(subject => "Please remove me from $list_name"); +Gianni Ceccarelli - return +{ - $self->$orig->%*, - subscribe => $sub_uri, - unsubscribe => $unsub_uri, - }; -}; +=head1 COPYRIGHT AND LICENSE +This software is copyright (c) 2017 by Gianni Ceccarelli . -1; +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. + +=cut diff --git a/lib/Sietima/Role/NoMail.pm b/lib/Sietima/Role/NoMail.pm index 10071d6..adb7f3e 100644 --- a/lib/Sietima/Role/NoMail.pm +++ b/lib/Sietima/Role/NoMail.pm @@ -3,9 +3,33 @@ use Moo::Role; use Sietima::Policy; use namespace::clean; -# VERSION +our $VERSION = '1.0.0'; # VERSION # ABSTRACT: don't send mail to those who don't want it + +around subscribers_to_send_to => sub ($orig,$self,$mail) { + return [ + grep { $_->prefs->{wants_mail} // 1 } + $self->$orig($mail)->@*, + ]; +}; + +1; + +__END__ + +=pod + +=encoding UTF-8 + +=head1 NAME + +Sietima::Role::NoMail - don't send mail to those who don't want it + +=head1 VERSION + +version 1.0.0 + =head1 SYNOPSIS my $sietima = Sietima->with_traits('NoMail')->new({ @@ -22,18 +46,22 @@ A L<< C >> list with this role applied will not send messages to subscribers that have the C preference set to a false value. -=modif C +=head1 MODIFIED METHODS + +=head2 C Filters out subscribers that have the C preference set to a false value. -=cut +=head1 AUTHOR -around subscribers_to_send_to => sub ($orig,$self,$mail) { - return [ - grep { $_->prefs->{wants_mail} // 1 } - $self->$orig($mail)->@*, - ]; -}; +Gianni Ceccarelli -1; +=head1 COPYRIGHT AND LICENSE + +This software is copyright (c) 2017 by Gianni Ceccarelli . + +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. + +=cut diff --git a/lib/Sietima/Role/ReplyTo.pm b/lib/Sietima/Role/ReplyTo.pm index 6b21f20..4a1ca48 100644 --- a/lib/Sietima/Role/ReplyTo.pm +++ b/lib/Sietima/Role/ReplyTo.pm @@ -6,9 +6,79 @@ use Sietima::Types qw(Address AddressFromStr); use List::AllUtils qw(part); use namespace::clean; -# VERSION +our $VERSION = '1.0.0'; # VERSION # ABSTRACT: munge the C header + +with 'Sietima::Role::WithPostAddress'; + + +has munge_reply_to => ( + is => 'ro', + isa => Bool, + default => 0, +); + + +around munge_mail => sub ($orig,$self,$mail) { + my @messages = $self->$orig($mail); + my @ret; + for my $m (@messages) { + my ($leave,$munge) = part { + my $m = $_->prefs->{munge_reply_to}; + defined $m ? ( + $m ? 1 : 0 + ) : ( $self->munge_reply_to ? 1 : 0 ) + } $m->to->@*; + + if (not ($munge and $munge->@*)) { + # nothing to do + push @ret,$m; + } + elsif (not ($leave and $leave->@*)) { + # all these recipients want munging + $m->mail->header_str_set('Reply-To',$self->post_address->address); + push @ret,$m; + } + else { + # some want it, some don't: create two different messages + my $leave_message = Sietima::Message->new({ + mail => $m->mail, + from => $m->from, + to => $leave, + }); + + my $munged_mail = Email::MIME->new($m->mail->as_string); + $munged_mail->header_str_set('Reply-To',$self->post_address->address); + + my $munged_message = Sietima::Message->new({ + mail => $munged_mail, + from => $m->from, + to => $munge, + }); + + push @ret,$leave_message,$munged_message; + } + } + return @ret; +}; + +1; + +__END__ + +=pod + +=encoding UTF-8 + +=head1 NAME + +Sietima::Role::ReplyTo - munge the C header + +=head1 VERSION + +version 1.0.0 + =head1 SYNOPSIS my $sietima = Sietima->with_traits('ReplyTo')->new({ @@ -36,26 +106,18 @@ not touched. This is a "sub-role" of L<< C|Sietima::Role::WithPostAddress >>. -=cut - -with 'Sietima::Role::WithPostAddress'; +=head1 ATTRIBUTES -=attr C +=head2 C Optional boolean, defaults to false. If set to a true value, all messages will have their C header set to the value of the L<< /C >> attribute. This setting can be overridden by individual subscribers with the C preference. -=cut - -has munge_reply_to => ( - is => 'ro', - isa => Bool, - default => 0, -); +=head1 MODIFIED METHODS -=modif C +=head2 C For each message returned by the original method, this method partitions the subscribers, who are recipients of the message, @@ -74,49 +136,15 @@ don't, this method will clone the message, modify the header in one copy, set the appropriate part of the recipients to each copy, and pass both through. -=cut +=head1 AUTHOR -around munge_mail => sub ($orig,$self,$mail) { - my @messages = $self->$orig($mail); - my @ret; - for my $m (@messages) { - my ($leave,$munge) = part { - my $m = $_->prefs->{munge_reply_to}; - defined $m ? ( - $m ? 1 : 0 - ) : ( $self->munge_reply_to ? 1 : 0 ) - } $m->to->@*; +Gianni Ceccarelli - if (not ($munge and $munge->@*)) { - # nothing to do - push @ret,$m; - } - elsif (not ($leave and $leave->@*)) { - # all these recipients want munging - $m->mail->header_str_set('Reply-To',$self->post_address->address); - push @ret,$m; - } - else { - # some want it, some don't: create two different messages - my $leave_message = Sietima::Message->new({ - mail => $m->mail, - from => $m->from, - to => $leave, - }); - - my $munged_mail = Email::MIME->new($m->mail->as_string); - $munged_mail->header_str_set('Reply-To',$self->post_address->address); +=head1 COPYRIGHT AND LICENSE - my $munged_message = Sietima::Message->new({ - mail => $munged_mail, - from => $m->from, - to => $munge, - }); +This software is copyright (c) 2017 by Gianni Ceccarelli . - push @ret,$leave_message,$munged_message; - } - } - return @ret; -}; +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. -1; +=cut diff --git a/lib/Sietima/Role/SubjectTag.pm b/lib/Sietima/Role/SubjectTag.pm index 7602405..20aeecc 100644 --- a/lib/Sietima/Role/SubjectTag.pm +++ b/lib/Sietima/Role/SubjectTag.pm @@ -4,9 +4,44 @@ use Sietima::Policy; use Types::Standard qw(Str); use namespace::clean; -# VERSION +our $VERSION = '1.0.0'; # VERSION # ABSTRACT: add a tag to messages' subjects + +has subject_tag => ( + is => 'ro', + isa => Str, + required => 1, +); + + +around munge_mail => sub ($orig,$self,$mail) { + my $tag = '['.$self->subject_tag.']'; + my $subject = $mail->header_str('Subject'); + unless ($subject =~ m{\Q$tag\E}) { + $mail->header_str_set( + Subject => "$tag $subject", + ); + } + return $self->$orig($mail); +}; + +1; + +__END__ + +=pod + +=encoding UTF-8 + +=head1 NAME + +Sietima::Role::SubjectTag - add a tag to messages' subjects + +=head1 VERSION + +version 1.0.0 + =head1 SYNOPSIS my $sietima = Sietima->with_traits('SubjectTag')->new({ @@ -19,7 +54,9 @@ use namespace::clean; A L<< C >> list with this role applied will prepend the given tag to every outgoing message's C header. -=attr C +=head1 ATTRIBUTES + +=head2 C Required string. This string, enclosed by square brackets, will be prepended to the C header of outgoing messages. For example, @@ -30,30 +67,22 @@ If the incoming message's C header already contains the tag, the header will not be modified. This prevents getting subjects like "[foo] Re: [foo] Re: [foo] new stuff". -=cut +=head1 MODIFIED METHODS -has subject_tag => ( - is => 'ro', - isa => Str, - required => 1, -); - -=modif C +=head2 C The subject of the incoming email is modified to add the tag (unless it's already there). The email is then processed normally. -=cut +=head1 AUTHOR -around munge_mail => sub ($orig,$self,$mail) { - my $tag = '['.$self->subject_tag.']'; - my $subject = $mail->header_str('Subject'); - unless ($subject =~ m{\Q$tag\E}) { - $mail->header_str_set( - Subject => "$tag $subject", - ); - } - return $self->$orig($mail); -}; +Gianni Ceccarelli -1; +=head1 COPYRIGHT AND LICENSE + +This software is copyright (c) 2017 by Gianni Ceccarelli . + +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. + +=cut diff --git a/lib/Sietima/Role/SubscriberOnly.pm b/lib/Sietima/Role/SubscriberOnly.pm index 6524d39..f457115 100644 --- a/lib/Sietima/Role/SubscriberOnly.pm +++ b/lib/Sietima/Role/SubscriberOnly.pm @@ -7,9 +7,50 @@ use Types::Standard qw(Object CodeRef); use Type::Params qw(compile); use namespace::clean; -# VERSION +our $VERSION = '1.0.0'; # VERSION # ABSTRACT: base role for "closed" lists + +requires 'munge_mail_from_non_subscriber'; + +our $let_it_pass=0; ## no critic(ProhibitPackageVars) + + +around munge_mail => sub ($orig,$self,$mail) { + my ($from) = Email::Address->parse( $mail->header_str('from') ); + if ( $let_it_pass or + any { $_->match($from) } $self->subscribers->@* ) { + $self->$orig($mail); + } + else { + $self->munge_mail_from_non_subscriber($mail); + } +}; + + +sub ignoring_subscriberonly($self,$code) { + state $check = compile(Object,CodeRef); $check->(@_); + + local $let_it_pass = 1; + return $code->($self); +} + +1; + +__END__ + +=pod + +=encoding UTF-8 + +=head1 NAME + +Sietima::Role::SubscriberOnly - base role for "closed" lists + +=head1 VERSION + +version 1.0.0 + =head1 SYNOPSIS package Sietima::Role::SubscriberOnly::MyPolicy; @@ -29,7 +70,9 @@ with messages from non-subscribers. See L<< C >> and L<< C >> for useable roles. -=require C +=head1 REQUIRED METHODS + +=head2 C sub munge_mail_from_non_subscriber($self,$mail) { ... } @@ -40,50 +83,37 @@ of L<< C >> objects, just like C. It can also have side-effects, like forwarding the email to the owner of the list. -=cut +=head1 METHODS -requires 'munge_mail_from_non_subscriber'; +=head2 C -our $let_it_pass=0; ## no critic(ProhibitPackageVars) + $sietima->ignoring_subscriberonly(sub($s) { + $s->handle_mail($mail); + }); + +This method provides a way to run Sietima ignoring the "subscriber +only" beaviour. Your coderef will be passed a Sietima object that will +behave exactly as the invocant of this method, minus this role's +modifications. + +=head1 MODIFIED METHODS -=modif C +=head2 C If the incoming email's C header contains an address that L any of the subscribers, the email is processed normally. Otherwise, L<< /C >> is invoked. -=cut +=head1 AUTHOR -around munge_mail => sub ($orig,$self,$mail) { - my ($from) = Email::Address->parse( $mail->header_str('from') ); - if ( $let_it_pass or - any { $_->match($from) } $self->subscribers->@* ) { - $self->$orig($mail); - } - else { - $self->munge_mail_from_non_subscriber($mail); - } -}; +Gianni Ceccarelli -=method C +=head1 COPYRIGHT AND LICENSE - $sietima->ignoring_subscriberonly(sub($s) { - $s->handle_mail($mail); - }); +This software is copyright (c) 2017 by Gianni Ceccarelli . -This method provides a way to run Sietima ignoring the "subscriber -only" beaviour. Your coderef will be passed a Sietima object that will -behave exactly as the invocant of this method, minus this role's -modifications. +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. =cut - -sub ignoring_subscriberonly($self,$code) { - state $check = compile(Object,CodeRef); $check->(@_); - - local $let_it_pass = 1; - return $code->($self); -} - -1; diff --git a/lib/Sietima/Role/SubscriberOnly/Drop.pm b/lib/Sietima/Role/SubscriberOnly/Drop.pm index d9de94e..5804b6f 100644 --- a/lib/Sietima/Role/SubscriberOnly/Drop.pm +++ b/lib/Sietima/Role/SubscriberOnly/Drop.pm @@ -3,9 +3,31 @@ use Moo::Role; use Sietima::Policy; use namespace::clean; -# VERSION +our $VERSION = '1.0.0'; # VERSION # ABSTRACT: drop messages from non-subscribers + +with 'Sietima::Role::SubscriberOnly'; + + +sub munge_mail_from_non_subscriber { } + +1; + +__END__ + +=pod + +=encoding UTF-8 + +=head1 NAME + +Sietima::Role::SubscriberOnly::Drop - drop messages from non-subscribers + +=head1 VERSION + +version 1.0.0 + =head1 SYNOPSIS my $sietima = Sietima->with_traits('SubscribersOnly::Drop')->new({ @@ -21,16 +43,21 @@ subscribers. This is a "sub-role" of L<< C|Sietima::Role::SubscriberOnly >>. -=cut - -with 'Sietima::Role::SubscriberOnly'; +=head1 METHODS -=method C +=head2 C Does nothing, returns an empty list. -=cut +=head1 AUTHOR -sub munge_mail_from_non_subscriber { } +Gianni Ceccarelli -1; +=head1 COPYRIGHT AND LICENSE + +This software is copyright (c) 2017 by Gianni Ceccarelli . + +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. + +=cut diff --git a/lib/Sietima/Role/SubscriberOnly/Moderate.pm b/lib/Sietima/Role/SubscriberOnly/Moderate.pm index c4d62c9..bf89fce 100644 --- a/lib/Sietima/Role/SubscriberOnly/Moderate.pm +++ b/lib/Sietima/Role/SubscriberOnly/Moderate.pm @@ -5,46 +5,14 @@ use Email::Stuffer; use Email::MIME; use namespace::clean; -# VERSION +our $VERSION = '1.0.0'; # VERSION # ABSTRACT: moderate messages from non-subscribers -=head1 SYNOPSIS - - my $sietima = Sietima->with_traits('SubscribersOnly::Moderate')->new({ - %args, - owner => 'listmaster@example.com', - mail_store => { - class => 'Sietima::MailStore::FS', - root => '/tmp', - }, - }); - -=head1 DESCRIPTION - -A L<< C >> list with this role applied will accept incoming -emails coming from non-subscribers, and store it for moderation. Each -such email will be forwarded (as an attachment) to the list's owner. - -The owner will the be able to delete the message, or allow it. - -This is a "sub-role" of L<< -C|Sietima::Role::SubscriberOnly >>, L<< -C|Sietima::Role::WithMailStore >>, and L<< -C|Sietima::Role::WithOwner >>. - -=cut with 'Sietima::Role::SubscriberOnly', 'Sietima::Role::WithMailStore', 'Sietima::Role::WithOwner'; -=method C - -L the email with the C -tag, and forwards it to the L. - -=cut sub munge_mail_from_non_subscriber ($self,$mail) { my $id = $self->mail_store->store($mail,'moderation'); @@ -67,17 +35,6 @@ sub munge_mail_from_non_subscriber ($self,$mail) { return; } -=method C - - $sietima->resume($mail_id); - -Given an identifier returned when L -an email, this method retrieves the email and re-processes it via L<< -C|Sietima::Role::SubscriberOnly/ignoring_subscriberonly ->>. This will make sure that the email is not caught again by the -subscriber-only filter. - -=cut sub resume ($self,$mail_id) { my $mail = $self->mail_store->retrieve_by_id($mail_id); @@ -87,32 +44,11 @@ sub resume ($self,$mail_id) { $self->mail_store->remove($mail_id); } -=method C - - $sietima->drop($mail_id); - -Given an identifier returned when L -an email, this method deletes the email from the store. - -=cut sub drop ($self,$mail_id) { $self->mail_store->remove($mail_id); } -=method C - - $sietima->list_mails_in_moderation_queue($sietima_runner); - -This method L of messages tagged -C, and L via the -L<< C >> object. - -This method is usually invoked from the command line, see L<< -/C >>. - -=cut sub list_mails_in_moderation_queue ($self,$runner,@) { my $mails = $self->mail_store->retrieve_by_tags('moderation'); @@ -127,18 +63,6 @@ sub list_mails_in_moderation_queue ($self,$runner,@) { } } -=method C - - $sietima->show_mail_from_moderation_queue($sietima_runner); - -This method L -of the message requested from the command line, and L via the L<< C >> object. - -This method is usually invoked from the command line, see L<< -/C >>. - -=cut sub show_mail_from_moderation_queue ($self,$runner,@) { my $id = $runner->parameters->{'mail-id'}; @@ -147,45 +71,6 @@ sub show_mail_from_moderation_queue ($self,$runner,@) { $runner->out($mail->as_string =~ s{\r\n}{\n}gr); } -=modif C - -This method adds the following sub-commands for the command line: - -=over - -=item C - - $ sietima list-held - -Invokes the L<< /C >> method, printing -the identifiers of all messages held for moderation. - -=item C - - $ sietima show-held 32946p6eu7867 - -Invokes the L<< /C >> method, -printing one message held for moderation; the identifier is expected -as a positional parameter. - -=item C - - $ sietima resume-held 32946p6eu7867 - -Invokes the L<< /C >> method, causing the held message to be -processed normally; the identifier is expected as a positional -parameter. - -=item C - - $ sietima drop-held 32946p6eu7867 - -Invokes the L<< /C >> method, removing the held message; the -identifier is expected as a positional parameter. - -=back - -=cut around command_line_spec => sub ($orig,$self) { my $spec = $self->$orig(); @@ -235,3 +120,142 @@ around command_line_spec => sub ($orig,$self) { }; 1; + +__END__ + +=pod + +=encoding UTF-8 + +=head1 NAME + +Sietima::Role::SubscriberOnly::Moderate - moderate messages from non-subscribers + +=head1 VERSION + +version 1.0.0 + +=head1 SYNOPSIS + + my $sietima = Sietima->with_traits('SubscribersOnly::Moderate')->new({ + %args, + owner => 'listmaster@example.com', + mail_store => { + class => 'Sietima::MailStore::FS', + root => '/tmp', + }, + }); + +=head1 DESCRIPTION + +A L<< C >> list with this role applied will accept incoming +emails coming from non-subscribers, and store it for moderation. Each +such email will be forwarded (as an attachment) to the list's owner. + +The owner will the be able to delete the message, or allow it. + +This is a "sub-role" of L<< +C|Sietima::Role::SubscriberOnly >>, L<< +C|Sietima::Role::WithMailStore >>, and L<< +C|Sietima::Role::WithOwner >>. + +=head1 METHODS + +=head2 C + +L the email with the C +tag, and forwards it to the L. + +=head2 C + + $sietima->resume($mail_id); + +Given an identifier returned when L +an email, this method retrieves the email and re-processes it via L<< +C|Sietima::Role::SubscriberOnly/ignoring_subscriberonly +>>. This will make sure that the email is not caught again by the +subscriber-only filter. + +=head2 C + + $sietima->drop($mail_id); + +Given an identifier returned when L +an email, this method deletes the email from the store. + +=head2 C + + $sietima->list_mails_in_moderation_queue($sietima_runner); + +This method L of messages tagged +C, and L via the +L<< C >> object. + +This method is usually invoked from the command line, see L<< +/C >>. + +=head2 C + + $sietima->show_mail_from_moderation_queue($sietima_runner); + +This method L +of the message requested from the command line, and L via the L<< C >> object. + +This method is usually invoked from the command line, see L<< +/C >>. + +=head1 MODIFIED METHODS + +=head2 C + +This method adds the following sub-commands for the command line: + +=over + +=item C + + $ sietima list-held + +Invokes the L<< /C >> method, printing +the identifiers of all messages held for moderation. + +=item C + + $ sietima show-held 32946p6eu7867 + +Invokes the L<< /C >> method, +printing one message held for moderation; the identifier is expected +as a positional parameter. + +=item C + + $ sietima resume-held 32946p6eu7867 + +Invokes the L<< /C >> method, causing the held message to be +processed normally; the identifier is expected as a positional +parameter. + +=item C + + $ sietima drop-held 32946p6eu7867 + +Invokes the L<< /C >> method, removing the held message; the +identifier is expected as a positional parameter. + +=back + +=head1 AUTHOR + +Gianni Ceccarelli + +=head1 COPYRIGHT AND LICENSE + +This software is copyright (c) 2017 by Gianni Ceccarelli . + +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. + +=cut diff --git a/lib/Sietima/Role/WithMailStore.pm b/lib/Sietima/Role/WithMailStore.pm index 7ca4b4e..e9f6b51 100644 --- a/lib/Sietima/Role/WithMailStore.pm +++ b/lib/Sietima/Role/WithMailStore.pm @@ -4,9 +4,33 @@ use Sietima::Policy; use Sietima::Types qw(MailStore MailStoreFromHashRef); use namespace::clean; -# VERSION +our $VERSION = '1.0.0'; # VERSION # ABSTRACT: role for lists with a store for messages + +has mail_store => ( + is => 'ro', + isa => MailStore, + required => 1, + coerce => MailStoreFromHashRef, +); + +1; + +__END__ + +=pod + +=encoding UTF-8 + +=head1 NAME + +Sietima::Role::WithMailStore - role for lists with a store for messages + +=head1 VERSION + +version 1.0.0 + =head1 SYNOPSIS my $sietima = Sietima->with_traits('WithMailStore')->new({ @@ -25,7 +49,9 @@ On its own, this role is not very useful, but other roles (like L<< C|Sietima::Role::SubscriberOnly::Moderate >>) can have uses for an object that can persistently store messages. -=attr C +=head1 ATTRIBUTES + +=head2 C Required instance of an object that consumes the L<< C >> role. Instead of passing an instance, you can @@ -33,13 +59,15 @@ pass a hashref (like in the L): the C key provides the class name, and the rest of the hash will be passed to its constructor. -=cut +=head1 AUTHOR -has mail_store => ( - is => 'ro', - isa => MailStore, - required => 1, - coerce => MailStoreFromHashRef, -); +Gianni Ceccarelli -1; +=head1 COPYRIGHT AND LICENSE + +This software is copyright (c) 2017 by Gianni Ceccarelli . + +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. + +=cut diff --git a/lib/Sietima/Role/WithOwner.pm b/lib/Sietima/Role/WithOwner.pm index 1dfd362..f5757be 100644 --- a/lib/Sietima/Role/WithOwner.pm +++ b/lib/Sietima/Role/WithOwner.pm @@ -4,9 +4,41 @@ use Sietima::Policy; use Sietima::Types qw(Address AddressFromStr); use namespace::clean; -# VERSION +our $VERSION = '1.0.0'; # VERSION # ABSTRACT: role for lists with an owner + +has owner => ( + is => 'ro', + isa => Address, + required => 1, + coerce => AddressFromStr, +); + + +around list_addresses => sub($orig,$self) { + return +{ + $self->$orig->%*, + owner => $self->owner, + }; +}; + +1; + +__END__ + +=pod + +=encoding UTF-8 + +=head1 NAME + +Sietima::Role::WithOwner - role for lists with an owner + +=head1 VERSION + +version 1.0.0 + =head1 SYNOPSIS my $sietima = Sietima->with_traits('WithOwner')->new({ @@ -23,31 +55,28 @@ On its own, this role is not very useful, but other roles (like L<< C|Sietima::Role::SubscriberOnly::Moderate >>) can have uses for an owner address. -=attr C +=head1 ATTRIBUTES + +=head2 C Required instance of L<< C >>, coercible from a string. This is the address of the owner of the list. -=cut - -has owner => ( - is => 'ro', - isa => Address, - required => 1, - coerce => AddressFromStr, -); +=head1 MODIFIED METHODS -=modif C +=head2 C This method declares the C address. -=cut +=head1 AUTHOR -around list_addresses => sub($orig,$self) { - return +{ - $self->$orig->%*, - owner => $self->owner, - }; -}; +Gianni Ceccarelli -1; +=head1 COPYRIGHT AND LICENSE + +This software is copyright (c) 2017 by Gianni Ceccarelli . + +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. + +=cut diff --git a/lib/Sietima/Role/WithPostAddress.pm b/lib/Sietima/Role/WithPostAddress.pm index 333c5e3..7cb82e5 100644 --- a/lib/Sietima/Role/WithPostAddress.pm +++ b/lib/Sietima/Role/WithPostAddress.pm @@ -4,9 +4,40 @@ use Sietima::Policy; use Sietima::Types qw(Address AddressFromStr); use namespace::clean; -# VERSION +our $VERSION = '1.0.0'; # VERSION # ABSTRACT: role for lists with a posting address + +has post_address => ( + is => 'lazy', + isa => Address, + coerce => AddressFromStr, +); +sub _build_post_address($self) { $self->return_path } + +around list_addresses => sub($orig,$self) { + return +{ + $self->$orig->%*, + post => $self->post_address, + }; +}; + +1; + +__END__ + +=pod + +=encoding UTF-8 + +=head1 NAME + +Sietima::Role::WithPostAddress - role for lists with a posting address + +=head1 VERSION + +version 1.0.0 + =head1 SYNOPSIS my $sietima = Sietima->with_traits('WithPostAddress')->new({ @@ -24,26 +55,23 @@ On its own, this role is not very useful, but other roles (like L<< C|Sietima::Role::ReplyTo >>) can have uses for a post address. -=attr C +=head1 ATTRIBUTES + +=head2 C An L<< C >> object, defaults to the value of the L<< C|Sietima/return_path >> attribute. This is the address that the mailing list receives messages at. -=cut +=head1 AUTHOR -has post_address => ( - is => 'lazy', - isa => Address, - coerce => AddressFromStr, -); -sub _build_post_address($self) { $self->return_path } +Gianni Ceccarelli -around list_addresses => sub($orig,$self) { - return +{ - $self->$orig->%*, - post => $self->post_address, - }; -}; +=head1 COPYRIGHT AND LICENSE -1; +This software is copyright (c) 2017 by Gianni Ceccarelli . + +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. + +=cut diff --git a/lib/Sietima/Runner.pm b/lib/Sietima/Runner.pm index ca64348..ee6ee23 100644 --- a/lib/Sietima/Runner.pm +++ b/lib/Sietima/Runner.pm @@ -3,9 +3,37 @@ use Moo; use Sietima::Policy; use namespace::clean; -# VERSION +our $VERSION = '1.0.0'; # VERSION # ABSTRACT: C for Sietima + +extends 'App::Spec::Run'; + +sub run_op($self,$op,$args=[]) { + if ($op =~ /^cmd_/) { + $self->$op($args); + } + else { + $self->cmd->$op($self,$args); + } +} + +1; + +__END__ + +=pod + +=encoding UTF-8 + +=head1 NAME + +Sietima::Runner - C for Sietima + +=head1 VERSION + +version 1.0.0 + =head1 DESCRIPTION You should never need to care about this class, it's used internally @@ -18,17 +46,15 @@ delegate back via L<< C >>. =for Pod::Coverage run_op -=cut +=head1 AUTHOR -extends 'App::Spec::Run'; +Gianni Ceccarelli -sub run_op($self,$op,$args=[]) { - if ($op =~ /^cmd_/) { - $self->$op($args); - } - else { - $self->cmd->$op($self,$args); - } -} +=head1 COPYRIGHT AND LICENSE -1; +This software is copyright (c) 2017 by Gianni Ceccarelli . + +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. + +=cut diff --git a/lib/Sietima/Subscriber.pm b/lib/Sietima/Subscriber.pm index b62e44f..f7c4cbf 100644 --- a/lib/Sietima/Subscriber.pm +++ b/lib/Sietima/Subscriber.pm @@ -8,26 +8,9 @@ use Email::Address; use List::AllUtils qw(any); use namespace::clean; -# VERSION +our $VERSION = '1.0.0'; # VERSION # ABSTRACT: a subscriber to a mailing list -=head1 DESCRIPTION - -This class holds the primary email address for a mailing list -subscriber, together with possible aliases and preferences. - -=head1 ATTRIBUTES - -All attributes are read-only. - -=attr C - -Required L<< C >> object, coercible from a string. - -This is the primary address for the subscriber, the one where they -will receive messages from the mailing list. - -=cut has primary => ( isa => Address, @@ -37,17 +20,6 @@ has primary => ( handles => [qw(address name original)], ); -=attr C - -Arrayref of L<< C >> objects, each coercible from a -string. Defaults to an empty arrayref. - -These are secondary addresses that the subscriber may write -from. Subscriber-only mailing lists should accept messages from any of -these addresses as if they were from the primary. The L<< /C >> -simplifies that task. - -=cut my $address_array = ArrayRef[ Address->plus_coercions( @@ -61,12 +33,6 @@ has aliases => ( ); sub _build_aliases { +[] } -=attr C - -A hashref. Various preferences that may be interpreted by Sietima -roles. Defaults to an empty hashref. - -=cut has prefs => ( isa => HashRef, @@ -74,18 +40,6 @@ has prefs => ( default => sub { +{} }, ); -=method C - - if ($subscriber->match($address)) { ... } - -Given a L<< C >> object (or a string), this method -returns true if the address is equivalent to the -L or any of the L. - -This method should be used to determine whether an address belongs to -a subscriber. - -=cut sub match { # we can't use the sub signature here, because we need the @@ -97,15 +51,85 @@ sub match { $self->primary, $self->aliases->@*; } -=method C
-=method C +1; + +__END__ + +=pod + +=encoding UTF-8 + +=head1 NAME + +Sietima::Subscriber - a subscriber to a mailing list + +=head1 VERSION -=method C +version 1.0.0 + +=head1 DESCRIPTION + +This class holds the primary email address for a mailing list +subscriber, together with possible aliases and preferences. + +=head1 ATTRIBUTES + +All attributes are read-only. + +=head2 C + +Required L<< C >> object, coercible from a string. + +This is the primary address for the subscriber, the one where they +will receive messages from the mailing list. + +=head2 C + +Arrayref of L<< C >> objects, each coercible from a +string. Defaults to an empty arrayref. + +These are secondary addresses that the subscriber may write +from. Subscriber-only mailing lists should accept messages from any of +these addresses as if they were from the primary. The L<< /C >> +simplifies that task. + +=head2 C + +A hashref. Various preferences that may be interpreted by Sietima +roles. Defaults to an empty hashref. + +=head1 METHODS + +=head2 C + + if ($subscriber->match($address)) { ... } + +Given a L<< C >> object (or a string), this method +returns true if the address is equivalent to the +L or any of the L. + +This method should be used to determine whether an address belongs to +a subscriber. + +=head2 C
+ +=head2 C + +=head2 C These methods delegate to L<< C >>'s methods of the same name, invoked on the L. -=cut +=head1 AUTHOR -1; +Gianni Ceccarelli + +=head1 COPYRIGHT AND LICENSE + +This software is copyright (c) 2017 by Gianni Ceccarelli . + +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. + +=cut diff --git a/lib/Sietima/Types.pm b/lib/Sietima/Types.pm index 9f052e3..5a56bfd 100644 --- a/lib/Sietima/Types.pm +++ b/lib/Sietima/Types.pm @@ -12,39 +12,94 @@ use Type::Library Subscriber SubscriberFromAddress SubscriberFromStr SubscriberFromHashRef Transport MailStore MailStoreFromHashRef); -# VERSION +our $VERSION = '1.0.0'; # VERSION # ABSTRACT: type library for Sietima -=head1 DESCRIPTION -This module is a L<< C >>. It declares a few type -constraints nad coercions. +class_type SietimaObj, { class => 'Sietima' }; -=type C -An instance of L<< C >>. +class_type EmailMIME, { class => 'Email::MIME' }; -=cut -class_type SietimaObj, { class => 'Sietima' }; +role_type Transport, { role => 'Email::Sender::Transport' }; -=type C -An instance of L<< C >>. +role_type MailStore, { role => 'Sietima::MailStore' }; -=cut +declare_coercion MailStoreFromHashRef, + to_type MailStore, from HashRef, + q{ require Module::Runtime; } . + q{ Module::Runtime::use_module(delete $_->{class})->new($_); }; -class_type EmailMIME, { class => 'Email::MIME' }; -=type C +class_type Address, { class => 'Email::Address' }; +declare_coercion AddressFromStr, + to_type Address, from Str, + q{ (Email::Address->parse($_))[0] }; -An object that consumes the role L<< C >>. -=cut +declare TagName, as Str, + where { /\A\w+\z/ }, + inline_as sub($constraint,$varname,@){ + $constraint->parent->inline_check($varname) + .qq{ && ($varname =~/\\A\\w+\\z/) }; + }; -role_type Transport, { role => 'Email::Sender::Transport' }; -=type C +class_type Message, { class => 'Sietima::Message' }; + + +class_type Subscriber, { class => 'Sietima::Subscriber' }; + +declare_coercion SubscriberFromAddress, + to_type Subscriber, from Address, + q{ Sietima::Subscriber->new(primary=>$_) }; + +declare_coercion SubscriberFromStr, + to_type Subscriber, from Str, + q{ Sietima::Subscriber->new(primary=>(Email::Address->parse($_))[0]) }; + +declare_coercion SubscriberFromHashRef, + to_type Subscriber, from HashRef, + q{ Sietima::Subscriber->new($_) }; + +1; + +__END__ + +=pod + +=encoding UTF-8 + +=head1 NAME + +Sietima::Types - type library for Sietima + +=head1 VERSION + +version 1.0.0 + +=head1 DESCRIPTION + +This module is a L<< C >>. It declares a few type +constraints nad coercions. + +=head1 TYPES + +=head2 C + +An instance of L<< C >>. + +=head2 C + +An instance of L<< C >>. + +=head2 C + +An object that consumes the role L<< C >>. + +=head2 C An object that consumes the role L<< C >>. @@ -68,16 +123,7 @@ the C<%constructor_args>. =back -=cut - -role_type MailStore, { role => 'Sietima::MailStore' }; - -declare_coercion MailStoreFromHashRef, - to_type MailStore, from HashRef, - q{ require Module::Runtime; } . - q{ Module::Runtime::use_module(delete $_->{class})->new($_); }; - -=type C
+=head2 C
An instance of L<< C >>. @@ -95,36 +141,16 @@ only the first one will be used. =back -=cut - -class_type Address, { class => 'Email::Address' }; -declare_coercion AddressFromStr, - to_type Address, from Str, - q{ (Email::Address->parse($_))[0] }; - -=type C +=head2 C A string composed exclusively of "word" (C) characters. Used by L to tag messages. -=cut - -declare TagName, as Str, - where { /\A\w+\z/ }, - inline_as sub($constraint,$varname,@){ - $constraint->parent->inline_check($varname) - .qq{ && ($varname =~/\\A\\w+\\z/) }; - }; - -=type C +=head2 C An instance of L<< C >>. -=cut - -class_type Message, { class => 'Sietima::Message' }; - -=type C +=head2 C An instance of L<< C >>. @@ -155,20 +181,15 @@ passing it to the constructor. =back -=cut +=head1 AUTHOR -class_type Subscriber, { class => 'Sietima::Subscriber' }; +Gianni Ceccarelli -declare_coercion SubscriberFromAddress, - to_type Subscriber, from Address, - q{ Sietima::Subscriber->new(primary=>$_) }; +=head1 COPYRIGHT AND LICENSE -declare_coercion SubscriberFromStr, - to_type Subscriber, from Str, - q{ Sietima::Subscriber->new(primary=>(Email::Address->parse($_))[0]) }; +This software is copyright (c) 2017 by Gianni Ceccarelli . -declare_coercion SubscriberFromHashRef, - to_type Subscriber, from HashRef, - q{ Sietima::Subscriber->new($_) }; +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. -1; +=cut diff --git a/t/author-critic.t b/t/author-critic.t new file mode 100644 index 0000000..30b99d8 --- /dev/null +++ b/t/author-critic.t @@ -0,0 +1,20 @@ +#!perl + +BEGIN { + unless ($ENV{AUTHOR_TESTING}) { + print qq{1..0 # SKIP these tests are for testing by the author\n}; + exit + } +} + + +use strict; +use warnings; + +use Test::More; +use English qw(-no_match_vars); + +eval "use Test::Perl::Critic"; +plan skip_all => 'Test::Perl::Critic required to criticise code' if $@; +Test::Perl::Critic->import( -profile => "perlcritic.rc" ) if -e "perlcritic.rc"; +all_critic_ok(); diff --git a/t/author-no-tabs.t b/t/author-no-tabs.t new file mode 100644 index 0000000..3bac52a --- /dev/null +++ b/t/author-no-tabs.t @@ -0,0 +1,60 @@ + +BEGIN { + unless ($ENV{AUTHOR_TESTING}) { + print qq{1..0 # SKIP these tests are for testing by the author\n}; + exit + } +} + +use strict; +use warnings; + +# this test was generated with Dist::Zilla::Plugin::Test::NoTabs 0.15 + +use Test::More 0.88; +use Test::NoTabs; + +my @files = ( + 'lib/Sietima.pm', + 'lib/Sietima/CmdLine.pm', + 'lib/Sietima/MailStore.pm', + 'lib/Sietima/MailStore/FS.pm', + 'lib/Sietima/Message.pm', + 'lib/Sietima/Policy.pm', + 'lib/Sietima/Role/AvoidDups.pm', + 'lib/Sietima/Role/Debounce.pm', + 'lib/Sietima/Role/Headers.pm', + 'lib/Sietima/Role/ManualSubscription.pm', + 'lib/Sietima/Role/NoMail.pm', + 'lib/Sietima/Role/ReplyTo.pm', + 'lib/Sietima/Role/SubjectTag.pm', + 'lib/Sietima/Role/SubscriberOnly.pm', + 'lib/Sietima/Role/SubscriberOnly/Drop.pm', + 'lib/Sietima/Role/SubscriberOnly/Moderate.pm', + 'lib/Sietima/Role/WithMailStore.pm', + 'lib/Sietima/Role/WithOwner.pm', + 'lib/Sietima/Role/WithPostAddress.pm', + 'lib/Sietima/Runner.pm', + 'lib/Sietima/Subscriber.pm', + 'lib/Sietima/Types.pm', + 't/lib/Test/Sietima.pm', + 't/lib/Test/Sietima/MailStore.pm', + 't/tests/sietima.t', + 't/tests/sietima/cmdline.t', + 't/tests/sietima/mailstore.t', + 't/tests/sietima/message.t', + 't/tests/sietima/multi-role/debounce-moderate.t', + 't/tests/sietima/role/avoid-dups.t', + 't/tests/sietima/role/debounce.t', + 't/tests/sietima/role/headers.t', + 't/tests/sietima/role/manualsubscription.t', + 't/tests/sietima/role/nomail.t', + 't/tests/sietima/role/replyto.t', + 't/tests/sietima/role/subject-tag.t', + 't/tests/sietima/role/subscriberonly/drop.t', + 't/tests/sietima/role/subscriberonly/moderate.t', + 't/tests/sietima/subscriber.t' +); + +notabs_ok($_) foreach @files; +done_testing; diff --git a/t/author-pod-coverage.t b/t/author-pod-coverage.t new file mode 100644 index 0000000..243340f --- /dev/null +++ b/t/author-pod-coverage.t @@ -0,0 +1,15 @@ +#!perl + +BEGIN { + unless ($ENV{AUTHOR_TESTING}) { + print qq{1..0 # SKIP these tests are for testing by the author\n}; + exit + } +} + +# This file was automatically generated by Dist::Zilla::Plugin::PodCoverageTests. + +use Test::Pod::Coverage 1.08; +use Pod::Coverage::TrustPod; + +all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::TrustPod' }); diff --git a/t/author-pod-syntax.t b/t/author-pod-syntax.t new file mode 100644 index 0000000..2233af0 --- /dev/null +++ b/t/author-pod-syntax.t @@ -0,0 +1,15 @@ +#!perl + +BEGIN { + unless ($ENV{AUTHOR_TESTING}) { + print qq{1..0 # SKIP these tests are for testing by the author\n}; + exit + } +} + +# This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. +use strict; use warnings; +use Test::More; +use Test::Pod 1.41; + +all_pod_files_ok(); diff --git a/weaver.ini b/weaver.ini deleted file mode 100644 index f4c9077..0000000 --- a/weaver.ini +++ /dev/null @@ -1,41 +0,0 @@ -[@CorePrep] - -[-SingleEncoding] - -[Name] -[Version] - -[Region / prelude] - -[Generic / SYNOPSIS] -[Generic / DESCRIPTION] -[Generic / OVERVIEW] - -[Collect / ATTRIBUTES] -command = attr - -[Collect / REQUIRED METHODS] -command = require - -[Collect / METHODS] -command = method - -[Collect / MODIFIED METHODS] -command = modif - -[Collect / FUNCTIONS] -command = func - -[Collect / TYPES] -command = type - -[Leftovers] - -[Region / postlude] - -[Authors] -[Legal] - -[-Transformer / Lists] -transformer = List -format_name = list -- cgit v1.2.3