Skip to content

Commit

Permalink
Do not attempt to read binary files
Browse files Browse the repository at this point in the history
While RDoc had binary checks, it did not apply them at the appropriate
location.  Now binary checking is performed before attempting to convert
a document to UTF-8 to avoid the warning.

Fixes #189
Fixes #190
Fixes #195
  • Loading branch information
drbrain committed Mar 21, 2013
1 parent 729b62a commit ceb81dd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions History.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
* RDoc::Servlet no longer ignores extra directories from -d. Pull request
#173 by Thomas Leitner
* Fixed `rdoc --ri-site`. Bug #193 by Michal Papis.
* RDoc no longer attempts to parse binary files. Bug #189 by postmodern,
Bug #190 by Christoffer Lervåg, Bug #195 by Aaron Patterson

=== 4.0.0 / 2013-02-24

Expand Down
2 changes: 2 additions & 0 deletions lib/rdoc/rdoc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,8 @@ def parse_file filename

@stats.add_file filename

return if RDoc::Parser.binary? filename

content = RDoc::Encoding.read_file filename, encoding

return unless content
Expand Down
18 changes: 18 additions & 0 deletions test/test_rdoc_rdoc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,24 @@ def test_parse_file
end
end

def test_parse_file_binary
@rdoc.store = RDoc::Store.new

root = File.dirname __FILE__
binary_dat = File.expand_path 'binary.dat', root

@rdoc.options.root = Pathname root

out, err = capture_io do
Dir.chdir root do
assert_nil @rdoc.parse_file 'binary.dat'
end
end

assert_empty out
assert_empty err
end

def test_parse_file_page_dir
@rdoc.store = RDoc::Store.new

Expand Down

0 comments on commit ceb81dd

Please sign in to comment.