rio 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/ChangeLog +225 -0
  2. data/README +12 -0
  3. data/Rakefile +1 -1
  4. data/VERSION +1 -1
  5. data/doc/ANNOUNCE +160 -71
  6. data/doc/RELEASE_NOTES +71 -2
  7. data/ex/colx.rb +1 -1
  8. data/ex/passwd_report.rb +4 -8
  9. data/ex/riocat +5 -5
  10. data/ex/riogunzip +1 -1
  11. data/ex/riogzip +6 -6
  12. data/ex/rioprompt.rb +6 -0
  13. data/lib/rio.rb +3 -13
  14. data/lib/rio/arycopy.rb +1 -1
  15. data/lib/rio/base.rb +1 -5
  16. data/lib/rio/construct.rb +75 -0
  17. data/lib/rio/constructor.rb +42 -11
  18. data/lib/rio/context.rb +1 -1
  19. data/lib/rio/context/dir.rb +50 -23
  20. data/lib/rio/context/methods.rb +5 -3
  21. data/lib/rio/{cxdir.rb → context/skip.rb} +24 -36
  22. data/lib/rio/context/stream.rb +38 -16
  23. data/lib/rio/cp.rb +24 -5
  24. data/lib/rio/dir.rb +8 -7
  25. data/lib/rio/doc/HOWTO.rb +33 -33
  26. data/lib/rio/doc/INTRO.rb +416 -256
  27. data/lib/rio/doc/MISC.rb +3 -1
  28. data/lib/rio/doc/SYNOPSIS.rb +28 -33
  29. data/lib/rio/entrysel.rb +76 -9
  30. data/lib/rio/file.rb +2 -1
  31. data/lib/rio/filter.rb +95 -0
  32. data/lib/rio/filter/closeoneof.rb +1 -1
  33. data/lib/rio/grande.rb +0 -74
  34. data/lib/rio/if.rb +2 -1
  35. data/lib/rio/if/basic.rb +1 -1
  36. data/lib/rio/if/csv.rb +1 -1
  37. data/lib/rio/if/dir.rb +1 -220
  38. data/lib/rio/if/fileordir.rb +26 -12
  39. data/lib/rio/if/grande.rb +55 -6
  40. data/lib/rio/if/grande_entry.rb +355 -0
  41. data/lib/rio/if/{methods.rb → grande_stream.rb} +69 -88
  42. data/lib/rio/if/path.rb +25 -3
  43. data/lib/rio/if/stream.rb +62 -37
  44. data/lib/rio/if/temp.rb +2 -2
  45. data/lib/rio/if/test.rb +23 -0
  46. data/lib/rio/impl/path.rb +5 -0
  47. data/lib/rio/match.rb +6 -3
  48. data/lib/rio/matchrecord.rb +50 -46
  49. data/lib/rio/{filter/chomp.rb → ops/construct.rb} +12 -20
  50. data/lib/rio/ops/create.rb +3 -0
  51. data/lib/rio/ops/dir.rb +12 -6
  52. data/lib/rio/ops/either.rb +17 -3
  53. data/lib/rio/ops/path.rb +4 -1
  54. data/lib/rio/ops/stream/input.rb +6 -1
  55. data/lib/rio/ops/stream/read.rb +1 -3
  56. data/lib/rio/{context/chomp.rb → prompt.rb} +17 -13
  57. data/lib/rio/rl/base.rb +1 -1
  58. data/lib/rio/rl/builder.rb +3 -1
  59. data/lib/rio/state.rb +7 -13
  60. data/lib/rio/stream.rb +8 -5
  61. data/lib/rio/stream/open.rb +1 -1
  62. data/lib/rio/version.rb +1 -1
  63. data/test/mswin32.rb +1 -1
  64. data/test/runtests_gem.rb +1 -1
  65. data/test/tc/all.rb +3 -0
  66. data/test/tc/copy-from.rb +13 -13
  67. data/test/tc/copy-to.rb +1 -1
  68. data/test/tc/copy.rb +1 -1
  69. data/test/tc/copydir.rb +0 -24
  70. data/test/tc/copysymlink.rb +39 -0
  71. data/test/tc/csv.rb +2 -2
  72. data/test/tc/csv2.rb +4 -4
  73. data/test/tc/misc.rb +16 -16
  74. data/test/tc/nolines.rb +26 -26
  75. data/test/tc/noqae.rb +74 -74
  76. data/test/tc/overload.rb +28 -28
  77. data/test/tc/riorl.rb +36 -0
  78. data/test/tc/selnosel.rb +36 -0
  79. data/test/tc/skip.rb +58 -0
  80. data/test/tc/skiplines.rb +42 -0
  81. data/test/tc/symlink.rb +1 -1
  82. data/test/tc/symlink0.rb +1 -1
  83. data/test/tc/temp.rb +1 -1
  84. data/test/tc/tempdir.rb +1 -1
  85. data/test/tc/testcase.rb +7 -1
  86. metadata +14 -8
  87. data/lib/rio/matchcolumns.rb +0 -266
  88. data/lib/rio/rangemath.rb +0 -44
