r17815 - in /trunk/libsmart-comments-perl: Changes MANIFEST META.yml README debian/changelog lib/Smart/Comments.pm t/ENV_0.t t/ENV_1.t t/ENV_str.t t/assert.t t/message.t t/var.t
dmn at users.alioth.debian.org
dmn at users.alioth.debian.org
Tue Mar 18 15:02:50 UTC 2008
Author: dmn
Date: Tue Mar 18 15:02:49 2008
New Revision: 17815
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=17815
Log:
* New upstream release
Added:
trunk/libsmart-comments-perl/t/ENV_0.t
- copied unchanged from r17814, branches/upstream/libsmart-comments-perl/current/t/ENV_0.t
trunk/libsmart-comments-perl/t/ENV_1.t
- copied unchanged from r17814, branches/upstream/libsmart-comments-perl/current/t/ENV_1.t
trunk/libsmart-comments-perl/t/ENV_str.t
- copied unchanged from r17814, branches/upstream/libsmart-comments-perl/current/t/ENV_str.t
Modified:
trunk/libsmart-comments-perl/Changes
trunk/libsmart-comments-perl/MANIFEST
trunk/libsmart-comments-perl/META.yml
trunk/libsmart-comments-perl/README
trunk/libsmart-comments-perl/debian/changelog
trunk/libsmart-comments-perl/lib/Smart/Comments.pm
trunk/libsmart-comments-perl/t/assert.t
trunk/libsmart-comments-perl/t/message.t
trunk/libsmart-comments-perl/t/var.t
Modified: trunk/libsmart-comments-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsmart-comments-perl/Changes?rev=17815&op=diff
==============================================================================
--- trunk/libsmart-comments-perl/Changes (original)
+++ trunk/libsmart-comments-perl/Changes Tue Mar 18 15:02:49 2008
@@ -27,3 +27,13 @@
(thanks Jerrad)
- Added <now>, <here>, etc. timespace stamps (thanks Tomi)
+
+
+
+1.0.3 Fri Feb 22 17:25:30 2008
+
+ - Added -ENV config option (thanks Steven)
+
+ - Added doc note about -MSmart::Comments approach (thanks David)
+
+ - Smartened up vertical spacing of output (thanks Steve!)
Modified: trunk/libsmart-comments-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsmart-comments-perl/MANIFEST?rev=17815&op=diff
==============================================================================
--- trunk/libsmart-comments-perl/MANIFEST (original)
+++ trunk/libsmart-comments-perl/MANIFEST Tue Mar 18 15:02:49 2008
@@ -26,3 +26,6 @@
t/while.t
t/while_num.t
t/brackets.t
+t/ENV_0.t
+t/ENV_1.t
+t/ENV_str.t
Modified: trunk/libsmart-comments-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsmart-comments-perl/META.yml?rev=17815&op=diff
==============================================================================
--- trunk/libsmart-comments-perl/META.yml (original)
+++ trunk/libsmart-comments-perl/META.yml Tue Mar 18 15:02:49 2008
@@ -1,7 +1,7 @@
# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: Smart-Comments
-version: v1.0.2
+version: v1.0.3
version_from: lib/Smart/Comments.pm
installdirs: site
requires:
@@ -13,4 +13,4 @@
version: 0
distribution_type: module
-generated_by: ExtUtils::MakeMaker version 6.17
+generated_by: ExtUtils::MakeMaker version 6.30
Modified: trunk/libsmart-comments-perl/README
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsmart-comments-perl/README?rev=17815&op=diff
==============================================================================
--- trunk/libsmart-comments-perl/README (original)
+++ trunk/libsmart-comments-perl/README Tue Mar 18 15:02:49 2008
@@ -1,4 +1,4 @@
-Smart::Comments version 1.0.2
+Smart::Comments version 1.0.3
Smart comments provide an easy way to insert debugging and tracking code
into a program. They can report the value of a variable, track the
Modified: trunk/libsmart-comments-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsmart-comments-perl/debian/changelog?rev=17815&op=diff
==============================================================================
--- trunk/libsmart-comments-perl/debian/changelog (original)
+++ trunk/libsmart-comments-perl/debian/changelog Tue Mar 18 15:02:49 2008
@@ -1,11 +1,15 @@
-libsmart-comments-perl (1.0.2-2) UNRELEASED; urgency=low
+libsmart-comments-perl (1.0.3-1) UNRELEASED; urgency=low
+ [ gregor herrmann ]
* debian/control: Added: Vcs-Svn field (source stanza); Vcs-Browser
field (source stanza); Homepage field (source stanza). Removed: XS-
Vcs-Svn fields.
* debian/watch: use dist-based URL.
- -- gregor herrmann <gregor+debian at comodo.priv.at> Tue, 09 Oct 2007 22:31:53 +0200
+ [ Damyan Ivanov ]
+ * New upstream release
+
+ -- Damyan Ivanov <dmn at debian.org> Tue, 18 Mar 2008 17:01:14 +0200
libsmart-comments-perl (1.0.2-1) unstable; urgency=low
Modified: trunk/libsmart-comments-perl/lib/Smart/Comments.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsmart-comments-perl/lib/Smart/Comments.pm?rev=17815&op=diff
==============================================================================
--- trunk/libsmart-comments-perl/lib/Smart/Comments.pm (original)
+++ trunk/libsmart-comments-perl/lib/Smart/Comments.pm Tue Mar 18 15:02:49 2008
@@ -1,6 +1,6 @@
package Smart::Comments;
-use version; $VERSION = qv('1.0.2');
+use version; $VERSION = qv('1.0.3');
use warnings;
use strict;
@@ -35,16 +35,48 @@
# Implement comments-to-code source filter...
FILTER {
- shift;
+ shift; # Don't need the package name
s/\r\n/\n/g; # Handle win32 line endings
+ # Default introducer pattern...
my $intro = qr/#{3,}/;
- if (my @unknowns = grep {!/$intro/} @_) {
+
+ # Handle args...
+ my @intros;
+ while (@_) {
+ my $arg = shift @_;
+
+ if ($arg =~ m{\A -ENV \Z}xms) {
+ my $env = $ENV{Smart_Comments} || $ENV{SMART_COMMENTS}
+ || $ENV{SmartComments} || $ENV{SMARTCOMMENTS}
+ ;
+
+ return if !$env; # i.e. if no filtering
+
+ if ($env !~ m{\A \s* 1 \s* \Z}xms) {
+ unshift @_, split m{\s+|\s*:\s*}xms, $env;
+ }
+ }
+ else {
+ push @intros, $arg;
+ }
+ }
+
+ if (my @unknowns = grep {!/$intro/} @intros) {
croak "Incomprehensible arguments: @unknowns\n",
"in call to 'use Smart::Comments'";
}
- elsif (@_) {
- $intro = '(?-x:'.join('|', at _).')(?!\#)';
+
+ # Make non-default introducer pattern...
+ if (@intros) {
+ $intro = '(?-x:'.join('|', at intros).')(?!\#)';
+ }
+
+ # Preserve DATA handle if any...
+ if (s{ ^ __DATA__ \s* $ (.*) \z }{}xms) {
+ no strict qw< refs >;
+ my $DATA = $1;
+ open *{caller(1).'::DATA'}, '<', \$DATA or die "Internal error: $!";
}
# Progress bar on a for loop...
@@ -95,11 +127,11 @@
{Smart::Comments::_Dump(pref=>q{$1},var=>[$2]);$DBX}gmx;
# Dump an 'in progress' message
- s{ ^ $hws* $intro $hws* (.+ [.]{3}) \s* $ }
+ s{ ^ $hws* $intro $hws* (.+ [.]{3}) $hws* $ }
{Smart::Comments::_Dump(pref=>qq{$1});$DBX}gmx;
# Dump an unlabelled expression (the expression is used as the label)...
- s{ ^ $hws* $intro $hws* (.*) $optcolon \s* $ }
+ s{ ^ $hws* $intro $hws* (.*) $optcolon $hws* $ }
{Smart::Comments::_Dump(pref=>q{$1:},var=>Smart::Comments::_quiet_eval(q{[$1]}));$DBX}gmx;
# An empty comment dumps an empty line...
@@ -107,9 +139,8 @@
{warn qq{\n};}gmx;
# Anything else is a literal string to be printed...
- s{ ^ $hws* $intro \s* (.*) }
+ s{ ^ $hws* $intro $hws* (.*) }
{Smart::Comments::_Dump(pref=>q{$1});$DBX}gmx;
-
};
sub _quiet_eval {
@@ -136,7 +167,7 @@
_uniq extract_multiple($assertion, [\&extract_variable], undef, 1);
# Generate the test-and-report code...
- return qq{unless($assertion){warn "\\n", '### $assertion was not true';@vars; $fatal}};
+ return qq{unless($assertion){warn "\\n", q{### $assertion was not true};@vars; $fatal}};
}
# Generate progress-bar code for a Perlish for loop...
@@ -388,6 +419,10 @@
use Data::Dumper 'Dumper';
# Dump a variable and then reformat the resulting string more prettily...
+my $prev_STDOUT = 0;
+my $prev_STDERR = 0;
+my %prev_caller = ( file => q{}, line => 0 );
+
sub _Dump {
my %args = @_;
my ($pref, $varref, $nonl) = @args{qw(pref var nonl)};
@@ -398,12 +433,22 @@
$pref =~ s/<(?:here|place|where)>/"$file", line $line/g;
# Add a newline?
- my $nl = $nonl ? "" : "\n";
+ my @caller = caller;
+ my $spacer_required
+ = $prev_STDOUT != tell(*STDOUT)
+ || $prev_STDERR != tell(*STDERR)
+ || $prev_caller{file} ne $caller[1]
+ || $prev_caller{line} != $caller[2]-1;
+ $spacer_required &&= !$nonl;
+ @prev_caller{qw<file line>} = @caller[1,2];
# Handle a prefix with no actual variable...
if ($pref && !defined $varref) {
$pref =~ s/:$//;
- warn "$nl### $pref\n";
+ print STDERR "\n" if $spacer_required;
+ warn "### $pref\n";
+ $prev_STDOUT = tell(*STDOUT);
+ $prev_STDERR = tell(*STDERR);
return;
}
@@ -430,7 +475,10 @@
$dumped =~ s/^[ ]{$indent}([ ]*)/### $outdent$1/gm;
# Print the message...
- warn "$nl### $pref $dumped\n$nl";
+ print STDERR "\n" if $spacer_required;
+ warn "### $pref $dumped\n";
+ $prev_STDERR = tell(*STDERR);
+ $prev_STDOUT = tell(*STDOUT);
}
1; # Magic true value required at end of module
@@ -443,7 +491,7 @@
=head1 VERSION
-This document describes Smart::Comments version 1.0.2
+This document describes Smart::Comments version 1.0.3
=head1 SYNOPSIS
@@ -503,6 +551,14 @@
directive, replacing any smart comments with smart code that implements the
comments behaviour.
+
+If you're debugging an application you can also invoke it with the module from
+the command-line:
+
+ perl -MSmart::Comments $application.pl
+
+Of course, this only enables smart comments in the application file itself,
+not in any modules that the application loads.
You can also specify particular levels of smartness, by including one or more
markers as arguments to the C<use>:
@@ -919,7 +975,31 @@
=head1 CONFIGURATION AND ENVIRONMENT
-Smart::Comments requires no configuration files or environment variables.
+Smart::Comments can make use of an environment variable from your shell:
+C<Smart_Comments>. This variable can be specified either with a
+true/false value (i.e. 1 or 0) or with the same arguments as may be
+passed on the C<use> line when loading the module (see L<"INTERFACE">).
+The following table summarizes the behaviour:
+
+ Value of
+ $ENV{Smart_Comments} Equivalent Perl
+
+ 1 use Smart::Comments;
+ 0 no Smart::Comments;
+ '###:####' use Smart::Comments qw(### ####);
+ '### ####' use Smart::Comments qw(### ####);
+
+To enable the C<Smart_Comments> environment variable, you need to load the
+module with the C<-ENV> flag:
+
+ use Smart::Comments -ENV;
+
+Note that you can still specify other arguments in the C<use> statement:
+
+ use Smart::Comments -ENV, qw(### #####);
+
+In this case, the contents of the environment variable replace the C<-ENV> in
+the argument list.
=head1 DEPENDENCIES
Modified: trunk/libsmart-comments-perl/t/assert.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsmart-comments-perl/t/assert.t?rev=17815&op=diff
==============================================================================
--- trunk/libsmart-comments-perl/t/assert.t (original)
+++ trunk/libsmart-comments-perl/t/assert.t Tue Mar 18 15:02:49 2008
@@ -6,7 +6,7 @@
open *STDERR, '>', \$STDERR;
my $x = 0;
-### assert: $x < 1
+### assert: $x < '1'
ok length $STDERR == 0 => 'True assertion is silent';
@@ -57,3 +57,5 @@
ok length $STDERR != 0 => 'False two-part assertion is loud';
is $STDERR, $ASSERTION2 => 'False two-part assertion is loudly correct';
+
+
Modified: trunk/libsmart-comments-perl/t/message.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsmart-comments-perl/t/message.t?rev=17815&op=diff
==============================================================================
--- trunk/libsmart-comments-perl/t/message.t (original)
+++ trunk/libsmart-comments-perl/t/message.t Tue Mar 18 15:02:49 2008
@@ -12,9 +12,7 @@
my $expected = <<"END_MESSAGES";
#\## Testing 1...
-
#\## Testing 2...
-
#\## Testing 3...
END_MESSAGES
Modified: trunk/libsmart-comments-perl/t/var.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsmart-comments-perl/t/var.t?rev=17815&op=diff
==============================================================================
--- trunk/libsmart-comments-perl/t/var.t (original)
+++ trunk/libsmart-comments-perl/t/var.t Tue Mar 18 15:02:49 2008
@@ -16,20 +16,15 @@
my $expected = <<"END_MESSAGES";
#\## \$scalar: 'scalar value'
-
-
#\## \@array: [
#\## 1,
#\## 2,
#\## 3
#\## ]
-
-
#\## \%hash: {
#\## a => 'b',
#\## c => 'd'
#\## }
-
END_MESSAGES
is $STDERR, $expected => 'Simple variables work';
@@ -39,13 +34,14 @@
open *STDERR, '>', \$STDERR;
### scalars: $scalar
+
### arrays: @array
+
### and hashes too: %hash
my $expected2 = <<"END_MESSAGES";
#\## scalars: 'scalar value'
-
#\## arrays: [
#\## 1,
@@ -53,12 +49,10 @@
#\## 3
#\## ]
-
#\## and hashes too: {
#\## a => 'b',
#\## c => 'd'
#\## }
-
END_MESSAGES
is $STDERR, $expected2 => 'Labelled variables work';
More information about the Pkg-perl-cvs-commits
mailing list