App-Pod

 view release on metacpan or  search on metacpan

t/01-usage-simple.t  view on Meta::CPAN

          ["Mojo::UserAgent - Non-blocking I/O HTTP and WebSocket user agent"],
    },
    {
        name  => "query with file at end and method",
        input => [ qw( --query head1[0]/Para ), $sample_pod, qw( get ) ],
        expected_output =>
          ["Mojo::UserAgent - Non-blocking I/O HTTP and WebSocket user agent"],
    },
    {
        name            => "query_dump file",
        input           => [ $sample_pod, qw( --query head1[0]/Para --dump ) ],
        expected_output => [
            "_process_non_main()",
            "Processing: query",
            "DEBUG_FIND_DUMP: [",
            "  {",
            "    \"keep\" => 1,",
            "    \"prev\" => [],",
            "    \"tag\" => \"Para\",",
"    \"text\" => \"Mojo::UserAgent - Non-blocking I/O HTTP and WebSocket user agent\"",
            "  }",
            "]",
            "",
            "Mojo::UserAgent - Non-blocking I/O HTTP and WebSocket user agent",
            "self={",
            "  \"_args\" => [],",
            "  \"_cache_path\" => \"PATH\",",
            "  \"_class\" => \"$windows_safe_path\",",
            "  \"_core_flags\" => [],",
            "  \"_method\" => undef,",
            "  \"_non_main_flags\" => [",
            "    {",
            "      \"description\" => \"Run a pod query.\",",
            "      \"handler\" => \"query_class\",",
            "      \"name\" => \"query\",",
            "      \"spec\" => \"query|q=s\"",
            "    }",
            "  ],",
            "  \"_opts\" => {",
            "    \"dump\" => 1,",
            "    \"query\" => \"head1[0]/Para\"",
            "  }",
            "}"
        ],
    },

    # Specific modules.
    {
        name            => "Module - Mojo:2:File",
        input           => [qw( Mojo2::File )],
        expected_output => [
            q(),
            q(Package: Mojo2::File),
            q(Path:    <PATH>),
            q(),
            q(Mojo::File - File system paths),
            q(),
            q(Methods (32):),
            q( basename    - Return the last level of the path wi ...),
            q( child       - Return a new Mojo::File object relat ...),
            q( chmod       - Change file permissions.),
            q( copy_to     - Copy file with File::Copy and return ...),
            q( curfile     - Construct a new scalar-based Mojo::F ...),
            q( dirname     - Return all but the last level of the ...),
            q( extname     - Return file extension of the path.),
            q( is_abs      - Check if the path is absolute.),
            q( list        - List all files in the directory and  ...),
            q( list_tree   - List all files recursively in the di ...),
            q( lstat       - Return a File::stat object for the s ...),
            q( make_path   - Create the directories if they don't ...),
            q( move_to     - Move file with File::Copy and return ...),
            q( new         - Construct a new Mojo::File object, d ...),
            q( open        - Open file with IO::File.),
            q( path        - Construct a new scalar-based Mojo::F ...),
            q( realpath    - Resolve the path with Cwd and return ...),
            q( remove      - Delete file.),
            q( remove_tree - Delete this directory and any files  ...),
            q( sibling     - Return a new Mojo::File object relat ...),
            q( slurp       - Read all data at once from the file.),
            q( spurt       - Write all data at once to the file.),
            q( stat        - Return a File::stat object for the path.),
            q( tap         - Alias for "tap" in Mojo::Base.),
            q( tempdir     - Construct a new scalar-based Mojo::F ...),
            q( tempfile    - Construct a new scalar-based Mojo::F ...),
            q( to_abs      - Return absolute path as a Mojo::File ...),
            q( to_array    - Split the path on directory separators.),
            q( to_rel      - Return a relative path from the orig ...),
            q( to_string   - Stringify the path.),
            q( touch       - Create file if it does not exist or  ...),
            q( with_roles  - Alias for "with_roles" in Mojo::Base.),
            q(),
            q(Use --all (or -a) to see all methods.),
        ],
    },
    {
        name            => "Module - Mojo2::File --all",
        input           => [qw( Mojo2::File --all )],
        expected_output => [
            q(),
            q(Package: Mojo2::File),
            q(Path:    <PATH>),
            q(),
            q(Mojo::File - File system paths),
            q(),
            q(Methods (55):),
            q{ (""},
            q{ ((},
            q{ ()},
            q{ (@{}},
            q{ (bool},
            q( BEGIN),
            q( EXPORT),
            q( EXPORT_OK),
            q( ISA),
            q( VERSION),
            q( __ANON__),
            q( abs2rel),
            q( basename              - Return the last level of t ...),
            q( canonpath),
            q( catfile),
            q( child                 - Return a new Mojo::File ob ...),
            q( chmod                 - Change file permissions.),
            q( copy),
            q( copy_to               - Copy file with File::Copy  ...),
            q( croak),
            q( curfile               - Construct a new scalar-bas ...),
            q( dirname               - Return all but the last le ...),
            q( extname               - Return file extension of t ...),
            q( file_name_is_absolute),
            q( find),
            q( getcwd),
            q( import),
            q( is_abs                - Check if the path is absolute.),
            q( list                  - List all files in the dire ...),
            q( list_tree             - List all files recursively ...),
            q( lstat                 - Return a File::stat object ...),
            q( make_path             - Create the directories if  ...),
            q( move),
            q( move_to               - Move file with File::Copy  ...),
            q( new                   - Construct a new Mojo::File ...),
            q( open                  - Open file with IO::File.),
            q( path                  - Construct a new scalar-bas ...),
            q( realpath              - Resolve the path with Cwd  ...),
            q( rel2abs),
            q( remove                - Delete file.),
            q( remove_tree           - Delete this directory and  ...),
            q( sibling               - Return a new Mojo::File ob ...),
            q( slurp                 - Read all data at once from ...),
            q( splitdir),
            q( spurt                 - Write all data at once to  ...),
            q( stat                  - Return a File::stat object ...),
            q( tap                   - Alias for "tap" in Mojo::Base.),
            q( tempdir               - Construct a new scalar-bas ...),
            q( tempfile              - Construct a new scalar-bas ...),
            q( to_abs                - Return absolute path as a  ...),
            q( to_array              - Split the path on director ...),
            q( to_rel                - Return a relative path fro ...),
            q( to_string             - Stringify the path.),
            q( touch                 - Create file if it does not ...),
            q( with_roles            - Alias for "with_roles" in  ...),
        ],
    },
);

my $is_path       = qr/ ^ Path: \s* \K (.*) $ /x;
my $is_version    = qr/ \b \d+\.\d+  $ /x;
my $is_cache_path = qr/ "_cache_path" \s+ => \K \s+ ".*" /x;

for my $case ( @cases ) {
    local @ARGV = ( $case->{input}->@* );
    my $input = "@ARGV";
    my $out   = "";

    # Capture output.
    {
        local *STDOUT;
        local *STDERR;
        open STDOUT, ">",  \$out or die $!;
        open STDERR, ">>", \$out or die $!;
        eval { App::Pod->run };
        if ( $@ ) {
            $out = $@;



( run in 0.781 second using v1.01-cache-2.11-cpan-39bf76dae61 )