631b516241605b57b1610a5c215d3d8f34196b3a
[irspy-moved-to-github.git] / lib / ZOOM / IRSpy / Stats.pm
1 # $Id: Stats.pm,v 1.1 2006-12-14 17:34:57 mike Exp $
2
3 package ZOOM::IRSpy::Stats;
4
5 use 5.008;
6 use strict;
7 use warnings;
8
9 =head1 NAME
10
11 ZOOM::IRSpy::Stats - statistics generated for IRSpy about its targets
12
13 =head1 SYNOPSIS
14
15  $stats = new ZOOM::IRSpy::Stats($dbname);
16  use Data::Dumper; print Dumper($stats);
17
18 =head1 DESCRIPTION
19
20 Provides a simple API to obtaining statistics about targets registered
21 in IRSpy.  This is done just by creating a Stats object.  Once this
22 object is made, it can be crudely dumped, or the application can walk
23 the structure to produce nice output.
24
25 =head1 METHODS
26
27 =head2 new()
28
29  $stats = new ZOOM::IRSpy::Stats($dbname, "dc.creator=wedel");
30  # Or:
31  $stats = new ZOOM::IRSpy::Stats($dbname,
32          new ZOOM::Query::PQF('@attr 1=1003 wedel');
33  # Or:
34  $spy = new ZOOM::IRSpy("target/string/for/irspy/database"); 
35  $stats = new ZOOM::IRSpy::Stats($spy, $query);
36
37 Creates a new C<ZOOM::IRSpy::Stats> object and populates it with
38 statistics for the targets in the nominated database.  This process
39 involves analysing the nominated IRSpy database at some length, and
40 which therefore takes some time
41
42 Either one or two arguments are required:
43
44 =over 4
45
46 =item $irspy (mandatory)
47
48 An indication of the IRSpy database that statistics are required for.
49 This may be in the form of a C<ZOOM::IRSpy> object or a database-name
50 string such as C<localhost:3313/IR-Explain---1>.
51
52 =item $query (optional)
53
54 The query with which to select a subset of the database to be
55 analysed.  This may be in the form of a C<ZOOM::Query> object (using
56 any of the supported subclasses) or a CQL string.  If this is omitted,
57 then all records in the database are included in the generated
58 statistics.
59
60 =back
61
62 =cut
63
64 sub new {
65     my $class = shift();
66     my($irspy, $query) = @_;
67
68     return bless {
69         irspy => $irspy,
70         query => $query || "cql.allRecords=1",
71     }, $class;
72 }
73
74
75 =head1 SEE ALSO
76
77 ZOOM::IRSpy
78
79 =head1 AUTHOR
80
81 Mike Taylor, E<lt>mike@indexdata.comE<gt>
82
83 =head1 COPYRIGHT AND LICENSE
84
85 Copyright (C) 2006 by Index Data ApS.
86
87 This library is free software; you can redistribute it and/or modify
88 it under the same terms as Perl itself, either Perl version 5.8.7 or,
89 at your option, any later version of Perl 5 you may have available.
90
91 =cut
92
93 1;