After all that code being moved around between the two modules.
More efficient when it's called multiple times, and it's going to be as import_archive is split up further.
I'm not happy that building it also indexes it, but I don't know how to instanciate a document without also adding it to the index.
This lets it derive its own attributes, easier to instantiate. It also gives it everything necessary to create an MC::Document::Release which is where we're heading next. Note: The fixed version was never used before. Now it is.
Needed to allow the model to make the MC::Document::Release.
Then if we change how archives are extracted in the future it only has to be done in one place. MC::Model::Archive deliberately does not clean up a directory given to it, we don't know the caller's intent, but it does use a temp directory by default. Someone can add an option later if it's needed.
CPAN releases are tarballs AND zipfiles (and some other weird things). It's wrong to refer to them as "tarballs" and can lead to forgetting about zip files. Instead use "archive" or "archive file". Also normalized the use of the "file" attribute to mean "the file I will be operating on" between MC::Model::Release and MC::Model::Archive.
MC::M::Archive handles the actual file now (and we have more than tarballs). This model is about building and indexing the release, most of what MC::Script::Release->import_tarball will go here. MC::Script::Release will decide what is indexed and how, but it will use MC::Model::Release to get its work done.
This makes managing the extraction directory easier, and it's an easier unit to test and improve. MetaCPAN::Model::Tarball can now focus on building the release.
This is mostly about being able to instanciate a Tarball object at all. It reveals a bunch of problems that will be dealt with later. The karma distribution used was too complicated, it needed a named pipe and that has permissions problems. Use something *waaay* simpler for right now. MetaCPAN::Model::Tarball needs a default tmpdir, but there's problems with how it's storing the directory (it can't store a File::Temp object properly). MetaCPAN::Model::Tarball needs to be a logger, so it has to be passed the logger and level now. This is sub-optimal, but it makes it work.
So non-scripts can use it.
Things that aren't scripts need to log. Script still has the code to setup the logger, that'll be extracted next.
It turns out, it's not "common" once you start making things that aren't scripts. More extractions of roles to come.
This fixes the tests broken by 4465251 Otherwise $tmpdir is empty when we go looking for metadata. More cleanup to come.
This is necessary to allow a separate extract method. That is necessary to fix the current test failures. See next commit.