Today I released a new version of
Mac::Choose which wraps the choose command line utility. Basically this lets you, from Perl, pop open a fuzzy match dialog like quicksilver, alfred, et al. This is probably best shown rather than explained:
use Mac::Choose qw(choose);
print choose qw(
red
orange
yellow
green
blue
indigo
violet
) or die "User canceled selection";
The exciting thing about this release is that while previous versions required you to go to
Tiny Robot Software's website to download a copy of
choose
, this version of Mac::Choose ships with the
choose
binary and installs a copy alongside the Perl module.
Using File::ShareDir
In order to handle the intallation of the binary in a place where my code could once again find it I altered my distribution to use the
File::ShareDir infrastructure. Essentially this infrastructure comes in two halves, an installer to install things in the shared dirctory and a module that can give you access to the files again.
In my Module::Intall powered Makefile.PL in order to use
Module::Intall::Share I simply had to add the line:
install_share;
This installs everything in the
share
directory of my distribution (which just contained one file, the
choose
binary) when you
make install
.
The changes to my module were also very simple:
use File::ShareDir qw(dist_file);
our $executable_path = dist_file("Mac-Choose","choose");
Testing
After those changes, everything worked flawlessly...apart from the test suite! The problem is that until the module is installed the files aren't in the shared directory, and traditionally we test a module
before we install them.
This isn't insurmountable however, we just need to make some changes to our tests to quietly override File::ShareDir's functionality with that from
Test::File::ShareDir:
use File::Spec::Functions qw(:ALL);
use FindBin;
use Test::File::ShareDir (
-root => catdir($FindBin::Bin, updir),
-share => { -dist => { "Mac-Choose" => "share" } },
);