Skip to content

Commit

Permalink
Merge pull request #20 from laouji/pr-challenge
Browse files Browse the repository at this point in the history
[cpan pull request challenge] patch for issue #8 & kwalitee fixes
  • Loading branch information
c9s committed Jul 26, 2015
2 parents 512eb76 + b922c12 commit 0d1d45e
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 9 deletions.
1 change: 1 addition & 0 deletions lib/Vimana/Installer/Auto.pm
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ sub find_files {



=encoding utf8
=head1 AUTHOR
Expand Down
12 changes: 6 additions & 6 deletions lib/Vimana/Installer/Text.pm
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ has script_type =>
is => 'rw';

sub read_text {
my $self =shift;
my $self = shift;
local $/;
open IN , "<" , $self->target;
my $text = <IN>;
close IN;
open my $fh , "<" , $self->target;
my $text = <$fh>;
close $fh;
return $text;
}

Expand All @@ -36,8 +36,8 @@ sub copy_to {
my ( $self , $path ) = @_;
my $src = $self->target;

my ( $v, $dir, $file ) = File::Spec->splitpath($path);
File::Path::mkpath [ $dir ];
my @dirs = File::Spec->splitdir($path);
File::Path::make_path( File::Spec->join(@dirs) );

my $ret = File::Copy::copy( $src => $path );
if( $ret ) {
Expand Down
4 changes: 2 additions & 2 deletions lib/Vimana/Manual.pm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
=begin
=begin MANUAL
=encoding utf8
Expand Down Expand Up @@ -110,4 +110,4 @@ under the same terms as Perl itself.
=cut

=cut
=end MANUAL
31 changes: 30 additions & 1 deletion t/01-installer.t
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/usr/bin/env perl
use warnings;
use strict;
use Test::More tests => 4;
use lib 'lib';
use Test::More tests => 6;
use File::Spec;

sub inst {
my $type = shift;
Expand All @@ -11,3 +13,30 @@ sub inst {

inst( $_ ) for qw(text makefile rakefile vimball);

{
my $tmpdir = File::Spec->tmpdir;
my $filename = 'hoge.vim';
my $target = File::Spec->join($tmpdir, $filename);

my $installer = Vimana::Installer->get_installer('text',
package_name => $filename,
target => $target,
runtime_path => $tmpdir,
);

my $file_content = "foo\nbar\nbaz";
open my $fh, '>', $target or die $!;
print $fh $file_content;
close $fh;

subtest "read_text" => sub {
is( $installer->read_text, $file_content, 'file content read ok' );
};

subtest "copy_to" => sub {
my $path = File::Spec->join($tmpdir, 'colors');
my $ret = $installer->copy_to($path);

ok( -e File::Spec->join( $path, $filename ), 'file copy ok' );
};
}
4 changes: 4 additions & 0 deletions t/pod.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
use Test::More;
eval "use Test::Pod 1.00";
plan skip_all => "Test::Pod 1.00 required for testing POD" if $@;
all_pod_files_ok();

0 comments on commit 0d1d45e

Please sign in to comment.