Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kentnl/dist-zilla-role-tempdir
Shell Out and collect the result in a DZ plug-in
https://github.com/kentnl/dist-zilla-role-tempdir
dist-zilla perl
Last synced: about 1 month ago
JSON representation
Shell Out and collect the result in a DZ plug-in
- Host: GitHub
- URL: https://github.com/kentnl/dist-zilla-role-tempdir
- Owner: kentnl
- License: other
- Created: 2009-10-26T02:44:15.000Z (about 15 years ago)
- Default Branch: master
- Last Pushed: 2017-03-10T12:10:00.000Z (almost 8 years ago)
- Last Synced: 2024-06-21T15:46:36.122Z (6 months ago)
- Topics: dist-zilla, perl
- Language: Perl
- Homepage:
- Size: 302 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.mkdn
- Changelog: Changes
- Contributing: CONTRIBUTING.pod
- License: LICENSE
Awesome Lists containing this project
README
# NAME
Dist::Zilla::Role::Tempdir - Shell Out and collect the result in a DZ plug-in.
# VERSION
version 1.001004
# SYNOPSIS
package #
Dist::Zilla::Plugin::FooBar;use Moose;
with 'Dist::Zilla::Role::FileInjector';
with 'Dist::Zilla::Role::InstallTool';
with 'Dist::Zilla::Role::Tempdir';sub setup_installer {
my ( $self, $arg ) = @_ ;my ( @generated_files ) = $self->capture_tempdir(sub{
system( $somecommand );
});for ( @generated_files ) {
if( $_->is_new && $_->name =~ qr/someregex/ ){
$self->add_file( $_->file );
}
}
}This role is a convenience role for factoring into other plug-ins to use the power of Unix
in any plug-in.If for whatever reason you need to shell out and run your own app that is not Perl ( i.e.: Java )
to go through the code and make modifications, produce documentation, etc, then this role is for you.Important to note however, this role **ONLY** deals with getting `Dist::Zilla`'s state written out to disk,
executing your given arbitrary code, and then collecting the results. At no point does it attempt to re-inject
those changes back into [`Dist::Zilla`](https://metacpan.org/pod/Dist::Zilla). That is left as an exercise to the plug-in developer.# METHODS
## capture\_tempdir
Creates a temporary and dumps the current state of Dist::Zilla's files into it.
Runs the specified code sub `chdir`'ed into that `tmpdir`, and captures the changed files.
my ( @array ) = $self->capture_tempdir(sub{
});
Response is an array of [`::Tempdir::Item`](https://metacpan.org/pod/Dist::Zilla::Tempdir::Item)
[ bless( { name => 'file/Name/Here' ,
status => 'O' # O = Original, N = New, M = Modified, D = Deleted
file => Dist::Zilla::Role::File object
}, 'Dist::Zilla::Tempdir::Item' ) , bless ( ... ) ..... ]Make sure to look at [`Dist::Zilla::Tempdir::Item`](https://metacpan.org/pod/Dist::Zilla::Tempdir::Item) for usage.
# SEE ALSO
- [`Dist::Zilla::Tempdir::Item`](https://metacpan.org/pod/Dist::Zilla::Tempdir::Item)
# AUTHOR
Kent Fredric
# COPYRIGHT AND LICENSE
This software is copyright (c) 2017 by Kent Fredric .
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.