Skip Menu |

This queue is for tickets about the Path-Iterator-Rule-RT CPAN distribution.

Report information
The Basics
Id: 93399
Status: open
Priority: 0/
Queue: Path-Iterator-Rule-RT

People
Owner: robert [...] robertblackwell.com
Requestors: SPACEBAT [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.01
Fixed in: (no value)



Subject: Build problems and assumptions
Hi Robert, I tried installing this module and ran into some problems - I haven't done anything with modules from the RT:: namespace before so my environment was relatively virgin in this regard. I ran into the following problems: * Path::Iterator::Rule was not a prereq * I had no ~/.rtrc file and failed test didn't tell me what file it failed to find So I figured I'd add the prereq, and allow for the config file to be a parameter at import time. However the config parsing and RT client construction were also happening at module load time so to support this I made them lazy. As that's a new feature I bumped the version. Now I can install the module without having ~/.rtrc in place, which is good, but now 00-load.t exercises slightly less code because the RT client is not constructed at import time. I'm not sure how to test the module more thorougly yet but thought I'd mention it. I'd also like to suggest that making all warnings fatal is not futureproof: http://www.modernperlbooks.com/mt/2014/01/fatal-warnings-are-a-ticking-time-bomb.html Cheers for the code, Andrew Kirkpatrick
Subject: Path-Iterator-Rule-RT-0.01-to-0.02.diff
diff -rubB Path-Iterator-Rule-RT-0.01/lib/Path/Iterator/Rule/RT.pm Path-Iterator-Rule-RT-0.02/lib/Path/Iterator/Rule/RT.pm --- Path-Iterator-Rule-RT-0.01/lib/Path/Iterator/Rule/RT.pm 2014-02-27 11:33:25.374416305 +1030 +++ Path-Iterator-Rule-RT-0.02/lib/Path/Iterator/Rule/RT.pm 2014-02-27 11:22:03.253580715 +1030 @@ -8,19 +8,47 @@ use Error qw(:try); use RT::Client::REST; use RT::Client::REST::Ticket; -my $config = parse_config_file( $ENV{HOME} . "/.rtrc" ); -my ( $username, $password, $server ) = + +my $config_file = $ENV{HOME} . "/.rtrc"; + +my $config; + +my $rt; + +sub import { + my $package = shift; + if (@_ % 2) { + die "${package}::import expects an even number of arguments, if any"; + } + my %args = @_; + if ($args{config_file}) { + $config_file = $args{config_file}; + } +} + +# lazy builder for the RT client in $rt and the configuration in $config +sub rt { + unless ($rt) { + $config = parse_config_file( $config_file ); + + my ( $username, $password, $server ) = ( $config->{user}, $config->{passwd}, $config->{server} ); -my $rt = RT::Client::REST->new( + + $rt = RT::Client::REST->new( server => $server, timeout => 30, -); -try { + ); + + try { $rt->login( username => $username, password => $password ); -} -catch Exception::Class::Base with { + } + catch Exception::Class::Base with { die "problem logging in: ", shift->message; -}; + }; + } + + return $rt; +} Path::Iterator::Rule->add_helper( "status" => sub { @@ -58,14 +86,16 @@ =head1 VERSION -Version 0.01 +Version 0.02 =cut -our $VERSION = '0.01'; +our $VERSION = '0.02'; =head1 SYNOPSIS + use Path::Iterator::Rule::RT; + my $rule = Path::Iterator::Rule->new; $rule->status("resolved"); for my $file ( $rule->all(@ARGV) ) { @@ -96,7 +126,7 @@ my $ticket; try { $ticket = RT::Client::REST::Ticket->new( - rt => $rt, + rt => rt(), id => $id, )->retrieve; } @@ -119,7 +149,7 @@ my $ticket; try { $ticket = RT::Client::REST::Ticket->new( - rt => $rt, + rt => rt(), id => $id, )->retrieve; } @@ -153,7 +183,7 @@ my $query = "id=$id AND "; $query .= $TicketSQL; - my @ids = $rt->search( + my @ids = rt()->search( type => 'ticket', query => $query, ); @@ -171,7 +201,7 @@ my ($file) = @_; local $_; - open( my $handle, '<', $file ) or die "$!"; + open( my $handle, '<', $file ) or die "Error opening '$file' for reading: $!"; while (<$handle>) { chomp; @@ -189,6 +219,15 @@ return \%cfg; } +=head1 IMPORT + +By default this module searches for RT client configuration in F<$HOME/.rtrc> + +You can override the location by importing the module like so + + use Path::Iterator::Rule::RT config_file => '/path/to/config/file'; + + =head1 AUTHOR Robert Blackwell, C<< <robert at robertblackwell.com> >> Only in Path-Iterator-Rule-RT-0.02: Makefile.old diff -rubB Path-Iterator-Rule-RT-0.01/Makefile.PL Path-Iterator-Rule-RT-0.02/Makefile.PL --- Path-Iterator-Rule-RT-0.01/Makefile.PL 2014-02-27 11:33:25.374416305 +1030 +++ Path-Iterator-Rule-RT-0.02/Makefile.PL 2014-02-27 11:18:18.406579349 +1030 @@ -6,6 +6,7 @@ 'VERSION_FROM' => 'lib/Path/Iterator/Rule/RT.pm', 'PREREQ_PM' => { 'RT::Client::REST' => '0.45', + 'Path::Iterator::Rule' => '1.008', 'Test::More' => 0 }, 'INSTALLDIRS' => 'site', diff -rubB Path-Iterator-Rule-RT-0.01/META.json Path-Iterator-Rule-RT-0.02/META.json --- Path-Iterator-Rule-RT-0.01/META.json 2014-02-27 11:33:25.374416305 +1030 +++ Path-Iterator-Rule-RT-0.02/META.json 2014-02-27 11:20:31.547619455 +1030 @@ -26,7 +26,8 @@ }, "runtime" : { "requires" : { - "RT::Client::REST" : "0.45" + "RT::Client::REST" : "0.45", + "Path::Iterator::Rule" : "1.008" } } }, @@ -42,5 +43,5 @@ "http://www.perlfoundation.org/artistic_license_2_0" ] }, - "version" : "0.01" + "version" : "0.02" } diff -rubB Path-Iterator-Rule-RT-0.01/META.yml Path-Iterator-Rule-RT-0.02/META.yml --- Path-Iterator-Rule-RT-0.01/META.yml 2014-02-27 11:33:25.374416305 +1030 +++ Path-Iterator-Rule-RT-0.02/META.yml 2014-02-27 11:20:48.151250335 +1030 @@ -16,9 +16,10 @@ provides: Path::Iterator::Rule::RT: file: lib/Path/Iterator/Rule/RT.pm - version: 0.01 + version: 0.02 requires: RT::Client::REST: 0.45 + Path::Iterator::Rule: 1.008 resources: license: http://www.perlfoundation.org/artistic_license_2_0 -version: 0.01 +version: 0.02
Subject: Re: [rt.cpan.org #93399] Build problems and assumptions
Date: Thu, 27 Feb 2014 09:13:37 -0500
To: bug-Path-Iterator-Rule-RT [...] rt.cpan.org
From: Robert Blackwell <robert [...] robertblackwell.com>
Andrew, Thank you for the patch. I have applied it and pushed it to PAUSE. Today I plan to get the repo up on github and off my gitlab install. I have more examples, features and tests to add but wanted to get it out of the dark sooner than later. Thanks Robert On Wed, Feb 26, 2014 at 8:20 PM, Andrew Kirkpatrick via RT <bug-Path-Iterator-Rule-RT@rt.cpan.org> wrote: Show quoted text
> Wed Feb 26 20:20:00 2014: Request 93399 was acted upon. > Transaction: Ticket created by SPACEBAT > Queue: Path-Iterator-Rule-RT > Subject: Build problems and assumptions > Broken in: 0.01 > Severity: Important > Owner: RBLACKWE > Requestors: SPACEBAT@cpan.org > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=93399 > > > > Hi Robert, > > I tried installing this module and ran into some problems - I haven't done anything with modules from the RT:: namespace before so my environment was relatively virgin in this regard. I ran into the following problems: > > * Path::Iterator::Rule was not a prereq > * I had no ~/.rtrc file and failed test didn't tell me what file it failed to find > > So I figured I'd add the prereq, and allow for the config file to be a parameter at import time. However the config parsing and RT client construction were also happening at module load time so to support this I made them lazy. > > As that's a new feature I bumped the version. > > Now I can install the module without having ~/.rtrc in place, which is good, but now 00-load.t exercises slightly less code because the RT client is not constructed at import time. I'm not sure how to test the module more thorougly yet but thought I'd mention it. > > I'd also like to suggest that making all warnings fatal is not futureproof: > http://www.modernperlbooks.com/mt/2014/01/fatal-warnings-are-a-ticking-time-bomb.html > > Cheers for the code, > Andrew Kirkpatrick > > diff -rubB Path-Iterator-Rule-RT-0.01/lib/Path/Iterator/Rule/RT.pm Path-Iterator-Rule-RT-0.02/lib/Path/Iterator/Rule/RT.pm > --- Path-Iterator-Rule-RT-0.01/lib/Path/Iterator/Rule/RT.pm 2014-02-27 11:33:25.374416305 +1030 > +++ Path-Iterator-Rule-RT-0.02/lib/Path/Iterator/Rule/RT.pm 2014-02-27 11:22:03.253580715 +1030 > @@ -8,19 +8,47 @@ > use Error qw(:try); > use RT::Client::REST; > use RT::Client::REST::Ticket; > -my $config = parse_config_file( $ENV{HOME} . "/.rtrc" ); > -my ( $username, $password, $server ) = > + > +my $config_file = $ENV{HOME} . "/.rtrc"; > + > +my $config; > + > +my $rt; > + > +sub import { > + my $package = shift; > + if (@_ % 2) { > + die "${package}::import expects an even number of arguments, if any"; > + } > + my %args = @_; > + if ($args{config_file}) { > + $config_file = $args{config_file}; > + } > +} > + > +# lazy builder for the RT client in $rt and the configuration in $config > +sub rt { > + unless ($rt) { > + $config = parse_config_file( $config_file ); > + > + my ( $username, $password, $server ) = > ( $config->{user}, $config->{passwd}, $config->{server} ); > -my $rt = RT::Client::REST->new( > + > + $rt = RT::Client::REST->new( > server => $server, > timeout => 30, > -); > -try { > + ); > + > + try { > $rt->login( username => $username, password => $password ); > -} > -catch Exception::Class::Base with { > + } > + catch Exception::Class::Base with { > die "problem logging in: ", shift->message; > -}; > + }; > + } > + > + return $rt; > +} > > Path::Iterator::Rule->add_helper( > "status" => sub { > @@ -58,14 +86,16 @@ > > =head1 VERSION > > -Version 0.01 > +Version 0.02 > > =cut > > -our $VERSION = '0.01'; > +our $VERSION = '0.02'; > > =head1 SYNOPSIS > > + use Path::Iterator::Rule::RT; > + > my $rule = Path::Iterator::Rule->new; > $rule->status("resolved"); > for my $file ( $rule->all(@ARGV) ) { > @@ -96,7 +126,7 @@ > my $ticket; > try { > $ticket = RT::Client::REST::Ticket->new( > - rt => $rt, > + rt => rt(), > id => $id, > )->retrieve; > } > @@ -119,7 +149,7 @@ > my $ticket; > try { > $ticket = RT::Client::REST::Ticket->new( > - rt => $rt, > + rt => rt(), > id => $id, > )->retrieve; > } > @@ -153,7 +183,7 @@ > my $query = "id=$id AND "; > $query .= $TicketSQL; > > - my @ids = $rt->search( > + my @ids = rt()->search( > type => 'ticket', > query => $query, > ); > @@ -171,7 +201,7 @@ > my ($file) = @_; > local $_; > > - open( my $handle, '<', $file ) or die "$!"; > + open( my $handle, '<', $file ) or die "Error opening '$file' for reading: $!"; > > while (<$handle>) { > chomp; > @@ -189,6 +219,15 @@ > return \%cfg; > } > > +=head1 IMPORT > + > +By default this module searches for RT client configuration in F<$HOME/.rtrc> > + > +You can override the location by importing the module like so > + > + use Path::Iterator::Rule::RT config_file => '/path/to/config/file'; > + > + > =head1 AUTHOR > > Robert Blackwell, C<< <robert at robertblackwell.com> >> > Only in Path-Iterator-Rule-RT-0.02: Makefile.old > diff -rubB Path-Iterator-Rule-RT-0.01/Makefile.PL Path-Iterator-Rule-RT-0.02/Makefile.PL > --- Path-Iterator-Rule-RT-0.01/Makefile.PL 2014-02-27 11:33:25.374416305 +1030 > +++ Path-Iterator-Rule-RT-0.02/Makefile.PL 2014-02-27 11:18:18.406579349 +1030 > @@ -6,6 +6,7 @@ > 'VERSION_FROM' => 'lib/Path/Iterator/Rule/RT.pm', > 'PREREQ_PM' => { > 'RT::Client::REST' => '0.45', > + 'Path::Iterator::Rule' => '1.008', > 'Test::More' => 0 > }, > 'INSTALLDIRS' => 'site', > diff -rubB Path-Iterator-Rule-RT-0.01/META.json Path-Iterator-Rule-RT-0.02/META.json > --- Path-Iterator-Rule-RT-0.01/META.json 2014-02-27 11:33:25.374416305 +1030 > +++ Path-Iterator-Rule-RT-0.02/META.json 2014-02-27 11:20:31.547619455 +1030 > @@ -26,7 +26,8 @@ > }, > "runtime" : { > "requires" : { > - "RT::Client::REST" : "0.45" > + "RT::Client::REST" : "0.45", > + "Path::Iterator::Rule" : "1.008" > } > } > }, > @@ -42,5 +43,5 @@ > "http://www.perlfoundation.org/artistic_license_2_0" > ] > }, > - "version" : "0.01" > + "version" : "0.02" > } > diff -rubB Path-Iterator-Rule-RT-0.01/META.yml Path-Iterator-Rule-RT-0.02/META.yml > --- Path-Iterator-Rule-RT-0.01/META.yml 2014-02-27 11:33:25.374416305 +1030 > +++ Path-Iterator-Rule-RT-0.02/META.yml 2014-02-27 11:20:48.151250335 +1030 > @@ -16,9 +16,10 @@ > provides: > Path::Iterator::Rule::RT: > file: lib/Path/Iterator/Rule/RT.pm > - version: 0.01 > + version: 0.02 > requires: > RT::Client::REST: 0.45 > + Path::Iterator::Rule: 1.008 > resources: > license: http://www.perlfoundation.org/artistic_license_2_0 > -version: 0.01 > +version: 0.02 >
On Thu Feb 27 09:13:53 2014, RBLACKWE wrote: Show quoted text
> I have more examples, features and tests to add but wanted to get it > out of the dark sooner than later.
Of course, release early, release often as they say. I always get a bit lost when preparing a patch, thinking I needed to diff whole directories and needed different names was part of the reason for the presumptuous version bump :) Good to read that there's a git repo. When I did update the version there were a few places to edit, Dist::Zilla helps with that. Feel free to close this ticket. Thanks, Andrew