comparison lib/CPT/Writer/Archive.pm @ 1:f093e08f21f3 draft default tip

planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
author cpt
date Mon, 05 Jun 2023 02:47:24 +0000
parents
children
comparison
equal deleted inserted replaced
0:b8b8b52904a5 1:f093e08f21f3
1 package CPT::Writer::Archive;
2 no warnings;
3 use Moose;
4 use Archive::Any::Create;
5 use File::Copy qw/move/;
6 with 'CPT::Writer';
7
8 has format => (
9 is => 'ro',
10 isa => 'Str',
11 default => sub {
12 'tar.gz',
13 },
14 );
15
16 sub process {
17 my ($self) = @_;
18 # Should be a Archive::Any::Create object
19 if(ref $self->data() ne 'Archive::Any::Create'){
20 warn 'Tool author sent non Archive::Any::Create data to the writer';
21 }else{
22 $self->processed_data( $self->data() );
23 $self->processing_complete(1);
24 }
25 }
26
27 sub write {
28 my ($self) = @_;
29 if ( $self->processing_complete ) {
30 # Force the extension to that of the specified format
31 $self->OutputFilesClass->extension( $self->format() );
32 # Get a filename
33 my $next_output_file = $self->OutputFilesClass->get_next_file();
34 # And get another filename with extension tacked on so we KNOW it'll behave correctly.
35 my $next_output_file_with_extension = $self->OutputFilesClass->get_next_file() . '.' . $self->format();
36 # Store the name of the file we used
37 push(@{$self->used_filenames()}, $next_output_file);
38 # Write data out
39 $self->processed_data->write_file($next_output_file_with_extension);
40 # If it has been written somewhere other than where we want,
41 # then we need to move it.
42 if($next_output_file ne $next_output_file_with_extension){
43 move($next_output_file_with_extension, $next_output_file);
44 }
45 }
46 else {
47 warn
48 "Write called but processing was not marked as complete. Not writing";
49 }
50
51 }
52
53 sub suffix {
54 return 'csv';
55 }
56 no Moose;
57 1;
58
59 __END__
60
61 =pod
62
63 =encoding UTF-8
64
65 =head1 NAME
66
67 CPT::Writer::Archive
68
69 =head1 VERSION
70
71 version 1.99.4
72
73 =head1 AUTHOR
74
75 Eric Rasche <rasche.eric@yandex.ru>
76
77 =head1 COPYRIGHT AND LICENSE
78
79 This software is Copyright (c) 2014 by Eric Rasche.
80
81 This is free software, licensed under:
82
83 The GNU General Public License, Version 3, June 2007
84
85 =cut