File Coverage

lib/DBIx/DR/Util.pm
Criterion Covered Total %
statement 26 26 100.0
branch 2 2 100.0
condition n/a
subroutine 6 6 100.0
pod 0 2 0.0
total 34 36 94.4


line stmt bran cond sub pod time code
1 3     3   27857 use utf8;
  3         4  
  3         16  
2 3     3   79 use strict;
  3         9  
  3         46  
3 3     3   9 use warnings;
  3         3  
  3         87  
4              
5             package DBIx::DR::Util;
6              
7 3     3   9 use base qw(Exporter);
  3         6  
  3         968  
8             our @EXPORT = qw(camelize decamelize);
9              
10              
11             sub camelize($) {
12 22     22 0 1564 my ($str) = @_;
13              
14 22         52 my ($module, $method) = split /#/, $str;
15              
16             $module =
17 51         77 join '', map { ucfirst } split /_/,
18 22         54 join '::' => map { ucfirst lc } split /-/ => $module;
  62         126  
19              
20 22         78 $module =~ s/dbix::dr::/DBIx::DR::/i;
21              
22 22         45 return ($module, $method);
23             }
24              
25              
26             sub decamelize($;$) {
27 7     7 0 604 my ($class, $constructor) = @_;
28 7         13 for ($class) {
29 7         57 s/(?
30 7         19 s/::_/::/g;
31 7         15 s/::/-/g;
32             }
33              
34 7 100       16 return lc $class unless $constructor;
35 6         28 return lc($class) . "#$constructor";
36             }
37              
38             1;
39              
40             =head1 NAME
41              
42             DBIx::DR::Util - some functions for L.
43              
44             =head1 COPYRIGHT
45              
46             Copyright (C) 2011 Dmitry E. Oboukhov
47             Copyright (C) 2011 Roman V. Nikolaev
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