line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# This file is part of autobox-Camelize |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# This software is Copyright (c) 2012 by Chris Weyl. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This is free software, licensed under: |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# The GNU Lesser General Public License, Version 2.1, February 1999 |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
package autobox::Camelize; |
11
|
|
|
|
|
|
|
{ |
12
|
|
|
|
|
|
|
$autobox::Camelize::VERSION = '0.001'; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# ABSTRACT: autobox methods for (de)camelcasing |
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
19647
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
18
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
1
|
|
716
|
use parent 'autobox'; |
|
1
|
|
|
|
|
269
|
|
|
1
|
|
|
|
|
6
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub import { |
23
|
1
|
|
|
1
|
|
7
|
my $class = shift @_; |
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
|
|
7
|
return $class->SUPER::import( |
26
|
|
|
|
|
|
|
STRING => 'autobox::Camelize::STRING', |
27
|
|
|
|
|
|
|
@_, |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
{ |
32
|
|
|
|
|
|
|
package autobox::Camelize::STRING; |
33
|
|
|
|
|
|
|
{ |
34
|
|
|
|
|
|
|
$autobox::Camelize::STRING::VERSION = '0.001'; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
1
|
|
|
1
|
|
9588
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
30
|
|
38
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
189
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub decamelize { |
41
|
2
|
|
|
2
|
|
1022
|
my $string = lcfirst shift @_; |
42
|
|
|
|
|
|
|
|
43
|
2
|
|
|
|
|
15
|
$string =~ s/::(.)/__\l$1/g; |
44
|
2
|
|
|
|
|
24
|
$string =~ s/([A-Z])/_\l$1/g; |
45
|
|
|
|
|
|
|
|
46
|
2
|
|
|
|
|
15
|
return $string; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub camelize { |
50
|
2
|
|
|
2
|
|
1034
|
my $string = ucfirst shift @_; |
51
|
|
|
|
|
|
|
|
52
|
2
|
|
|
|
|
11
|
$string =~ s/__(.)/::\u$1/g; |
53
|
2
|
|
|
|
|
19
|
$string =~ s/_(.)/\u$1/g; |
54
|
|
|
|
|
|
|
|
55
|
2
|
|
|
|
|
14
|
return $string; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
!!42; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=pod |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=encoding utf-8 |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=for :stopwords Chris Weyl camelize decamelize Camelize Decamelize Camelizing Decamelizing |
68
|
|
|
|
|
|
|
camelization lowercased |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 NAME |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
autobox::Camelize - autobox methods for (de)camelcasing |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 VERSION |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
This document describes version 0.001 of autobox::Camelize - released March 17, 2013 as part of autobox-Camelize. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 SYNOPSIS |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
use autobox::Camelize; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# $foo is 'this_is__my__name' |
83
|
|
|
|
|
|
|
my $foo = 'ThisIs::My::Name'->decamelize; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# $bar is 'ThisIs::NotMy::Name' |
86
|
|
|
|
|
|
|
my $bar = 'this_is__not_my__name'->camelize; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 DESCRIPTION |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
This is a simple set of autobox methods that work on strings, and |
91
|
|
|
|
|
|
|
camelize/decamelize them according to how the author thinks camelization |
92
|
|
|
|
|
|
|
should work: |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Camelizing replaces '__[a-z]' with '::[A-Z]', and '_[a-z]' with '[A-Z]'. |
95
|
|
|
|
|
|
|
The first character is capitalized. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Decamelizing replaces '::[A-Z]' with '__[a-z]', and '[A-Z]' with '_[a-z]'. |
98
|
|
|
|
|
|
|
The first character is lowercased. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 STRING METHODS |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 camelize |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Camelize a string. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 decamelize |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Decamelize a string. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 SEE ALSO |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Please see those modules/websites for more information related to this module. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=over 4 |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item * |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
L<autobox> |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=item * |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
L<L<autobox::Core> has a fairly comprehensive collection of autobox methods.|L<autobox::Core> has a fairly comprehensive collection of autobox methods.> |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=back |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 SOURCE |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
The development version is on github at L<http://github.com/RsrchBoy/autobox-Camelize> |
129
|
|
|
|
|
|
|
and may be cloned from L<git://github.com/RsrchBoy/autobox-Camelize.git> |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 BUGS |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Please report any bugs or feature requests on the bugtracker website |
134
|
|
|
|
|
|
|
https://github.com/RsrchBoy/autobox-Camelize/issues |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
When submitting a bug or request, please include a test-file or a |
137
|
|
|
|
|
|
|
patch to an existing test-file that illustrates the bug or desired |
138
|
|
|
|
|
|
|
feature. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 AUTHOR |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Chris Weyl <cweyl@alumni.drew.edu> |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
This software is Copyright (c) 2012 by Chris Weyl. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
This is free software, licensed under: |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
The GNU Lesser General Public License, Version 2.1, February 1999 |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=cut |