Toby Inkster avatar Toby Inkster committed e07c7da

more cross-platform file path handling

Comments (0)

Files changed (3)

 See https://bitbucket.org/tobyink/p5-app-cpantimes for the latest development.
 
+1.501804	2012-12-17
+	- more cross-platform technique to locate metabase_id.json
+
 1.501803	2012-12-17
 	- don't even attempt to send reports for local tarballs
 

lib/App/cpantimes.pm

 package App::cpantimes;
-our $VERSION = "1.501803";
+our $VERSION = "1.501804";
 
 =encoding utf8
 

lib/App/cpantimes/script.pm

 package App::cpantimes::script;
 
-our $VERSION = "1.501803";
+our $VERSION = "1.501804";
 
 use 5.008;
 use strict;
 use base 'App::cpanminus::script';
 
+my $HOME =
+	defined $ENV{HOME}     ? $ENV{HOME} :
+	defined $ENV{APPDATA}  ? $ENV{APPDATA} :
+	die("Could not determine home directory!");
+
 sub new
 {
 	my ($class, @args) = @_;
 	my $self = $class->SUPER::new(@args);
 	
 	$self->{_metabase_api}  = 'https://metabase.cpantesters.org/api/v1/';
-	$self->{_metabase_file} = "$ENV{HOME}/.cpantesters/metabase_id.json";
+	$self->{_metabase_file} = "File::Spec"->catfile(
+		$HOME,
+		qw< .cpantesters metabase_id.json >,
+	);
 
 	eval {
 		require Test::Reporter;
 	return 1 if $self->{notest};
 
 	my $oldlog  = $self->{log};
-	my $logfile = File::Spec->catfile($self->{home}, "test.log");
+	my $logfile = "File::Spec"->catfile($self->{home}, "test.log");
 	1 while unlink $logfile;
 
 	local $ENV{PERL_MM_USE_DEFAULT} = 1;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.