@@ -85,7 +85,7 @@ module RIO
85
85
  str
86
86
  end
87
87
  def bequeath()
88
- keys = %w[chomp closeoneof rename]
88
+ keys = %w[chomp strip closeoneof rename]
89
89
  q = {}
90
90
  p = {}
91
91
  ncx = Vars.new(q,p)
@@ -42,24 +42,66 @@ require 'rio/entrysel'
42
42
  module RIO
43
43
  module Cx
44
44
  module Methods
45
- def dir_iter?() cx.has_key?('sel') || cx.has_key?('nosel') end
45
+ def dir_iter?() cx.has_key?('entry_sel') end
46
46
 
47
47
  private
48
48
 
49
- def _addselkey(key,sym,*args)
50
- cx[key] ||= Match::Entry::Sels.new
51
- cx[key] << Match::Entry::List.new(sym,*args)
52
- self
53
- end
49
+ def _set_entry_sel_args(sel_type,*args)
50
+ #p callstr('_set_entry_sel_args',sel_type,*args)
54
51
 
52
+ es = (cx['entry_sel'] ||= {})
53
+ eargs = (es['args'] ||= {})
54
+ eargs[sel_type] ||= []
55
+ eargs[sel_type] += args
56
+ end
55
57
 
56
- def _set_select(ss_type,key,sym,*args,&block)
58
+ def _set_select(ss_type,*args,&block)
57
59
  cx['ss_type'] = ss_type
58
- _addselkey(key,sym,*args)
60
+ _set_entry_sel_args(ss_type,*args)
59
61
  return each(&block) if block_given?
60
62
  self
61
63
  end
62
64
 
65
+ def _selkey(sel_type)
66
+ #p callstr('_selkey',sel_type,skipping?)
67
+ if skipping?
68
+ cx['skipping'] = false
69
+ 'skip' + sel_type
70
+ else
71
+ sel_type
72
+ end
73
+ end
74
+ public
75
+
76
+ def entries(*args,&block)
77
+ _set_select(_selkey('entries'),*args,&block)
78
+ end
79
+ def files(*args,&block)
80
+ _set_select(_selkey('files'),*args,&block)
81
+ end
82
+ def dirs(*args,&block)
83
+ _set_select(_selkey('dirs'),*args,&block)
84
+ end
85
+
86
+ def skipentries(*args,&block)
87
+ _set_select('skipentries',*args,&block)
88
+ end
89
+ def skipfiles(*args,&block)
90
+ _set_select('skipfiles',*args,&block)
91
+ end
92
+ def skipdirs(*args,&block)
93
+ _set_select('skipdirs',*args,&block)
94
+ end
95
+
96
+ private
97
+
98
+ def _addselkey(key,sym,*args)
99
+ #p callstr('_addselkey',key,sym,*args)
100
+ cx[key] ||= Match::Entry::Sels.new
101
+ cx[key] << Match::Entry::List.new(sym,*args)
102
+ self
103
+ end
104
+
63
105
  public
64
106
 
65
107
  def recurse(*args,&block)
@@ -72,21 +114,6 @@ module RIO
72
114
  return each(&block) if block_given?
73
115
  self
74
116
  end
