| 1 | package Store::Digest; | ||||||||||||
| 2 | |||||||||||||
| 3 | 1 | ▶ | use 5.010; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 1 | ▶ | use warnings FATAL => 'all'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | |||||||||||||
| 7 | 1 | ▶ | use Moose; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 1 | ▶ | use namespace::autoclean; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | |||||||||||||
| 10 | # actually this doesn't do what i wanted | ||||||||||||
| 11 | #use Module::Pluggable search_path => __PACKAGE__ . '::Driver'; | ||||||||||||
| 12 | |||||||||||||
| 13 | # MooseX::Object::Pluggable maybe? | ||||||||||||
| 14 | |||||||||||||
| 15 | # nope, this! | ||||||||||||
| 16 | 1 | ▶ | use String::RewritePrefix (); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 17 | 1 | ▶ | use Class::Load (); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 18 | |||||||||||||
| 19 | =head1 NAME | ||||||||||||
| 20 | |||||||||||||
| 21 | Store::Digest - Store opaque data objects keyed on their cryptographic digests | ||||||||||||
| 22 | |||||||||||||
| 23 | =head1 VERSION | ||||||||||||
| 24 | |||||||||||||
| 25 | Version 0.06 | ||||||||||||
| 26 | |||||||||||||
| 27 | =cut | ||||||||||||
| 28 | |||||||||||||
| 29 | 1 | our $VERSION = '0.06'; | |||||||||||
| 30 | |||||||||||||
| 31 | 1 | has _driver => ( | |||||||||||
| 32 | is => 'rw', | ||||||||||||
| 33 | does => 'Store::Digest::Driver', | ||||||||||||
| 34 | handles => 'Store::Digest::Driver', | ||||||||||||
| 35 | ); | ||||||||||||
| 36 | |||||||||||||
| 37 | =head1 SYNOPSIS | ||||||||||||
| 38 | |||||||||||||
| 39 | use Store::Digest; | ||||||||||||
| 40 | |||||||||||||
| 41 | # initialize the store | ||||||||||||
| 42 | |||||||||||||
| 43 | my $store = Store::Digest->new( | ||||||||||||
| 44 | driver => 'FileSystem', | ||||||||||||
| 45 | # all other options pass through to the driver | ||||||||||||
| 46 | dir => '/var/db/store-digest', | ||||||||||||
| 47 | ); | ||||||||||||
| 48 | |||||||||||||
| 49 | # add an object | ||||||||||||
| 50 | |||||||||||||
| 51 | my $obj = $store->add( | ||||||||||||
| 52 | content => $fh, | ||||||||||||
| 53 | language => 'en', | ||||||||||||
| 54 | mtime => DateTime->now, | ||||||||||||
| 55 | ); | ||||||||||||
| 56 | |||||||||||||
| 57 | # if you want to get the object back | ||||||||||||
| 58 | |||||||||||||
| 59 | my $str = 'ni:///sha-256;IcnxQtEMlihv1wFHTMjkMprLO-9-ZXZD2lcsQLmQ1xA'; | ||||||||||||
| 60 | my $uri = URI->new($str); | ||||||||||||
| 61 | my $obj = $store->get($uri); | ||||||||||||
| 62 | |||||||||||||
| 63 | =head1 METHODS | ||||||||||||
| 64 | |||||||||||||
| 65 | This module will eventually act as a unifying interface for multiple | ||||||||||||
| 66 | storage drivers, but there is currently only one implemented: | ||||||||||||
| 67 | L<Store::Digest::Driver::FileSystem>. Go see that. | ||||||||||||
| 68 | |||||||||||||
| 69 | =over 4 | ||||||||||||
| 70 | |||||||||||||
| 71 | B<Note to users prior to this version> (all two of you): The | ||||||||||||
| 72 | C<control> database that contains the store-wide metadata was for some | ||||||||||||
| 73 | stupid reason a L<BerkeleyDB::Hash>, and I have changed it to be a | ||||||||||||
| 74 | L<BerkeleyDB::Btree>. I have included a conversion routine in the | ||||||||||||
| 75 | driver which I<should> do the job transparently, but since it deletes | ||||||||||||
| 76 | the old control database, you may run into trouble if you don't shut | ||||||||||||
| 77 | down all processes attached to this database before upgrading. | ||||||||||||
| 78 | |||||||||||||
| 79 | =back | ||||||||||||
| 80 | |||||||||||||
| 81 | =cut | ||||||||||||
| 82 | |||||||||||||
| 83 | 0 | ▶ | sub BUILD { | ||||||||||
|
Subroutine
BUILD: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||
| 84 | 0 | my ($self, $p) = @_; | |||||||||||
| 85 | |||||||||||||
| 86 | 0 | ▶ | my $driver = delete $p->{driver} || 'FileSystem'; | ||||||||||
|
Condition0%0/2
delete $p->{'driver'} || 'FileSystem'
MC/DC0%0/1
delete $p->{'driver'} || 'FileSystem'
delete $p->{'driver'}
Truth table0%0/2
A
A= delete $p->{'driver'}
| |||||||||||||
| 87 | 0 | ($driver) = String::RewritePrefix->rewrite( | |||||||||||
| 88 | { '' => 'Store::Digest::Driver::', '+' => '' }, $driver); | ||||||||||||
| 89 | |||||||||||||
| 90 | 0 | Class::Load::load_class($driver); | |||||||||||
| 91 | 0 | $self->_driver($driver->new(%$p)); | |||||||||||
| 92 | } | ||||||||||||
| 93 | |||||||||||||
| 94 | =head1 SEE ALSO | ||||||||||||
| 95 | |||||||||||||
| 96 | =over 4 | ||||||||||||
| 97 | |||||||||||||
| 98 | =item | ||||||||||||
| 99 | |||||||||||||
| 100 | L<Store::Digest::Driver::FileSystem> | ||||||||||||
| 101 | |||||||||||||
| 102 | =item | ||||||||||||
| 103 | |||||||||||||
| 104 | L<Store::Digest::Object> | ||||||||||||
| 105 | |||||||||||||
| 106 | =item | ||||||||||||
| 107 | |||||||||||||
| 108 | L<URI::ni> | ||||||||||||
| 109 | |||||||||||||
| 110 | =item | ||||||||||||
| 111 | |||||||||||||
| 112 | L<https://tools.ietf.org/html/rfc6920> | ||||||||||||
| 113 | |||||||||||||
| 114 | =back | ||||||||||||
| 115 | |||||||||||||
| 116 | =cut | ||||||||||||
| 117 | |||||||||||||
| 118 | =head1 AUTHOR | ||||||||||||
| 119 | |||||||||||||
| 120 | Dorian Taylor, C<E<lt>dorian at cpan.orgE<gt>> | ||||||||||||
| 121 | |||||||||||||
| 122 | =head1 BUGS | ||||||||||||
| 123 | |||||||||||||
| 124 | Please report any issues to | ||||||||||||
| 125 | L<https://github.com/doriantaylor/p5-store-digest/issues>. | ||||||||||||
| 126 | |||||||||||||
| 127 | =head1 SUPPORT | ||||||||||||
| 128 | |||||||||||||
| 129 | You can find documentation for this module with the perldoc command. | ||||||||||||
| 130 | |||||||||||||
| 131 | perldoc Store::Digest | ||||||||||||
| 132 | |||||||||||||
| 133 | You can also look for information at: | ||||||||||||
| 134 | |||||||||||||
| 135 | =over 4 | ||||||||||||
| 136 | |||||||||||||
| 137 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||||
| 138 | |||||||||||||
| 139 | L<http://annocpan.org/dist/Store-Digest> | ||||||||||||
| 140 | |||||||||||||
| 141 | =item * CPAN Ratings | ||||||||||||
| 142 | |||||||||||||
| 143 | L<http://cpanratings.perl.org/d/Store-Digest> | ||||||||||||
| 144 | |||||||||||||
| 145 | =item * Search CPAN | ||||||||||||
| 146 | |||||||||||||
| 147 | L<http://search.cpan.org/dist/Store-Digest/> | ||||||||||||
| 148 | |||||||||||||
| 149 | =back | ||||||||||||
| 150 | |||||||||||||
| 151 | =head1 LICENSE AND COPYRIGHT | ||||||||||||
| 152 | |||||||||||||
| 153 | Copyright 2012-2018 Dorian Taylor. | ||||||||||||
| 154 | |||||||||||||
| 155 | Licensed under the Apache License, Version 2.0 (the "License"); you | ||||||||||||
| 156 | may not use this file except in compliance with the License. You may | ||||||||||||
| 157 | obtain a copy of the License at | ||||||||||||
| 158 | L<http://www.apache.org/licenses/LICENSE-2.0>. | ||||||||||||
| 159 | |||||||||||||
| 160 | Unless required by applicable law or agreed to in writing, software | ||||||||||||
| 161 | distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||||
| 162 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||||||||||||
| 163 | implied. See the License for the specific language governing | ||||||||||||
| 164 | permissions and limitations under the License. | ||||||||||||
| 165 | |||||||||||||
| 166 | =cut | ||||||||||||
| 167 | |||||||||||||
| 168 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||||
| 169 | |||||||||||||
| 170 | 1 | 1; # End of Store::Digest | |||||||||||