unix_utils 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,9 @@
1
+ == 0.0.8 / 2012-04-12
2
+
3
+ * Bug fixes
4
+
5
+ * Let perl handle its own input files (ARGF)... my implementation using IO.select was not working.
6
+
1
7
  == 0.0.7 / 2012-04-11
2
8
 
3
9
  * Bug fixes
@@ -169,8 +169,8 @@ module UnixUtils
169
169
  def self.perl(infile, *expr)
170
170
  infile = ::File.expand_path infile
171
171
  outfile = tmp_path infile
172
- argv = [ 'perl', expr.map { |e| ['-pe', e] } ].flatten
173
- spawn argv, :read_from => infile, :write_to => outfile
172
+ argv = [ 'perl', expr.map { |e| ['-pe', e] }, infile ].flatten
173
+ spawn argv, :write_to => outfile
174
174
  outfile
175
175
  end
176
176
 
@@ -1,3 +1,3 @@
1
1
  module UnixUtils
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -196,7 +196,7 @@ describe UnixUtils do
196
196
  describe :perl do
197
197
  before do
198
198
  @f = Tempfile.new('perl.txt')
199
- @f.write "bad\n"*10
199
+ @f.write "badWord\n"*10_000
200
200
  @f.flush
201
201
  @infile = @f.path
202
202
  end
@@ -205,7 +205,7 @@ describe UnixUtils do
205
205
  end
206
206
  it "processes a file" do
207
207
  outfile = UnixUtils.perl(@infile, 's/bad/good/g')
208
- File.read(outfile).must_equal "good\n"*10
208
+ File.read(outfile).must_equal "goodWord\n"*10_000
209
209
  safe_delete outfile
210
210
  end
211
211
  it "does not touch the infile" do
@@ -221,7 +221,7 @@ describe UnixUtils do
221
221
  describe :awk do
222
222
  before do
223
223
  @f = Tempfile.new('awk.txt')
224
- @f.write "bad\n"*10
224
+ @f.write "badWord\n"*10_000
225
225
  @f.flush
226
226
  @infile = @f.path
227
227
  end
@@ -230,7 +230,7 @@ describe UnixUtils do
230
230
  end
231
231
  it "processes a file" do
232
232
  outfile = UnixUtils.awk(@infile, '{gsub(/bad/, "good"); print}')
233
- File.read(outfile).must_equal "good\n"*10
233
+ File.read(outfile).must_equal "goodWord\n"*10_000
234
234
  safe_delete outfile
235
235
  end
236
236
  it "does not touch the infile" do
@@ -246,8 +246,8 @@ describe UnixUtils do
246
246
  describe :unix2dos do
247
247
  before do
248
248
  @f = Tempfile.new('unix2dos.txt')
249
- @f.write "unix\n"*5
250
- @f.write "dos\r\n"*5
249
+ @f.write "unix\n"*5_000
250
+ @f.write "dos\r\n"*5_000
251
251
  @f.flush
252
252
  @infile = @f.path
253
253
  end
@@ -256,7 +256,7 @@ describe UnixUtils do
256
256
  end
257
257
  it 'converts newlines' do
258
258
  outfile = UnixUtils.unix2dos @infile
259
- File.read(outfile).must_equal("unix\r\n"*5 + "dos\r\n"*5)
259
+ File.read(outfile).must_equal("unix\r\n"*5_000 + "dos\r\n"*5_000)
260
260
  safe_delete outfile
261
261
  end
262
262
  end
@@ -282,8 +282,8 @@ describe UnixUtils do
282
282
  describe :wc do
283
283
  before do
284
284
  @f = Tempfile.new('wc.txt')
285
- @f.write "dos line\r\n"*5
286
- @f.write "unix line\n"*5
285
+ @f.write "dos line\r\n"*5_000
286
+ @f.write "unix line\n"*5_000
287
287
  @f.flush
288
288
  @infile = @f.path
289
289
  end
@@ -291,14 +291,14 @@ describe UnixUtils do
291
291
  @f.close
292
292
  end
293
293
  it 'counts lines, words, and bytes' do
294
- UnixUtils.wc(@infile).must_equal [5+5, 10+10, 50+50]
294
+ UnixUtils.wc(@infile).must_equal [5_000+5_000, 10_000+10_000, 50_000+50_000]
295
295
  end
296
296
  end
297
297
 
298
298
  describe :sed do
299
299
  before do
300
300
  @f = Tempfile.new('sed.txt')
301
- @f.write "bad\n"*10
301
+ @f.write "badWord\n"*10_000
302
302
  @f.flush
303
303
  @infile = @f.path
304
304
  end
@@ -307,7 +307,7 @@ describe UnixUtils do
307
307
  end
308
308
  it "processes a file" do
309
309
  outfile = UnixUtils.sed(@infile, 's/bad/good/g')
310
- File.read(outfile).must_equal "good\n"*10
310
+ File.read(outfile).must_equal "goodWord\n"*10_000
311
311
  safe_delete outfile
312
312
  end
313
313
  it "does not touch the infile" do
@@ -413,7 +413,7 @@ describe UnixUtils do
413
413
  File.extname(UnixUtils.tmp_path("dirname1/dirname2/basename.extname", '.foobar')).must_equal '.foobar'
414
414
  end
415
415
  it "doesn't create excessively long filenames" do
416
- File.basename(UnixUtils.tmp_path("a"*5000)).length.must_equal 255
416
+ 100.times { File.basename(UnixUtils.tmp_path("a"*5000)).length.must_be :<, 256 }
417
417
  end
418
418
  it "doesn't include directory part of ancestor" do
419
419
  UnixUtils.tmp_path("dirname1/dirname2/basename.extname").wont_include 'dirname1'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unix_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: