DR/Util.pm

filter: Statementstmt 100% 28 / 28 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 2 totaltotal 94.7% 36 / 38 CC 3 SCAR 5.6
CC
3
Cov
100%
decamelize
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.8
« DR/PlPlaceHolders.pm ↑ Summary DR/PerlishTemplate.pm »
1 4 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package DBIx::DR::Util;
6  
7 4 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 our @EXPORT = qw(camelize decamelize);
9  
10  
11 31 ▶sub camelize($) {
Subroutine camelize: called CC=1 SCAR=0.0
Pod undocumented
12 31 my ($str) = @_;
13  
14 31 my ($module, $method) = split /#/, $str;
15  
16 $module =
17 70 join '', map { ucfirst } split /_/,
18 31 join '::' => map { ucfirst lc } split /-/ => $module;
19  
20 31 $module =~ s/dbix::dr::/DBIx::DR::/i;
21  
22 31 return ($module, $method);
23 }
24  
25  
26 7 ▶sub decamelize($;$) {
Subroutine decamelize: called CC=3 SCAR=11.0
Pod undocumented
27 7 my ($class, $constructor) = @_;
28 7 for ($class) {
29 7 s/(?<!^)[A-Z]/_$&/g;
30 7 s/::_/::/g;
31 7 s/::/-/g;
32 }
33  
34 7 ▶ return lc $class unless $constructor;
Branch: 1 branch
BranchTrueFalseTotal
unless $constructor 1 6 7
35 6 return lc($class) . "#$constructor";
36 }
37  
38 4 1;
39  
40 =head1 NAME
41  
42 DBIx::DR::Util - some functions for L<DBIx::DR>.
43  
44 =head1 COPYRIGHT
45  
46 Copyright (C) 2011 Dmitry E. Oboukhov <unera@debian.org>
47 Copyright (C) 2011 Roman V. Nikolaev <rshadow@rambler.ru>
48  
49 This program is free software, you can redistribute it and/or
50 modify it under the terms of the Artistic License.
51  
52 =cut
53  
« DR/PlPlaceHolders.pm ↑ Summary DR/PerlishTemplate.pm »