Skip to content

Commit

Permalink
mv tempdir function to Vimana::Util
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s committed Oct 22, 2009
1 parent da743bd commit a9f9e5f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
7 changes: 2 additions & 5 deletions lib/Vimana.pm
Expand Up @@ -14,11 +14,11 @@ Vimana - Vim script manager.
=head1 VERSION
Version 0.082
Version 0.083
=cut

our $VERSION = '0.082';
our $VERSION = '0.083';

=head1 DESCRIPTION
Expand Down Expand Up @@ -72,9 +72,6 @@ sub index {
return $INDEX;
}

sub tmpdir {
return "/tmp/vimana-" . join '',map { [ 'a' .. 'z' ]->[ int rand(26) ] } 1 .. 6;
}


=head1 AUTHOR
Expand Down
2 changes: 1 addition & 1 deletion lib/Vimana/AutoInstall.pm
Expand Up @@ -111,7 +111,7 @@ sub install_from_archive {
}
}

my $out = Vimana::tmpdir();
my $out = Vimana::Util::tempdir();
rmtree [ $out ] if -e $out;
mkpath [ $out ];
$logger->info("Temporary directory created: $out") if $options->{verbose};
Expand Down
2 changes: 1 addition & 1 deletion lib/Vimana/Command/Install.pm
Expand Up @@ -36,7 +36,7 @@ sub run {

my $page = Vimana::VimOnline::ScriptPage->fetch( $info->{script_id} );

my $dir = '/tmp' || Vimana::tmpdir();
my $dir = '/tmp' || Vimana::Util::tempdir();

my $url = $page->{download};
my $filename = $page->{filename};
Expand Down
4 changes: 4 additions & 0 deletions lib/Vimana/Util.pm
Expand Up @@ -14,6 +14,10 @@ sub canonical_script_name {
$name;
}

sub tempdir {
return "/tmp/vimana-" . join '',map { [ 'a' .. 'z' ]->[ int rand(26) ] } 1 .. 6;
}

sub get_mine_type {
my $type = File::Type->new->checktype_filename( $_[ 0 ] );
die "can not found file type from @{[ $_[0] ]}" unless $type;
Expand Down

0 comments on commit a9f9e5f

Please sign in to comment.