75
- def entries(*args,&block) _set_select('entries','sel',:true?,*args,&block) end
76
- def files(*args,&block) _set_select('files','sel',:file?,*args,&block) end
77
- def dirs(*args,&block) _set_select('dirs','sel',:dir?,*args,&block) end
78
-
79
- def noentries(*args,&block)
80
- _set_select('noentries','nosel',:true?,*args,&block)
81
- end
82
- def nofiles(*args,&block)
83
- _addselkey('sel',:file?) unless args.empty?
84
- _set_select('nofiles','nosel',:file?,*args,&block)
85
- end
86
- def nodirs(*args,&block)
87
- _addselkey('sel',:dir?) unless args.empty?
88
- _set_select('nodirs','nosel',:dir?,*args,&block)
89
- end
90
117
  end
91
118
  end
92
119
  end
@@ -40,19 +40,21 @@ require 'rio/iomode'
40
40
 
41
41
  require 'rio/context/stream'
42
42
  require 'rio/context/dir'
43
- require 'rio/context/chomp'
43
+ require 'rio/context/skip'
44
+ require 'rio/filter'
44
45
  require 'rio/context/closeoneof'
45
46
  require 'rio/context/gzip'
46
47
 
47
48
  module RIO
48
49
  module Cx #:nodoc: all
49
50
  module SS
50
- STREAM_KEYS = %w[records lines rows bytes nolines norows norecords nobytes]
51
- ENTRY_KEYS = %w[entries files dirs nofiles nodirs noentries]
51
+ STREAM_KEYS = %w[records lines rows bytes skiplines skiprows skiprecords nobytes]
52
+ ENTRY_KEYS = %w[entries files dirs skipfiles skipdirs skipentries]
52
53
  KEYS = ENTRY_KEYS + STREAM_KEYS
53
54
  end
54
55
  end
55
56
  end
57
+
56
58
  module RIO
57
59
  module Cx
58
60
  module Methods
@@ -35,45 +35,33 @@
35
35
  # The documented interface and behavior is subject to change without notice.</b>
36
36
 
37
37
 
38
+ require 'rio/context/cxx.rb'
39
+
38
40
  module RIO
39
- module CxDir #:nodoc: all
40
- private
41
-
42
- def _ss_keys() Cx::SS::ENTRY_KEYS + Cx::SS::STREAM_KEYS end
43
- CX_ALL_SKIP_KEYS = ['retrystate']
44
- def _add_recurse_iter_cx(ario)
45
- new_cx = ario.cx
46
- cx.keys.reject { |k| CX_ALL_SKIP_KEYS.include?(k) }.each { |k|
47
- new_cx.set_(k,cx[k])
48
- }
49
- ario.cx = new_cx
50
- ario
51
- end
52
- def _add_cx(ario,keys)
53
- new_cx = ario.cx
54
- keys.each {|k|
55
- next unless cx.has_key?(k)
56
- new_cx.set_(k,cx[k])
57
- }
58
- ario.cx = new_cx
59
- end
60
- CX_DIR_ITER_KEYS = %w[sel nosel]
61
- CX_STREAM_ITER_KEYS = %w[stream_rectype stream_itertype stream_sel stream_nosel]
62
- def _add_iter_cx(ario)
63
- if nostreamenum?
64
- _add_cx(ario,CX_DIR_ITER_KEYS)
41
+ module Cx
42
+ module Methods
43
+ def _arg_skip(args)
44
+ #p callstr('_arg_skip',args,cx.inspect)
45
+ cx['ss_skipped'] = cx['ss_type'].sub(/^skip/,'') if cx['ss_type']
46
+ cx['ss_type'] = 'skip'
47
+ cx['skip_args'] = args
65
48
  end
66
- _add_stream_iter_cx(ario)
67
- end
68
- def _add_stream_iter_cx(ario)
69
- _add_cx(ario,CX_STREAM_ITER_KEYS)
70
- new_cx = ario.cx
71
- if stream_iter?
72
- new_cx.set_('ss_args',cx['ss_args']) if cx.has_key?('ss_args')
73
- new_cx.set_('ss_type',cx['ss_type']) if cx.has_key?('ss_type')
49
+ def _noarg_skip
50
+ cx['ss_skipped'] = cx['ss_type'].sub(/^skip/,'') if cx['ss_type']
51
+ cx['ss_type'] = 'skip'
52
+ cx['skipping'] = true
53
+ end
54
+ def skipping?() cx['skipping'] end
55
+ def skip(*args,&block)
56
+ if args.empty?
57
+ _noarg_skip
58
+ else
59
+ _arg_skip(args)
60
+ end
61
+ each(&block) if block_given?
62
+ self
74
63
  end
