File-TreeCreate-0.0.1/0000755000076400007640000000000014111671752014311 5ustar shlomifshlomifFile-TreeCreate-0.0.1/Changes0000644000076400007640000000016514111671752015606 0ustar shlomifshlomifRevision history for File-TreeCreate 0.0.1 2021-08-26 - First version, released on an unsuspecting world File-TreeCreate-0.0.1/LICENSE0000644000076400007640000000220614111671752015316 0ustar shlomifshlomifThis software is Copyright (c) 2021 by Shlomi Fish. This is free software, licensed under: The MIT (X11) License The MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. File-TreeCreate-0.0.1/scripts/0000755000076400007640000000000014111671752016000 5ustar shlomifshlomifFile-TreeCreate-0.0.1/scripts/tag-release.pl0000644000076400007640000000073214111671752020530 0ustar shlomifshlomif#!/usr/bin/env perl use strict; use warnings; use Path::Tiny qw/ path /; my ($version) = ( map { m{\Aversion * = *(\S+)} ? ($1) : () } path("./dist.ini")->lines_utf8() ); if ( !defined($version) ) { die "Version is undefined!"; } my $PROJECT = "perl-File-TreeCreate"; my @cmd = ( "git", "tag", "-m", "Tagging the $PROJECT release as $version", "$PROJECT-$version", ); print join( " ", map { /\s/ ? qq{"$_"} : $_ } @cmd ), "\n"; exec(@cmd); File-TreeCreate-0.0.1/inc/0000755000076400007640000000000014111671752015062 5ustar shlomifshlomifFile-TreeCreate-0.0.1/inc/Test/0000755000076400007640000000000014111671752016001 5ustar shlomifshlomifFile-TreeCreate-0.0.1/inc/Test/Run/0000755000076400007640000000000014111671752016545 5ustar shlomifshlomifFile-TreeCreate-0.0.1/inc/Test/Run/Builder.pm0000644000076400007640000000342714111671752020477 0ustar shlomifshlomifpackage Test::Run::Builder; use strict; use warnings; use Module::Build; use vars qw(@ISA); @ISA = (qw(Module::Build)); sub ACTION_runtest { my ($self) = @_; my $p = $self->{properties}; $self->depends_on('code'); local @INC = @INC; # Make sure we test the module in blib/ unshift @INC, ( File::Spec->catdir( $p->{base_dir}, $self->blib, 'lib' ), File::Spec->catdir( $p->{base_dir}, $self->blib, 'arch' ) ); $self->do_test_run_tests; } sub ACTION_distruntest { my ($self) = @_; $self->depends_on('distdir'); my $start_dir = $self->cwd; my $dist_dir = $self->dist_dir; chdir $dist_dir or die "Cannot chdir to $dist_dir: $!"; # XXX could be different names for scripts $self->run_perl_script( 'Build.PL') # XXX Should this be run w/ --nouse-rcfile or die "Error executing 'Build.PL' in dist directory: $!"; $self->run_perl_script('Build') or die "Error executing 'Build' in dist directory: $!"; $self->run_perl_script( 'Build', [], ['runtest'] ) or die "Error executing 'Build test' in dist directory"; chdir $start_dir; } sub do_test_run_tests { my $self = shift; require Test::Run::CmdLine::Iface; my $test_run = Test::Run::CmdLine::Iface->new( { 'test_files' => [ glob("t/*.t") ], } # 'backend_params' => $self->_get_backend_params(), ); return $test_run->run(); } sub ACTION_tags { my $self = shift; return $self->do_system( "ctags", qw(-f tags --recurse --totals --exclude=blib/** --exclude=t/lib/** --exclude=**/.svn/** --exclude='*~'), "--exclude=" . $self->dist_name() . "-*/**", qw(--languages=Perl --langmap=Perl:+.t) ); } 1; File-TreeCreate-0.0.1/META.yml0000644000076400007640000002600414111671752015564 0ustar shlomifshlomif--- abstract: 'recursively create a directory tree.' author: - 'Shlomi Fish ' build_requires: File::Path: '0' File::Spec: '0' IO::Handle: '0' IPC::Open3: '0' Module::Build: '0.28' Test::More: '0.88' perl: '5.006' configure_requires: Module::Build: '0.28' dynamic_config: 0 generated_by: 'Dist::Zilla version 6.017, CPAN::Meta::Converter version 2.150010' license: mit meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: File-TreeCreate provides: File::TreeCreate: file: lib/File/TreeCreate.pm version: v0.0.1 requires: Carp: '0' File::Spec: '0' autodie: '0' strict: '0' warnings: '0' resources: bugtracker: https://github.com/shlomif/perl-File-TreeCreate/issues homepage: http://metacpan.org/release/File-TreeCreate repository: git://github.com/shlomif/perl-File-TreeCreate.git version: 0.0.1 x_Dist_Zilla: perl: version: '5.032001' plugins: - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: test type: requires name: '@Filter/TestMoreDoneTesting' version: '6.017' - class: Dist::Zilla::Plugin::AutoPrereqs name: '@Filter/AutoPrereqs' version: '6.017' - class: Dist::Zilla::Plugin::ExecDir name: '@Filter/ExecDir' version: '6.017' - class: Dist::Zilla::Plugin::GatherDir config: Dist::Zilla::Plugin::GatherDir: exclude_filename: [] exclude_match: [] follow_symlinks: 0 include_dotfiles: 0 prefix: '' prune_directory: [] root: . name: '@Filter/GatherDir' version: '6.017' - class: Dist::Zilla::Plugin::License name: '@Filter/License' version: '6.017' - class: Dist::Zilla::Plugin::ManifestSkip name: '@Filter/ManifestSkip' version: '6.017' - class: Dist::Zilla::Plugin::MetaYAML name: '@Filter/MetaYAML' version: '6.017' - class: Dist::Zilla::Plugin::PruneCruft name: '@Filter/PruneCruft' version: '6.017' - class: Dist::Zilla::Plugin::Readme name: '@Filter/Readme' version: '6.017' - class: Dist::Zilla::Plugin::RunExtraTests config: Dist::Zilla::Role::TestRunner: default_jobs: 1 name: '@Filter/RunExtraTests' version: '0.029' - class: Dist::Zilla::Plugin::ShareDir name: '@Filter/ShareDir' version: '6.017' - class: Dist::Zilla::Plugin::CheckChangesHasContent name: '@Filter/CheckChangesHasContent' version: '0.011' - class: Dist::Zilla::Plugin::ConfirmRelease name: '@Filter/ConfirmRelease' version: '6.017' - class: Dist::Zilla::Plugin::Manifest name: '@Filter/Manifest' version: '6.017' - class: Dist::Zilla::Plugin::MetaConfig name: '@Filter/MetaConfig' version: '6.017' - class: Dist::Zilla::Plugin::MetaJSON name: '@Filter/MetaJSON' version: '6.017' - class: Dist::Zilla::Plugin::MetaProvides::Package config: Dist::Zilla::Plugin::MetaProvides::Package: finder_objects: - class: Dist::Zilla::Plugin::FinderCode name: '@Filter/MetaProvides::Package/AUTOVIV/:InstallModulesPM' version: '6.017' include_underscores: 0 Dist::Zilla::Role::MetaProvider::Provider: $Dist::Zilla::Role::MetaProvider::Provider::VERSION: '2.002004' inherit_missing: '1' inherit_version: '1' meta_noindex: '1' Dist::Zilla::Role::ModuleMetadata: Module::Metadata: '1.000037' version: '0.006' name: '@Filter/MetaProvides::Package' version: '2.004003' - class: Dist::Zilla::Plugin::MetaResources name: '@Filter/MetaResources' version: '6.017' - class: Dist::Zilla::Plugin::ModuleBuild config: Dist::Zilla::Role::TestRunner: default_jobs: 1 name: '@Filter/ModuleBuild' version: '6.017' - class: Dist::Zilla::Plugin::PkgVersion name: '@Filter/PkgVersion' version: '6.017' - class: Dist::Zilla::Plugin::PodCoverageTests name: '@Filter/PodCoverageTests' version: '6.017' - class: Dist::Zilla::Plugin::PodSyntaxTests name: '@Filter/PodSyntaxTests' version: '6.017' - class: Dist::Zilla::Plugin::Test::Compile config: Dist::Zilla::Plugin::Test::Compile: bail_out_on_fail: '0' fail_on_warning: author fake_home: 0 filename: t/00-compile.t module_finder: - ':InstallModules' needs_display: 0 phase: test script_finder: - ':PerlExecFiles' skips: [] switch: [] name: '@Filter/Test::Compile' version: '2.058' - class: Dist::Zilla::Plugin::Test::CPAN::Changes config: Dist::Zilla::Plugin::Test::CPAN::Changes: changelog: Changes name: '@Filter/Test::CPAN::Changes' version: '0.012' - class: Dist::Zilla::Plugin::Test::EOL config: Dist::Zilla::Plugin::Test::EOL: filename: xt/author/eol.t finder: - ':ExecFiles' - ':InstallModules' - ':TestFiles' trailing_whitespace: 1 name: '@Filter/Test::EOL' version: '0.19' - class: Dist::Zilla::Plugin::Test::NoTabs config: Dist::Zilla::Plugin::Test::NoTabs: filename: xt/author/no-tabs.t finder: - ':InstallModules' - ':ExecFiles' - ':TestFiles' name: '@Filter/Test::NoTabs' version: '0.15' - class: Dist::Zilla::Plugin::Test::TrailingSpace name: '@Filter/Test::TrailingSpace' version: ~ - class: Dist::Zilla::Plugin::TestRelease name: '@Filter/TestRelease' version: '6.017' - class: Dist::Zilla::Plugin::PodWeaver config: Dist::Zilla::Plugin::PodWeaver: finder: - ':InstallModules' - ':ExecFiles' plugins: - class: Pod::Weaver::Plugin::SingleEncoding name: '@SHLOMIF/SingleEncoding' version: '4.017' - class: Pod::Weaver::Plugin::WikiDoc name: '@SHLOMIF/WikiDoc' version: '0.093004' - class: Pod::Weaver::Plugin::EnsurePod5 name: '@CorePrep/EnsurePod5' version: '4.017' - class: Pod::Weaver::Plugin::H1Nester name: '@CorePrep/H1Nester' version: '4.017' - class: Pod::Weaver::Section::Generic name: '@SHLOMIF/Name' version: '4.017' - class: Pod::Weaver::Section::Version name: '@SHLOMIF/Version' version: '4.017' - class: Pod::Weaver::Section::Region name: '@SHLOMIF/Prelude' version: '4.017' - class: Pod::Weaver::Section::Generic name: '@SHLOMIF/Synopsis' version: '4.017' - class: Pod::Weaver::Section::Generic name: '@SHLOMIF/Description' version: '4.017' - class: Pod::Weaver::Section::Generic name: '@SHLOMIF/Usage' version: '4.017' - class: Pod::Weaver::Section::Generic name: '@SHLOMIF/Overview' version: '4.017' - class: Pod::Weaver::Section::Generic name: '@SHLOMIF/Stability' version: '4.017' - class: Pod::Weaver::Section::Collect name: Requirements version: '4.017' - class: Pod::Weaver::Section::Collect name: Attributes version: '4.017' - class: Pod::Weaver::Section::Collect name: Constructors version: '4.017' - class: Pod::Weaver::Section::Collect name: Methods version: '4.017' - class: Pod::Weaver::Section::Collect name: Functions version: '4.017' - class: Pod::Weaver::Section::Leftovers name: '@SHLOMIF/Leftovers' version: '4.017' - class: Pod::Weaver::Section::Region name: '@SHLOMIF/postlude' version: '4.017' - class: Pod::Weaver::Section::Support name: '@SHLOMIF/Support' version: '1.013' - class: Pod::Weaver::Section::Authors name: '@SHLOMIF/Authors' version: '4.017' - class: Pod::Weaver::Section::Bugs name: '@SHLOMIF/Bugs' version: '4.017' - class: Pod::Weaver::Section::Contributors name: '@SHLOMIF/Contributors' version: '0.009' - class: Pod::Weaver::Section::Legal name: '@SHLOMIF/Legal' version: '4.017' - class: Pod::Weaver::Plugin::Transformer name: '@SHLOMIF/List' version: '4.017' name: '@Filter/PodWeaver' version: '4.008' - class: Dist::Zilla::Plugin::UploadToCPAN name: '@Filter/UploadToCPAN' version: '6.017' - class: Dist::Zilla::Plugin::Test::TidyAll name: Test::TidyAll version: '0.04' - class: Dist::Zilla::Plugin::FinderCode name: ':InstallModules' version: '6.017' - class: Dist::Zilla::Plugin::FinderCode name: ':IncModules' version: '6.017' - class: Dist::Zilla::Plugin::FinderCode name: ':TestFiles' version: '6.017' - class: Dist::Zilla::Plugin::FinderCode name: ':ExtraTestFiles' version: '6.017' - class: Dist::Zilla::Plugin::FinderCode name: ':ExecFiles' version: '6.017' - class: Dist::Zilla::Plugin::FinderCode name: ':PerlExecFiles' version: '6.017' - class: Dist::Zilla::Plugin::FinderCode name: ':ShareFiles' version: '6.017' - class: Dist::Zilla::Plugin::FinderCode name: ':MainModule' version: '6.017' - class: Dist::Zilla::Plugin::FinderCode name: ':AllFiles' version: '6.017' - class: Dist::Zilla::Plugin::FinderCode name: ':NoFiles' version: '6.017' - class: Dist::Zilla::Plugin::FinderCode name: '@Filter/MetaProvides::Package/AUTOVIV/:InstallModulesPM' version: '6.017' zilla: class: Dist::Zilla::Dist::Builder config: is_trial: '0' version: '6.017' x_generated_by_perl: v5.32.1 x_serialization_backend: 'YAML::Tiny version 1.73' x_spdx_expression: MIT File-TreeCreate-0.0.1/dist.ini0000644000076400007640000000047514111671752015763 0ustar shlomifshlomifname = File-TreeCreate author = Shlomi Fish license = MIT copyright_holder = Shlomi Fish copyright_year = 2021 version = 0.0.1 [@Filter] -bundle = @SHLOMIF -remove = MakeMaker dist = File-TreeCreate github_name = perl-File-TreeCreate [Test::TidyAll] ; authordep Pod::Weaver::PluginBundle::SHLOMIF File-TreeCreate-0.0.1/README0000644000076400007640000000045514111671752015175 0ustar shlomifshlomifThis archive contains the distribution File-TreeCreate, version 0.0.1: recursively create a directory tree. This software is Copyright (c) 2021 by Shlomi Fish. This is free software, licensed under: The MIT (X11) License This README file was generated by Dist::Zilla::Plugin::Readme v6.017. File-TreeCreate-0.0.1/t/0000755000076400007640000000000014111671752014554 5ustar shlomifshlomifFile-TreeCreate-0.0.1/t/00-compile.t0000644000076400007640000000264014111671752016610 0ustar shlomifshlomifuse 5.006; use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.058 use Test::More; plan tests => 1 + ($ENV{AUTHOR_TESTING} ? 1 : 0); my @module_files = ( 'File/TreeCreate.pm' ); # no fake home requested my @switches = ( -d 'blib' ? '-Mblib' : '-Ilib', ); use File::Spec; use IPC::Open3; use IO::Handle; open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!"; my @warnings; for my $lib (@module_files) { # see L my $stderr = IO::Handle->new; diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'} . $str . q{'} } $^X, @switches, '-e', "require q[$lib]")) if $ENV{PERL_COMPILE_TEST_DEBUG}; my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-e', "require q[$lib]"); binmode $stderr, ':crlf' if $^O eq 'MSWin32'; my @_warnings = <$stderr>; waitpid($pid, 0); is($?, 0, "$lib loaded ok"); shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/ and not eval { +require blib; blib->VERSION('1.01') }; if (@_warnings) { warn @_warnings; push @warnings, @_warnings; } } is(scalar(@warnings), 0, 'no warnings found') or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) ) if $ENV{AUTHOR_TESTING}; File-TreeCreate-0.0.1/t/sample-data/0000755000076400007640000000000014111671752016744 5ustar shlomifshlomifFile-TreeCreate-0.0.1/t/sample-data/h.txt0000644000076400007640000000000614111671752017730 0ustar shlomifshlomifHello.File-TreeCreate-0.0.1/t/tree-create.t0000644000076400007640000001070014111671752017137 0ustar shlomifshlomif#!/usr/bin/perl use strict; use warnings; use Test::More tests => 22; use File::Path qw( rmtree mkpath ); use File::TreeCreate (); { my $t = File::TreeCreate->new(); # TEST ok( $t, "TreeCreate object was initialized" ); # TEST is( $t->get_path("./t/file.txt"), File::Spec->catfile( File::Spec->curdir(), "t", "file.txt" ) ); # TEST is( $t->get_path("./t/mydir/"), File::Spec->catdir( File::Spec->curdir(), "t", "mydir" ) ); # TEST is( $t->get_path("./t/hello/there/world.jpg"), File::Spec->catfile( File::Spec->curdir(), "t", "hello", "there", "world.jpg" ) ); # TEST is( $t->get_path("./one/two/three/four/"), File::Spec->catdir( File::Spec->curdir(), "one", "two", "three", "four" ) ); } { my $t = File::TreeCreate->new(); # TEST ok( $t->exist("./MANIFEST"), "Checking the exist() method" ); # TEST ok( !$t->exist("./BKLASDJASFDJODIJASDOJASODJ.wok"), "Checking the exist() method" ); # TEST ok( $t->is_file("./MANIFEST"), "Checking the is_file method" ); # TEST ok( !$t->is_file("./t"), "Checking the is_file method - 2" ); # TEST ok( !$t->is_dir("./MANIFEST"), "Checking the is_dir method - false" ); # TEST ok( $t->is_dir("./t"), "Checking the is_dir method - true" ); # TEST is( $t->cat("./t/sample-data/h.txt"), "Hello.", "Checking the cat method" ); { mkdir( $t->get_path("./t/sample-data/tree-create-ls-test") ); mkdir( $t->get_path("./t/sample-data/tree-create-ls-test/a") ); { open my $out_fh, ">", $t->get_path("./t/sample-data/tree-create-ls-test/b.txt"); print {$out_fh} "Yowza"; close($out_fh); } mkdir( $t->get_path("./t/sample-data/tree-create-ls-test/c") ); { open my $out_fh, ">", $t->get_path("./t/sample-data/tree-create-ls-test/h.xls"); print {$out_fh} "FooBardom!\n"; close($out_fh); } # TEST is_deeply( $t->ls("./t/sample-data/tree-create-ls-test"), [ "a", "b.txt", "c", "h.xls" ], "Testing the ls method", ); # Cleanup rmtree( $t->get_path("./t/sample-data/tree-create-ls-test") ); } { my $tree = { 'name' => "tree-create--tree-test-1/", 'subs' => [ { 'name' => "b.doc", 'contents' => "This file was spotted in the wild.", }, { 'name' => "a/", }, { 'name' => "foo/", 'subs' => [ { 'name' => "yet/", }, ], }, ], }; $t->create_tree( "./t/sample-data/", $tree ); # TEST is_deeply( $t->ls("./t/sample-data/tree-create--tree-test-1"), [ "a", "b.doc", "foo" ], "Testing the contents of the root tree" ); # TEST ok( $t->is_dir("./t/sample-data/tree-create--tree-test-1/a"), "a is a dir" ); # TEST is_deeply( $t->ls("./t/sample-data/tree-create--tree-test-1/a"), [], "Testing the contents of a" ); # TEST is_deeply( $t->ls("./t/sample-data/tree-create--tree-test-1/foo"), ["yet"], "Testing the contents of foo" ); # TEST ok( $t->is_dir("./t/sample-data/tree-create--tree-test-1/foo/yet"), "Testing that foo/yet is a dir" ); # TEST is_deeply( $t->ls("./t/sample-data/tree-create--tree-test-1/foo/yet"), [], "Testing that foo/yet is a dir" ); # TEST ok( $t->is_file("./t/sample-data/tree-create--tree-test-1/b.doc"), "Checking that b.doc is a file" ); # TEST is( $t->cat("./t/sample-data/tree-create--tree-test-1/b.doc"), "This file was spotted in the wild.", "Checking for contents of b.doc" ); # Cleanup rmtree( $t->get_path("./t/sample-data/tree-create--tree-test-1") ); } { # TEST is( $t->get_path("s/hello"), File::Spec->catfile( "s", "hello" ), "Bug that eliminated ^[AnyChar]/ instead of ^\\./" ); } } File-TreeCreate-0.0.1/lib/0000755000076400007640000000000014111671752015057 5ustar shlomifshlomifFile-TreeCreate-0.0.1/lib/File/0000755000076400007640000000000014111671752015736 5ustar shlomifshlomifFile-TreeCreate-0.0.1/lib/File/TreeCreate.pm0000644000076400007640000001442514111671752020325 0ustar shlomifshlomifpackage File::TreeCreate; $File::TreeCreate::VERSION = '0.0.1'; use autodie; use strict; use warnings; use Carp (); use File::Spec (); sub new { my $class = shift; my $self = {}; bless $self, $class; $self->_init(@_); return $self; } sub _init { return; } sub get_path { my $self = shift; my $path = shift; my @components; if ( $path =~ s{^\./}{} ) { push @components, File::Spec->curdir(); } my $is_dir = ( $path =~ s{/$}{} ); push @components, split( /\//, $path ); if ($is_dir) { return File::Spec->catdir(@components); } else { return File::Spec->catfile(@components); } } sub exist { my $self = shift; return ( -e $self->get_path(@_) ); } sub is_file { my $self = shift; return ( -f $self->get_path(@_) ); } sub is_dir { my $self = shift; return ( -d $self->get_path(@_) ); } sub cat { my $self = shift; open my $in, "<", $self->get_path(@_) or Carp::confess("cat failed!"); my $data; { local $/; $data = <$in>; } close($in); return $data; } sub ls { my $self = shift; opendir my $dir, $self->get_path(@_) or Carp::confess("opendir failed!"); my @files = sort { $a cmp $b } File::Spec->no_upwards( readdir($dir) ); closedir($dir); return \@files; } sub create_tree { my ( $self, $unix_init_path, $tree ) = @_; my $real_init_path = $self->get_path($unix_init_path); return $self->_real_create_tree( $real_init_path, $tree ); } sub _real_create_tree { my ( $self, $init_path, $tree ) = @_; my $name = $tree->{'name'}; if ( $name =~ s{/$}{} ) { my $dir_name = File::Spec->catfile( $init_path, $name ); mkdir($dir_name); if ( exists( $tree->{'subs'} ) ) { foreach my $sub ( @{ $tree->{'subs'} } ) { $self->_real_create_tree( $dir_name, $sub ); } } } else { open my $out, ">", File::Spec->catfile( $init_path, $name ); print {$out} +( exists( $tree->{'contents'} ) ? $tree->{'contents'} : "" ); close($out); } return; } 1; __END__ =pod =encoding UTF-8 =head1 NAME File::TreeCreate - recursively create a directory tree. =head1 VERSION version 0.0.1 =head1 SYNOPSIS use File::TreeCreate (); my $t = File::TreeCreate->new(); my $tree = { 'name' => "tree-create--tree-test-1/", 'subs' => [ { 'name' => "b.doc", 'contents' => "This file was spotted in the wild.", }, { 'name' => "a/", }, { 'name' => "foo/", 'subs' => [ { 'name' => "yet/", }, ], }, ], }; $t->create_tree( "./t/sample-data/", $tree ); # TEST is_deeply( $t->ls("./t/sample-data/tree-create--tree-test-1"), [ "a", "b.doc", "foo" ], "Testing the contents of the root tree" ); =head1 DESCRIPTION This module was extracted from several near-identical copies used in the tests of some of my CPAN distributions. =head1 METHODS =head2 $obj->cat($path) Slurp the file. =head2 $obj->create_tree($unix_init_path, $tree) create the tree. =head2 $obj->exist($path) Does the path exist =head2 $obj->get_path($path) Canonicalize the path from UNIX-like. =head2 $obj->is_dir($path) is the path a directory. =head2 $obj->is_file($path) is the path a file. =head2 $obj->ls($dir_path) list files in a directory =head2 my $obj = File::TreeCreate->new() Instantiates a new object. =for :stopwords cpan testmatrix url bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan =head1 SUPPORT =head2 Websites The following websites have more information about this module, and may be of help to you. As always, in addition to those websites please use your favorite search engine to discover more resources. =over 4 =item * MetaCPAN A modern, open-source CPAN search engine, useful to view POD in HTML format. L =item * RT: CPAN's Bug Tracker The RT ( Request Tracker ) website is the default bug/issue tracking system for CPAN. L =item * CPANTS The CPANTS is a website that analyzes the Kwalitee ( code metrics ) of a distribution. L =item * CPAN Testers The CPAN Testers is a network of smoke testers who run automated tests on uploaded CPAN distributions. L =item * CPAN Testers Matrix The CPAN Testers Matrix is a website that provides a visual overview of the test results for a distribution on various Perls/platforms. L =item * CPAN Testers Dependencies The CPAN Testers Dependencies is a website that shows a chart of the test results of all dependencies for a distribution. L =back =head2 Bugs / Feature Requests Please report any bugs or feature requests by email to C, or through the web interface at L. You will be automatically notified of any progress on the request by the system. =head2 Source Code The code is open to the world, and available for you to hack on. Please feel free to browse it and play with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull from your repository :) L git clone git://github.com/shlomif/perl-File-TreeCreate.git =head1 AUTHOR Shlomi Fish =head1 BUGS Please report any bugs or feature requests on the bugtracker website L When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. =head1 COPYRIGHT AND LICENSE This software is Copyright (c) 2021 by Shlomi Fish. This is free software, licensed under: The MIT (X11) License =cut File-TreeCreate-0.0.1/Build.PL0000644000076400007640000000243514111671752015611 0ustar shlomifshlomif # This file was automatically generated by Dist::Zilla::Plugin::ModuleBuild v6.017. use strict; use warnings; use Module::Build 0.28; my %module_build_args = ( "build_requires" => { "Module::Build" => "0.28" }, "configure_requires" => { "Module::Build" => "0.28" }, "dist_abstract" => "recursively create a directory tree.", "dist_author" => [ "Shlomi Fish " ], "dist_name" => "File-TreeCreate", "dist_version" => "0.0.1", "license" => "mit", "module_name" => "File::TreeCreate", "recursive_test_files" => 1, "requires" => { "Carp" => 0, "File::Spec" => 0, "autodie" => 0, "strict" => 0, "warnings" => 0 }, "test_requires" => { "File::Path" => 0, "File::Spec" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Test::More" => "0.88", "perl" => "5.006" } ); my %fallback_build_requires = ( "File::Path" => 0, "File::Spec" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Module::Build" => "0.28", "Test::More" => "0.88", "perl" => "5.006" ); unless ( eval { Module::Build->VERSION(0.4004) } ) { delete $module_build_args{test_requires}; $module_build_args{build_requires} = \%fallback_build_requires; } my $build = Module::Build->new(%module_build_args); $build->create_build_script; File-TreeCreate-0.0.1/MANIFEST.SKIP0000644000076400007640000000000314111671752016200 0ustar shlomifshlomif~$ File-TreeCreate-0.0.1/META.json0000644000076400007640000004276014111671752015743 0ustar shlomifshlomif{ "abstract" : "recursively create a directory tree.", "author" : [ "Shlomi Fish " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 6.017, CPAN::Meta::Converter version 2.150010", "license" : [ "mit" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "File-TreeCreate", "prereqs" : { "build" : { "requires" : { "Module::Build" : "0.28" } }, "configure" : { "requires" : { "Module::Build" : "0.28" } }, "develop" : { "requires" : { "Pod::Coverage::TrustPod" : "0", "Test::CPAN::Changes" : "0.19", "Test::Code::TidyAll" : "0.50", "Test::EOL" : "0", "Test::More" : "0.96", "Test::NoTabs" : "0", "Test::Pod" : "1.41", "Test::Pod::Coverage" : "1.08", "Test::TrailingSpace" : "0.0203" } }, "runtime" : { "requires" : { "Carp" : "0", "File::Spec" : "0", "autodie" : "0", "strict" : "0", "warnings" : "0" } }, "test" : { "requires" : { "File::Path" : "0", "File::Spec" : "0", "IO::Handle" : "0", "IPC::Open3" : "0", "Test::More" : "0.88", "perl" : "5.006" } } }, "provides" : { "File::TreeCreate" : { "file" : "lib/File/TreeCreate.pm", "version" : "v0.0.1" } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/shlomif/perl-File-TreeCreate/issues" }, "homepage" : "http://metacpan.org/release/File-TreeCreate", "repository" : { "type" : "git", "url" : "git://github.com/shlomif/perl-File-TreeCreate.git", "web" : "https://github.com/shlomif/perl-File-TreeCreate" } }, "version" : "0.0.1", "x_Dist_Zilla" : { "perl" : { "version" : "5.032001" }, "plugins" : [ { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "test", "type" : "requires" } }, "name" : "@Filter/TestMoreDoneTesting", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::AutoPrereqs", "name" : "@Filter/AutoPrereqs", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::ExecDir", "name" : "@Filter/ExecDir", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::GatherDir", "config" : { "Dist::Zilla::Plugin::GatherDir" : { "exclude_filename" : [], "exclude_match" : [], "follow_symlinks" : 0, "include_dotfiles" : 0, "prefix" : "", "prune_directory" : [], "root" : "." } }, "name" : "@Filter/GatherDir", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::License", "name" : "@Filter/License", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::ManifestSkip", "name" : "@Filter/ManifestSkip", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::MetaYAML", "name" : "@Filter/MetaYAML", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::PruneCruft", "name" : "@Filter/PruneCruft", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::Readme", "name" : "@Filter/Readme", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::RunExtraTests", "config" : { "Dist::Zilla::Role::TestRunner" : { "default_jobs" : 1 } }, "name" : "@Filter/RunExtraTests", "version" : "0.029" }, { "class" : "Dist::Zilla::Plugin::ShareDir", "name" : "@Filter/ShareDir", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::CheckChangesHasContent", "name" : "@Filter/CheckChangesHasContent", "version" : "0.011" }, { "class" : "Dist::Zilla::Plugin::ConfirmRelease", "name" : "@Filter/ConfirmRelease", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::Manifest", "name" : "@Filter/Manifest", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::MetaConfig", "name" : "@Filter/MetaConfig", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::MetaJSON", "name" : "@Filter/MetaJSON", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::MetaProvides::Package", "config" : { "Dist::Zilla::Plugin::MetaProvides::Package" : { "finder_objects" : [ { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : "@Filter/MetaProvides::Package/AUTOVIV/:InstallModulesPM", "version" : "6.017" } ], "include_underscores" : 0 }, "Dist::Zilla::Role::MetaProvider::Provider" : { "$Dist::Zilla::Role::MetaProvider::Provider::VERSION" : "2.002004", "inherit_missing" : 1, "inherit_version" : 1, "meta_noindex" : 1 }, "Dist::Zilla::Role::ModuleMetadata" : { "Module::Metadata" : "1.000037", "version" : "0.006" } }, "name" : "@Filter/MetaProvides::Package", "version" : "2.004003" }, { "class" : "Dist::Zilla::Plugin::MetaResources", "name" : "@Filter/MetaResources", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::ModuleBuild", "config" : { "Dist::Zilla::Role::TestRunner" : { "default_jobs" : 1 } }, "name" : "@Filter/ModuleBuild", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::PkgVersion", "name" : "@Filter/PkgVersion", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::PodCoverageTests", "name" : "@Filter/PodCoverageTests", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::PodSyntaxTests", "name" : "@Filter/PodSyntaxTests", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::Test::Compile", "config" : { "Dist::Zilla::Plugin::Test::Compile" : { "bail_out_on_fail" : 0, "fail_on_warning" : "author", "fake_home" : 0, "filename" : "t/00-compile.t", "module_finder" : [ ":InstallModules" ], "needs_display" : 0, "phase" : "test", "script_finder" : [ ":PerlExecFiles" ], "skips" : [], "switch" : [] } }, "name" : "@Filter/Test::Compile", "version" : "2.058" }, { "class" : "Dist::Zilla::Plugin::Test::CPAN::Changes", "config" : { "Dist::Zilla::Plugin::Test::CPAN::Changes" : { "changelog" : "Changes" } }, "name" : "@Filter/Test::CPAN::Changes", "version" : "0.012" }, { "class" : "Dist::Zilla::Plugin::Test::EOL", "config" : { "Dist::Zilla::Plugin::Test::EOL" : { "filename" : "xt/author/eol.t", "finder" : [ ":ExecFiles", ":InstallModules", ":TestFiles" ], "trailing_whitespace" : 1 } }, "name" : "@Filter/Test::EOL", "version" : "0.19" }, { "class" : "Dist::Zilla::Plugin::Test::NoTabs", "config" : { "Dist::Zilla::Plugin::Test::NoTabs" : { "filename" : "xt/author/no-tabs.t", "finder" : [ ":InstallModules", ":ExecFiles", ":TestFiles" ] } }, "name" : "@Filter/Test::NoTabs", "version" : "0.15" }, { "class" : "Dist::Zilla::Plugin::Test::TrailingSpace", "name" : "@Filter/Test::TrailingSpace", "version" : null }, { "class" : "Dist::Zilla::Plugin::TestRelease", "name" : "@Filter/TestRelease", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::PodWeaver", "config" : { "Dist::Zilla::Plugin::PodWeaver" : { "finder" : [ ":InstallModules", ":ExecFiles" ], "plugins" : [ { "class" : "Pod::Weaver::Plugin::SingleEncoding", "name" : "@SHLOMIF/SingleEncoding", "version" : "4.017" }, { "class" : "Pod::Weaver::Plugin::WikiDoc", "name" : "@SHLOMIF/WikiDoc", "version" : "0.093004" }, { "class" : "Pod::Weaver::Plugin::EnsurePod5", "name" : "@CorePrep/EnsurePod5", "version" : "4.017" }, { "class" : "Pod::Weaver::Plugin::H1Nester", "name" : "@CorePrep/H1Nester", "version" : "4.017" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "@SHLOMIF/Name", "version" : "4.017" }, { "class" : "Pod::Weaver::Section::Version", "name" : "@SHLOMIF/Version", "version" : "4.017" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@SHLOMIF/Prelude", "version" : "4.017" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "@SHLOMIF/Synopsis", "version" : "4.017" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "@SHLOMIF/Description", "version" : "4.017" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "@SHLOMIF/Usage", "version" : "4.017" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "@SHLOMIF/Overview", "version" : "4.017" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "@SHLOMIF/Stability", "version" : "4.017" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "Requirements", "version" : "4.017" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "Attributes", "version" : "4.017" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "Constructors", "version" : "4.017" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "Methods", "version" : "4.017" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "Functions", "version" : "4.017" }, { "class" : "Pod::Weaver::Section::Leftovers", "name" : "@SHLOMIF/Leftovers", "version" : "4.017" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@SHLOMIF/postlude", "version" : "4.017" }, { "class" : "Pod::Weaver::Section::Support", "name" : "@SHLOMIF/Support", "version" : "1.013" }, { "class" : "Pod::Weaver::Section::Authors", "name" : "@SHLOMIF/Authors", "version" : "4.017" }, { "class" : "Pod::Weaver::Section::Bugs", "name" : "@SHLOMIF/Bugs", "version" : "4.017" }, { "class" : "Pod::Weaver::Section::Contributors", "name" : "@SHLOMIF/Contributors", "version" : "0.009" }, { "class" : "Pod::Weaver::Section::Legal", "name" : "@SHLOMIF/Legal", "version" : "4.017" }, { "class" : "Pod::Weaver::Plugin::Transformer", "name" : "@SHLOMIF/List", "version" : "4.017" } ] } }, "name" : "@Filter/PodWeaver", "version" : "4.008" }, { "class" : "Dist::Zilla::Plugin::UploadToCPAN", "name" : "@Filter/UploadToCPAN", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::Test::TidyAll", "name" : "Test::TidyAll", "version" : "0.04" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":InstallModules", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":IncModules", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":TestFiles", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExtraTestFiles", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExecFiles", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":PerlExecFiles", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ShareFiles", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":MainModule", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":AllFiles", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":NoFiles", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : "@Filter/MetaProvides::Package/AUTOVIV/:InstallModulesPM", "version" : "6.017" } ], "zilla" : { "class" : "Dist::Zilla::Dist::Builder", "config" : { "is_trial" : 0 }, "version" : "6.017" } }, "x_generated_by_perl" : "v5.32.1", "x_serialization_backend" : "Cpanel::JSON::XS version 4.26", "x_spdx_expression" : "MIT" } File-TreeCreate-0.0.1/MANIFEST0000644000076400007640000000070614111671752015445 0ustar shlomifshlomif# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.017. Build.PL Changes LICENSE MANIFEST MANIFEST.SKIP META.json META.yml README dist.ini inc/Test/Run/Builder.pm lib/File/TreeCreate.pm scripts/tag-release.pl t/00-compile.t t/sample-data/h.txt t/tree-create.t weaver.ini xt/author/eol.t xt/author/no-tabs.t xt/author/pod-coverage.t xt/author/pod-syntax.t xt/author/tidyall.t xt/release/cpan-changes.t xt/release/trailing-space.t File-TreeCreate-0.0.1/weaver.ini0000644000076400007640000000001314111671752016275 0ustar shlomifshlomif[@SHLOMIF] File-TreeCreate-0.0.1/xt/0000755000076400007640000000000014111671752014744 5ustar shlomifshlomifFile-TreeCreate-0.0.1/xt/release/0000755000076400007640000000000014111671752016364 5ustar shlomifshlomifFile-TreeCreate-0.0.1/xt/release/cpan-changes.t0000644000076400007640000000034414111671752021101 0ustar shlomifshlomifuse strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::CPAN::Changes 0.012 use Test::More 0.96 tests => 1; use Test::CPAN::Changes; subtest 'changes_ok' => sub { changes_file_ok('Changes'); }; File-TreeCreate-0.0.1/xt/release/trailing-space.t0000644000076400007640000000103414111671752021451 0ustar shlomifshlomif#!perl use strict; use warnings; use Test::More; eval "use Test::TrailingSpace"; if ($@) { plan skip_all => "Test::TrailingSpace required for trailing space test."; } else { plan tests => 1; } # TODO: add .pod, .PL, the README/Changes/TODO/etc. documents and possibly # some other stuff. my $finder = Test::TrailingSpace->new( { root => '.', filename_regex => qr#(?:\.(?:t|pm|pl|xs|c|h|txt|pod|PL)|README|Changes|TODO|LICENSE)\z#, }, ); # TEST $finder->no_trailing_space( "No trailing space was found." ); File-TreeCreate-0.0.1/xt/author/0000755000076400007640000000000014111671752016246 5ustar shlomifshlomifFile-TreeCreate-0.0.1/xt/author/pod-syntax.t0000644000076400007640000000025214111671752020540 0ustar shlomifshlomif#!perl # This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. use strict; use warnings; use Test::More; use Test::Pod 1.41; all_pod_files_ok(); File-TreeCreate-0.0.1/xt/author/no-tabs.t0000644000076400007640000000045514111671752020002 0ustar shlomifshlomifuse strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::NoTabs 0.15 use Test::More 0.88; use Test::NoTabs; my @files = ( 'lib/File/TreeCreate.pm', 't/00-compile.t', 't/sample-data/h.txt', 't/tree-create.t' ); notabs_ok($_) foreach @files; done_testing; File-TreeCreate-0.0.1/xt/author/tidyall.t0000644000076400007640000000052214111671752020074 0ustar shlomifshlomif# This file was automatically generated by Dist::Zilla::Plugin::Test::TidyAll v$VERSION use Test::More 0.88; use Test::Code::TidyAll 0.24; tidyall_ok( verbose => ( exists $ENV{TEST_TIDYALL_VERBOSE} ? $ENV{TEST_TIDYALL_VERBOSE} : 0 ), jobs => ( exists $ENV{TEST_TIDYALL_JOBS} ? $ENV{TEST_TIDYALL_JOBS} : 1 ), ); done_testing; File-TreeCreate-0.0.1/xt/author/pod-coverage.t0000644000076400007640000000033414111671752021006 0ustar shlomifshlomif#!perl # This file was automatically generated by Dist::Zilla::Plugin::PodCoverageTests. use Test::Pod::Coverage 1.08; use Pod::Coverage::TrustPod; all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::TrustPod' }); File-TreeCreate-0.0.1/xt/author/eol.t0000644000076400007640000000050714111671752017214 0ustar shlomifshlomifuse strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::EOL 0.19 use Test::More 0.88; use Test::EOL; my @files = ( 'lib/File/TreeCreate.pm', 't/00-compile.t', 't/sample-data/h.txt', 't/tree-create.t' ); eol_unix_ok($_, { trailing_whitespace => 1 }) foreach @files; done_testing;