blib/lib/CPAN/Testers/Metabase/AWS.pm

filter: Statementstmt 97.7% 44 / 45 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 92.8% 13 / 14 Podpod n/a totaltotal 96.6% 57 / 59 CC 1 SCAR 0.7
CC
1
Cov
98%
_build_fact_classes
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
↑ Summary
1 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package CPAN::Testers::Metabase::AWS;
4 # ABSTRACT: Metabase backend on Amazon Web Services
5 2 our $VERSION = '1.999002'; # VERSION
6  
7 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Metabase::Archive::S3 1.000;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Metabase::Index::SimpleDB 1.000;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Metabase::Librarian 1.000;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Net::Amazon::Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 2 with 'Metabase::Gateway';
15  
16 2 has 'bucket' => (
17 is => 'ro',
18 isa => 'Str',
19 required => 1,
20 );
21  
22 2 has 'namespace' => (
23 is => 'ro',
24 isa => 'Str',
25 required => 1,
26 );
27  
28 has 'amazon_config' => (
29 is => 'ro',
30 isa => 'Net::Amazon::Config',
31 1 ▶ default => sub { return Net::Amazon::Config->new },
Subroutine __ANON__: called CC=1 SCAR=0.0
32 2 );
33  
34 2 has 'profile_name' => (
35 is => 'ro',
36 isa => 'Str',
37 default => 'cpantesters'
38 );
39  
40 2 has '_profile' => (
41 is => 'ro',
42 isa => 'Net::Amazon::Config::Profile',
43 lazy => 1,
44 builder => '_build__profile',
45 handles => [ qw/access_key_id secret_access_key/ ],
46 );
47  
48 1 ▶sub _build__profile {
Subroutine _build__profile: called CC=1 SCAR=0.0
49 1 my $self = shift;
50 1 return $self->amazon_config->get_profile( $self->profile_name );
51 }
52  
53 0 ▶sub _build_fact_classes { return [qw/CPAN::Testers::Report/] }
Subroutine _build_fact_classes: not called CC=1 SCAR=6.9
54  
55 1 ▶sub _build_public_librarian { return $_[0]->__build_librarian("public") }
Subroutine _build_public_librarian: called CC=1 SCAR=0.0
56  
57 1 ▶sub _build_private_librarian { return $_[0]->__build_librarian("private") }
Subroutine _build_private_librarian: called CC=1 SCAR=0.0
58  
59 2 ▶sub __build_librarian {
Subroutine __build_librarian: called CC=1 SCAR=0.0
60 2 my ($self, $subspace) = @_;
61  
62 2 my $bucket = $self->bucket;
63 2 my $namespace = $self->namespace;
64 2 my $s3_prefix = "metabase/${namespace}/${subspace}/";
65 2 my $sdb_domain = "${bucket}.metabase.${namespace}.${subspace}";
66  
67 2 return Metabase::Librarian->new(
68 archive => Metabase::Archive::S3->new(
69 access_key_id => $self->access_key_id,
70 secret_access_key => $self->secret_access_key,
71 bucket => $self->bucket,
72 prefix => $s3_prefix,
73 compressed => 1,
74 retry => 1,
75 ),
76 index => Metabase::Index::SimpleDB->new(
77 access_key_id => $self->access_key_id,
78 secret_access_key => $self->secret_access_key,
79 domain => $sdb_domain,
80 ),
81 );
82 }
83  
84 2 __PACKAGE__->meta->make_immutable;
85 2 1;
86  
87  
88  
89 =pod
90  
91 =head1 NAME
92  
93 CPAN::Testers::Metabase::AWS - Metabase backend on Amazon Web Services
94  
95 =head1 VERSION
96  
97 version 1.999002
98  
99 =head1 SYNOPSIS
100  
101 =head2 Direct usage
102  
103 use CPAN::Testers::Metabase::AWS;
104
105 my $mb = CPAN::Testers::Metabase::AWS->new(
106 bucket => 'myS3bucket',
107 namespace => 'prod'
108 );
109
110 $mb->public_librarian->search( %search spec );
111 ...
112  
113 =head2 Metabase::Web config
114  
115 ---
116 Model::Metabase:
117 class: CPAN::Testers::Metabase::AWS
118 args:
119 bucket: myS3bucket
120 namespace: prod
121  
122 =head1 DESCRIPTION
123  
124 This class instantiates a Metabase backend on the S3 and SimpleDB Amazon
125 Web Services (AWS). It uses L<Net::Amazon::Config> to provide user credentials
126 and the L<Metabase::Gateway> Role to provide actual functionality. As such,
127 it is mostly glue to get the right credentials to setup AWS clients and provide
128 them with standard resource names.
129  
130 For example, given the C<<< bucket >>> "example" and the C<<< namespace >>> "alpha",
131 the following resource names would be used:
132  
133 Public S3: http://example.s3.amazonaws.com/metabase/alpha/public/*
134 Public SDB domain: example.metabase.alpha.public
135
136 Private S3: http://example.s3.amazonaws.com/metabase/alpha/private/*
137 Private SDB domain: example.metabase.alpha.private
138  
139 =head1 USAGE
140  
141 =head2 new
142  
143 my $mb = CPAN::Testers::Metabase::AWS->new(
144 bucket => 'myS3bucket',
145 namespace => 'prod',
146 profile_name => 'cpantesters',
147 );
148  
149 Arguments for C<<< new >>>:
150  
151 =over
152  
153 =item *
154  
155 C<<< bucket >>> -- required -- the Amazon S3 bucket name to hold both public and private
156 fact content. Bucket names must be unique across all of AWS. The bucket
157 name is also used as part of the SimpleDB namespace for consistency.
158  
159 =item *
160  
161 C<<< namespace >>> -- required -- a short phrase that uniquely identifies this
162 metabase. E.g. "dev", "test" or "prod". It is used to specify
163 specific locations within the S3 bucket and to uniquely identify a SimpleDB
164 domain for indexing.
165  
166 =item *
167  
168 C<<< amazon_config >>> -- optional -- a L<Net::Amazon::Config> object containing
169 Amazon Web Service credentials. If not provided, one will be created using
170 the default location for the config file.
171  
172 =item *
173  
174 C<<< profile_name >>> -- optional -- the name of a profile for use with
175 Net::Amazon::Config. If not provided, it defaults to 'cpantesters'.
176  
177 =back
178  
179 =head2 access_key_id
180  
181 Returns the AWS Access Key ID.
182  
183 =head2 secret_access_key
184  
185 Returns the AWS Secret Access Key
186  
187 =head2 Metabase::Gateway Role
188  
189 This class does the L<Metabase::Gateway> role, including the following
190 methods:
191  
192 =over
193  
194 =item *
195  
196 C<<< handle_submission >>>
197  
198 =item *
199  
200 C<<< handle_registration >>>
201  
202 =item *
203  
204 C<<< enqueue >>>
205  
206 =back
207  
208 see L<Metabase::Gateway> for more.
209  
210 =head1 SEE ALSO
211  
212 =over
213  
214 =item *
215  
216 L<CPAN::Testers::Metabase>
217  
218 =item *
219  
220 L<Metabase::Gateway>
221  
222 =item *
223  
224 L<Metabase::Web>
225  
226 =item *
227  
228 L<Net::Amazon::Config>
229  
230 =back
231  
232 =for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan
233  
234 =head1 SUPPORT
235  
236 =head2 Bugs / Feature Requests
237  
238 Please report any bugs or feature requests through the issue tracker
239 at L<http://rt.cpan.org/Public/Dist/Display.html?Name=CPAN-Testers-Metabase-AWS>.
240 You will be notified automatically of any progress on your issue.
241  
242 =head2 Source Code
243  
244 This is open source software. The code repository is available for
245 public review and contribution under the terms of the license.
246  
247 L<https://github.com/dagolden/cpan-testers-metabase-aws>
248  
249 git clone https://github.com/dagolden/cpan-testers-metabase-aws.git
250  
251 =head1 AUTHOR
252  
253 David Golden <dagolden@cpan.org>
254  
255 =head1 COPYRIGHT AND LICENSE
256  
257 This software is Copyright (c) 2012 by David Golden.
258  
259 This is free software, licensed under:
260  
261 The Apache License, Version 2.0, January 2004
262  
263 =cut
264  
265  
266 __END__
↑ Summary