Class: File

Inherits:
Object
  • Object
show all
Defined in:
lib/hoe.rb

Overview

:nodoc:

Class Method Summary collapse

Class Method Details

.read_utf(path) ⇒ Object

Like File::read, but strips out a BOM marker if it exists.



953
954
955
956
957
958
959
960
961
962
963
964
# File 'lib/hoe.rb', line 953

def self.read_utf path
  r19 = "<3".respond_to? :encoding
  opt = r19 ? "r:bom|utf-8" : "rb"

  open path, opt do |f|
    if r19 then
      f.read
    else
      f.read.sub %r%\A\xEF\xBB\xBF%, ""
    end
  end
end