While I haven’t been blogging much, I have been busy coding. To riff from Damian’s “Conway Channel” talks, this blog post summarizes the various (mostly new) CPAN modules I’ve been working on.
::Tiny and not so ::Tiny
I appear to be one of the leading proponents of “::Tiny” modules. I love the Unix-like small-tools philosophy. Sometimes, though, they can be too tiny, and need extension for situations that need extra features and/or can handle more dependencies.
- Class::Tiny is my response to the excessive minimalism of Object::Tiny. When you just need read-write accessors with lazy defaults and maybe BUILD/DEMOLISH, Class::Tiny gives it to you in about 120 lines of code.
- HTTP::Tiny::UA extends HTTP::Tiny. HTTP::Tiny is in the Perl core and Christian and I consider it nearly feature-complete. I hope HTTP::Tiny::UA can become common ground for user-agent extensions that are consistent with the HTTP::Tiny philosophy and use HTTP::Tiny as the underlying transport.
- Path::Tiny is not new, but it gets steady improvements. Lately, I’ve been sorting out Windows and volumes. One of these days, I hope to get around to tackling some big changes to file moving, copying and renaming (maybe by the QA hackathon next year).
Embellishing the Moose
Roles are one of the best features of Moose and Moo. I wrote two roles I thought worth sharing.
- MooseX::Role::Logger provides a Log::Any-based logger. I think Log::Any is a great idea and underappreciated. I’ve taken over maintenance and hope to someday soon ship a new release that is even more flexible than it is today.
- MooseX::Role::MongoDB provides an API for using MongoDB::MongoClient and associated databases/collections. It provides lazy-instantiation, caching and fork-safety.
A MongoDB Framework
You either love MongoDB or you hate it. Or both at the same time. MongoDB’s document-centric data model is different than you’re used to and everything I found on CPAN was too complex or was doing it wrong.
- Meerkat is a framework that uses Moose objects as projections of the document state maintained in the database. I think it makes it easy use the right conceptual model in a Perl-ish way. Of course, it uses MooseX::Role::MongoDB under the hood.
Living with failure
Perl’s poor excuse for an exception system is painful, so it falls to CPAN to provide improvements. Here are my latest two attempts to provide better tools.
- failures makes creating and using exception classes extremely easy. Other than relying on Class::Tiny, it’s implemented in about 70 lines of code.
- Try::Tiny::Retry extends Try::Tiny to make it easy to retry a code block on error. It defaults to exponential-backoff, but is easily customizable.
CPAN minus archive equals index
Without an index, CPAN is just a distributed file store.
- CPAN::Common::Index is a common library for accessing several types of CPAN indexes. I hope someday it will be something that CPAN clients will use.
If I didn’t use Dist::Zilla, I couldn’t possibly be as prolific as I am. So some fraction of my time is spent adding to the the Dist::Zilla ecosystem. In addition to helping make Dist::Zilla safe for encodings, I churned out a few new plugins.
- Dist::Zilla::Plugin::Prereqs::AuthorDeps puts authoring dependencies into the META file
- Dist::Zilla::Plugin::Upload::SCP releases a distribution via
scp. This is great for DarkPAN code.
- Dist::Zilla::Plugin::MakeMaker::Highlander is a hack for dual-life modules. It sets
UNINST=1on old Perls to ensure that only one copy of a dual-life module is installed.
Pod::Spell gets used by my Dist::Zilla spell checking plugins. I merged in the word list from Pod::Wordlist::Hanekomu, improved wordlist matching with Lingua::EN::Inflect and made some other algorithm improvements.
More for the core
I kept pushing some core modules forward in various ways, mostly just applying patches or fixing bugs.
- HTTP::Tiny got some minor bug fixes
- File::Temp got some dependency management and Travis CI smoking
- CPAN::Meta got some fixes to validation and a couple new features
YAML::Tiny isn’t really core, but it is the basis for CPAN::Meta::YAML, so I count it in the same category. Working with Ingy, Karen Etheridge and Jim Keenan, we fixed encoding, overhauled the test suite and added test coverage.
Inspired by rjbs’s code-review practices, I’ve started gradually cleaning up and re-releasing old distributions of mine.
- ExtUtils::ModuleMaker::TT (which I deprecated)
I for Incomplete
There are a number of other projects that I’ve started or just conceived that I haven’t finished. They may yet see the light of day in the future.
- A “tiny” URI module
- A better benchmarking library, with statistical rigor for non-parametric timing distributions with unequal variance
- Some extensions for Data::Faker
- A module providing a standard way to safely evaluate
$VERSIONlines parsed from modules
What you can do
First, if any of these are interesting to you, please try them out and let me know what you think.
Second, if you’re not in the habit of releasing code to CPAN, consider starting. When you write some library, take an extra second or two to think about how it could be generalized for others and ship it.
Give thanks for CPAN by giving back.