File tree 6 files changed +66
-59
lines changed
6 files changed +66
-59
lines changed Original file line number Diff line number Diff line change 8
8
"depends" : [ " Slang::Tuxic" , " File::Temp" ],
9
9
"test-depends" : [ " Test" , " Test::META" ],
10
10
"provides" : {
11
- "Text::CSV" : " lib/Text/CSV.pm"
11
+ "Text::CSV" : " lib/Text/CSV.pm" ,
12
+ "IO::String" : " lib/IO/String.pm6"
12
13
},
13
14
"repo-type" : " git" ,
14
15
"source-url" : " git://github.com/Tux/CSV.git" ,
Original file line number Diff line number Diff line change
1
+ use Slang::Tuxic; # Need it for space before parenthesis
2
+
3
+ unit class IO::String is IO ::Handle;
4
+
5
+ has $ . nl-in is rw ;
6
+ has $ . nl-out is rw ;
7
+ has Bool $ . ro is rw is default (False );
8
+ has Str $ ! str ;
9
+ has Str @ ! content ;
10
+
11
+ # my $fh = IO::String.new ($foo);
12
+ multi method new (Str $ str ! is rw , * % init ) {
13
+ my \obj = self . new ($ str . Str , | % init );
14
+ obj. bind-str ($ str );
15
+ obj;
16
+ }
17
+
18
+ # my $fh = IO::String.new ("foo");
19
+ multi method new (Str $ str ! , * % init ) {
20
+ my \obj = self . bless ;
21
+ obj. nl-in = $ * IN . nl-in;
22
+ obj. nl-out = $ * OUT . nl-out;
23
+ obj. ro = % init <ro > if % init <ro >: exists ;
24
+ obj. nl-in = % init <nl-in > if % init <nl-in >: exists ;
25
+ obj. nl-out = % init <nl-out > if % init <nl-out >: exists ;
26
+ obj. print ($ str );
27
+ obj;
28
+ }
29
+
30
+ method bind-str (Str $ s is rw ) {
31
+ $ ! str := $ s ;
32
+ }
33
+
34
+ method print (* @ what ) {
35
+ if (my Str $ str = @ what . join (" " )) {
36
+ my Str @ x = $ str eq " " || ! $ . nl-in . defined
37
+ ?? $ str
38
+ !! | $ str . split ($ . nl-in , : v). map (-> $ a , $ b ? --> Str { $ a ~ ($ b // " " ) });
39
+ @ x . elems > 1 && @ x . tail eq " " and @ x . pop ;
40
+ @ ! content . push : | @ x ;
41
+ }
42
+ self ;
43
+ }
44
+
45
+ method print-nl {
46
+ self . print ($ . nl-out );
47
+ }
48
+
49
+ method get {
50
+ @ ! content ?? @ ! content . shift !! Str ;
51
+ }
52
+
53
+ method close {
54
+ $ ! str . defined && ! $ . ro and $ ! str = ~ self ;
55
+ }
56
+
57
+ method Str {
58
+ @ ! content . join (" " );
59
+ }
60
+
Original file line number Diff line number Diff line change 3
3
use v6.c ;
4
4
use Slang::Tuxic;
5
5
use File::Temp;
6
+ use IO ::String;
6
7
7
8
my $ VERSION = " 0.009" ;
8
9
@@ -99,65 +100,7 @@ sub progress (*@y) {
99
100
$ x . say ;
100
101
} # progress
101
102
102
- # I don't want this inside Text::CSV
103
- class IO::String is IO ::Handle {
104
-
105
- has $ . nl-in is rw ;
106
- has $ . nl-out is rw ;
107
- has Bool $ . ro is rw is default (False );
108
- has Str $ ! str ;
109
- has Str @ ! content ;
110
-
111
- # my $fh = IO::String.new ($foo);
112
- multi method new (Str $ str ! is rw , * % init ) {
113
- my \obj = self . new ($ str . Str , | % init );
114
- obj. bind-str ($ str );
115
- obj;
116
- }
117
-
118
- # my $fh = IO::String.new ("foo");
119
- multi method new (Str $ str ! , * % init ) {
120
- my \obj = self . bless ;
121
- obj. nl-in = $ * IN . nl-in;
122
- obj. nl-out = $ * OUT . nl-out;
123
- obj. ro = % init <ro > if % init <ro >: exists ;
124
- obj. nl-in = % init <nl-in > if % init <nl-in >: exists ;
125
- obj. nl-out = % init <nl-out > if % init <nl-out >: exists ;
126
- obj. print ($ str );
127
- obj;
128
- }
129
-
130
- method bind-str (Str $ s is rw ) {
131
- $ ! str := $ s ;
132
- }
133
-
134
- method print (* @ what ) {
135
- if (my Str $ str = @ what . join (" " )) {
136
- my Str @ x = $ str eq " " || ! $ . nl-in . defined
137
- ?? $ str
138
- !! | $ str . split ($ . nl-in , : v). map (-> $ a , $ b ? --> Str { $ a ~ ($ b // " " ) });
139
- @ x . elems > 1 && @ x . tail eq " " and @ x . pop ;
140
- @ ! content . push : | @ x ;
141
- }
142
- self ;
143
- }
144
-
145
- method print-nl {
146
- self . print ($ . nl-out );
147
- }
148
-
149
- method get {
150
- @ ! content ?? @ ! content . shift !! Str ;
151
- }
152
-
153
- method close {
154
- $ ! str . defined && ! $ . ro and $ ! str = ~ self ;
155
- }
156
103
157
- method Str {
158
- @ ! content . join (" " );
159
- }
160
- }
161
104
162
105
class RangeSet {
163
106
Original file line number Diff line number Diff line change 4
4
use Slang::Tuxic;
5
5
6
6
use Text::CSV;
7
+ use IO ::String;
7
8
use Test ;
8
9
9
10
my $ fh = IO ::String. new (q :to /EOC /);
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ use Slang::Tuxic;
5
5
6
6
use Test ;
7
7
use Text::CSV;
8
+ use IO ::String;
8
9
9
10
my Str $ efn ;
10
11
my Str @ rs = " \n " , " \r\n " , " \r " ;
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ use Slang::Tuxic;
5
5
6
6
use Test ;
7
7
use Text::CSV;
8
+ use IO ::String;
8
9
9
10
my $ csv = Text::CSV. new ;
10
11
my $ tfn = " _77test.csv" ;
You can’t perform that action at this time.
0 commit comments