Permalink
Browse files

Don't use a separate core_ext include.

  • Loading branch information...
1 parent 2b885c8 commit de9837247d2d93c3ea6c8324cfa3ec5522c3a58a @Manfred committed Jan 11, 2010
Showing with 6 additions and 9 deletions.
  1. +0 −5 lib/core_ext.rb
  2. +5 −1 lib/ensure/encoding.rb
  3. +1 −1 spec/regression/sniff_encoding_spec.rb
  4. +0 −2 spec/start.rb
View
@@ -1,5 +0,0 @@
-# encoding: utf-8
-
-class String
- include Ensure::Encoding::String
-end
View
@@ -11,7 +11,7 @@ module Encoding
# Tries to guess the encoding of the string and returns the most likely
# encoding.
def self.sniff_encoding(string)
- first_bytes = unpack('C3')
+ first_bytes = string.unpack('C3')
BYTE_ORDER_MARKS.each do |encoding, bytes|
if first_bytes[0...bytes.length] == bytes
return encoding
@@ -125,4 +125,8 @@ def ensure_encoding!(target_encoding, options={})
end
end
end
+end
+
+class String
+ include Ensure::Encoding::String
end
@@ -7,7 +7,7 @@
[
['UTF-8', Encoding::UTF_8],
['UTF-16LE', Encoding::UTF_16LE],
- ['UTF-16BE', Encoding::UTF_18BE]
+ ['UTF-16BE', Encoding::UTF_16BE]
].each do |source, expected|
e, _ = example(source)
Ensure::Encoding.sniff_encoding(e).should == expected
View
@@ -9,8 +9,6 @@
$:.unshift(File.expand_path('../../lib', __FILE__))
require 'ensure'
-require 'core_ext'
-
module EncodingTestHelpers
EXAMPLES = {

0 comments on commit de98372

Please sign in to comment.