{
    "mode": "perldoc",
    "parameter": "TAP::Parser::IteratorFactory",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/TAP%3A%3AParser%3A%3AIteratorFactory/json",
    "generated": "2026-06-12T12:56:55Z",
    "synopsis": "use TAP::Parser::IteratorFactory;\nmy $factory = TAP::Parser::IteratorFactory->new({ %config });\nmy $iterator  = $factory->makeiterator( $filename );",
    "sections": {
        "NAME": {
            "content": "TAP::Parser::IteratorFactory - Figures out which SourceHandler objects to use for a given Source\n",
            "subsections": []
        },
        "VERSION": {
            "content": "Version 3.43\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use TAP::Parser::IteratorFactory;\nmy $factory = TAP::Parser::IteratorFactory->new({ %config });\nmy $iterator  = $factory->makeiterator( $filename );\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This is a factory class that takes a TAP::Parser::Source and runs it through all the registered\nTAP::Parser::SourceHandlers to see which one should handle the source.\n\nIf you're a plugin author, you'll be interested in how to \"registerhandler\"s, how\n\"detectsource\" works.\n",
            "subsections": []
        },
        "METHODS": {
            "content": "",
            "subsections": [
                {
                    "name": "Class Methods",
                    "content": "\"new\"\nCreates a new factory class:\n\nmy $sf = TAP::Parser::IteratorFactory->new( $config );\n\n$config is optional. If given, sets \"config\" and calls \"loadhandlers\".\n\n\"registerhandler\"\nRegisters a new TAP::Parser::SourceHandler with this factory.\n\nPACKAGE->registerhandler( $handlerclass );\n\n\"handlers\"\nList of handlers that have been registered.\n"
                },
                {
                    "name": "Instance Methods",
                    "content": "\"config\"\nmy $cfg = $sf->config;\n$sf->config({ Perl => { %config } });\n\nChaining getter/setter for the configuration of the available source handlers. This is a hashref\nkeyed on handler class whose values contain config to be passed onto the handlers during\ndetection & creation. Class names may be fully qualified or abbreviated, eg:\n\n# these are equivalent\n$sf->config({ 'TAP::Parser::SourceHandler::Perl' => { %config } });\n$sf->config({ 'Perl' => { %config } });\n\n\"loadhandlers\"\n$sf->loadhandlers;\n\nLoads the handler classes defined in \"config\". For example, given a config:\n\n$sf->config({\nMySourceHandler => { some => 'config' },\n});\n\n\"loadhandlers\" will attempt to load the \"MySourceHandler\" class by looking in @INC for it in\nthis order:\n\nTAP::Parser::SourceHandler::MySourceHandler\nMySourceHandler\n\n\"croak\"s on error.\n\n\"makeiterator\"\nmy $iterator = $srcfactory->makeiterator( $source );\n\nGiven a TAP::Parser::Source, finds the most suitable TAP::Parser::SourceHandler to use to create\na TAP::Parser::Iterator (see \"detectsource\"). Dies on error.\n\n\"detectsource\"\nGiven a TAP::Parser::Source, detects what kind of source it is and returns *one*\nTAP::Parser::SourceHandler (the most confident one). Dies on error.\n\nThe detection algorithm works something like this:\n\nfor (@registeredhandlers) {\n# ask them how confident they are about handling this source\n$confidence{$handler} = $handler->canhandle( $source )\n}\n# choose the most confident handler\n\nTies are handled by choosing the first handler.\n"
                }
            ]
        },
        "SUBCLASSING": {
            "content": "Please see \"SUBCLASSING\" in TAP::Parser for a subclassing overview.\n",
            "subsections": [
                {
                    "name": "Example",
                    "content": "If we've done things right, you'll probably want to write a new source, rather than sub-classing\nthis (see TAP::Parser::SourceHandler for that).\n\nBut in case you find the need to...\n\npackage MyIteratorFactory;\n\nuse strict;\n\nuse base 'TAP::Parser::IteratorFactory';\n\n# override source detection algorithm\nsub detectsource {\nmy ($self, $rawsourceref, $meta) = @;\n# do detective work, using $meta and whatever else...\n}\n\n1;\n"
                }
            ]
        },
        "AUTHORS": {
            "content": "Steve Purkis\n",
            "subsections": []
        },
        "ATTRIBUTION": {
            "content": "Originally ripped off from Test::Harness.\n\nMoved out of TAP::Parser & converted to a factory class to support extensible TAP source\ndetective work by Steve Purkis.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "TAP::Object, TAP::Parser, TAP::Parser::SourceHandler, TAP::Parser::SourceHandler::File,\nTAP::Parser::SourceHandler::Perl, TAP::Parser::SourceHandler::RawTAP,\nTAP::Parser::SourceHandler::Handle, TAP::Parser::SourceHandler::Executable\n",
            "subsections": []
        }
    },
    "summary": "TAP::Parser::IteratorFactory - Figures out which SourceHandler objects to use for a given Source",
    "flags": [],
    "examples": [],
    "see_also": []
}