line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Locale::File::PO::Header::ContentTypeItem; ## no critic (TidyCode) |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
43
|
use Moose; |
|
5
|
|
|
|
|
15
|
|
|
5
|
|
|
|
|
42
|
|
4
|
5
|
|
|
5
|
|
33543
|
use MooseX::StrictConstructor; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
37
|
|
5
|
5
|
|
|
5
|
|
15066
|
use namespace::autoclean; |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
49
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.004'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
extends qw(Locale::File::PO::Header::Base); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has name => ( |
12
|
|
|
|
|
|
|
is => 'rw', |
13
|
|
|
|
|
|
|
isa => 'Str', |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has default => ( |
17
|
|
|
|
|
|
|
is => 'rw', |
18
|
|
|
|
|
|
|
isa => 'HashRef', |
19
|
|
|
|
|
|
|
trigger => sub { |
20
|
|
|
|
|
|
|
my ($self, $arg_ref) = @_; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
$self->default_content_type( $arg_ref->{'Content-Type'} ); |
23
|
|
|
|
|
|
|
$self->default_charset( $arg_ref->{charset} ); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
return $arg_ref; |
26
|
|
|
|
|
|
|
}, |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
has default_content_type => ( |
30
|
|
|
|
|
|
|
is => 'rw', |
31
|
|
|
|
|
|
|
isa => 'Str', |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has default_charset => ( |
35
|
|
|
|
|
|
|
is => 'rw', |
36
|
|
|
|
|
|
|
isa => 'Str', |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
has content_type => ( |
40
|
|
|
|
|
|
|
is => 'rw', |
41
|
|
|
|
|
|
|
isa => 'Str|Undef', |
42
|
|
|
|
|
|
|
lazy => 1, |
43
|
|
|
|
|
|
|
default => sub { |
44
|
|
|
|
|
|
|
my $self = shift; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
return $self->default_content_type; |
47
|
|
|
|
|
|
|
}, |
48
|
|
|
|
|
|
|
trigger => sub { |
49
|
|
|
|
|
|
|
my ($self, $content_type, $current_content_type) = @_; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
return $self->trigger_helper({ |
52
|
|
|
|
|
|
|
new => $content_type, |
53
|
|
|
|
|
|
|
current => $current_content_type, |
54
|
|
|
|
|
|
|
default => scalar $self->default_content_type, |
55
|
|
|
|
|
|
|
writer => 'content_type', |
56
|
|
|
|
|
|
|
}); |
57
|
|
|
|
|
|
|
}, |
58
|
|
|
|
|
|
|
); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
has charset => ( |
61
|
|
|
|
|
|
|
is => 'rw', |
62
|
|
|
|
|
|
|
isa => 'Str|Undef', |
63
|
|
|
|
|
|
|
lazy => 1, |
64
|
|
|
|
|
|
|
default => sub { |
65
|
|
|
|
|
|
|
my $self = shift; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
return $self->default_charset; |
68
|
|
|
|
|
|
|
}, |
69
|
|
|
|
|
|
|
trigger => sub { |
70
|
|
|
|
|
|
|
my ($self, $charset, $current_charset) = @_; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
return $self->trigger_helper({ |
73
|
|
|
|
|
|
|
new => $charset, |
74
|
|
|
|
|
|
|
current => $current_charset, |
75
|
|
|
|
|
|
|
default => scalar $self->default_charset, |
76
|
|
|
|
|
|
|
writer => 'charset', |
77
|
|
|
|
|
|
|
}); |
78
|
|
|
|
|
|
|
}, |
79
|
|
|
|
|
|
|
); |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub header_keys { |
82
|
3
|
|
|
3
|
0
|
6
|
my $self = shift; |
83
|
|
|
|
|
|
|
|
84
|
3
|
|
|
|
|
108
|
return $self->name, 'charset'; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub data { |
88
|
3
|
|
|
3
|
0
|
9
|
my ($self, $key, @args) = @_; |
89
|
|
|
|
|
|
|
|
90
|
3
|
50
|
|
|
|
10
|
defined $key |
91
|
|
|
|
|
|
|
or confess 'Undefined key'; |
92
|
3
|
100
|
|
|
|
9
|
my $value = @args ? $args[0] : (); |
93
|
3
|
100
|
|
|
|
10
|
if ( $key eq 'Content-Type' ) { |
94
|
|
|
|
|
|
|
return |
95
|
|
|
|
|
|
|
@args |
96
|
|
|
|
|
|
|
? ( |
97
|
|
|
|
|
|
|
$self->content_type( # set |
98
|
|
|
|
|
|
|
ref $value eq 'HASH' |
99
|
2
|
50
|
|
|
|
75
|
? $value->{$key} |
|
|
100
|
|
|
|
|
|
100
|
|
|
|
|
|
|
: $value |
101
|
|
|
|
|
|
|
) |
102
|
|
|
|
|
|
|
) |
103
|
|
|
|
|
|
|
: $self->content_type; # get |
104
|
|
|
|
|
|
|
} |
105
|
1
|
50
|
|
|
|
4
|
if ( $key eq 'charset' ) { |
106
|
|
|
|
|
|
|
return |
107
|
|
|
|
|
|
|
@args |
108
|
|
|
|
|
|
|
? ( |
109
|
|
|
|
|
|
|
$self->charset( # set |
110
|
|
|
|
|
|
|
ref $value eq 'HASH' |
111
|
1
|
50
|
|
|
|
32
|
? $value->{$key} |
|
|
50
|
|
|
|
|
|
112
|
|
|
|
|
|
|
: $value |
113
|
|
|
|
|
|
|
) |
114
|
|
|
|
|
|
|
) |
115
|
|
|
|
|
|
|
: $self->charset; # get |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
0
|
|
|
|
|
0
|
confess "Unknown key $key"; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub extract_msgstr { |
122
|
2
|
|
|
2
|
0
|
8
|
my ($self, $msgstr_ref) = @_; |
123
|
|
|
|
|
|
|
|
124
|
2
|
|
|
|
|
5
|
${$msgstr_ref} =~ s{ |
|
2
|
|
|
|
|
19
|
|
125
|
|
|
|
|
|
|
^ |
126
|
|
|
|
|
|
|
Content-Type : |
127
|
|
|
|
|
|
|
\s* |
128
|
|
|
|
|
|
|
( [^;\n]*? ) ; |
129
|
|
|
|
|
|
|
\s* |
130
|
|
|
|
|
|
|
charset = ( \S* ) |
131
|
|
|
|
|
|
|
\s* |
132
|
|
|
|
|
|
|
$ |
133
|
|
|
|
|
|
|
}{}xmsi; |
134
|
2
|
|
|
|
|
82
|
$self->content_type($1); ## no critic (CaptureWithoutTest) |
135
|
2
|
|
|
|
|
79
|
$self->charset($2); ## no critic (CaptureWithoutTest) |
136
|
|
|
|
|
|
|
|
137
|
2
|
|
|
|
|
6
|
return; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub lines { |
141
|
3
|
|
|
3
|
0
|
6
|
my $self = shift; |
142
|
|
|
|
|
|
|
|
143
|
3
|
|
|
|
|
93
|
return $self->format_line( |
144
|
|
|
|
|
|
|
'{name}: {content_type}; charset={charset}', |
145
|
|
|
|
|
|
|
name => $self->name, |
146
|
|
|
|
|
|
|
content_type => $self->content_type, |
147
|
|
|
|
|
|
|
charset => $self->charset, |
148
|
|
|
|
|
|
|
); |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
# $Id: Utils.pm 602 2011-11-13 13:49:23Z steffenw $ |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
1; |