Skip to content

Instantly share code, notes, and snippets.

@taiyoh
Created December 6, 2011 10:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taiyoh/1437701 to your computer and use it in GitHub Desktop.
Save taiyoh/1437701 to your computer and use it in GitHub Desktop.
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