08 Jun 2010 22:03:37 UTC
- Distribution: App-SimpleScan
- Module version: 3.01
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (0)
- Testers (2 / 57 / 0)
- KwaliteeBus factor: 1
- 68.91% Coverage
- License: unknown
- Activity24 month
- Download (53.79KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest versionMCMAHON Joe McMahonand 1 contributors
- Joe McMahon
- IMPORTANT NOTE
- Class methods
- Instance methods
- Pragma methods
- Input/output methods
- EXTENDING SIMPLESCAN
- PLUGIN SUMMARY
- CONFIGURATION AND ENVIRONMENT
- BUGS AND LIMITATIONS
- LICENCE AND COPYRIGHT
- DISCLAIMER OF WARRANTY
App::SimpleScan - simple_scan's core code
This document describes App::SimpleScan version 0.0.1
use App::SimpleScan; my $app = new App::SimpleScan; $app->go;
App::SimpleScanallows us to package the core of
simple_scanas a class; most importantly, this allows us to use
Module::Pluggableto write extensions to this application without directly modifying this module or this
The interfaces to this module are still evolving; plugin developers should monitor CPAN and look for new versions of this module. Henceforth, any change to the externals of this module will be denoted by a full version increase (e.g., from 0.34 to 1.00).
Creates a new instance of the application. Also invokes all of the basic setup so that when
gois called, all of the plugins are available and all callbacks are in place.
Executes the application. Calls the subsidiary methods to read input, parse it, do substitutions, and transform it into code; loads the plugins and any code filters which they wish to install.
After the code is created, it consults the command-line switches and runs the generated program, prints it, or both.
Transforms the input into code, and finalizes them, returning the actual test code (if any) to its caller.
Does all the work of transforming test specs into code, including processing substitutions, test specs, and pragmas, and handling substitutions.
Adds all of the Perl modules required to run the tests to the test code generated by this module. This includes any modules specified by plugins via the plugin's
Actually run the generated test code. Currently just
eval's the generated code.
Parses the command line and sets the corresponding fields in the
App::SimpleScanobject. See the section for more information.
This method initializes your
App::SimpleScanobject. It installs the standard options (--run, --generate, and --warn), installs any options defined by plugins, and then calls
parse_command_lineto actually parse the command line and set the options.
Plugin method - optional.
Installs an entry into the options description passed to
parse_command_lineis called. This automatically creates an accessor for the option. The option description(s) should conform to the requirements of
You may specify as many option descriptions as you like in a single call. Remember that your option definitions will cause a new method to be created for each option; be careful not to accidentally override a pre-existing method ... unless you want to do that, for whatever reason.
Set up the default assumptions for the application. Simply turns
runon if neither
This installs the standard pragmas (
agent). Checks each plugin for a
pragmasmethod and calls it to get the pragmas to be installed. In addition, if any pragmas are found, calls the corresponding plugin's
initmethod if it exists.
Provides access to pragma-processing code. Useful in plugins to get to the pragmas installed for the plugin concerned.
Reads the next line of input, handling the possibility that a plugin or substitution processing has stacked lines on the input queue to be read and processed (or perhaps reprocessed).
Core and plugin method - a useful line-parsing utility.
Expands single-quoted, double-quoted, and backticked items in a text string as follows:
single-quoted: remove the quotes and use the string as-is.
double-quoted: eval() the string in the current context and embed the result.
backquoted: evaluate the string as a shell command and embed the output.
Queues one or more lines of input ahead of the current "next line".
If no lines have been queued yet, simply adds the lines to the input queue. If there are existing lines in the input queue, lines passed to this routine are queued ahead of those lines, like this:
# Input queue = () # $app->queue_lines("save this") # # Input queue now = ("save this") # $app->queue_lines("this one", "another") # # input queue now = ("this one", "another", "save this")
This is done so that if a pragma queues lines which are other pragmas, these get processed before any other pending input does.
Save the object passed as the current test spec. If no argument is passed, deletes the current test spec object.
Retrieve the current test spec. Can be used to extract data from the parsed test spec.
Plugin and core method.
Current input line setter/getter. Can be used by plugins to look at the current line.
Plugin and core method.
Adds code to the final output without incrementing the number of tests. Does not go through code filters, and does not increment the test count.
Adds code to the final output and bumps the test count by one. The code passes through any plugin code filters.
Accessor that stores the test code generated during the run.
Plugins can add new command-line options by defining an
optionsclass method which returns a list of parameter/variable pairs, like those used to define options with
App::SimpleScanwill check for the
optionsmethod in your plugin when it is loaded, and call it to install your options automatically.
Plugins can install new pragmas by implementing a
pragmasclass method. This method should return a list of array references, with each array reference containing a pragma name and a code reference which will implement the pragma.
The actual pragma implementation will, when called by
transform_test_specs, receive a reference to the
App::SimpleScanobject and the arguments to the pragma (from the pragma line in the input) as a string of text. It is up to the pragma to parse the string; the use of
expand_backtickedis recommended for pragmas which take a variable number of arguments, and wish to adhere to the same syntax that standard substitutions use.
Standard plugin methods that App::SimpleScan will look for; none of these is required, though you should choose to implement the ones that you actually need.
initclass method is called by
App:SimpleScanwhen the plugin class is loaded; the
App::SimpleScanobject is suppled to allow the plugin to alter or add to the contents of the object. This allows plugins to export methods to the base class, or to add instance variables dynamically.
Note that the class passed in to this method is the class of the plugin, not of the caller (
App::SimpleScanor a derived class). You should use
caller()if you wish to export subroutines into the package corresponding to the base class object.
Defines any pragmas that this plugin implements. Returns a list of names and subroutine references. These will be called with a reference to the
Defines any code filters that this plugin wants to add to the output filter queue. These methods are called with a copy of the App::SimpleScan object and an array of code that is about to be stacked. The filter should return an array containing either the unaltered code, or the code with any changes the plugin sees fit to make.
If your filter wants to stack tests, it should call
stack_codeand increment the test count itself (by a call to test_count); trying to use
stack_testin a filter will cause it to be called again and again in an infinite recursive loop.
If your plugin generates code that requires other Perl modules, its test_modules class method should return an array of the names of these modules.
Defines options to be added to the command-line options. You should return an array of items that would be suitable for passing to
Getopt::Long, which is what we'll do with them.
Validate your options. You can access any of the variables you passed to
options; these will be initialized with whatever values
Getopt::Longgot from the command line. You should try to ignore invalid values and choose defaults for missing items if possible; if not, you should
diewith an appropriate message.
If a plugin wishes to read the input stream for its own purposes, it may do so by using
next_line. This returns either a string or undef (at end of file).
Adds lines to the input queue ahead of the next line to be read from whatever source is supplying them. This allows your plugin to process a line into multiple lines "in place".
Your pragma will probably use one of the following methods to output code:
A call to
stack_codewill cause the string passed back to be emitted immediately into the code stream. The test count will remain at its current value.
stack_testwill immediately emit the code supplied as its argument, and will increment the test count by one. You should use multiple calls to
stack_testif you need to stack more than one test.
Code passed to stack_test will go through all of the filters in the output filter queue; be careful to not call
stack_testin an output filter, as this will cause a recursive loop that will run you out of memory.
Returns the current App::SimpleScan::TestSpec object, if there is one. If code in your plugin is called when either we haven't read any lines yet, or the last line read was a pragma, there won't be any "current test spec".
Returns the actual text of the previous line read. Plugin code that does not specifically involve the current line (like output filters) may wish to look at the current line.
None as yet.
App::SimpleScan requires no configuration files or environment variables.
Module::Pluggable and WWW::Mechanize::Pluggable.
No bugs have been reported.
Please report any bugs or feature requests to
firstname.lastname@example.org, or through the web interface at http://rt.cpan.org.
Copyright (c) 2005, Joe McMahon
<email@example.com >. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
Module Install Instructions
To install App::SimpleScan, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install App::SimpleScan
For more information on module installation, please visit the detailed CPAN module installation guide.