blib/lib/DBIx/DR/Util.pm untested

filter: Statementstmt 0.0% 0 / 27 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 37 SCAR 17.9
CC
2
Cov
0%
decamelize
6.0
camelize
2.0
BEGIN
2.0
CRAP 6.0
1 use utf8;
2 use strict;
3 use warnings;
4  
5 package DBIx::DR::Util;
6  
7 use base qw(Exporter);
8 our @EXPORT = qw(camelize decamelize);
9  
10  
11 sub camelize($) {
12 my ($str) = @_;
13  
14 my ($module, $method) = split /#/, $str;
15  
16 $module =
17 join '', map { ucfirst } split /_/,
18 join '::' => map { ucfirst lc } split /-/ => $module;
19  
20 $module =~ s/dbix::dr::/DBIx::DR::/i;
21  
22 return ($module, $method);
23 }
24  
25  
26 sub decamelize($;$) {
27 my ($class, $constructor) = @_;
28 for ($class) {
29 s/(?<!^)[A-Z]/_$&/g;
30 s/::_/::/g;
31 s/::/-/g;
32 }
33  
34 return lc $class unless $constructor;
35 return lc($class) . "#$constructor";
36 }
37  
38 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