DE.pm

filter: Statementstmt 53.4% 23 / 43 Branchbran 50.0% 1 / 2 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 53.8% 7 / 13 Podpod 100% 1 / 1 totaltotal 53.2% 33 / 62 CC 3 SCAR 6.3
CC
3
Cov
53%
_native_setup_search
3.4
_result_count_element_specs_NOT_NEEDED
2.0
_result_count_pattern
2.0
CRAP 1.9
« Europe.pm ↑ Summary FR.pm »
1  
2 package WWW::Search::Ebay::DE;
3  
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 our
8 1 $VERSION = 2.105;
9  
10 =head1 NAME
11  
12 WWW::Search::Ebay::DE - backend for searching auctions at www.ebay.de
13  
14 =head1 SYNOPSIS
15  
16 use WWW::Search;
17 my $oSearch = new WWW::Search('Ebay::DE');
18 my $sQuery = WWW::Search::escape_query("Yakface");
19 $oSearch->native_query($sQuery);
20 while (my $oResult = $oSearch->next_result())
21 { print $oResult->url, "\n"; }
22  
23 =head1 DESCRIPTION
24  
25 Acts just like WWW::Search::Ebay.
26  
27 =head1 AUTHOR
28  
29 Martin 'Kingpin' Thurn, C<mthurn at cpan.org>, L<http://tinyurl.com/nn67z>.
30  
31 =cut
32  
33 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
34 1 ▶use base 'WWW::Search::Ebay';
Subroutine BEGIN: called CC=1 SCAR=0.0
35 # We need the version that allows shipping to be "unknown":
36 1 ▶use WWW::Search::Ebay 2.273;
Subroutine BEGIN: called CC=1 SCAR=0.0
37  
38 sub _native_setup_search
39 2 ▶ {
Subroutine _native_setup_search: called CC=3 SCAR=12.3
40 2 my ($self, $native_query, $rhOptsArg) = @_;
41 2 ▶ $rhOptsArg ||= {};
Condition50%1/2
$rhOptsArg ||= {}
l!l
20
MC/DC0%0/1
$rhOptsArg ||= {}
$rhOptsArg
Truth table50%1/2
A
A= $rhOptsArg
Aresult
11
00
42 2 ▶ unless (ref($rhOptsArg) eq 'HASH')
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $rhOptsArg eq "HASH") 0 2 2
43 {
44 0 carp " --- second argument to _native_setup_search should be hashref";
45 0 return undef;
46 } # unless
47 2 $self->{search_host} = 'http://www.ebay.de';
48 2 return $self->SUPER::_native_setup_search($native_query, $rhOptsArg);
49 } # _native_setup_search
50  
51 # This is what we look_down for to find the HTML element that contains
52 # the result count:
53 sub _result_count_element_specs_NOT_NEEDED
54 0 ▶ {
Subroutine _result_count_element_specs_NOT_NEEDED: not called CC=1 SCAR=6.9
55 return (
56 0 '_tag' => 'p',
57 class => 'count'
58 );
59 } # _result_count_element_specs
60  
61  
62 sub _result_count_pattern
63 0 ▶ {
Subroutine _result_count_pattern: not called CC=1 SCAR=6.9
64 0 return qr'(\d+)\s+(?:Artikel|Ergebnis(?:se)?|Angebote)'i;
65 } # _result_count_pattern
66  
67 sub _next_text
68 0 ▶ {
Subroutine _next_text: not called CC=1 SCAR=6.9
69 # The text of the "Next" button, localized:
70 0 return 'Weiter';
71 } # _next_text
72  
73 sub _currency_pattern
74 1 ▶ {
Subroutine _currency_pattern: called CC=1 SCAR=0.0
75 # A pattern to match all possible currencies found in eBay listings
76 # (if one character looks weird, it's really a British Pound symbol
77 # but Emacs shows it wrong):
78 1 return qr{(?:US\s?\$|£|EUR)}; # } } # Emacs indentation bugfix
79 } # _currency_pattern
80  
81 =head2 preprocess_results_page
82  
83 Tweak the HTML to make it easy to parse
84  
85 =cut
86  
87 sub preprocess_results_page
88 0 ▶ {
Subroutine preprocess_results_page: not called CC=1 SCAR=6.9
Pod documented
89 0 my $self = shift;
90 0 my $sPage = shift;
91 # Make it easy to parse the shipping portion of the list:
92 0 $sPage =~ s!(<span\s(class="ship[^"]*")>)!</td><td $2>$1!g;
93 # Clean up "no shipping info":
94 0 $sPage =~ s/\s*Keine Angaben zum Versand\s*/UNKNOWN/g;
95 # print STDERR $sPage;
96 0 return $self->SUPER::preprocess_results_page($sPage);
97 # print STDERR Dumper($self->{response});
98 # For debugging:
99 0 print STDERR $sPage;
100 0 exit 88;
101 } # _preprocess_results_page
102  
103 sub _columns
104 0 ▶ {
Subroutine _columns: not called CC=1 SCAR=6.9
105 0 my $self = shift;
106 # This is for DE:
107 0 return qw( paypal bids price shipping enddate );
108 } # _columns
109  
110 sub _process_date_abbrevs
111 0 ▶ {
Subroutine _process_date_abbrevs: not called CC=1 SCAR=6.9
112 0 my $self = shift;
113 0 my $s = shift;
114 # Convert German abbreviations for units of time to something
115 # Date::Manip can parse (namely, English words):
116 0 $s =~ s!(\d)T!$1 days!;
117 0 $s =~ s!(\d)Std\.?!$1 hours!;
118 0 $s =~ s!(\d)Min\.?!$1 minutes!;
119 0 return $s;
120 } # _process_date_abbrevs
121  
122  
123 1 1;
124  
125 __END__
« Europe.pm ↑ Summary FR.pm »