75
- ario.cx = new_cx
76
- ario
64
+
77
65
  end
78
66
  end
79
67
  end
@@ -72,6 +72,7 @@ module RIO
72
72
  else cx.set_('stream_itertype',rt)
73
73
  end
74
74
  end
75
+
75
76
  def _set_selargs(sa,sel=true,&block)
76
77
  key = (sel ? 'stream_sel' : 'stream_nosel')
77
78
  cx[key] = sa
@@ -96,52 +97,73 @@ module RIO
96
97
  _set_selargs(args,sel,&block)
97
98
  end
98
99
 
100
+ def _sel()
101
+ !skipping?
102
+ end
103
+ def _sel_key(key)
104
+ (skipping? ? 'skip'+key : key)
105
+ end
99
106
  public
100
107
 
101
108
  def lines(*args,&block)
102
109
  #p callstr('lines',*args)
103
- _set_sstype('lines')
104
- _lines(args,&block)
110
+ if skipping?
111
+ cx['skipping'] = false
112
+ skiplines(*args,&block)
113
+ else
114
+ _set_sstype('lines')
115
+ _lines(args,_sel,&block)
116
+ end
105
117
  end
106
118
  def lines_(*args,&block)
107
119
  #p callstr('lines_',*args)
108
120
  _set_sstype('lines',false)
109
- _lines(args,true,false,&block)
121
+ _lines(args,_sel,false,&block)
110
122
  end
111
123
 
112
124
  def records(*args,&block)
113
- _set_sstype('records')
114
- _records(args,&block)
125
+ if skipping?
126
+ cx['skipping'] = false
127
+ skiprecords(*args,&block)
128
+ else
129
+ _set_sstype('records')
130
+ _records(args,_sel,&block)
131
+ end
115
132
  end
116
133
  def records_(*args,&block)
117
134
  _set_sstype('records',false)
118
- _records(args,true,false,&block)
135
+ _records(args,_sel,false,&block)
119
136
  end
120
137
 
121
138
  def rows(*args,&block)
122
- _set_sstype('rows')
123
- _rows(args,&block)
139
+ if skipping?
140
+ cx['skipping'] = false
141
+ skiprows(*args,&block)
142
+ else
143
+ _set_sstype('rows')
144
+ _rows(args,_sel,&block)
145
+ end
124
146
  end
125
147
  def rows_(*args,&block)
126
148
  _set_sstype('rows',false)
127
- _rows(args,true,false,&block)
149
+ _rows(args,_sel,false,&block)
128
150
  end
129
151
 
130
152
 
131
- def nolines(*args,&block)
132
- #p callstr('nolines',*args)
153
+ def skiplines(*args,&block)
154
+ #p callstr('skiplines',*args)
133
155
  self.lines() unless args.empty? or cx.has_key?('stream_sel')
134
- _set_sstype('nolines')
156
+ _set_sstype('skiplines')
135
157
  _lines(args,false,&block)
136
158
  end
137
- def norecords(*args,&block)
159
+ def skiprecords(*args,&block)
138
160
  self.records() unless args.empty? or cx.has_key?('stream_sel')
139
- _set_sstype('norecords')
161
+ _set_sstype('skiprecords')
140
162
  _records(args,false,&block)
141
163
  end
142
- def norows(*args,&block)
164
+ def skiprows(*args,&block)
143
165
  self.rows() unless args.empty? or cx.has_key?('stream_sel')
144
- _set_sstype('norows')
166
+ _set_sstype('skiprows')
145
167
  _rows(args,false,&block)
146
168
  end
147
169
 
@@ -79,7 +79,6 @@ module RIO
79
79
  module Output
80
80
  include InOut
81
81
 
82
-
83
82
  protected
84
83
 
85
84
  def cpfrom_obj_(obj)
@@ -119,7 +118,10 @@ module RIO
119
118
  self
120
119
  }
