Open solutus opened 11 years ago
Can we get a test with this? I know this is crazy old but it'd be great to get this merged in!
Running the Travis build against this PR: https://travis-ci.org/gerrywastaken/awesome_print/builds/129617661
@solutus I haven't yet looked at the change, but a test would indeed be helpful.
As a note, we should fix this, but ls
isn't portable. We need to figure the right way to do that (wrt the recent ENV['HOME']
piece, portability is clearly more important than we might have considered!)
Test case:
echo "a\nb\nc" > /tmp/test
irb
irb >File.open("/tmp/test") { |file| file.each_line { |line| puts "Got #{ line.dump }" } }
Log: Got "a\nb\nc\n" IOError: closed stream from /Users/user/.rvm/gems/ruby-2.1.0-preview1/gems/awesome_print-1.2.0/lib/awesome_print/formatter.rb:199:in `directory?'
Root cause:
File.directory?(f)
asks closed f(ile)It looks like it isn't necessary to do this check. If
ls -d
runs for file, '-d' - is ignored