Skip to content

Commit

Permalink
Merge pull request #9 from aggrolite/Reddit-Client/find-files-unix-ho…
Browse files Browse the repository at this point in the history
…me-dir

expand unix tilde symbol to find session file in home directory
  • Loading branch information
sysread committed Mar 20, 2015
2 parents e837424 + 735c6f2 commit 369017d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ WriteMakefile(
'List::Util' => 0,
'LWP::UserAgent' => 0,
'URI::Encode' => 0,
'File::Path::Expand' => 1.02,
},

BUILD_REQUIRES => {
Expand Down
9 changes: 7 additions & 2 deletions lib/Reddit/Client.pm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use JSON qw//;
use File::Spec qw//;
use Digest::MD5 qw/md5_hex/;
use POSIX qw/strftime/;
use File::Path::Expand qw//;

require Reddit::Client::Account;
require Reddit::Client::Comment;
Expand Down Expand Up @@ -256,7 +257,9 @@ sub save_session {

# Prepare session and file path
my $session = { modhash => $self->{modhash}, cookie => $self->{cookie} };
my $file_path = defined $file ? $file : $self->{session_file};
my $file_path = File::Path::Expand::expand_filename(
defined $file ? $file : $self->{session_file}
);

DEBUG('Save session to %s', $file_path);

Expand All @@ -274,7 +277,9 @@ sub save_session {
sub load_session {
my ($self, $file) = @_;
$self->{session_file} || $file || croak 'Expected $file';
my $file_path = defined $file ? $file : $self->{session_file};
my $file_path = File::Path::Expand::expand_filename(
defined $file ? $file : $self->{session_file}
);

DEBUG('Load session from %s', $file_path);

Expand Down

0 comments on commit 369017d

Please sign in to comment.