awesome-print / awesome_print

Pretty print your Ruby objects with style -- in full color and with proper indentation
http://github.com/michaeldv/awesome_print
MIT License
4.08k stars 454 forks source link

awesome_file works with closed file #141

Open solutus opened 11 years ago

solutus commented 11 years ago

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

imajes commented 9 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!

gerrywastaken commented 8 years ago

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.

imajes commented 7 years ago

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!)