DBIx/Class/Migration/RunScript/Trait/Populate.pm untested

filter: Statementstmt 0.0% 0 / 13 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 21 CC 2 SCAR 12.8
CC
2
Cov
0%
set_has_fixtures
6.0
populate
2.0
BEGIN
2.0
CRAP 3.6
1 package DBIx::Class::Migration::RunScript::Trait::Populate;
2  
3 use Moose::Role;
4 use File::Spec::Functions 'catdir', 'catfile';
5  
6 requires 'schema';
7  
8 sub populate {
9 my ($self, @sets) = @_;
10 foreach my $set(@sets) {
11 $ENV{DBIC_MIGRATION_FIXTURES_OBJ}->populate({
12 no_deploy => 1,
13 schema => $self->schema,
14 directory => catdir($ENV{DBIC_MIGRATION_FIXTURE_DIR}, $set) });
15 }
16 }
17  
18 sub set_has_fixtures {
19 my ($self, $set_to_check) = @_;
20 return -d catdir($ENV{DBIC_MIGRATION_FIXTURE_DIR}, $set_to_check) ? 1:0;
21 }
22  
23 1;
24  
25 =head1 NAME
26  
27 DBIx::Class::Migration::RunScript::Trait::Populate - Populate fixtures
28 =head1 SYNOPSIS
29  
30 use DBIx::Class::Migration::RunScript;
31  
32 builder {
33 'SchemaLoader',
34 'Populate',
35 sub {
36 shift->populate('countries');
37 };
38 };
39  
40 =head1 DESCRIPTION
41  
42 This is a L<Moose::Role> that adds a C<populate> method to your run script.
43 This allows you to access any of your previously dumped fixtures. You might
44 find this useful when installing a database that was previously setup.
45  
46 This trait requires a C<schema> previously defined, such as provided by
47 L<DBIx::Class::Migration::RunScript::Trait::SchemaLoader>.
48  
49 =head1 methods
50  
51 This class defines the follow methods.
52  
53 =head2 populate
54  
55 Requires $arg || @args
56  
57 Given a fixture set (or list of sets), use L<DBIx::Class::Fixtures> to populate
58 them to the current database.
59  
60 When naming sets, you skip the '.json' extension.
61  
62 =head2 set_has_fixtures
63  
64 Requires $arg
65  
66 Given a set name, returns a boolean about if that set actually has fixtures
67 previously dumped.
68  
69 =head1 SEE ALSO
70  
71 L<DBIx::Class::Migration>, L<DBIx::Class::Migration::RunScript>
72  
73 =head1 AUTHOR
74  
75 See L<DBIx::Class::Migration> for author information
76  
77 =head1 COPYRIGHT & LICENSE
78  
79 See L<DBIx::Class::Migration> for copyright and license information
80  
81 =cut
82  
83