Froze rails gems
[depot.git] / vendor / rails / activesupport / lib / active_support / core_ext / string / filters.rb
diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/string/filters.rb b/vendor/rails/activesupport/lib/active_support/core_ext/string/filters.rb
new file mode 100644 (file)
index 0000000..0329fbb
--- /dev/null
@@ -0,0 +1,26 @@
+module ActiveSupport #:nodoc:
+  module CoreExtensions #:nodoc:
+    module String #:nodoc:
+      module Filters
+        # Returns the string, first removing all whitespace on both ends of
+        # the string, and then changing remaining consecutive whitespace
+        # groups into one space each.
+        #
+        # Examples:
+        #   %{ Multi-line
+        #      string }.squish                   # => "Multi-line string"
+        #   " foo   bar    \n   \t   boo".squish # => "foo bar boo"
+        def squish
+          dup.squish!
+        end
+
+        # Performs a destructive squish. See String#squish.
+        def squish!
+          strip!
+          gsub!(/\s+/, ' ')
+          self
+        end
+      end
+    end
+  end
+end