File Coverage

blib/lib/TM/Materialized/Stream.pm
Criterion Covered Total %
statement 13 13 100.0
branch 5 6 83.3
condition 1 2 50.0
subroutine 3 3 100.0
pod 0 1 0.0
total 22 25 88.0


line stmt bran cond sub pod time code
1             package TM::Materialized::Stream;
2              
3 12     12   16225 use TM;
  12         37  
  12         790  
4 12     12   108 use base qw(TM);
  12         20  
  12         3415  
5              
6             =pod
7              
8             =head1 NAME
9              
10             TM::Materialized::Stream - Topic Maps, abstract class for maps with stream based input/output drivers
11              
12             =head1 SYNOPSIS
13              
14             # this class will never be directly used for instantiation
15             # see the description in TM and individual low-level drivers (AsTMa, ...)
16              
17             =head1 DESCRIPTION
18              
19             This class is a subclass of L, so it implements map objects. It is abstract, though, as it only
20             defined how a stream-based driver package should behave. It may thus be inherited by classes which
21             implement external formats (L, L, ....).
22              
23             =head1 INTERFACE
24              
25             =head2 Constructor
26              
27             The constructor of implementations should expect a hash as parameter containing the field(s) from
28             L and one or more of the following:
29              
30             =over
31              
32             =item I:
33              
34             If given, then the instance will be read from this url whenever synced in.
35              
36             =item I:
37              
38             If given, then the data will be read/written from/to this file. This is just a convenience as it
39             will be mapped to I.
40              
41             =item I:
42              
43             If given, then the instance will be read directly from this text provided inline when synced.
44              
45             =back
46              
47             If several fields (C, C, C) are specified, it is undefined which one will be
48             taken.
49              
50             Examples (using AsTMa):
51              
52             # opening from an AsTMa= file
53             $atm = new TM::Materialized::AsTMa (file => 'here.atm');
54              
55             # why need a file? files are evil, anyway
56             $atm = new TM::Materialized::AsTMa (inline => '# this is AsTMa');
57              
58             =cut
59              
60             sub new {
61 4     4 0 6400 my $class = shift;
62 4         43 my %options = @_;
63              
64 4 100       24 my $url = 'inline:'.delete $options{inline} if $options{inline};
65 4 50       15 $url = 'file:'. delete $options{file} if $options{file};
66 4 100       14 $url = delete $options{url} if $options{url};
67 4   50     13 $url ||= 'null:'; # default
68              
69 4         32 return bless $class->SUPER::new (%options, url => $url), $class;
70             }
71              
72             =pod
73              
74             =head1 SEE ALSO
75              
76             L
77              
78             =head1 AUTHOR INFORMATION
79              
80             Copyright 200[2-6], Robert Barta , All rights reserved.
81              
82             This library is free software; you can redistribute it and/or modify
83             it under the same terms as Perl itself.
84             http://www.perl.com/perl/misc/Artistic.html
85              
86             =cut
87              
88             our $VERSION = 0.10;
89             our $REVISION = '$Id: Stream.pm,v 1.2 2006/11/13 08:02:34 rho Exp $';
90              
91             1;
92              
93             __END__