line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
931
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
2
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
51
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package ElasticSearchX::Model::Generator::TypenameTranslator; |
5
|
|
|
|
|
|
|
BEGIN { |
6
|
1
|
|
|
1
|
|
28
|
$ElasticSearchX::Model::Generator::TypenameTranslator::AUTHORITY = 'cpan:KENTNL'; |
7
|
|
|
|
|
|
|
} |
8
|
|
|
|
|
|
|
{ |
9
|
|
|
|
|
|
|
$ElasticSearchX::Model::Generator::TypenameTranslator::VERSION = '0.1.8'; |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# ABSTRACT: Transform upstream type/document names to downstream Package/Class/File names. |
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
855
|
use Moo; |
|
1
|
|
|
|
|
18954
|
|
|
1
|
|
|
|
|
7
|
|
15
|
1
|
|
|
1
|
|
2995
|
use Path::Tiny (); |
|
1
|
|
|
|
|
14685
|
|
|
1
|
|
|
|
|
31
|
|
16
|
1
|
|
|
1
|
|
840
|
use Data::Dump qw( pp ); |
|
1
|
|
|
|
|
6241
|
|
|
1
|
|
|
|
|
94
|
|
17
|
1
|
|
|
1
|
|
443
|
use MooseX::Has::Sugar qw( rw required weak_ref ); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has |
21
|
|
|
|
|
|
|
'generator_base' => rw, |
22
|
|
|
|
|
|
|
required, weak_ref, handles => [qw( attribute_generator document_generator generated_base_class base_dir )]; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub _words { |
26
|
|
|
|
|
|
|
my ( $self, $input ) = @_; |
27
|
|
|
|
|
|
|
return split /\W+/, $input; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub translate_to_path { |
32
|
|
|
|
|
|
|
my ( $self, %args ) = @_; |
33
|
|
|
|
|
|
|
my $package = $self->translate_to_package(%args); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my (@words) = split /::/, $package; |
36
|
|
|
|
|
|
|
if ( not @words ) { |
37
|
|
|
|
|
|
|
require Carp; |
38
|
|
|
|
|
|
|
Carp::confess("Error translating typename to deploy path: $package "); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
my $basename = pop @words; |
41
|
|
|
|
|
|
|
if ( not length $basename ) { |
42
|
|
|
|
|
|
|
require Carp; |
43
|
|
|
|
|
|
|
Carp::confess("\$basename Path part was 0 characters long: $package"); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
$basename .= '.pm'; |
46
|
|
|
|
|
|
|
return Path::Tiny::path( $self->base_dir )->child( map { ucfirst $_ } @words )->child( ucfirst $basename ); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub translate_to_package { |
51
|
|
|
|
|
|
|
my ( $self, %args ) = @_; |
52
|
|
|
|
|
|
|
return sprintf q{%s::%s}, $self->generated_base_class, join q{}, map { ucfirst $_ } $self->_words( $args{typename} ); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
no Moo; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
__END__ |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=pod |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=encoding UTF-8 |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 NAME |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
ElasticSearchX::Model::Generator::TypenameTranslator - Transform upstream type/document names to downstream Package/Class/File names. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 VERSION |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
version 0.1.8 |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 METHODS |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 translate_to_path |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
my $path = $instance->translate_to_path( 'file' ); |
78
|
|
|
|
|
|
|
# -> /my/base/dir/File.pm |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head2 translate_to_package |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
my $package = $instance->translate_to_package('file'); |
83
|
|
|
|
|
|
|
# -> MyBaseClass::File |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 generator_base |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
rw, required, weak_ref |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 PRIVATE METHODS |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head2 _words |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
@words = $instance->_words( $string ); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 AUTHOR |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Kent Fredric <kentfredric@gmail.com> |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
This software is copyright (c) 2013 by Kent Fredric <kentfredric@gmail.com>. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
106
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |