File Coverage

blib/lib/Test/Shared/Fixture/Data/InfoBox/Items.pm
Criterion Covered Total %
statement 25 25 100.0
branch n/a
condition n/a
subroutine 8 8 100.0
pod 1 1 100.0
total 34 34 100.0


line stmt bran cond sub pod time code
1             package Test::Shared::Fixture::Data::InfoBox::Items;
2              
3 4     4   527897 use base qw(Data::InfoBox);
  4         9  
  4         2284  
4 4     4   44 use strict;
  4         8  
  4         143  
5 4     4   39 use warnings;
  4         8  
  4         253  
6              
7 4     4   2260 use Data::Icon;
  4         338967  
  4         222  
8 4     4   2613 use Data::InfoBox::Item 0.03;
  4         86  
  4         141  
9 4     4   2210 use Data::Text::Simple;
  4         1173989  
  4         224  
10 4     4   1993 use Unicode::UTF8 qw(decode_utf8);
  4         2890  
  4         1183  
11              
12             our $VERSION = 0.07;
13              
14             sub new {
15 2     2 1 425963 my $class = shift;
16              
17 2         38 my @params = (
18             'items' => [
19             Data::InfoBox::Item->new(
20             'icon' => Data::Icon->new(
21             'color' => 'green',
22             'char' => decode_utf8('✓'),
23             ),
24             'text' => Data::Text::Simple->new(
25             'lang' => 'en',
26             'text' => 'Create project',
27             ),
28             ),
29             Data::InfoBox::Item->new(
30             'text' => Data::Text::Simple->new(
31             'lang' => 'en',
32             'text' => 'Present project',
33             ),
34             ),
35             Data::InfoBox::Item->new(
36             'icon' => Data::Icon->new(
37             'color' => 'red',
38             'char' => decode_utf8('✗'),
39             ),
40             'text' => Data::Text::Simple->new(
41             'lang' => 'en',
42             'text' => 'Add money to project',
43             ),
44             ),
45             Data::InfoBox::Item->new(
46             'text' => Data::Text::Simple->new(
47             'lang' => 'en',
48             'text' => 'Finish project',
49             ),
50             ),
51             ],
52             );
53              
54 2         35 my $self = $class->SUPER::new(@params);
55              
56 2         19 return $self;
57             }
58              
59             1;
60              
61             __END__
62              
63             =pod
64              
65             =encoding utf8
66              
67             =head1 NAME
68              
69             Test::Shared::Fixture::Data::InfoBox::Items - Items info box fixture.
70              
71             =head1 SYNOPSIS
72              
73             use Test::Shared::Fixture::Data::InfoBox::Items;
74              
75             my $obj = Test::Shared::Fixture::Data::InfoBox::Items->new;
76             my $items_ar = $obj->items;
77              
78             =head1 METHODS
79              
80             =head2 C<new>
81              
82             my $obj = Test::Shared::Fixture::Data::InfoBox::Items->new;
83              
84             Constructor.
85              
86             Returns instance of object.
87              
88             =head2 C<items>
89              
90             my $items_ar = $obj->items;
91              
92             Get list of items in info box.
93              
94             Returns reference to array with L<Data::InfoBox::Item> objects.
95              
96             =head1 EXAMPLE
97              
98             =for comment filename=create_items_fixture_object_and_print.pl
99              
100             use strict;
101             use warnings;
102              
103             use Term::ANSIColor;
104             use Test::Shared::Fixture::Data::InfoBox::Items;
105             use Unicode::UTF8 qw(encode_utf8);
106              
107             my $obj = Test::Shared::Fixture::Data::InfoBox::Items->new;
108              
109             # Print out.
110             my $num = 0;
111             foreach my $item (@{$obj->items}) {
112             $num++;
113             my $icon_char = defined $item->icon
114             ? color($item->icon->color).encode_utf8($item->icon->char).color('reset')
115             : ' ';
116             print $icon_char.' '.encode_utf8($item->text->text)."\n";
117             }
118              
119             # Output (real output is colored):
120             # ✓ Create project
121             # Present project
122             # ✗ Add money to project
123             # Finish project
124              
125             =head1 DEPENDENCIES
126              
127             L<Data::Icon>,
128             L<Data::InfoBox>,
129             L<Data::InfoBox::Item>,
130             L<Data::Text::Simple>,
131             L<Unicode::UTF8>.
132              
133             =head1 REPOSITORY
134              
135             L<https://github.com/michal-josef-spacek/Data-InfoBox>
136              
137             =head1 AUTHOR
138              
139             Michal Josef Špaček L<mailto:skim@cpan.org>
140              
141             L<http://skim.cz>
142              
143             =head1 LICENSE AND COPYRIGHT
144              
145             © 2024-2025 Michal Josef Špaček
146              
147             BSD 2-Clause License
148              
149             =head1 VERSION
150              
151             0.07
152              
153             =cut