1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Import RDoc 2.2.1 r185

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
drbrain 2008-09-25 02:43:03 +00:00
parent 00b4a3f9c4
commit 858362e761
54 changed files with 2893 additions and 2268 deletions

View file

@ -62,11 +62,32 @@ class RDoc::Parser
true
end
##
# Shamelessly stolen from the ptools gem (since RDoc cannot depend on
# the gem).
def self.binary?(file)
s = (File.read(file, File.stat(file).blksize) || "").split(//)
((s.size - s.grep(" ".."~").size) / s.size.to_f) > 0.30
end
private_class_method :binary?
##
# Return a parser that can handle a particular extension
def self.can_parse(file_name)
RDoc::Parser.parsers.find { |regexp, parser| regexp =~ file_name }.last
parser = RDoc::Parser.parsers.find { |regexp,| regexp =~ file_name }.last
#
# The default parser should *NOT* parse binary files.
#
if parser == RDoc::Parser::Simple then
if binary? file_name then
return nil
end
end
return parser
end
##