Created
December 6, 2011 10:30
-
-
Save taiyoh/1437701 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Archer::Plugin::File; | |
use strict;use warnings; | |
use base qw( Archer::Plugin ); | |
use File::Spec; | |
use FindBin; | |
sub run { | |
my ($self, $context, $args) = @_; | |
my $f = File::Util->new; | |
my $global = $context->{config}->{global}; | |
my $path = File::Spec->catfile( $FindBin::Bin, 'assets', 'file', $self->{config}->{source} ); | |
my $source = $f->load_file( $path ); | |
my $dest = $self->{config}->{dest} || File::Spec->devnull; | |
delete $self->{config}{source}; | |
delete $self->{config}{dest}; | |
$source = $self->templatize($source); | |
$dest = $self->templatize($dest); | |
$f->write_file(file => $dest, content => $source); | |
} | |
1; | |
__END__ | |
=head1 NAME | |
Archer::Plugin::File | |
=head1 SYNOPSIS | |
- module: File | |
name: file-replace | |
config: | |
source: config.yml | |
dest: "[% dest_dir %]/config.yml" | |
=head1 AUTHORS | |
Taiyoh Tanaka | |
=cut |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment