Skip to content

Instantly share code, notes, and snippets.

@eiro
Created March 25, 2013 13:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eiro/5237064 to your computer and use it in GitHub Desktop.
Save eiro/5237064 to your computer and use it in GitHub Desktop.
sub parse_path (_) {
my %data;
@data{qw< name path file ext >} = map {
$_
, [split m(/)]
, m{
( # file
[^/]*?
( # ext
[^.]*?)) $ }x
} shift;
\%data;
}
@eiro
Copy link
Author

eiro commented Mar 25, 2013

use App::Skyfall;
use Test::More;

for (
[ 'prj/data/index.md' =>
{ name => 'prj/data/index.md'
, path => [qw< prj data index.md >]
, file => 'index.md'
, ext => 'md' }
]
) { my ( $path, $expected ) = @$_;

is_deeply
( (App::Skyfall::parse_path $path)
, $expected
, "$path parsing" )

}

done_testing;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment