During my talk at YAPC I recommended that people writing functional tests for a web service client ensure that Internet access is available before running the rest of the test. Later, a question was asked about an easy way to test for Internet access, and I was informed of the existence of Net::Detect.
With a recent thread from CPAN-workers fresh in my memory, I promised to release Test::RequiresInternet to CPAN during YAPC if I was fortunate enough to get through all of it.
I uploaded Test::RequiresInternet shortly before game night and its available on CPAN (also Github.) I just haven't gotten around to publicizing it a bit until I was back from Florida.
That means you can now write your test like this:
use Test::RequiresInternet ( 'fluxcapacitor.io' => 1953 );
# I got Internet!
Why not just use Net::Detect? I wanted a simple module that uses TAP output and didn't have any dependencies outside of the Perl core. I also wanted to account for the environment variable
NO_NETWORK_TESTING and the syntax I adopted.
I recently updated a client called WebService::Geocodio for the Geocod.io geocoding service. Traditionally, geocoding means turning a mailing address into latitude/longitude coordinates (or the reverse operation, turning latitude/longitude into a mailing address.)
In a recent update of the upstream service they included the ability to fetch additional data fields including timezone, congressional district, school district and so forth. Is there a good CPAN module (or a recommendation) to take a Perl data structure like a hash and turn it into a Moo(::Lax) object "automagically?" I had a look but I didn't find anything especially suitable.
These data structures are purely informational in nature and just have getters for their attribute names. This would be less difficult to accomplish using Moose (obviously) but I'm wondering if there are any suggestions for something that installs getters for hash keys dynamically and is Moo-friendly.
Neil Bowers released a survey of markdown to HTML formatters recently. I thought it was an interesting coincidence, because I have recently written a CPAN library to go the opposite way, from HTML to Markdown.
For various and sundry reasons I wanted to move my blog from a Wordpress installation to a static blog where the post content is represented as markdown, but there were (to my complete astonishment) no CPAN modules to convert HTML to markdown, so I decided to write one based on HTML::Format.
In general, I was surprised by the lack of tools (in any language) to convert Wordpress exports into markdown, but now we have something for Perl. I was pleasantly surprised how quick and straightforward it was to implement the converter. If you have a need to convert HTML into format X, give HTML::Format some serious consideration as the base platform to do that work.
Over the weekend my new module was merged and released to CPAN by the HTML::Format maintainer. The driver script for the WordPress to Markdown conversion is here. I may revise my driver script to put post metadata into TOML but I haven't done that yet mostly because the static blog engine is still under construction so the exact post format requirements are still unstable.
I used a fairly good sized corpus of posts as tests and had good results but more tests are always welcome.
CPANfile is a simple way to declare your project's dependencies in a build system independent manner.
- In recent versions of cpanminus, it makes your entire project installable from a git repository, and,
- it also allows you to "pin" your dependencies on a specific CPAN release in a very sophisticated way, rather than "this version or newer" which is the typical Perl dependency resolution.
Why would you want to install a project from git instead of the normal CPAN download/build/test/install process? There are a lot of use cases, but the one I c…