File Coverage

blib/lib/WWW/Google/CustomSearch/Item.pm
Criterion Covered Total %
statement 11 11 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 15 15 100.0


line stmt bran cond sub pod time code
1             package WWW::Google::CustomSearch::Item;
2              
3             $WWW::Google::CustomSearch::Item::VERSION = '0.37';
4             $WWW::Google::CustomSearch::Item::AUTHORITY = 'cpan:MANWAR';
5              
6             =head1 NAME
7              
8             WWW::Google::CustomSearch::Item - Placeholder for Google JSON/Atom Custom Search Item.
9              
10             =head1 VERSION
11              
12             Version 0.37
13              
14             =cut
15              
16 5     5   65 use 5.006;
  5         43  
17 5     5   39 use Data::Dumper;
  5         20  
  5         172  
18              
19 5     5   22 use Moo;
  5         9  
  5         45  
20 5     5   3425 use namespace::autoclean;
  5         6334  
  5         15  
21              
22             has [qw(kind link displayLink snippet htmlSnippet cacheId formattedUrl htmlFormattedUrl title htmlTitle)] => (is => 'ro');
23              
24             =head1 DESCRIPTION
25              
26             Provides the interface to the individual search page result items based on the
27             search criteria.
28              
29             =head1 METHODS
30              
31             =head2 kind()
32              
33             Returns the 'kind' attribute of the search.
34              
35             use strict; use warnings;
36             use WWW::Google::CustomSearch;
37              
38             my $api_key = 'Your_API_Key';
39             my $cx = 'Search_Engine_Identifier';
40             my $engine = WWW::Google::CustomSearch->new(api_key => $api_key, cx => $cx);
41             my $result = $engine->search("Google");
42             foreach my $item (@{$result->items}) {
43             print "Item Kind: ", $item->kind, "\n" if defined $item->kind;
44             }
45              
46             =head2 link()
47              
48             Returns the 'link' attribute of the search.
49              
50             use strict; use warnings;
51             use WWW::Google::CustomSearch;
52              
53             my $api_key = 'Your_API_Key';
54             my $cx = 'Search_Engine_Identifier';
55             my $engine = WWW::Google::CustomSearch->new(api_key => $api_key, cx => $cx);
56             my $result = $engine->search("Google");
57             foreach my $item (@{$result->items}) {
58             print "Item Link: ", $item->link, "\n" if defined $item->link;
59             }
60              
61             =head2 displayLink()
62              
63             Returns the 'displayLink' attribute of the search.
64              
65             use strict; use warnings;
66             use WWW::Google::CustomSearch;
67              
68             my $api_key = 'Your_API_Key';
69             my $cx = 'Search_Engine_Identifier';
70             my $engine = WWW::Google::CustomSearch->new(api_key => $api_key, cx => $cx);
71             my $result = $engine->search("Google");
72             foreach my $item (@{$result->items}) {
73             print "Item Display Link: ", $item->displayLink, "\n" if defined $item->displayLink;
74             }
75              
76             =head2 snippet()
77              
78             Returns the 'snippet' attribute of the search.
79              
80             use strict; use warnings;
81             use WWW::Google::CustomSearch;
82              
83             my $api_key = 'Your_API_Key';
84             my $cx = 'Search_Engine_Identifier';
85             my $engine = WWW::Google::CustomSearch->new(api_key => $api_key, cx => $cx);
86             my $result = $engine->search("Google");
87             foreach my $item (@{$result->items}) {
88             print "Item Snippet: ", $item->snippet, "\n" if defined $item->snippet;
89             }
90              
91             =head2 htmlSnippet()
92              
93             Returns the 'htmlSnippet' attribute of the search.
94              
95             use strict; use warnings;
96             use WWW::Google::CustomSearch;
97              
98             my $api_key = 'Your_API_Key';
99             my $cx = 'Search_Engine_Identifier';
100             my $engine = WWW::Google::CustomSearch->new(api_key => $api_key, cx => $cx);
101             my $result = $engine->search("Google");
102             foreach my $item (@{$result->items}) {
103             print "Item HTML Snippet: ", $item->htmlSnippet, "\n" if defined $item->htmlSnippet;
104             }
105              
106             =head2 cacheId()
107              
108             Returns the 'cacheId' attribute of the search.
109              
110             use strict; use warnings;
111             use WWW::Google::CustomSearch;
112              
113             my $api_key = 'Your_API_Key';
114             my $cx = 'Search_Engine_Identifier';
115             my $engine = WWW::Google::CustomSearch->new(api_key => $api_key, cx => $cx);
116             my $result = $engine->search("Google");
117             foreach my $item (@{$result->items}) {
118             print "Item Cache Id: ", $item->cacheId, "\n" if defined $item->cacheId;
119             }
120              
121             =head2 formattedUrl()
122              
123             Returns the 'formattedUrl' attribute of the search.
124              
125             use strict; use warnings;
126             use WWW::Google::CustomSearch;
127              
128             my $api_key = 'Your_API_Key';
129             my $cx = 'Search_Engine_Identifier';
130             my $engine = WWW::Google::CustomSearch->new(api_key => $api_key, cx => $cx);
131             my $result = $engine->search("Google");
132             foreach my $item (@{$result->items}) {
133             print "Item Formatted URL: ", $item->formattedUrl, "\n" if defined $item->formattedUrl;
134             }
135              
136             =head2 htmlFormattedUrl()
137              
138             Returns the 'htmlFormattedUrl' attribute of the search.
139              
140             use strict; use warnings;
141             use WWW::Google::CustomSearch;
142              
143             my $api_key = 'Your_API_Key';
144             my $cx = 'Search_Engine_Identifier';
145             my $engine = WWW::Google::CustomSearch->new(api_key => $api_key, cx => $cx);
146             my $result = $engine->search("Google");
147             foreach my $item (@{$result->items}) {
148             print "Item HTML Formatted URL: ", $item->htmlFormattedUrl, "\n" if defined $item->htmlFormattedUrl;
149             }
150              
151             =head2 title()
152              
153             Returns the 'title' attribute of the search.
154              
155             use strict; use warnings;
156             use WWW::Google::CustomSearch;
157              
158             my $api_key = 'Your_API_Key';
159             my $cx = 'Search_Engine_Identifier';
160             my $engine = WWW::Google::CustomSearch->new(api_key => $api_key, cx => $cx);
161             my $result = $engine->search("Google");
162             foreach my $item (@{$result->items}) {
163             print "Item Title: ", $item->title, "\n" if defined $item->title;
164             }
165              
166             =head2 htmlTitle()
167              
168             Returns the 'htmlTitle' attribute of the search.
169              
170             use strict; use warnings;
171             use WWW::Google::CustomSearch;
172              
173             my $api_key = 'Your_API_Key';
174             my $cx = 'Search_Engine_Identifier';
175             my $engine = WWW::Google::CustomSearch->new(api_key => $api_key, cx => $cx);
176             my $result = $engine->search("Google");
177             foreach my $item (@{$result->items}) {
178             print "Item HTML Title: ", $item->htmlTitle, "\n" if defined $item->htmlTitle;
179             }
180              
181             =head1 AUTHOR
182              
183             Mohammad S Anwar, C<< >>
184              
185             =head1 REPOSITORY
186              
187             L
188              
189             =head1 CONTRIBUTORS
190              
191             David Kitcher-Jones (m4ddav3)
192              
193             =head1 BUGS
194              
195             Please report any bugs or feature requests to C
196             rt.cpan.org>, or through the web interface at L.
197             I will be notified, and then you'll automatically be notified of progress on your
198             bug as I make changes.
199              
200             =head1 SUPPORT
201              
202             You can find documentation for this module with the perldoc command.
203              
204             perldoc WWW::Google::CustomSearch::Item
205              
206             You can also look for information at:
207              
208             =over 4
209              
210             =item * RT: CPAN's request tracker (report bugs here)
211              
212             L
213              
214             =item * AnnoCPAN: Annotated CPAN documentation
215              
216             L
217              
218             =item * CPAN Ratings
219              
220             L
221              
222             =item * Search CPAN
223              
224             L
225              
226             =back
227              
228             =head1 LICENSE AND COPYRIGHT
229              
230             Copyright (C) 2011 - 2015 Mohammad S Anwar.
231              
232             This program is free software; you can redistribute it and / or modify it under
233             the terms of the the Artistic License (2.0). You may obtain a copy of the full
234             license at:
235              
236             L
237              
238             Any use, modification, and distribution of the Standard or Modified Versions is
239             governed by this Artistic License.By using, modifying or distributing the Package,
240             you accept this license. Do not use, modify, or distribute the Package, if you do
241             not accept this license.
242              
243             If your Modified Version has been derived from a Modified Version made by someone
244             other than you,you are nevertheless required to ensure that your Modified Version
245             complies with the requirements of this license.
246              
247             This license does not grant you the right to use any trademark, service mark,
248             tradename, or logo of the Copyright Holder.
249              
250             This license includes the non-exclusive, worldwide, free-of-charge patent license
251             to make, have made, use, offer to sell, sell, import and otherwise transfer the
252             Package with respect to any patent claims licensable by the Copyright Holder that
253             are necessarily infringed by the Package. If you institute patent litigation
254             (including a cross-claim or counterclaim) against any party alleging that the
255             Package constitutes direct or contributory patent infringement,then this Artistic
256             License to you shall terminate on the date that such litigation is filed.
257              
258             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND
259             CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED
260             WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
261             NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS
262             REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT,
263             INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE
264             OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
265              
266             =cut
267              
268             1; # End of WWW::Google::CustomSearch::Item