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 4     4   23492 use utf8;
  4         3  
  4         15  
2 4     4   87 use strict;
  4         8  
  4         51  
3 4     4   15 use warnings;
  4         3  
  4         102  
4              
5             package DBIx::DR::Util;
6              
7 4     4   11 use base qw(Exporter);
  4         3  
  4         1238  
8             our @EXPORT = qw(camelize decamelize);
9              
10              
11             sub camelize($) {
12 31     31 0 1320 my ($str) = @_;
13              
14 31         72 my ($module, $method) = split /#/, $str;
15              
16             $module =
17 70         93 join '', map { ucfirst } split /_/,
18 31         62 join '::' => map { ucfirst lc } split /-/ => $module;
  71         152  
19              
20 31         81 $module =~ s/dbix::dr::/DBIx::DR::/i;
21              
22 31         59 return ($module, $method);
23             }
24              
25              
26             sub decamelize($;$) {
27 7     7 0 535 my ($class, $constructor) = @_;
28 7         10 for ($class) {
29 7         50 s/(?
30 7         20 s/::_/::/g;
31 7         17 s/::/-/g;
32             }
33              
34 7 100       12 return lc $class unless $constructor;
35 6         33 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