aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/string
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/core_ext/string')
-rw-r--r--activesupport/lib/active_support/core_ext/string/access.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/string/bytesize.rb5
-rw-r--r--activesupport/lib/active_support/core_ext/string/interpolation.rb3
-rw-r--r--activesupport/lib/active_support/core_ext/string/iterators.rb13
-rw-r--r--activesupport/lib/active_support/core_ext/string/starts_ends_with.rb14
5 files changed, 3 insertions, 34 deletions
diff --git a/activesupport/lib/active_support/core_ext/string/access.rb b/activesupport/lib/active_support/core_ext/string/access.rb
index 57385d86d2..182b3e745d 100644
--- a/activesupport/lib/active_support/core_ext/string/access.rb
+++ b/activesupport/lib/active_support/core_ext/string/access.rb
@@ -1,3 +1,5 @@
+require "active_support/multibyte"
+
class String
unless '1.9'.respond_to?(:force_encoding)
# Returns the character at the +position+ treating the string as an array (where 0 is the first character).
diff --git a/activesupport/lib/active_support/core_ext/string/bytesize.rb b/activesupport/lib/active_support/core_ext/string/bytesize.rb
deleted file mode 100644
index ed051b921e..0000000000
--- a/activesupport/lib/active_support/core_ext/string/bytesize.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-unless '1.9'.respond_to?(:bytesize)
- class String
- alias :bytesize :size
- end
-end
diff --git a/activesupport/lib/active_support/core_ext/string/interpolation.rb b/activesupport/lib/active_support/core_ext/string/interpolation.rb
index d9159b690a..2048d35091 100644
--- a/activesupport/lib/active_support/core_ext/string/interpolation.rb
+++ b/activesupport/lib/active_support/core_ext/string/interpolation.rb
@@ -5,8 +5,7 @@
You may redistribute it and/or modify it under the same license terms as Ruby.
=end
-if RUBY_VERSION < '1.9'
- require 'active_support/core_ext/string/bytesize'
+if RUBY_VERSION < '1.9' && !"".respond_to?(:interpolate_without_ruby_19_syntax)
# KeyError is raised by String#% when the string contains a named placeholder
# that is not contained in the given arguments hash. Ruby 1.9 includes and
diff --git a/activesupport/lib/active_support/core_ext/string/iterators.rb b/activesupport/lib/active_support/core_ext/string/iterators.rb
deleted file mode 100644
index 2f8aa84024..0000000000
--- a/activesupport/lib/active_support/core_ext/string/iterators.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-unless '1.9'.respond_to?(:each_char)
- class String
- # Yields a single-character string for each character in the string.
- # When $KCODE = 'UTF8', multi-byte characters are yielded appropriately.
- def each_char
- require 'strscan' unless defined? ::StringScanner
- scanner, char = ::StringScanner.new(self), /./mu
- while c = scanner.scan(char)
- yield c
- end
- end
- end
-end
diff --git a/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb b/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb
index f65bb8f75b..641acf62d0 100644
--- a/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb
+++ b/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb
@@ -1,18 +1,4 @@
class String
- unless '1.8.7 and up'.respond_to?(:start_with?)
- # Does the string start with the specified +prefix+?
- def start_with?(prefix)
- prefix = prefix.to_s
- self[0, prefix.length] == prefix
- end
-
- # Does the string end with the specified +suffix+?
- def end_with?(suffix)
- suffix = suffix.to_s
- self[-suffix.length, suffix.length] == suffix
- end
- end
-
alias_method :starts_with?, :start_with?
alias_method :ends_with?, :end_with?
end