line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Elasticsearch::Util; |
2
|
|
|
|
|
|
|
$Elasticsearch::Util::VERSION = '1.05'; |
3
|
50
|
|
|
50
|
|
315
|
use Moo; |
|
50
|
|
|
|
|
106
|
|
|
50
|
|
|
|
|
305
|
|
4
|
50
|
|
|
50
|
|
51822
|
use Elasticsearch::Error(); |
|
50
|
|
|
|
|
181
|
|
|
50
|
|
|
|
|
1871
|
|
5
|
50
|
|
|
50
|
|
517
|
use Scalar::Util qw(blessed); |
|
50
|
|
|
|
|
93
|
|
|
50
|
|
|
|
|
10760
|
|
6
|
50
|
|
|
50
|
|
341
|
use Module::Runtime qw(compose_module_name is_module_name use_module); |
|
50
|
|
|
|
|
114
|
|
|
50
|
|
|
|
|
572
|
|
7
|
50
|
|
|
|
|
623
|
use Sub::Exporter -setup => { |
8
|
|
|
|
|
|
|
exports => [ qw( |
9
|
|
|
|
|
|
|
parse_params |
10
|
|
|
|
|
|
|
to_list |
11
|
|
|
|
|
|
|
load_plugin |
12
|
|
|
|
|
|
|
new_error |
13
|
|
|
|
|
|
|
throw |
14
|
|
|
|
|
|
|
upgrade_error |
15
|
|
|
|
|
|
|
is_compat |
16
|
|
|
|
|
|
|
) |
17
|
|
|
|
|
|
|
] |
18
|
50
|
|
|
50
|
|
84613
|
}; |
|
50
|
|
|
|
|
900791
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
#=================================== |
21
|
|
|
|
|
|
|
sub to_list { |
22
|
|
|
|
|
|
|
#=================================== |
23
|
248
|
100
|
|
248
|
0
|
1243
|
grep {defined} ref $_[0] eq 'ARRAY' ? @{ $_[0] } : @_; |
|
240
|
|
|
|
|
1441
|
|
|
74
|
|
|
|
|
266
|
|
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
#=================================== |
27
|
|
|
|
|
|
|
sub parse_params { |
28
|
|
|
|
|
|
|
#=================================== |
29
|
477
|
|
|
477
|
0
|
1118
|
my $self = shift; |
30
|
477
|
|
|
|
|
855
|
my %params; |
31
|
477
|
100
|
|
|
|
1922
|
if ( @_ % 2 ) { |
32
|
117
|
50
|
|
|
|
680
|
throw( |
33
|
|
|
|
|
|
|
"Param", |
34
|
|
|
|
|
|
|
'Expecting a HASH ref or a list of key-value pairs', |
35
|
|
|
|
|
|
|
{ params => \@_ } |
36
|
|
|
|
|
|
|
) unless ref $_[0] eq 'HASH'; |
37
|
117
|
|
|
|
|
234
|
%params = %{ shift() }; |
|
117
|
|
|
|
|
1047
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
else { |
40
|
360
|
|
|
|
|
1710
|
%params = @_; |
41
|
|
|
|
|
|
|
} |
42
|
477
|
|
|
|
|
2020
|
return ( $self, \%params ); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
#=================================== |
46
|
|
|
|
|
|
|
sub load_plugin { |
47
|
|
|
|
|
|
|
#=================================== |
48
|
497
|
|
|
497
|
0
|
9384
|
my ( $base, $spec ) = @_; |
49
|
497
|
|
66
|
|
|
2057
|
$spec ||= "+$base"; |
50
|
497
|
50
|
|
|
|
7212
|
return $spec if blessed $spec; |
51
|
|
|
|
|
|
|
|
52
|
497
|
|
|
|
|
758
|
my ( $class, $version ); |
53
|
497
|
50
|
|
|
|
1946
|
if ( ref $spec eq 'ARRAY' ) { |
54
|
0
|
|
|
|
|
0
|
( $class, $version ) = @$spec; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
else { |
57
|
497
|
|
|
|
|
882
|
$class = $spec; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
497
|
100
|
|
|
|
2278
|
unless ( $class =~ s/\A\+// ) { |
61
|
322
|
|
|
|
|
10728
|
$class = compose_module_name( $base, $class ); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
497
|
50
|
|
|
|
27655
|
$version ? use_module( $class, $version ) : use_module($class); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
#=================================== |
68
|
|
|
|
|
|
|
sub throw { |
69
|
|
|
|
|
|
|
#=================================== |
70
|
80
|
|
|
80
|
0
|
755
|
my ( $type, $msg, $vars ) = @_; |
71
|
80
|
|
|
|
|
599
|
die Elasticsearch::Error->new( $type, $msg, $vars, 1 ); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
#=================================== |
75
|
|
|
|
|
|
|
sub new_error { |
76
|
|
|
|
|
|
|
#=================================== |
77
|
30
|
|
|
30
|
0
|
80
|
my ( $type, $msg, $vars ) = @_; |
78
|
30
|
|
|
|
|
157
|
return Elasticsearch::Error->new( $type, $msg, $vars, 1 ); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
#=================================== |
82
|
|
|
|
|
|
|
sub upgrade_error { |
83
|
|
|
|
|
|
|
#=================================== |
84
|
47
|
|
|
47
|
0
|
108
|
my ( $error, $vars ) = @_; |
85
|
47
|
50
|
33
|
|
|
1009
|
return ref($error) && $error->isa('Elasticsearch::Error') |
|
|
|
0
|
|
|
|
|
86
|
|
|
|
|
|
|
? $error |
87
|
|
|
|
|
|
|
: Elasticsearch::Error->new( "Internal", $error, $vars || {}, 1 ); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
#=================================== |
91
|
|
|
|
|
|
|
sub is_compat { |
92
|
|
|
|
|
|
|
#=================================== |
93
|
142
|
|
|
142
|
0
|
376
|
my ( $attr, $one, $two ) = @_; |
94
|
142
|
50
|
|
|
|
1386
|
my $role |
95
|
|
|
|
|
|
|
= $one->does('Elasticsearch::Role::Is_Sync') |
96
|
|
|
|
|
|
|
? 'Elasticsearch::Role::Is_Sync' |
97
|
|
|
|
|
|
|
: 'Elasticsearch::Role::Is_Async'; |
98
|
|
|
|
|
|
|
|
99
|
142
|
50
|
|
|
|
5030
|
return if eval { $two->does($role); }; |
|
142
|
|
|
|
|
907
|
|
100
|
0
|
|
0
|
|
|
|
my $class = ref($two) || $two; |
101
|
0
|
|
|
|
|
|
die "$attr ($class) does not do $role"; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
1; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# ABSTRACT: A utility class for internal use by Elasticsearch |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
__END__ |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=pod |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=encoding UTF-8 |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 NAME |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Elasticsearch::Util - A utility class for internal use by Elasticsearch |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 VERSION |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
version 1.05 |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 AUTHOR |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Clinton Gormley <drtech@cpan.org> |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
This software is Copyright (c) 2014 by Elasticsearch BV. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
This is free software, licensed under: |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
The Apache License, Version 2.0, January 2004 |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=cut |