Using Dist::Zilla to extract parts of your distribution
Imagine you are working on a smallish Catalyst project with an DBIx::Class model. You have been a good citizen and adhered to the principal of separation of concerns. Now you would like to extract the schema to use it anywhere else (in my case a monitoring interface that is in place and allows simple plugins). Creating a whole distribution with the related infrastructure out of the schema classes is just to much work for this one-off task. Dist::Zilla to the rescue.
Dist::Zilla can't handle multiple dists in one directory,
so you have to create an empty subdir in the project.
I'll go with contrib/schema
for now.
Put the following
name = MyApp-Schema author = You <you@example.com> license = None copyright_holder = You copyright_year = 2011 version = 0.01 main_module = lib/MyApp/Schema.pm [Manifest] [MakeMaker] [TestRelease] [Prereqs] DBIx::Class = 0 DBD::SQLite = 0 Test::DBIx::Class = 0 [GatherDir] root = ../../lib/MyApp/Schema prefix = lib/MyApp/Schema ; this is a hack to additionally gather the schema class ; maybe there is a better way, but I was not able to ; find a plugin that can gather files and also support ; a GatherDir-like prefix option [GatherDir / Schema] root = ../../lib/MyApp/ prefix = lib/MyApp/ exclude_match = (?<!Schema.pm)$ [GatherDir / Tests] root = ../../t/schema prefix = t/schema
Now change to the directory and run
dzil build
and you should have a shiny MyApp-Schema-0.01.tar.gz
at your (not really best practice) disposal.
Leave a comment