Permalink
Browse files

tried to use handles, see S12

  • Loading branch information...
1 parent 4159178 commit 570c0e109eaab0d52d703b09b43cdfd8edf2a5fb @FROGGS committed Sep 14, 2012
Showing with 37 additions and 21 deletions.
  1. +28 −20 lib/File/Spec.pm
  2. +4 −0 lib/File/Spec/Guts.pm
  3. +3 −1 lib/File/Spec/Unix.pm
  4. +2 −0 t/01_unix.t
View
48 lib/File/Spec.pm
@@ -1,6 +1,8 @@
module File::Spec;
+use File::Spec::Guts;
+
my %module = (
'MacOS' => 'Mac',
'MSWin32' => 'Win32',
@@ -13,29 +15,35 @@ my %module = (
'cygwin' => 'Cygwin'
);
-my $module = "File::Spec::" ~ ($module{$*OS} // 'Unix');
+sub pck($os) {
+ warn $os;
+ my $module = "File::Spec::" ~ ($module{$*OS} // 'Unix');
+
+ require $module;
-require $module;
+ return ::($module).new;
+};
class File::Spec {
- method canonpath { ::($module).canonpath() }
- method catdir { ::($module).catdir() }
- method catfile { ::($module).catfile() }
- method curdir { ::($module).curdir() }
- method devnull { ::($module).devnull() }
- method rootdir { ::($module).rootdir() }
- method tmpdir { ::($module).tmpdir() }
- method updir { ::($module).updir() }
- method no_upwards { ::($module).no_upwards() }
- method case_tolerant { ::($module).case_tolerant() }
- method file_name_is_absolute { ::($module).file_name_is_absolute() }
- method path { ::($module).path() }
- method join { ::($module).join() }
- method splitpath { ::($module).splitpath() }
- method splitdir { ::($module).splitdir() }
- method catpath { ::($module).catpath() }
- method abs2rel { ::($module).abs2rel() }
- method rel2ab { ::($module).rel2ab() }
+ has $!fsg handles File::Spec::Guts = pck($*OS);
+# method canonpath { ::($module).canonpath() }
+# method catdir { ::($module).catdir() }
+# method catfile { ::($module).catfile() }
+ method curdir { $!fsg.curdir() }
+# method devnull { ::($module).devnull() }
+# method rootdir { ::($module).rootdir() }
+# method tmpdir { ::($module).tmpdir() }
+# method updir { ::($module).updir() }
+# method no_upwards { ::($module).no_upwards() }
+# method case_tolerant { ::($module).case_tolerant() }
+# method file_name_is_absolute { ::($module).file_name_is_absolute() }
+# method path { ::($module).path() }
+# method join { ::($module).join() }
+# method splitpath { ::($module).splitpath() }
+# method splitdir { ::($module).splitdir() }
+# method catpath { ::($module).catpath() }
+# method abs2rel { ::($module).abs2rel() }
+# method rel2ab { ::($module).rel2ab() }
}
1;
View
4 lib/File/Spec/Guts.pm
@@ -0,0 +1,4 @@
+
+module File::Spec::Guts;
+
+role File::Spec::Guts { * };
View
4 lib/File/Spec/Unix.pm
@@ -1,7 +1,9 @@
module File::Spec::Unix;
-class File::Spec::Unix {
+use File::Spec::Guts;
+
+class File::Spec::Unix does File::Spec::Guts {
method curdir {
'.'
}
View
2 t/01_unix.t
@@ -3,6 +3,8 @@ use lib 'lib';
use Test;
use File::Spec;
+File::Spec.new;
+
plan 4;
if $*OS ~~ any(<MacOS MSWin32 os2 VMS epoc NetWare symbian dos cygwin>) {

0 comments on commit 570c0e1

Please sign in to comment.