| 1 | package Purple; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 4 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 4 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 4 | our $VERSION = '1.4'; | |||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 4 | my $DEFAULT_TYPE = 'SQLite'; | |||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | # XXX these are not what they look like | ||||||||||||||||||||
| 11 | # make this an explicit factory | ||||||||||||||||||||
| 12 | 3 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||
| 13 | 3 | my $class = shift; | |||||||||||||||||||
| 14 | 3 | my %p = @_; | |||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 3 | ▶ | $p{type} ||= $DEFAULT_TYPE; | ||||||||||||||||||
|
Condition66%2/3
$p{"type"} ||= $DEFAULT_TYPE
MC/DC0%0/2
$p{"type"} ||= $DEFAULT_TYPE
$p{"type"}
$DEFAULT_TYPE
Truth table66%2/3
A ||= B
A= $p{"type"}B= $DEFAULT_TYPE
| |||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | 3 | my $real_class = 'Purple::' . $p{type}; | |||||||||||||||||||
| 19 | 3 | ▶ | unless ( $real_class->can('_New') ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 20 | 2 | eval "require $real_class"; | |||||||||||||||||||
| 21 | 2 | ▶ | die "Unable to load $real_class: $@" if $@; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 22 | } | ||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | # store is a directory | ||||||||||||||||||||
| 25 | 2 | return $real_class->_New(store => $p{store}); | |||||||||||||||||||
| 26 | } | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | =head1 NAME | ||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | Purple - Distributed granular addresses on the web | ||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | =head1 VERSION | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | Version 1.4 | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | =head1 SYNOPSIS | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | Factory class for generating purple numbers. | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | use Purple; | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | my $p = Purple->new; # by default, uses SQLite backend | ||||||||||||||||||||
| 43 | ... | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | =head1 METHODS | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | =head2 new(%options) | ||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | You can specify a different backend by passing: | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | type => 'backend' | ||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | where 'backend' is the name of the backend. If you don't pass any | ||||||||||||||||||||
| 54 | parameters, uses SQLite by default. | ||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | =head1 AUTHOR | ||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | Chris Dent, E<lt>cdent@burningchrome.comE<gt> | ||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | Eugene Eric Kim, E<lt>eekim@blueoxen.comE<gt> | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | =head1 BUGS | ||||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | Please report any bugs or feature requests to | ||||||||||||||||||||
| 65 | C<bug-purple@rt.cpan.org>, or through the web interface at | ||||||||||||||||||||
| 66 | L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Purple>. | ||||||||||||||||||||
| 67 | I will be notified, and then you'll automatically be notified of progress on | ||||||||||||||||||||
| 68 | your bug as I make changes. | ||||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | =head1 COPYRIGHT & LICENSE | ||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | (C) Copyright 2006 Blue Oxen Associates. All rights reserved. | ||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||
| 75 | under the same terms as Perl itself. | ||||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | =cut | ||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | 4 | 1; # End of Purple | |||||||||||||||||||