SocialMeta/Twitter.pm

filter: Statementstmt 97.2% 35 / 36 Branchbran 83.3% 5 / 6 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 10 / 10 Podpod 80.0% 4 / 5 totaltotal 95.1% 59 / 62 CC 5 SCAR 9.0
CC
5
Cov
96%
provider_convert
5.1
BEGIN
1.0
BEGIN
1.0
CRAP 2.5
↑ Summary SocialMeta/Base.pm »
1 package HTML::SocialMeta::Twitter;
2  
3 5 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 5 extends 'HTML::SocialMeta::Base';
8  
9 5 our $VERSION = '0.4';
10  
11 # Provider Specific Fields
12 5 has 'meta_attribute' =>
13 ( isa => 'Str', is => 'ro', required => 1, default => 'name' );
14 5 has 'meta_namespace' =>
15 ( isa => 'Str', is => 'ro', required => 1, default => 'twitter' );
16  
17 has '+card_options' => (
18 default => sub {
19 return {
20 8 ▶ summary => q(create_summary),
Subroutine __ANON__: called CC=1 SCAR=0.0
21 featured_image => q(create_summary_large_image),
22 app => q(create_app),
23 player => q(create_player),
24 };
25 },
26 5 );
27  
28 has '+build_fields' => (
29 default => sub {
30 return {
31 8 ▶ summary => [qw(card site title description image)],
Subroutine __ANON__: called CC=1 SCAR=0.0
32 summary_large_image => [qw(card site title description image)],
33 app =>
34 [qw(card site description app_country app_name app_id app_url)],
35 player => [
36 qw(card site title description image player player_width player_height)
37 ],
38 };
39 },
40 5 );
41  
42 sub create_summary {
43 5 ▶ my ($self) = @_;
Subroutine create_summary: called CC=1 SCAR=0.0
Pod documented
44  
45 5 $self->card('summary');
46  
47 5 return $self->build_meta_tags( $self->card );
48 }
49  
50 sub create_summary_large_image {
51 4 ▶ my ($self) = @_;
Subroutine create_summary_large_image: called CC=1 SCAR=0.0
Pod documented
52  
53 4 $self->card('summary_large_image');
54  
55 4 return $self->build_meta_tags( $self->card );
56 }
57  
58 sub create_app {
59 6 ▶ my ($self) = @_;
Subroutine create_app: called CC=1 SCAR=0.0
Pod documented
60  
61 6 $self->card('app');
62  
63 6 return $self->build_meta_tags( $self->card );
64 }
65  
66 sub create_player {
67 3 ▶ my ($self) = @_;
Subroutine create_player: called CC=1 SCAR=0.0
Pod documented
68  
69 3 $self->card('player');
70  
71 3 return $self->build_meta_tags( $self->card );
72 }
73  
74 sub provider_convert {
75 33 ▶ my ( $self, $field ) = @_;
Subroutine provider_convert: called CC=5 SCAR=16.2
Pod undocumented
76  
77 33 ▶ return [ { field_type => $field } ]
Branch: 1 branch
BranchTrueFalseTotal
if not $field =~ /^app/msx or $field =~ /country$/msx 15 18 33
Condition100%3/3
not $field =~ /^app/msx or $field =~ /country$/msx
l!l&&r!l&&!r
9618
MC/DC100%2/2
not $field =~ /^app/msx or $field =~ /country$/msx
not $field =~ /^app/msx $field =~ /country$/msx
Truth table100%3/3
not(A) or B
A= not $field =~ /^app/msxB= $field =~ /country$/msx
ABresult
1X1
011
000
78 if $field !~ m{^app}xms || $field =~ m{country$}xms;
79  
80 18 ▶ return [ { field_type => $field . ':googleplay' } ]
Branch: 1 branch
BranchTrueFalseTotal
if $self->operatingSystem eq "ANDROID" 9 9 18
81 if $self->operatingSystem eq q{ANDROID};
82  
83 return [
84 9 ▶ { field_type => $field . ':iphone' },
Branch: 1 branch
BranchTrueFalseTotal
if $self->operatingSystem eq "IOS" 9 0 9
85 { field_type => $field . ':ipad' }
86 ]
87 if $self->operatingSystem eq q{IOS};
88  
89 0 return croak 'We currently do not support this APP type';
90 }
91  
92 #
93 # The End
94 #
95 5 __PACKAGE__->meta->make_immutable;
96  
97 5 1;
98  
99 __END__
100  
101 =head1 NAME
102  
103 HTML::SocialMeta::Twitter
104  
105 =head1 VERSION
106  
107 Version 0.2
108  
109 =cut
110  
111 =head1 DESCRIPTION
112  
113 Base class to create Twitter Cards
114  
115 =head1 SYNOPSIS
116
117 $twitter_meta => HTML::Social::Twitter->new(
118 card_type => 'summary',
119 site => '@example_twitter',
120 site_name => 'Example Site, anything',
121 title => 'You can have any title you wish here',
122 description => 'Description goes here may have to do a little validation',
123 image => 'www.urltoimage.com/blah.jpg',
124 url => 'www.someurl.com',
125 operatingSystem => 'ANDROID',
126 app_country => 'test',
127 app_name => 'test',
128 app_id => 'test',
129 app_url => 'test',
130 player => 'www.urltovideo.com/blah.jpg',
131 player_width => '500',
132 player_height => '500',
133 );
134  
135 $twitter->create('summary featured_image app player');
136
137 $twitter->create_summary;
138 $twitter->create_summary_large_image;
139 $twitter->create_app;
140 $twitter->create_player;
141  
142 =cut
143  
144 =head1 SUBROUTINES/METHODS
145  
146 =head1 VERSION
147  
148 Version 0.4
149  
150 =cut
151  
152 =head1 DESCRIPTION
153  
154 Base class for creating OpenGraph meta data
155  
156 =head1 SYNOPSIS
157  
158 =head1 SUBROUTINES/METHODS
159  
160 =head2 card_options
161  
162 An Hash Reference of card options available for this meta provider, it is used to map the create function when create is called.
163  
164 =cut
165  
166 =head2 build_fields
167
168 An Hash Reference of fields that are attached to the selected card:
169  
170 =cut
171  
172 =head2 create_summary
173  
174 Generate Twitter Summary meta data
175  
176 =cut
177  
178 =head2 create_summary_large_image
179  
180 Generate Twitter Summary Large Image Video meta data
181  
182 =cut
183  
184 =head2 create_app
185  
186 Generate Twitter App meta data
187  
188 =cut
189  
190 =head2 create_player
191  
192 Generate Twitter Player meta data
193  
194 =cut
195  
196 =head1 AUTHOR
197  
198 Robert Acock <ThisUsedToBeAnEmail@gmail.com>
199 Robert Haliday <robh@cpan.org>
200  
201 =head1 TODO
202
203 * Add support for player streaming
204
205 =head1 BUGS AND LIMITATIONS
206
207 Most probably. Please report any bugs at http://rt.cpan.org/.
208  
209 =head1 INCOMPATIBILITIES
210  
211 =head1 DEPENDENCIES
212  
213 =head1 CONFIGURATION AND ENVIRONMENT
214  
215 =head1 DIAGNOSTICS
216
217 =head1 LICENSE AND COPYRIGHT
218
219 Copyright 2015 Robert Acock.
220
221 This program is free software; you can redistribute it and/or modify it
222 under the terms of the the Artistic License (2.0). You may obtain a
223 copy of the full license at:
224
225 L<http://www.perlfoundation.org/artistic_license_2_0>
226
227 Any use, modification, and distribution of the Standard or Modified
228 Versions is governed by this Artistic License. By using, modifying or
229 distributing the Package, you accept this license. Do not use, modify,
230 or distribute the Package, if you do not accept this license.
231
232 If your Modified Version has been derived from a Modified Version made
233 by someone other than you, you are nevertheless required to ensure that
234 your Modified Version complies with the requirements of this license.
235
236 This license does not grant you the right to use any trademark, service
237 mark, tradename, or logo of the Copyright Holder.
238
239 This license includes the non-exclusive, worldwide, free-of-charge
240 patent license to make, have made, use, offer to sell, sell, import and
241 otherwise transfer the Package with respect to any patent claims
242 licensable by the Copyright Holder that are necessarily infringed by the
243 Package. If you institute patent litigation (including a cross-claim or
244 counterclaim) against any party alleging that the Package constitutes
245 direct or contributory patent infringement, then this Artistic License
246 to you shall terminate on the date that such litigation is filed.
247
248 Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
249 AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
250 THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
251 PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
252 YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
253 CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
254 CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
255 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
256  
257  
258  
↑ Summary SocialMeta/Base.pm »