{
    "content": [
        {
            "type": "text",
            "text": "# TAP::Parser::SourceHandler (perldoc)\n\n## NAME\n\nTAP::Parser::SourceHandler - Base class for different TAP source handlers\n\n## SYNOPSIS\n\n# abstract class - don't use directly!\n# see TAP::Parser::IteratorFactory for general usage\n# must be sub-classed for use\npackage MySourceHandler;\nuse base 'TAP::Parser::SourceHandler';\nsub canhandle    { return $confidencelevel }\nsub makeiterator { return $iterator }\n# see example below for more details\n\n## DESCRIPTION\n\nThis is an abstract base class for TAP::Parser::Source handlers / handlers.\n\n## Sections\n\n- **NAME**\n- **VERSION**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **METHODS** (1 subsections)\n- **SUBCLASSING** (1 subsections)\n- **AUTHORS**\n- **SEE ALSO**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "TAP::Parser::SourceHandler",
        "section": "",
        "mode": "perldoc",
        "summary": "TAP::Parser::SourceHandler - Base class for different TAP source handlers",
        "synopsis": "# abstract class - don't use directly!\n# see TAP::Parser::IteratorFactory for general usage\n# must be sub-classed for use\npackage MySourceHandler;\nuse base 'TAP::Parser::SourceHandler';\nsub canhandle    { return $confidencelevel }\nsub makeiterator { return $iterator }\n# see example below for more details",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "VERSION",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 11,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 12,
                "subsections": []
            },
            {
                "name": "METHODS",
                "lines": 1,
                "subsections": [
                    {
                        "name": "Class Methods",
                        "lines": 21
                    }
                ]
            },
            {
                "name": "SUBCLASSING",
                "lines": 14,
                "subsections": [
                    {
                        "name": "Example",
                        "lines": 50
                    }
                ]
            },
            {
                "name": "AUTHORS",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 5,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "TAP::Parser::SourceHandler - Base class for different TAP source handlers\n",
                "subsections": []
            },
            "VERSION": {
                "content": "Version 3.44\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "# abstract class - don't use directly!\n# see TAP::Parser::IteratorFactory for general usage\n\n# must be sub-classed for use\npackage MySourceHandler;\nuse base 'TAP::Parser::SourceHandler';\nsub canhandle    { return $confidencelevel }\nsub makeiterator { return $iterator }\n\n# see example below for more details\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "This is an abstract base class for TAP::Parser::Source handlers / handlers.\n\nA \"TAP::Parser::SourceHandler\" does whatever is necessary to produce & capture a stream of TAP\nfrom the *raw* source, and package it up in a TAP::Parser::Iterator for the parser to consume.\n\n\"SourceHandlers\" must implement the *source detection & handling* interface used by\nTAP::Parser::IteratorFactory. At 2 methods, the interface is pretty simple: \"canhandle\" and\n\"makesource\".\n\nUnless you're writing a new TAP::Parser::SourceHandler, a plugin, or subclassing TAP::Parser,\nyou probably won't need to use this module directly.\n",
                "subsections": []
            },
            "METHODS": {
                "content": "",
                "subsections": [
                    {
                        "name": "Class Methods",
                        "content": "\"canhandle\"\n*Abstract method*.\n\nmy $vote = $class->canhandle( $source );\n\n$source is a TAP::Parser::Source.\n\nReturns a number between 0 & 1 reflecting how confidently the raw source can be handled. For\nexample, 0 means the source cannot handle it, 0.5 means it may be able to, and 1 means it\ndefinitely can. See \"detectsource\" in TAP::Parser::IteratorFactory for details on how this is\nused.\n\n\"makeiterator\"\n*Abstract method*.\n\nmy $iterator = $class->makeiterator( $source );\n\n$source is a TAP::Parser::Source.\n\nReturns a new TAP::Parser::Iterator object for use by the TAP::Parser. \"croak\"s on error.\n"
                    }
                ]
            },
            "SUBCLASSING": {
                "content": "Please see \"SUBCLASSING\" in TAP::Parser for a subclassing overview, and any of the subclasses\nthat ship with this module as an example. What follows is a quick overview.\n\nStart by familiarizing yourself with TAP::Parser::Source and TAP::Parser::IteratorFactory.\nTAP::Parser::SourceHandler::RawTAP is the easiest sub-class to use as an example.\n\nIt's important to point out that if you want your subclass to be automatically used by\nTAP::Parser you'll have to and make sure it gets loaded somehow. If you're using prove you can\nwrite an App::Prove plugin. If you're using TAP::Parser or TAP::Harness directly (e.g. through a\ncustom script, ExtUtils::MakeMaker, or Module::Build) you can use the \"config\" option which will\ncause \"loadsources\" in TAP::Parser::IteratorFactory to load your subclass).\n\nDon't forget to register your class with \"registerhandler\" in TAP::Parser::IteratorFactory.\n",
                "subsections": [
                    {
                        "name": "Example",
                        "content": "package MySourceHandler;\n\nuse strict;\n\nuse MySourceHandler; # see TAP::Parser::SourceHandler\nuse TAP::Parser::IteratorFactory;\n\nuse base 'TAP::Parser::SourceHandler';\n\nTAP::Parser::IteratorFactory->registerhandler( PACKAGE );\n\nsub canhandle {\nmy ( $class, $src ) = @;\nmy $meta   = $src->meta;\nmy $config = $src->configfor( $class );\n\nif ($config->{acceptall}) {\nreturn 1.0;\n} elsif (my $file = $meta->{file}) {\nreturn 0.0 unless $file->{exists};\nreturn 1.0 if $file->{lcext} eq '.tap';\nreturn 0.9 if $file->{shebang} && $file->{shebang} =~ /^#!.+tap/;\nreturn 0.5 if $file->{text};\nreturn 0.1 if $file->{binary};\n} elsif ($meta->{scalar}) {\nreturn 0.8 if $$rawsourceref =~ /\\d\\.\\.\\d/;\nreturn 0.6 if $meta->{hasnewlines};\n} elsif ($meta->{array}) {\nreturn 0.8 if $meta->{size} < 5;\nreturn 0.6 if $rawsourceref->[0] =~ /foo/;\nreturn 0.5;\n} elsif ($meta->{hash}) {\nreturn 0.6 if $rawsourceref->{foo};\nreturn 0.2;\n}\n\nreturn 0;\n}\n\nsub makeiterator {\nmy ($class, $source) = @;\n# this is where you manipulate the source and\n# capture the stream of TAP in an iterator\n# either pick a TAP::Parser::Iterator::* or write your own...\nmy $iterator = TAP::Parser::Iterator::Array->new([ 'foo', 'bar' ]);\nreturn $iterator;\n}\n\n1;\n"
                    }
                ]
            },
            "AUTHORS": {
                "content": "TAPx Developers.\n\nSource detection stuff added by Steve Purkis\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "TAP::Object, TAP::Parser, TAP::Parser::Source, TAP::Parser::Iterator,\nTAP::Parser::IteratorFactory, TAP::Parser::SourceHandler::Executable,\nTAP::Parser::SourceHandler::Perl, TAP::Parser::SourceHandler::File,\nTAP::Parser::SourceHandler::Handle, TAP::Parser::SourceHandler::RawTAP\n",
                "subsections": []
            }
        }
    }
}