From: Darren Chamberlain Date: Tue, 6 May 2003 12:44:54 +0000 (+0000) Subject: Doc changes (use C<> instead of B<>) X-Git-Tag: v0.02~142 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5760246dbd9b3e03521df51b88801a3363fcf9da;p=dbsrgits%2FSQL-Translator.git Doc changes (use C<> instead of B<>) --- diff --git a/lib/SQL/Translator.pm b/lib/SQL/Translator.pm index 0687532..f99a4fc 100644 --- a/lib/SQL/Translator.pm +++ b/lib/SQL/Translator.pm @@ -1,7 +1,7 @@ package SQL::Translator; # ---------------------------------------------------------------------- -# $Id: Translator.pm,v 1.24 2003-04-24 16:15:58 kycl4rk Exp $ +# $Id: Translator.pm,v 1.25 2003-05-06 12:44:54 dlc Exp $ # ---------------------------------------------------------------------- # Copyright (C) 2003 Ken Y. Clark , # darren chamberlain , @@ -27,7 +27,7 @@ use vars qw( $VERSION $REVISION $DEFAULT_SUB $DEBUG $ERROR ); use base 'Class::Base'; $VERSION = '0.01'; -$REVISION = sprintf "%d.%02d", q$Revision: 1.24 $ =~ /(\d+)\.(\d+)/; +$REVISION = sprintf "%d.%02d", q$Revision: 1.25 $ =~ /(\d+)\.(\d+)/; $DEBUG = 0 unless defined $DEBUG; $ERROR = ""; @@ -657,7 +657,10 @@ sub load { my $module = do { my $m = shift; $m =~ s[::][/]g; "$m.pm" }; return 1 if $INC{$module}; - eval { require $module }; + eval { + require $module; + $module->import(@_); + }; return __PACKAGE__->error($@) if ($@); return 1; @@ -762,7 +765,7 @@ would use the Postgres parser and the Oracle producer. =head1 CONSTRUCTOR -The constructor is called B, and accepts a optional hash of options. +The constructor is called C, and accepts a optional hash of options. Valid options are: =over 4 @@ -803,12 +806,12 @@ advantage is gained by passing options to the constructor. =head1 METHODS -=head2 B +=head2 add_drop_table Toggles whether or not to add "DROP TABLE" statements just before the create definitions. -=head2 B +=head2 custom_translate Allows the user to override default translation of fields. For example, if a MySQL "text" field would normally be converted to a "long" for Oracle, @@ -816,26 +819,26 @@ the user could specify to change it to a "CLOB." Accepts a hashref where keys are the "from" value and values are the "to," returns the current value of the field. -=head2 B +=head2 no_comments Toggles whether to print comments in the output. Accepts a true or false value, returns the current value. -=head2 B +=head2 producer -The B method is an accessor/mutator, used to retrieve or +The C method is an accessor/mutator, used to retrieve or define what subroutine is called to produce the output. A subroutine defined as a producer will be invoked as a function (I) and passed 2 parameters: its container C instance and a data structure. It is expected that the function transform the data structure to a string. The C instance is provided for informational purposes; for example, the type of the parser can be -retrieved using the B method, and the B and -B methods can be called when needed. +retrieved using the C method, and the C and +C methods can be called when needed. When defining a producer, one of several things can be passed in: A -module name (e.g., C, a module name relative to -the C namespace (e.g., MySQL), a module +module name (e.g., C), a module name relative to +the C namespace (e.g., C), a module name and function combination (C), or a reference to an anonymous subroutine. If a full module name is passed in (for the purposes of this method, a string containing "::" @@ -844,8 +847,8 @@ function called "produce" will be invoked: C<$modulename::produce>. If $modulename cannot be loaded, the final portion is stripped off and treated as a function. In other words, if there is no file named F, C will attempt -to load F and use transmogrify as the name of -the function, instead of the default "produce". +to load F and use C as the name of +the function, instead of the default C. my $tr = SQL::Translator->new; @@ -864,12 +867,12 @@ the function, instead of the default "produce". # $subref->($tr, $data); $tr->producer(\&my_producer); -There is also a method named B, which is a string -containing the classname to which the above B function +There is also a method named C, which is a string +containing the classname to which the above C function belongs. In the case of anonymous subroutines, this method returns the string "CODE". -Finally, there is a method named B, which is both an +Finally, there is a method named C, which is both an accessor and a mutator. Arbitrary data may be stored in name => value pairs for the producer subroutine to access: @@ -879,8 +882,8 @@ pairs for the producer subroutine to access: # $pr_args is a hashref. -Extra data passed to the B method is passed to -B: +Extra data passed to the C method is passed to +C: $tr->producer("xSV", delimiter => ',\s*'); @@ -888,11 +891,11 @@ B: my $args = $tr->producer_args; my $delimiter = $args->{'delimiter'}; # value is ,\s* -=head2 B +=head2 parser -The B method defines or retrieves a subroutine that will be +The C method defines or retrieves a subroutine that will be called to perform the parsing. The basic idea is the same as that of -B (see above), except the default subroutine name is +C (see above), except the default subroutine name is "parse", and will be invoked as C<$module_name::parse($tr, $data)>. Also, the parser subroutine will be passed a string containing the entirety of the data to be parsed. @@ -910,10 +913,10 @@ entirety of the data to be parsed. return $dumper->Dump; }); -There is also B and B, which perform -analogously to B and B +There is also C and C, which perform +analogously to C and C -=head2 B +=head2 show_warnings Toggles whether to print warnings of name conflicts, identifier mutations, etc. Probably only generated by producers to let the user @@ -921,15 +924,15 @@ know when something won't translate very smoothly (e.g., MySQL "enum" fields into Oracle). Accepts a true or false value, returns the current value. -=head2 B +=head2 translate -The B method calls the subroutines referenced by the -B and B data members (described above). It accepts +The C method calls the subroutines referenced by the +C and C data members (described above). It accepts as arguments a number of things, in key => value format, including (potentially) a parser and a producer (they are passed directly to the -B and B methods). +C and C methods). -Here is how the parameter list to B is parsed: +Here is how the parameter list to C is parsed: =over @@ -967,12 +970,12 @@ You get the idea. =back -=head2 B, B +=head2 filename, data -Using the B method, the filename of the data to be parsed -can be set. This method can be used in conjunction with the B -method, below. If both the B and B methods are -invoked as mutators, the data set in the B method is used. +Using the C method, the filename of the data to be parsed +can be set. This method can be used in conjunction with the C +method, below. If both the C and C methods are +invoked as mutators, the data set in the C method is used. $tr->filename("/my/data/files/create.sql"); @@ -985,15 +988,15 @@ or: }; $tr->data(\$create_script); -B takes a string, which is interpreted as a filename. -B takes a reference to a string, which is used as the data to be +C takes a string, which is interpreted as a filename. +C takes a reference to a string, which is used as the data to be parsed. If a filename is set, then that file is opened and read when -the B method is called, as long as the data instance +the C method is called, as long as the data instance variable is not set. =pod -=head2 B +=head2 trace Turns on/off the tracing option of Parse::RecDescent.