Browse files

Checking in changes prior to tagging of version 0.10. Changelog diff is:

  • Loading branch information...
1 parent b0491bd commit a2414d79ef2f3786d557cf2533e54f8f0fac67c1 @sekimura committed Dec 5, 2008
Showing with 36 additions and 5 deletions.
  1. +5 −0 Changes
  2. +1 −0 MANIFEST
  3. +1 −1 Makefile.PL
  4. +14 −4 lib/LWP/UserAgent/WithCache.pm
  5. +15 −0 t/01_new.t
View
5 Changes
@@ -1,5 +1,10 @@
Revision history for Perl extension LWP::UserAgent::WithCache.
+0.10 Fri Dec 5 17:52:33 PST 2008
+ - RT:41474 fixed typo in PREREQ_PM
+ - RT:41475 SYNOPSIS: File::HomeDir->my_home insted of $HOME
+ - RT:41476 supported non-ref hash in the new() method
+
0.09 Thu Dec 4 19:27:11 PST 2008
- #41430 use File::HomdDir->my_home and to get the cache dir
View
1 MANIFEST
@@ -3,6 +3,7 @@ Makefile.PL
MANIFEST
README
t/00_compile.t
+t/01_new.t
t/10_request.t
lib/LWP/UserAgent/WithCache.pm
META.yml Module meta-data (added by MakeMaker)
View
2 Makefile.PL
@@ -5,6 +5,6 @@ WriteMakefile(
PREREQ_PM => {
LWP::UserAgent => 0,
Cache::FileCache => 0,
- File::HomeDIr => 0,
+ File::HomeDir => 0,
},
);
View
18 lib/LWP/UserAgent/WithCache.pm
@@ -8,7 +8,7 @@ use Cache::FileCache;
use File::HomeDir;
use File::Spec;
-our $VERSION = '0.09';
+our $VERSION = '0.10';
our %default_cache_args = (
'namespace' => 'lwp-cache',
@@ -17,8 +17,18 @@ our %default_cache_args = (
sub new {
my $class = shift;
- my $cache_opt = shift || {};
- my $self = $class->SUPER::new(@_);
+ my $cache_opt;
+ my %lwp_opt;
+ unless (scalar @_ % 2) {
+ %lwp_opt = @_;
+ for my $key (qw(namespace cache_root default_expires_in)) {
+ $cache_opt->{$key} = delete $lwp_opt{$key};
+ }
+ } else {
+ $cache_opt = shift || {};
+ %lwp_opt = @_;
+ }
+ my $self = $class->SUPER::new(%lwp_opt);
my %cache_args = (%default_cache_args, %$cache_opt);
$self->{cache} = Cache::FileCache->new(\%cache_args);
return $self
@@ -85,7 +95,7 @@ LWP::UserAgent::WithCache - LWP::UserAgent extension with local cache
use LWP::UserAgent::WithCache;
my %cache_opt = (
'namespace' => 'lwp-cache',
- 'cache_root' => "$HOME/.cache",
+ 'cache_root' => File::Spec->catfile(File::HomeDir->my_home, '.cache'),
'default_expires_in' => 600 );
my $ua = LWP::UserAgent::WithCache->new(\%cache_opt);
my $response = $ua->get('http://search.cpan.org/');
View
15 t/01_new.t
@@ -0,0 +1,15 @@
+use strict;
+use Test::More tests => 4;
+
+use LWP::UserAgent::WithCache;
+{
+my $ua = LWP::UserAgent::WithCache->new(namespace => 'other_cache_namespace', timeout => 99);
+is $ua->{cache}->get_namespace, 'other_cache_namespace';
+is $ua->timeout, 99;
+}
+
+{
+my $ua = LWP::UserAgent::WithCache->new({namespace => 'other_cache_namespace'}, timeout => 99);
+is $ua->{cache}->get_namespace, 'other_cache_namespace';
+is $ua->timeout, 99;
+}

0 comments on commit a2414d7

Please sign in to comment.