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.5';
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.5
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 # 'summary', 'featured_image', 'app', 'player'
136 $twitter->create('summary');
137
138 $twitter->create_summary;
139 $twitter->create_summary_large_image;
140 $twitter->create_app;
141 $twitter->create_player;
142  
143 =cut
144  
145 =head1 SUBROUTINES/METHODS
146  
147 =head1 VERSION
148  
149 Version 0.5
150  
151 =cut
152  
153 =head1 DESCRIPTION
154  
155 Base class for creating OpenGraph meta data
156  
157 =head1 SYNOPSIS
158  
159 =head1 SUBROUTINES/METHODS
160  
161 =head2 card_options
162  
163 An Hash Reference of card options available for this meta provider, it is used to map the create function when create is called.
164  
165 =cut
166  
167 =head2 build_fields
168
169 An Hash Reference of fields that are attached to the selected card:
170  
171 =cut
172  
173 =head2 create_summary
174  
175 Generate Twitter Summary meta data
176  
177 =cut
178  
179 =head2 create_summary_large_image
180  
181 Generate Twitter Summary Large Image Video meta data
182  
183 =cut
184  
185 =head2 create_app
186  
187 Generate Twitter App meta data
188  
189 =cut
190  
191 =head2 create_player
192  
193 Generate Twitter Player meta data
194  
195 =cut
196  
197 =head1 AUTHOR
198  
199 Robert Acock <ThisUsedToBeAnEmail@gmail.com>
200 Robert Haliday <robh@cpan.org>
201  
202 =head1 TODO
203
204 =head1 BUGS AND LIMITATIONS
205
206 Most probably. Please report any bugs at http://rt.cpan.org/.
207  
208 =head1 INCOMPATIBILITIES
209  
210 =head1 DEPENDENCIES
211  
212 =head1 CONFIGURATION AND ENVIRONMENT
213  
214 =head1 DIAGNOSTICS
215
216 =head1 LICENSE AND COPYRIGHT
217
218 Copyright 2015 Robert Acock.
219
220 This program is free software; you can redistribute it and/or modify it
221 under the terms of the the Artistic License (2.0). You may obtain a
222 copy of the full license at:
223
224 L<http://www.perlfoundation.org/artistic_license_2_0>
225
226 Any use, modification, and distribution of the Standard or Modified
227 Versions is governed by this Artistic License. By using, modifying or
228 distributing the Package, you accept this license. Do not use, modify,
229 or distribute the Package, if you do not accept this license.
230
231 If your Modified Version has been derived from a Modified Version made
232 by someone other than you, you are nevertheless required to ensure that
233 your Modified Version complies with the requirements of this license.
234
235 This license does not grant you the right to use any trademark, service
236 mark, tradename, or logo of the Copyright Holder.
237
238 This license includes the non-exclusive, worldwide, free-of-charge
239 patent license to make, have made, use, offer to sell, sell, import and
240 otherwise transfer the Package with respect to any patent claims
241 licensable by the Copyright Holder that are necessarily infringed by the
242 Package. If you institute patent litigation (including a cross-claim or
243 counterclaim) against any party alleging that the Package constitutes
244 direct or contributory patent infringement, then this Artistic License
245 to you shall terminate on the date that such litigation is filed.
246
247 Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
248 AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
249 THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
250 PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
251 YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
252 CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
253 CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
254 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
255  
256  
257  
↑ Summary SocialMeta/Base.pm »