Plagger/Plugin/Subscription/Bookmarks.pm untested

filter: Statementstmt 0.0% 0 / 34 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 72 CC 7 SCAR 34.4
CC
7
Cov
0%
auto_configure
56.0
init
2.0
register
2.0
CRAP 31.1
1 package Plagger::Plugin::Subscription::Bookmarks;
2 use strict;
3 use base qw( Plagger::Plugin );
4
5 use UNIVERSAL::require;
6
7 sub init {
8 my $self = shift;
9 $self->SUPER::init(@_);
10
11 my $browser = $self->conf->{browser} || $self->auto_configure;
12 my $class = __PACKAGE__ . "::$browser";
13 $class->require or Plagger->context->error("Error loading $class: $@");
14
15 bless $self, $class;
16 }
17
18 sub auto_configure {
19 my $self = shift;
20
21 my $path = $self->conf->{path};
22 if ($path) {
23 if (-d _ && $^O eq 'MSWin32') {
24 Plagger->context->log(debug => "$path is a directory. read as IE");
25 return "InternetExplorer";
26 } elsif ($path =~ /bookmarks\.html$/i) {
27 Plagger->context->log(debug => "$path is a Mozilla bookmarks");
28 return "Mozilla";
29 } elsif ($path =~ /Bookmarks\.plist$/) {
30 Plagger->context->log(debug => "$path is a Safari bookmarks");
31 return "Safari";
32 } else {
33 Plagger->context->error("Don't know Bookmark type of $path");
34 }
35 }
36
37 # Hmm, no clue for path. Find it automatically ... only works for IE
38 if ($^O eq 'MSWin32') {
39 return "InternetExplorer";
40 } elsif ($^O eq 'darwin') {
41 return "Safari"; # xxx
42 } else {
43 return "Mozilla"; # xxx don't work because path is missing
44 }
45 }
46
47 sub register {
48 my($self, $context) = @_;
49 $context->register_hook(
50 $self,
51 'subscription.load' => $self->can('load'),
52 );
53 }
54
55 sub load { die "Override load" }
56
57 1;
58
59 __END__