annotate lib/IMPL/Test/Straps/ShellExecutor.pm @ 407:c6e90e02dd17 ref20150831

renamed Lib->lib
author cin
date Fri, 04 Sep 2015 19:40:23 +0300
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
407
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
1 package IMPL::Test::Straps::ShellExecutor;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
2 use strict;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
3 use warnings;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
4
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
5 use parent qw(IMPL::Object IMPL::Object::Serializable);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
6
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
7 if ($^O =~ /win32/i) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
8 require Win32::Console;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
9 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
10
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
11 sub Execute {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
12 my ($this,$file) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
13
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
14 my $h;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
15
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
16 if ($^O =~ /win32/i) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
17 Win32::Console::OutputCP(65001);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
18 unless ( open $h,'-|',$file ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
19 return undef;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
20 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
21 binmode $h,':encoding(utf-8)';
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
22 } else {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
23 unless ( open $h,'-|',$file ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
24 return undef;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
25 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
26 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
27
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
28 return $h;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
29 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
30
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
31
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
32 1;