aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorSergey Nartimov <just.lest@gmail.com>2011-12-24 15:57:54 +0300
committerSergey Nartimov <just.lest@gmail.com>2011-12-24 15:57:54 +0300
commit5ca86ac8f924b333a5a01a47cc07cbcf39c16e80 (patch)
treeda7a9a4d9cd8ad05648bde5d283715d5feea4d81 /activesupport
parenta5fa310f406e299a1ac54d1a227bde93b7ce282b (diff)
downloadrails-5ca86ac8f924b333a5a01a47cc07cbcf39c16e80.tar.gz
rails-5ca86ac8f924b333a5a01a47cc07cbcf39c16e80.tar.bz2
rails-5ca86ac8f924b333a5a01a47cc07cbcf39c16e80.zip
deprecate String#encoding_aware? and remove its usage
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/cache/mem_cache_store.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/string/encoding.rb5
-rw-r--r--activesupport/lib/active_support/gzip.rb2
-rw-r--r--activesupport/test/core_ext/string_ext_test.rb4
-rw-r--r--activesupport/test/gzip_test.rb5
5 files changed, 10 insertions, 8 deletions
diff --git a/activesupport/lib/active_support/cache/mem_cache_store.rb b/activesupport/lib/active_support/cache/mem_cache_store.rb
index 530839b24d..e38a8387b4 100644
--- a/activesupport/lib/active_support/cache/mem_cache_store.rb
+++ b/activesupport/lib/active_support/cache/mem_cache_store.rb
@@ -165,7 +165,7 @@ module ActiveSupport
# characters properly.
def escape_key(key)
key = key.to_s.dup
- key = key.force_encoding("BINARY") if key.encoding_aware?
+ key = key.force_encoding("BINARY")
key = key.gsub(ESCAPE_KEY_CHARS){ |match| "%#{match.getbyte(0).to_s(16).upcase}" }
key = "#{key[0, 213]}:md5:#{Digest::MD5.hexdigest(key)}" if key.size > 250
key
diff --git a/activesupport/lib/active_support/core_ext/string/encoding.rb b/activesupport/lib/active_support/core_ext/string/encoding.rb
index 236f72e933..dc635ed6a5 100644
--- a/activesupport/lib/active_support/core_ext/string/encoding.rb
+++ b/activesupport/lib/active_support/core_ext/string/encoding.rb
@@ -1,5 +1,8 @@
+require 'active_support/deprecation'
+
class String
def encoding_aware?
+ ActiveSupport::Deprecation.warn 'String#encoding_aware? is deprecated', caller
true
end
-end \ No newline at end of file
+end
diff --git a/activesupport/lib/active_support/gzip.rb b/activesupport/lib/active_support/gzip.rb
index 9651f02c73..f7036315d6 100644
--- a/activesupport/lib/active_support/gzip.rb
+++ b/activesupport/lib/active_support/gzip.rb
@@ -8,7 +8,7 @@ module ActiveSupport
class Stream < StringIO
def initialize(*)
super
- set_encoding "BINARY" if "".encoding_aware?
+ set_encoding "BINARY"
end
def close; rewind; end
end
diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb
index aeae2579b4..2e44cbe247 100644
--- a/activesupport/test/core_ext/string_ext_test.rb
+++ b/activesupport/test/core_ext/string_ext_test.rb
@@ -445,7 +445,9 @@ class OutputSafetyTest < ActiveSupport::TestCase
end
test 'knows whether it is encoding aware' do
- assert 'ruby'.encoding_aware?
+ assert_deprecated do
+ assert 'ruby'.encoding_aware?
+ end
end
test "call to_param returns a normal string" do
diff --git a/activesupport/test/gzip_test.rb b/activesupport/test/gzip_test.rb
index f564e63f29..626981dc9d 100644
--- a/activesupport/test/gzip_test.rb
+++ b/activesupport/test/gzip_test.rb
@@ -9,10 +9,7 @@ class GzipTest < Test::Unit::TestCase
def test_compress_should_return_a_binary_string
compressed = ActiveSupport::Gzip.compress('')
- if "".encoding_aware?
- assert_equal Encoding.find('binary'), compressed.encoding
- end
-
+ assert_equal Encoding.find('binary'), compressed.encoding
assert !compressed.blank?, "a compressed blank string should not be blank"
end
end