example/lib/Web/VWF/Data/states.pm

filter: Statementstmt 94.7% 18 / 19 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 92.5% 25 / 27 CC 2 SCAR 3.2
CC
2
Cov
90%
new
2.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.4
« blib/lib/Web/VWF/Data/vwf_log.pm ↑ Summary lib/Web/VWF/Data/index.pm »
1 package Web::VWF::Data::states;
2  
3 # The database associated with the states page: states.csv in the database
4 # directory, one row for each of the 50 U.S. states.
5 #
6 # The file is a standard comma-separated file with a header line, which is
7 # not what Database::Abstraction assumes (it defaults to "!" as the separator
8 # and to a key column called "entry"), so both are set here. The key column
9 # is "state", the two letter code, so a single state can be fetched with
10 # $states->fetchrow_hashref(state => 'NY')
11  
12 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 ▶use Database::Abstraction;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 1 ▶use version; our $VERSION = version->declare('0.003.0');
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 1 our @ISA = ('Database::Abstraction');
20  
21 1 ▶sub new {
Subroutine new: called CC=2 SCAR=7.6
Pod documented
22 1 my $class = shift;
23 0 ▶ my %args = (ref($_[0]) eq 'HASH') ? %{$_[0]} : @_;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 1 1
24  
25 # Caller's arguments come last so a site can still override either setting
26 1 return $class->SUPER::new(id => 'state', sep_char => ',', %args);
27 }
28  
29 1 1;
30  
31 =encoding utf8
32  
33 =head1 NAME
34  
35 Web::VWF::Data::states - The example site's database of U.S. states
36  
37 =head1 VERSION
38  
39 Version 0.003.0
40  
41 =head1 DESCRIPTION
42  
43 A L<Database::Abstraction> over F<example/data/states.csv>, which has a header
44 line and one row for each of the 50 states: C<state> (the two letter code, which
45 is the key), C<abbreviation> and C<name>. It is the example of a data module in
46 a site's own directory, which L<Web::VWF/CONFIGURATION> describes. Unlike
47 L<Web::VWF::Data::index> the file is comma separated.
48  
49 my $row = $states->fetchrow_hashref(state => 'NY'); # { state => 'NY', ..., name => 'New York' }
50  
51 =head1 AUTHOR
52  
53 Nigel Horne, C<< <njh at nigelhorne.com> >>
54  
55 =head1 LICENCE AND COPYRIGHT
56  
57 Copyright 2010-2026 Nigel Horne.
58  
59 Usage is subject to the GPL2 licence terms.
60 If you use it,
61 please let me know.
62  
63 =cut
« blib/lib/Web/VWF/Data/vwf_log.pm ↑ Summary lib/Web/VWF/Data/index.pm »