From a88993b997a4dac773a9415f8a31f263f41bc69b Mon Sep 17 00:00:00 2001
From: Nelo Onyiah <io1@sanger.ac.uk>
Date: Tue, 14 Apr 2009 00:37:16 +0100
Subject: [PATCH] Implemented the slurp method to be invoked on Str filenames:

my @contents = 'filename'.slurp();
---
 src/setting/Any-str.pm              |   10 ++++++++++
 t/01-sanity/10-filename-dot-slurp.t |   14 ++++++++++++++
 2 files changed, 24 insertions(+), 0 deletions(-)
 create mode 100644 t/01-sanity/10-filename-dot-slurp.t

diff --git a/src/setting/Any-str.pm b/src/setting/Any-str.pm
index 36fb931..a43c2aa 100644
--- a/src/setting/Any-str.pm
+++ b/src/setting/Any-str.pm
@@ -1,4 +1,14 @@
 class Any is also {
+    our List multi method slurp() is export {
+        my @contents;
+        try {
+            my $handle = open self;
+            @contents  = =$handle;
+            $handle.close;
+        }
+        $! ?? fail($!) !! return @contents;
+    }
+
     our Str multi method capitalize() is export {
         self.lc.subst(/\w+/, { .ucfirst }, :global)
     }
diff --git a/t/01-sanity/10-filename-dot-slurp.t b/t/01-sanity/10-filename-dot-slurp.t
new file mode 100644
index 0000000..a418376
--- /dev/null
+++ b/t/01-sanity/10-filename-dot-slurp.t
@@ -0,0 +1,14 @@
+use v6;
+use Test;
+
+plan 2;
+
+my $file     = %*ENV<RAKUDO_DIR>~'/README';
+my @expected = slurp($file); # use the IO::slurp() here
+my @observed = $file.slurp;  # they should work the same ...
+
+is(@observed.elems, @expected.elems, 'same number of elements');
+is_deeply(@observed, @expected, 'slurp works!');
+
+# plan * goes 1..0 -- me thinks that is wrong ... should be 0..0 if there were no tests
+# There must be a better way to test this as currently this requires RAKUDO_DIR to be set.
-- 
1.5.6.4

