File Coverage

lib/Bio/Roary/SpreadsheetRole.pm
Criterion Covered Total %
statement 20 22 90.9
branch 1 2 50.0
condition n/a
subroutine 7 8 87.5
pod 0 1 0.0
total 28 33 84.8


line stmt bran cond sub pod time code
1             package Bio::Roary::SpreadsheetRole;
2             $Bio::Roary::SpreadsheetRole::VERSION = '3.10.2';
3             # ABSTRACT: Read and write a spreadsheet
4              
5 4     4   2183 use Moose::Role;
  4         10  
  4         31  
6              
7             has 'spreadsheet' => ( is => 'ro', isa => 'Str', required => 1 );
8             has '_fixed_headers' => ( is => 'ro', isa => 'ArrayRef', lazy => 1, builder => '_build__fixed_headers' );
9             has '_input_spreadsheet_fh' => ( is => 'ro', lazy => 1, builder => '_build__input_spreadsheet_fh' );
10             has '_output_spreadsheet_fh' => ( is => 'ro', lazy => 1, builder => '_build__output_spreadsheet_fh' );
11             has '_fixed_headers' => ( is => 'ro', isa => 'ArrayRef', lazy => 1, builder => '_build__fixed_headers' );
12             has '_num_fixed_headers' => ( is => 'ro', isa => 'Int', lazy => 1, builder => '_build__num_fixed_headers' );
13             has '_csv_parser' => ( is => 'ro', isa => 'Text::CSV',lazy => 1, builder => '_build__csv_parser' );
14             has '_csv_output' => ( is => 'ro', isa => 'Text::CSV',lazy => 1, builder => '_build__csv_output' );
15              
16             sub BUILD
17             {
18 0     0 0 0 my ($self) = @_;
19 0         0 $self->_input_spreadsheet_fh;
20             }
21              
22             sub _build__fixed_headers
23             {
24 18     18   42 my ($self) = @_;
25 18         24 my @fixed_headers = @{Bio::Roary::GroupStatistics->fixed_headers()};
  18         174  
26 18         398 return \@fixed_headers;
27             }
28              
29             sub _build__csv_parser
30             {
31 18     18   41 my ($self) = @_;
32 18         176 return Text::CSV->new( { binary => 1, always_quote => 1} );
33             }
34              
35             sub _build__csv_output
36             {
37 14     14   28 my ($self) = @_;
38 14         166 return Text::CSV->new( { binary => 1, always_quote => 1, eol => "\r\n"} );
39             }
40              
41             sub _build__input_spreadsheet_fh {
42 18     18   41 my ($self) = @_;
43 18 50       450 open( my $fh, $self->spreadsheet ) or die "Couldnt open input spreadsheet: ".$self->spreadsheet ;
44 18         432 return $fh;
45             }
46              
47             sub _build__output_spreadsheet_fh {
48 14     14   38 my ($self) = @_;
49 14         380 open( my $fh, '>', $self->output_filename );
50 14         380 return $fh;
51             }
52              
53             sub _build__num_fixed_headers
54             {
55 18     18   46 my ($self) = @_;
56 18         24 return @{$self->_fixed_headers};
  18         444  
57             }
58              
59              
60              
61             1;
62              
63             __END__
64              
65             =pod
66              
67             =encoding UTF-8
68              
69             =head1 NAME
70              
71             Bio::Roary::SpreadsheetRole - Read and write a spreadsheet
72              
73             =head1 VERSION
74              
75             version 3.10.2
76              
77             =head1 SYNOPSIS
78              
79             with 'Bio::Roary::SpreadsheetRole';
80              
81             =head1 AUTHOR
82              
83             Andrew J. Page <ap13@sanger.ac.uk>
84              
85             =head1 COPYRIGHT AND LICENSE
86              
87             This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute.
88              
89             This is free software, licensed under:
90              
91             The GNU General Public License, Version 3, June 2007
92              
93             =cut