| 1 | package Dist::Zilla::Plugin::Test::CreateFromMojoTemplates; | ||
| 2 | |||
| 3 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 2 | ▶ | use 5.10.1; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 2 | our $VERSION = '0.0701'; # VERSION | |
| 7 | # ABSTRACT: Create Mojolicious tests from a custom template format (deprecated) | ||
| 8 | |||
| 9 | 2 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | 2 | ▶ | use File::Find::Rule; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | 2 | ▶ | use namespace::autoclean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | 2 | ▶ | use Path::Tiny; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | 2 | ▶ | use MojoX::CustomTemplateFileParser; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 14 | |||
| 15 | 2 | ▶ | use Dist::Zilla::File::InMemory; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 16 | 2 | with 'Dist::Zilla::Role::FileGatherer'; | |
| 17 | |||
| 18 | has directory => ( | ||
| 19 | is => 'ro', | ||
| 20 | isa => 'Str', | ||
| 21 | 0 | ▶ | default => sub { 'examples/source/' }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 22 | 2 | ); | |
| 23 | has filepattern => ( | ||
| 24 | is => 'ro', | ||
| 25 | isa => 'Str', | ||
| 26 | 0 | ▶ | default => sub { '^\w+-\d+\.mojo$' }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 27 | 2 | ); | |
| 28 | |||
| 29 | 0 | ▶ | sub gather_files { |
|
Subroutine
gather_files: not called CC=2 SCAR=17.9
Pod
undocumented
| |||
| 30 | 0 | my $self = shift; | |
| 31 | 0 | my $arg = shift; | |
| 32 | |||
| 33 | 0 | my $test_template_path = (File::Find::Rule->file->name('template.test')->in($self->directory))[0]; | |
| 34 | 0 | my $test_template = path($test_template_path)->slurp; | |
| 35 | |||
| 36 | 0 | my @paths = File::Find::Rule->file->name(qr/@{[ $self->filepattern ]}/)->in($self->directory); | |
| 37 | 0 | foreach my $path (@paths) { | |
| 38 | |||
| 39 | 0 | my $contents = MojoX::CustomTemplateFileParser->new(path => path($path)->absolute->canonpath, output => ['Test'])->to_test; | |
| 40 | 0 | my $filename = path($path)->basename(qr{\.[^.]+}); | |
| 41 | |||
| 42 | 0 | my $file = Dist::Zilla::File::InMemory->new( | |
| 43 | name => "t/$filename.t", | ||
| 44 | content => $test_template . $contents, | ||
| 45 | ); | ||
| 46 | 0 | $self->add_file($file); | |
| 47 | |||
| 48 | } | ||
| 49 | |||
| 50 | 0 | return; | |
| 51 | } | ||
| 52 | |||
| 53 | 2 | __PACKAGE__->meta->make_immutable; | |
| 54 | |||
| 55 | 2 | 1; | |
| 56 | |||
| 57 | __END__ | ||