121
120
  end
121
+ alias :copy_to :>
122
+ alias :append_to :>>
122
123
  private
124
+
123
125
  def _cpto_rio(arg,sym)
124
126
  ario = ensure_rio(arg)
125
127
  ario = ario.join(self.filename) if ario.dir?
@@ -132,10 +134,13 @@ module RIO
132
134
  }
133
135
  end
134
136
  end
137
+
135
138
  module Output
136
139
  include Util::Output
137
140
  def <<(arg) cpclose { _cpfrom(arg) } end
138
141
  def <(arg) cpclose { _cpfrom(arg) } end
142
+ alias :copy_from :<
143
+ alias :append_from :<<
139
144
 
140
145
  private
141
146
 
@@ -164,6 +169,8 @@ module RIO
164
169
  include Util::Output
165
170
  def <(arg) cpclose { self.iostate(:<) < arg } end
166
171
  def <<(arg) cpclose { self.iostate(:<<) << arg } end
172
+ alias :copy_from :<
173
+ alias :append_from :<<
167
174
  end
168
175
  module Input
169
176
  include Util::Input
@@ -173,6 +180,8 @@ module RIO
173
180
  def >>(arg)
174
181
  spcp(arg) || cpclose(arg) { self.iostate(:>>) >> arg }
175
182
  end
183
+ alias :copy_to :>
184
+ alias :append_to :>>
176
185
  def copy_as_file?(arg)
177
186
  arg.kind_of?(Rio) and arg.scheme == 'ftp'
178
187
  end
@@ -184,7 +193,6 @@ module RIO
184
193
  nil
185
194
  end
186
195
  end
187
- alias :copy :>
188
196
  end
189
197
  end
190
198
  end
@@ -196,12 +204,15 @@ module RIO
196
204
  include Util::Output
197
205
  def <(arg) cpclose { self.iostate(:<) < arg } end
198
206
  def <<(arg) cpclose { self.iostate(:<<) << arg } end
207
+ alias :copy_from :<
208
+ alias :append_from :<<
199
209
  end
200
210
  module Input
201
211
  include Util::Input
202
212
  def >(arg) cpclose(arg) { self.iostate(:>) > arg } end
203
213
  def >>(arg) cpclose(arg) { self.iostate(:>>) >> arg } end
204
- alias :copy :>
214
+ alias :copy_to :>
215
+ alias :append_to :>>
205
216
  end
206
217
  end
207
218
  end
@@ -213,6 +224,8 @@ module RIO
213
224
  include Util::Output
214
225
  def <<(arg) _cpfrom(arg); self end
215
226
  def <(arg) _cpfrom(arg); self end
227
+ alias :copy_from :<
228
+ alias :append_from :<<
216
229
 
217
230
  private
218
231
 
@@ -225,7 +238,10 @@ module RIO
225
238
  def _cpfrom_rio(ario)
226
239
  #p callstr('_cpfrom_rio',ario)
227
240
  dest = self.join(ario.filename)
228
- if ario.dir?
241
+ case
242
+ when ario.symlink?
243
+ ::File.symlink(ario.readlink.to_s,dest.to_s)
244
+ when ario.dir?
229
245
  dest.mkdir
230
246
  ario.nostreamenum.each do |el|
231
247
  dest < el
@@ -251,7 +267,8 @@ module RIO
251
267
  end
252
268
  self
253
269
  end
254
- alias :copy :>
270
+ alias :copy_to :>
271
+ alias :append_to :>>
255
272
 
256
273
  private
257
274
 
@@ -284,6 +301,8 @@ module RIO
284
301
  _cpsrc(arg) << arg
285
302
  end
286
303
  end
304
+ alias :copy_from :<
305
+ alias :append_from :<<
287
306
 
288
307
  private
289
308
 
@@ -115,9 +115,9 @@ module RIO
115
115
  cx['retrystate'] = nil
116
116
  self
117
117
  end
118
-
119
- def close_()
120
- #p callstr('close_')+" ioh=#{self.ioh} open?=#{open?}"
118
+
119
+ def close_()
120
+ #p callstr('close_')+" ioh=#{self.ioh} open?=#{open?}"
121
121
  return self unless self.open?
122
122
  self.clear_selection
