Sprog::GearMetadata.3pm

Langue: en

Version: 2005-07-02 (fedora - 01/12/10)

Section: 3 (Bibliothèques de fonctions)

NAME

Sprog::GearMetaData - Information about installed Sprog::Gear classes

DESCRIPTION

This class is responsible for auto-discovering installed gear classes and determining their attributes.

Querying the attributes of a class does not cause the class file to be compiled. Instead, each gear class is expected to start with a special metadata POD section, like this:

   package Sprog::Gear::Grep;
 
   =begin sprog-gear-metadata
 
     title: Pattern Match
     type_in: P
     type_out: P
     keywords: grep regex regular expression search
 
   =end sprog-gear-metadata
 
   =cut
 
 

A cache of metadata is maintained so that each gear class file only needs to be parsed once.

GEAR ATTRIBUTES

The following attributes can be defined in the metadata section:
title
Mandatory - defines the text which will appear on the gear.
type_in
Mandatory - the input connector type. One of:
   _ - no connector
   P - a 'Pipe' connector
   A - a 'List' connector
   H - a 'Record' connector
 
 
type_out
Mandatory - the output connector type. (Same values as above).
keywords
An optional list of keywords that describe the gears function. Used by the palette search function.
no_properties
An optional boolean which should be set to true (1) if the gear has no properties dialog. This will cause the properties option to be greyed out on the gear's right-click menu.
view_subclass
An optional attribute for defining a view (user interface) class for the gear. Rather than defining the whole class name, only the final component is required. For example, the Sprog::Gear::TextWindow gear sets this value to 'TextWindow' which gets translated to Sprog::GtkGearView::TextWindow.
custom_command_gear
This flag should be true for a gear created via the 'Make Command Gear' dialog and false otherwise.

CLASS METHODS

gear_class_info( class_name )

Given a full class name (eg: "Sprog::Gear::ReadFile"), this method returns a metadata object describing the class. Returns undef if the class does not exist or does not define the required metadata POD section.

search( input_connector_type, output_connector_type, keywords )

Returns a list of all classes matching the supplied arguments (all of which are optional). If no arguments are supplied, a list of all known gear classes will be returned.

The input and output connector type arguments should each be a single character as follows:

   * - accept any connector type (this is the default)
   _ - no connector at all (ie: input or output gears)
   P - a 'Pipe' connector
   A - a 'List' connector
   H - a 'Record' connector
 
 

The 'keywords' argument (if supplied) should be a string which will be used for a case-insensitive match against each gear's title and keywords attributes.

The list of gears returned will be those that match all three arguments (or as many as were supplied).

connector_types

This method returns a list of connector type names and the corresponding codes. It is intended to be used to build GUI widgets for selecting input and output connector types.

OBJECT METHODS

Each metadata object returned from "gear_class_info()" or "search()" will have the following (read-only) properties:

class

The class name for the gear (eg: "Sprog::Gear::ReadFile").

file

The pathname of the file which defines the class.

title

The human-readable name of the gear.

type_in

The type of the input connector ('_', 'P', 'A' or 'H').

type_out

The type of the output connector (same values as for "type_in").

keywords

A space separated string of keywords describing the gear.

view_subclass

The gear view subclass which implements the gear's user interface. Copyright 2004-2005 Grant McLean <grantm@cpan.org>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.