1package Test2::Event::Encoding;
2use strict;
3use warnings;
4
5our $VERSION = '1.302162';
6
7use Carp qw/croak/;
8
9BEGIN { require Test2::Event; our @ISA = qw(Test2::Event) }
10use Test2::Util::HashBase qw/encoding/;
11
12sub init {
13    my $self = shift;
14    defined $self->{+ENCODING} or croak "'encoding' is a required attribute";
15}
16
17sub summary { 'Encoding set to ' . $_[0]->{+ENCODING} }
18
19sub facet_data {
20    my $self = shift;
21    my $out = $self->common_facet_data;
22    $out->{control}->{encoding} = $self->{+ENCODING};
23    $out->{about}->{details} = $self->summary;
24    return $out;
25}
26
27
281;
29
30__END__
31
32=pod
33
34=encoding UTF-8
35
36=head1 NAME
37
38Test2::Event::Encoding - Set the encoding for the output stream
39
40=head1 DESCRIPTION
41
42The encoding event is generated when a test file wants to specify the encoding
43to be used when formatting its output. This event is intended to be produced
44by formatter classes and used for interpreting test names, message contents,
45etc.
46
47=head1 SYNOPSIS
48
49    use Test2::API qw/context/;
50    use Test2::Event::Encoding;
51
52    my $ctx = context();
53    my $event = $ctx->send_event('Encoding', encoding => 'UTF-8');
54
55=head1 METHODS
56
57Inherits from L<Test2::Event>. Also defines:
58
59=over 4
60
61=item $encoding = $e->encoding
62
63The encoding being specified.
64
65=back
66
67=head1 SOURCE
68
69The source code repository for Test2 can be found at
70F<http://github.com/Test-More/test-more/>.
71
72=head1 MAINTAINERS
73
74=over 4
75
76=item Chad Granum E<lt>exodist@cpan.orgE<gt>
77
78=back
79
80=head1 AUTHORS
81
82=over 4
83
84=item Chad Granum E<lt>exodist@cpan.orgE<gt>
85
86=back
87
88=head1 COPYRIGHT
89
90Copyright 2019 Chad Granum E<lt>exodist@cpan.orgE<gt>.
91
92This program is free software; you can redistribute it and/or
93modify it under the same terms as Perl itself.
94
95See F<http://dev.perl.org/licenses/>
96
97=cut
98