| 1 | package DBIx::Class::Migration::RunScript::Trait::TargetPath; | ||
| 2 | |||
| 3 | 2 | ▶ | use Moo::Role; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 2 | ▶ | use File::Spec; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 0 | ▶ | sub target_path { |
|
Subroutine
target_path: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 7 | 0 | my ($self, @paths) = @_; | |
| 8 | 0 | return File::Spec->catdir($ENV{DBIC_MIGRATION_FIXTURE_DIR}, @paths); | |
| 9 | } | ||
| 10 | |||
| 11 | 2 | 1; | |
| 12 | |||
| 13 | =head1 NAME | ||
| 14 | |||
| 15 | DBIx::Class::Migration::RunScript::Trait::TargetPath - Your migration target directory | ||
| 16 | |||
| 17 | =head1 SYNOPSIS | ||
| 18 | |||
| 19 | use DBIx::Class::Migration::RunScript; | ||
| 20 | |||
| 21 | builder { | ||
| 22 | 'TargetPath', | ||
| 23 | sub { | ||
| 24 | open(my $file, '<', shift->target_path('file')); | ||
| 25 | }; | ||
| 26 | }; | ||
| 27 | |||
| 28 | =head1 DESCRIPTION | ||
| 29 | |||
| 30 | Sometimes you would like to access your migration target directory when running | ||
| 31 | migration scripts. For example, you might have some data stored in CSV files | ||
| 32 | and you want to load that data into the database as part of your migration. | ||
| 33 | |||
| 34 | =head1 methods | ||
| 35 | |||
| 36 | This class defines the follow methods. | ||
| 37 | |||
| 38 | =head2 target_path | ||
| 39 | |||
| 40 | @args are optional. | ||
| 41 | |||
| 42 | returns a path to whatever C<target_dir> is (typically PROJECT_ROOT/share if | ||
| 43 | you are using the default). If you pass @args, those args will be added as | ||
| 44 | path parts to the returned path. | ||
| 45 | |||
| 46 | Example usage: | ||
| 47 | |||
| 48 | $self->target_path | ||
| 49 | $self->target_path('file'); | ||
| 50 | $self->target_path('path', 'to', 'file'); | ||
| 51 | |||
| 52 | =head1 SEE ALSO | ||
| 53 | |||
| 54 | L<DBIx::Class::Migration>, L<DBIx::Class::Migration::RunScript> | ||
| 55 | |||
| 56 | =head1 AUTHOR | ||
| 57 | |||
| 58 | See L<DBIx::Class::Migration> for author information | ||
| 59 | |||
| 60 | =head1 COPYRIGHT & LICENSE | ||
| 61 | |||
| 62 | See L<DBIx::Class::Migration> for copyright and license information | ||
| 63 | |||
| 64 | =cut | ||
| 65 | |||
| 66 | |||