123
123
  self.ioh.close
@@ -126,11 +126,12 @@ module RIO
126
126
  self
127
127
  end
128
128
  protected :close_
129
-
129
+
130
+ CX_ENTRY_SEL_KEYS = %w[nostreamenum entry_sel skip_args ss_skipped]
130
131
  def clear_selection()
131
- cx.delete('sel')
132
- cx.delete('nosel')
133
- cx.delete('nostreamenum')
132
+ CX_ENTRY_SEL_KEYS.each { |k|
133
+ cx.delete(k)
134
+ }
134
135
  self
135
136
  end
136
137
 
@@ -53,7 +53,7 @@ IO, File, Dir, Pathname, FileUtils, Tempfile, StringIO, OpenURI, Zlib, and CSV.
53
53
 
54
54
  * Read a file into a string.
55
55
  # method 1
56
- string = ario.slurp
56
+ string = ario.contents
57
57
  # method 2
58
58
  ario > string
59
59
 
@@ -61,7 +61,7 @@ IO, File, Dir, Pathname, FileUtils, Tempfile, StringIO, OpenURI, Zlib, and CSV.
61
61
  # method 1
62
62
  ario >> string
63
63
  # method 2
64
- string += ario.slurp
64
+ string += ario.contents
65
65
 
66
66
  * Read lines of a file into an array
67
67
  # method 1
@@ -111,13 +111,13 @@ IO, File, Dir, Pathname, FileUtils, Tempfile, StringIO, OpenURI, Zlib, and CSV.
111
111
  # method 1
112
112
  rio('afile.gz').gzip > string
113
113
  # method 2
114
- string = rio('afile.gz').gzip.slurp
114
+ string = rio('afile.gz').gzip.contents
115
115
 
116
116
  * Append a gzipped file into a string
117
117
  # method 1
118
118
  rio('afile.gz').gzip >> string
119
119
  # method 2
120
- string += rio('afile.gz').gzip.slurp
120
+ string += rio('afile.gz').gzip.contents
121
121
 
122
122
  * Iterate through all the lines of a file
123
123
  # method 1
@@ -132,7 +132,7 @@ IO, File, Dir, Pathname, FileUtils, Tempfile, StringIO, OpenURI, Zlib, and CSV.
132
132
  rio('afile.gz').gzip { |line| ... }
133
133
 
134
134
  * Iterate through all non-empty lines of a gzipped file, with each line chomped
135
- rio('afile.gz').gzip.chomp.nolines(:empty?) { |line| ... }
135
+ rio('afile.gz').gzip.chomp.skiplines(:empty?) { |line| ... }
136
136
 
137
137
  * Iterate through the first 100 lines of a file
138
138
  # method 1
