File Coverage

blib/lib/Netscape/Bookmarks/Alias.pm
Criterion Covered Total %
statement 28 36 77.7
branch 0 2 0.0
condition n/a
subroutine 8 12 66.6
pod 8 8 100.0
total 44 58 75.8


line stmt bran cond sub pod time code
1             package Netscape::Bookmarks::Alias;
2              
3             =encoding utf8
4              
5             =head1 NAME
6              
7             Netscape::Bookmarks::Alias - object for an Alias in a Netscape Bookmarks file
8              
9             =head1 SYNOPSIS
10              
11             use Netscape::Bookmarks;
12             use Netscape::Bookmarks::Alias;
13              
14             my $bookmarks = Netscape::Bookmarks->new();
15              
16             my $alias = Netscape::Bookmarks::Alias->new();
17              
18             $bookmarks->add( $alias );
19             # ... and other Netscape::Bookmark::Category methods
20              
21             =head1 DESCRIPTION
22              
23             THIS IS AN ABANDONED MODULE. THERE IS NO SUPPORT. YOU CAN ADOPT IT
24             IF YOU LIKE: https://pause.perl.org/pause/query?ACTION=pause_04about#takeover
25              
26             This module provides an abstraction for an Alias object in a Netscape
27             Bookmarks file. An alias is simply a reference to another link in the
28             Bookmarks file, henceforth called the target. If you change the alias,
29             the target link also changes.
30              
31             =over 4
32              
33             =cut
34              
35 6     6   55511 use strict;
  6         11  
  6         182  
36              
37 6     6   27 use base qw( Netscape::Bookmarks::AcceptVisitor Netscape::Bookmarks::Isa );
  6         12  
  6         2051  
38 6     6   30 use subs qw();
  6         12  
  6         92  
39 6     6   25 use vars qw($VERSION $ERROR %aliases);
  6         8  
  6         1807  
40              
41             $VERSION = "2.304";
42              
43             =item $obj = Netscape::Bookmarks::Alias->new( ALIASID )
44              
45             Creates a new C object with the ALIASOF
46             attribute value of ALIASID. This object relies on a corresponding
47             C object with the same ALIASID, although
48             C does not check to see if that object exists (although it probably
49             should).
50              
51             =cut
52              
53             sub new {
54 2     2 1 5 my $class = shift;
55 2         5 my $param = shift;
56              
57 2         4 my $self = {};
58              
59 2         5 bless $self, $class;
60              
61 2         19 $self->{'alias_of'} = $param;
62              
63 2         7 $self;
64             }
65              
66             =item $obj->alias_of()
67              
68             Returns the alias key for this C object.
69              
70             =cut
71              
72             sub alias_of {
73 0     0 1 0 my $self = shift;
74              
75 0         0 return $self->{'alias_of'};
76             }
77              
78             =item $obj->target( ALIAS_KEY )
79              
80             Returns the target Link of the given alias key. The return value
81             is a C object if the target exists, or
82             C in scalar context or the empty list in list context if the
83             target does not exist. If you want to simply check to see if a
84             target exists, use C.
85              
86             =cut
87              
88             sub target {
89 1     1 1 2 my $self = shift;
90              
91 1         12 return $aliases{$self->{'alias_of'}};
92             }
93              
94             =item add_target( $link_obj, ALIAS_KEY )
95              
96             Adds a target link for the given ALIAS_KEY. You can add target
97             links before the Alias is created.
98              
99             =cut
100              
101             # this should really be in Link.pm right?
102             sub add_target {
103 2     2 1 5 my $target = shift; #link reference
104 2         5 my $alias_id = shift;
105              
106 2         10 $target->aliasid($alias_id);
107 2         6 $aliases{$alias_id} = $target;
108             }
109              
110             =item target_exists( TARGET_KEY )
111              
112             For the given target key returns TRUE or FALSE if the target
113             exists.
114              
115             =cut
116              
117             sub target_exists {
118 0     0 1 0 my $target = shift;
119              
120 0 0       0 exists $aliases{$target} ? 1 : 0;
121             }
122              
123             =item $obj->as_string()
124              
125             Returns a string representation on the alias. This is
126             almost identical from the representation of the link which
127             is aliases except that the ALIASID attribute is changed
128             to the ALIASOF attribute.
129              
130             =cut
131              
132             sub as_string {
133 1     1 1 4 my $self = shift;
134              
135 1         3 my $string = $self->target->as_string;
136              
137 1         5 $string =~ s/ALIASID/ALIASOF/;
138              
139 1         4 return $string;
140             }
141              
142             =item $obj->title()
143              
144             Returns the tile of the Alias.
145              
146             =cut
147              
148             sub title {
149 0     0 1   my $self = shift;
150              
151 0           return "Alias: " . $self->target->title;
152             }
153              
154             =item $obj->remove()
155              
156             Performs any clean up necessary to remove this object from the
157             Bookmarks tree. Although this method does not affect the Link object
158             which is its target, it probably should.
159              
160             =cut
161              
162             sub remove {
163 0     0 1   my $self = shift;
164              
165 0           return 1;
166             }
167              
168             "if you want to believe everything you read, so be it.";
169              
170             =back
171              
172             =head1 AUTHOR
173              
174             brian d foy C<< >>
175              
176             =head1 COPYRIGHT AND LICENSE
177              
178             Copyright © 2002-2019, brian d foy . All rights reserved.
179              
180             This program is free software; you can redistribute it and/or modify
181             it under the terms of the Artistic License 2.0.
182              
183             =head1 SEE ALSO
184              
185             L, L
186              
187             =cut
188              
189             __END__