File Coverage

blib/lib/Icon/FamFamFam/Silk.pm
Criterion Covered Total %
statement 23 32 71.8
branch 4 10 40.0
condition n/a
subroutine 8 11 72.7
pod 7 7 100.0
total 42 60 70.0


line stmt bran cond sub pod time code
1             package Icon::FamFamFam::Silk;
2              
3 1     1   30492 use 5.006;
  1         4  
  1         49  
4 1     1   1026 use MIME::Base64 qw[];
  1         816  
  1         20  
5 1     1   1765 use URI;
  1         7254  
  1         354  
6              
7             our $VERSION = '0.002001003';
8             our $_data = {};
9              
10             sub new
11             {
12 1     1 1 12 my ($class, $icon) = @_;
13 1         6 bless \$icon, $class;
14             }
15              
16             sub _load_data()
17             {
18 1 50   1   4 return if %$_data;
19 1         4 local $/;
20 1         27925 eval ;
21             }
22              
23             sub name
24             {
25 1     1 1 4244 my ($icon) = @_;
26 1 50       6 return (ref $icon) ? ${$icon} : $icon;
  1         7  
27             }
28              
29             sub list
30             {
31 0     0 1 0 my ($class) = @_;
32 0 0       0 _load_data() unless %$_data;
33 0         0 return map { my $icon = $_; bless \$icon, $class; } keys %$_data;
  0         0  
  0         0  
34             }
35              
36             sub base64
37             {
38 1     1 1 2 my ($icon) = @_;
39 1 50       8 _load_data() unless %$_data;
40 1 50       11 return (ref $icon) ? $_data->{${$icon}} : $_data->{$icon};
  1         61  
41             }
42              
43             sub uri
44             {
45 1     1 1 7 my ($icon) = @_;
46 1         4 return URI->new('data:image/png;base64,' . base64($icon));
47             }
48              
49             sub raw
50             {
51 0     0 1   my ($icon) = @_;
52 0           MIME::Base64::decode_base64(base64($icon));
53             }
54              
55             sub attribution_data
56             {
57 0     0 1   my %data = (
58             -url => 'http://www.famfamfam.com/lab/icons/silk/famfamfam_silk_icons_v013.zip',
59             -title => 'Silk icons',
60             -attributionName => 'Mark James',
61             -attributionURL => 'http://www.famfamfam.com/lab/icons/silk/',
62             -licence => 'by',
63             -type => 'Collection',
64             );
65 0           return %data;
66             }
67              
68             1;
69              
70             =head1 NAME
71              
72             Icon::FamFamFam::Silk - embed these famous icons in your code
73              
74             =head1 VERSION
75              
76             0.002001003
77              
78             (Version 0.002 of this module and version 1.3 of the icons.)
79              
80             =head1 SYNOPSIS
81              
82             use Icon::FamFamFam::Silk;
83             my $wrench = Icon::FamFamFam::Silk->new('wrench_orange');
84             print $wrench->base64;
85              
86             or
87              
88             use Icon::FamFamFam::Silk;
89             print Icon::FamFamFam::Silk::base64('wrench_orange');
90              
91             =head1 DESCRIPTION
92              
93             These methods can be called as functions taking the name of the icon (a string)
94             as their argument, or can be called as object methods on an instantiated icon
95             object. (See L.)
96              
97             =over
98              
99             =item C<< Icon::FamFamFam::Silk->new($name) >>
100              
101             Returns a blessed icon object.
102              
103             =item C<< Icon::FamFamFam::Silk->list >>
104              
105             Returns a list of all the icons.
106              
107             =item C<< $icon->name >>
108              
109             Returns the name of the icon.
110              
111             =item C<< $icon->base64 >>
112              
113             Returns base64-encoded PNG data.
114              
115             =item C<< $icon->raw >>
116              
117             Returns raw PNG data.
118              
119             =item C<< $icon->uri >>
120              
121             Returns a "data:" URI for the icon.
122              
123             =item C<< $icon->attribution_data >>
124             =item C<< Icon::FamFamFam::Silk->attribution_data >>
125              
126             Returns a hash of data useful for giving credit to Mark James.
127              
128             This is in a format suitable for passing to L's
129             C function, should you want to do something like
130             that.
131              
132             =back
133              
134             =head1 BUGS
135              
136             Please report any bugs to L.
137              
138             =head1 SEE ALSO
139              
140             L.
141              
142             =head1 AUTHOR
143              
144             Icons by Mark James of L.
145              
146             Module by Toby Inkster Etobyink@cpan.orgE.
147              
148             =head1 COPYRIGHT AND LICENCE
149              
150             Mark James distributes the icons themselves under the CC-BY 3.0 licence
151             L. Applications using
152             Icon::FamFamFam::Silk (even indirectly via another module) must provide
153             credit. Including a link to L in the
154             documentation of the application is probably sufficient.
155              
156             Toby Inkster releases the additional Perl coding into the Public Domain.
157              
158             =head1 DISCLAIMER OF WARRANTIES
159              
160             THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
161             WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
162             MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
163              
164             =cut
165              
166             __DATA__