@@ -142,7 +142,7 @@ IO, File, Dir, Pathname, FileUtils, Tempfile, StringIO, OpenURI, Zlib, and CSV.
142
142
  rio('afile.rb.gz').gzip.lines(0,/^\s*#/) { |line| ... }
143
143
 
144
144
  * Iterate through the lines of a ruby file that are neither empty nor comments, with all lines chomped
145
- rio('afile.rb.gz').chomp.nolines(/^\s*#/,:empty?) { |line| ... }
145
+ rio('afile.rb.gz').chomp.skiplines(/^\s*#/,:empty?) { |line| ... }
146
146
 
147
147
  * Read all the comment lines from a ruby file into an array with all lines chomped
148
148
  # method 1
@@ -155,7 +155,7 @@ IO, File, Dir, Pathname, FileUtils, Tempfile, StringIO, OpenURI, Zlib, and CSV.
155
155
  # method 1
156
156
  ario.chomp.lines(proc{ |line| line.length <= 1024}) > array
157
157
  # method 2
158
- array = ario.chomp.nolines[proc{ |line| line.length > 1024}]
158
+ array = ario.chomp.skiplines[proc{ |line| line.length > 1024}]
159
159
  # method 3
160
160
  array = ario.chomp.lines(proc{ |line| line.length <= 1024}).to_a
161
161
 
@@ -240,21 +240,21 @@ IO, File, Dir, Pathname, FileUtils, Tempfile, StringIO, OpenURI, Zlib, and CSV.
240
240
  # method 2
241
241
  array = ario.lines[proc{ |l| l.length > 128}]
242
242
  # method 3
243
- array = ario.nolines[proc{ |l| l.length <= 128}]
243
+ array = ario.skiplines[proc{ |l| l.length <= 128}]
244
244
 
245
245
  * Copy all lines that do not start with 'zippy' into another file
246
246
  # method 1
247
- ario.nolines(/^zippy/) > rio('another_file')
247
+ ario.skiplines(/^zippy/) > rio('another_file')
248
248
  # method 2
249
- ario.lines.nolines(/^zippy/) > rio('another_file')
249
+ ario.lines.skiplines(/^zippy/) > rio('another_file')
250
250
  # method 3
251
- rio('another_file') < ario.nolines(/^zippy/)
251
+ rio('another_file') < ario.skiplines(/^zippy/)
252
252
 
253
253
  * Copy the first 10 lines and lines starting with 'zippy', but exclude any lines longer than 128 bytes
254
254
  # method 1
255
- ario.lines(0...10,/^zippy/).nolines(proc{ |l| l.length > 128}] > rio('another_file')
255
+ ario.lines(0...10,/^zippy/).skiplines(proc{ |l| l.length > 128}] > rio('another_file')
256
256
  # method 2
257
- rio('another_file') < ario.lines(0...10,/^zippy/).nolines(proc{ |l| l.length > 128})
257
+ rio('another_file') < ario.lines(0...10,/^zippy/).skiplines(proc{ |l| l.length > 128})
258
258
 
259
259
 
260
260
 
@@ -313,19 +313,19 @@ IO, File, Dir, Pathname, FileUtils, Tempfile, StringIO, OpenURI, Zlib, and CSV.
313
313
 
314
314
  * Put all files excluding those that are symlinks to files in an array
315
315
  # method 1
316
- array = ario.nofiles[:symlink?]
316
+ array = ario.skipfiles[:symlink?]
317
317
  # method 2
318
- array = ario.nofiles(:symlink?).files[]
318
+ array = ario.skipfiles(:symlink?).files[]
319
319
  # method 3
320
- array = ario.nofiles(:symlink?).to_a
320
+ array = ario.skipfiles(:symlink?).to_a
321
321
  # method 4
322
- array = ario.files.nofiles[:symlink?]
322
+ array = ario.files.skipfiles[:symlink?]
323
323
 
324
324
  * Put all entries that are not files (or symlinks to files) into an array
325
325
  # method 1
326
- array = ario.nofiles[]
326
+ array = ario.skipfiles[]
327
327
  # method 2
328
- array = ario.nofiles.to_a
328
+ array = ario.skipfiles.to_a
329
329
 
330
330
  * Put all entries that are symlinks to files into an array
331
331
  # method 1
@@ -335,15 +335,15 @@ IO, File, Dir, Pathname, FileUtils, Tempfile, StringIO, OpenURI, Zlib, and CSV.
335
335
 
336
336
  * Put all directories except those named '.svn' into an array
337
337
  # method 1
338
- array = ario.nodirs['.svn']
338
+ array = ario.skipdirs['.svn']
339
339
  # method 2
340
- array = ario.nodirs[/^\.svn/]
340
+ array = ario.skipdirs[/^\.svn/]
341
341
  # method 3
342
- array = ario.nodirs('.svn').to_a
342
+ array = ario.skipdirs('.svn').to_a
343
343
  # method 4
344
- array = ario.nodirs('.svn').dirs[]
344
+ array = ario.skipdirs('.svn').dirs[]
345
345
  # method 5
346
- array = ario.nodirs('.svn')[]
346
+ array = ario.skipdirs('.svn')[]
347
347
 
348
348
 
349
349
  ---
@@ -359,7 +359,7 @@ IO, File, Dir, Pathname, FileUtils, Tempfile, StringIO, OpenURI, Zlib, and CSV.
359
359
  # method 2
360
360
  rio('dstfile') < rio('srcfile')
361
361
  # method 3
362
- rip('dstfile').print!(rio('srcfile').slurp)
362
+ rip('dstfile').print!(rio('srcfile').contents)
363
363
 
364
364
  * Append the contents of one file to another file
365
365
  # method 1
@@ -367,7 +367,7 @@ IO, File, Dir, Pathname, FileUtils, Tempfile, StringIO, OpenURI, Zlib, and CSV.
367
367
  # method 2
368
368
  rio('dstfile') << rio('srcfile')
369
369
  # method 3
370
- rip('dstfile').a.print!(rio('srcfile').slurp)
370
+ rip('dstfile').a.print!(rio('srcfile').contents)
371
371
 
372
372
  * Copy the first 10 lines of one file to another file
373
373
  # method 1
@@ -389,7 +389,7 @@ IO, File, Dir, Pathname, FileUtils, Tempfile, StringIO, OpenURI, Zlib, and CSV.
389
389
  # method 2
390
390
  rio('afile') < rio('http://ruby-doc.org/')
391
391
  # method 3
392
- rio('afile').print!(rio('http://ruby-doc.org/').slurp)
392
+ rio('afile').print!(rio('http://ruby-doc.org/').contents)
393
393
 
394
394
  * Append the output of the daytime server running on the localhost to a file
395
395
  # method 1
@@ -416,7 +416,7 @@ IO, File, Dir, Pathname, FileUtils, Tempfile, StringIO, OpenURI, Zlib, and CSV.
416
416
  # method 2
417
417
  rio('afile.gz').gzip < rio('afile')
418
418
  # method 3
419
- rio('afile.gz').gzip.print!( rio('afile').slurp )
419
+ rio('afile.gz').gzip.print!( rio('afile').contents )
420
420
 
421
421
  * Create an ungzipped copy of a gzipped file
422
422
  # method 1
@@ -424,7 +424,7 @@ IO, File, Dir, Pathname, FileUtils, Tempfile, StringIO, OpenURI, Zlib, and CSV.
424
424
  # method 2
425
425
  rio('afile.gz').gzip > rio('afile')
426
426
  # method 3
427
- rio('afile').print!( rio('afile.gz').gzip.slurp )
427
+ rio('afile').print!( rio('afile.gz').gzip.contents )
428
428
 
429
429
  * Copy the first 100 lines of gzipped file on a webserver into a local file
430
430
  # method 1
@@ -448,9 +448,9 @@ IO, File, Dir, Pathname, FileUtils, Tempfile, StringIO, OpenURI, Zlib, and CSV.
448
448
 
449
449
  * Count the lines of code in a directory tree of ruby source files
450
450
  # method 1
451
- cnt = ario.all.files('*.rb').chomp.nolines(/^\s*#/,/^\s*$/).inject(0) { |sum,l| sum += 1 }
451
+ cnt = ario.all.files('*.rb').chomp.skiplines(/^\s*#/,/^\s*$/).inject(0) { |sum,l| sum += 1 }
452
452
  # method 2
453
- cnt = ario.all.files('*.rb').chomp.nolines[/^\s*#/,/^\s*$/].size
453
+ cnt = ario.all.files('*.rb').chomp.skiplines[/^\s*#/,/^\s*$/].size
454
454
 
455
455
  * Concatanate the contents of all .txt files in a directory into an array
456
456
  # method 1
@@ -548,7 +548,7 @@ IO, File, Dir, Pathname, FileUtils, Tempfile, StringIO, OpenURI, Zlib, and CSV.
548
548
  # method 4
549
549
  rio(?-) < rio('afile')
550
550
  # method 5
551
- rio(?-).print(rio('afile').slurp)
551
+ rio(?-).print(rio('afile').contents)
552
552
 
553
553
  * Emulate a simplified unix 'head' command which reads from stdin and writes the first 10 lines to stdout
554
554
  # method 1
@@ -560,7 +560,7 @@ IO, File, Dir, Pathname, FileUtils, Tempfile, StringIO, OpenURI, Zlib, and CSV.
560
560
 
561
561
  * Read the output of the 'ps' command into an array without the header line or the line representing
562
562
  the 'ps' command itself
563
- ps = rio(?-,'ps -a').nolines[0,/ps$/]
563
+ ps = rio(?-,'ps -a').skiplines[0,/ps$/]
564
564
 
565
565
  * Run an external program, copying its input from one location and its output from another,
566
566
  and make it look very much like a shell command.