From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: poffice@blade.nagaokaut.ac.jp Delivered-To: poffice@blade.nagaokaut.ac.jp Received: from kankan.nagaokaut.ac.jp (smtp.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id 16A991A20917 for ; Fri, 20 May 2016 02:21:16 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id 8F720B5DB65 for ; Fri, 20 May 2016 02:57:14 +0900 (JST) Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id 7472418D1D3F for ; Fri, 20 May 2016 02:57:14 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 41118120472; Fri, 20 May 2016 02:57:12 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from o10.shared.sendgrid.net (o10.shared.sendgrid.net [173.193.132.135]) by neon.ruby-lang.org (Postfix) with ESMTPS id 56CCD120461 for ; Fri, 20 May 2016 02:57:09 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.me; h=from:to:references:subject:mime-version:content-type:content-transfer-encoding:list-id; s=smtpapi; bh=9ydBVDMKi6D4q2hrZfR3oN9WJk8=; b=JziR85JcsbhqLQp3nF URFch5ZHEUMVINOGR/U8fzCv4iVcEqcLN4hIhCsKz2v4PfSiQ+WrVuMicLBdJ7xP e4Pzo8eCe8koenNFUFUAo+Ew0Pxb9sphHOeCB/VLgtbSBOE5+I6LEDByAzqAPIrW +YO6bL1gDBjl6UOVddnWknD1Q= Received: by filter0419p1mdw1.sendgrid.net with SMTP id filter0419p1mdw1.5656.573DFE6ED 2016-05-19 17:57:02.193466332 +0000 UTC Received: from herokuapp.com (ec2-54-90-197-137.compute-1.amazonaws.com [54.90.197.137]) by ismtpd0001p1iad1.sendgrid.net (SG) with ESMTP id OY0eXWqZRUqkdbPI9-uNJg Thu, 19 May 2016 17:57:02.126 +0000 (UTC) Date: Thu, 19 May 2016 17:57:02 +0000 From: amd@gurge.com To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 50308 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 11735 X-Redmine-Issue-Author: sikachu X-Redmine-Issue-Assignee: matz X-Redmine-Sender: gurgeous X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS6uEGkEBKccXw6Sx98IbiESHAZlGTLgMoJ6gp 67yl04+fSsXWUbdZ0e5j4AEUlO5W1EeP8bvXsUIvS5fQuTSsg5ZlR3vqLJ3iIifRTyTkGDcbQJN2uC rnMyyVauk6KA8xU7lujwn3Vhq9xFTpcHwjZ5 X-ML-Name: ruby-core X-Mail-Count: 75616 Subject: [ruby-core:75616] [Ruby trunk Feature#11735] Porting String#squish and String#squish! from Ruby on Rails' Active Support X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #11735 has been updated by Adam Doppelt. It would be great to include squish in String. I've been writing production Ruby code for years and I often pull in ActiveSupport just to get squish. Getting input from a user? squish Cleaning up an iffy array.join? squish Pulling data from a web crawl? squish Normalizing concatenated data? squish Squish squish squish. 60k hits on github for Ruby squish. Just squish it. Squish it into core, please. ---------------------------------------- Feature #11735: Porting String#squish and String#squish! from Ruby on Rails' Active Support https://bugs.ruby-lang.org/issues/11735#change-58748 * Author: Prem Sichanugrist * Status: Open * Priority: Normal * Assignee: Yukihiro Matsumoto ---------------------------------------- Hi, I have been using this `String#squish` method so many time when I'm using Rails, and I think it should be a useful addition to core. Here's the method on Rails' documentation: http://api.rubyonrails.org/v4.2.5/classes/String.html#method-i-squish This method is very useful when you have to write a multi-line string using heredoc, but you actually does not care about the white-spaces before, after, and in-between the string. For example: ~~~ruby <<-SQL.squish SELECT * FROM users WHERE users.username = 'sikachu' SQL #=> "SELECT * FROM users WHERE users.username='sikachu'" ~~~ Another example usage is when you are on the project that have a line length code standard, and you have to write a long warning message that needs to be printed to stdout: ~~~ruby puts <<-WARNING.squish Unable to connect to the server. Please double-check that you are currently connecting to the internet and your proxy server is working. WARNING #=> Unable to connect to the server. Please double-check that you are currently connecting to the internet and your proxy server is working. ~~~ By the way, this is my first patch and my first time writing something in C, so there might be something that does not look right to you. I'll happy to revise this patch (and learn about C in the process!) from your feedback. Thank you, Prem ---Files-------------------------------- 0001-Introduce-String-squish-and-String-squish.patch (4.67 KB) -- https://bugs.ruby-lang.org/