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 (kankan.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id F14021A201CB for ; Fri, 20 May 2016 11:02:13 +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 1AD4BB5D94B for ; Fri, 20 May 2016 11:38:11 +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 59B2718CC83D for ; Fri, 20 May 2016 11:38:11 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 38AAD120485; Fri, 20 May 2016 11:38:10 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from o2.heroku.sendgrid.net (o2.heroku.sendgrid.net [67.228.50.55]) by neon.ruby-lang.org (Postfix) with ESMTPS id AF58F120478 for ; Fri, 20 May 2016 11:38:07 +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=jvc/VJgxUeo2c7k5Z0iWAOTQc+A=; b=QjK6VSCc+EPdFe+AqT hfmkeniGnouuanUKzvjsRKVdvKEdd/axfbGzy9WdnIaloEB+kHVUBUrOF+NSI5OZ IgYE2MgKoavBAzvrjkNks55jPRbFdtMYBrnkyq8IG1ApbtZC4TzNh7zPuQobnLQ9 ZiuK2/gEBp1iV4ei9GJE1mm/I= Received: by filter0525p1mdw1.sendgrid.net with SMTP id filter0525p1mdw1.31968.573E788B1 2016-05-20 02:38:03.003771085 +0000 UTC Received: from herokuapp.com (ec2-54-234-165-22.compute-1.amazonaws.com [54.234.165.22]) by ismtpd0005p1iad1.sendgrid.net (SG) with ESMTP id liQQ0-C5TlGKXOgG-Biq4g Fri, 20 May 2016 02:38:03.165 +0000 (UTC) Date: Fri, 20 May 2016 02:38:02 +0000 From: shyouhei@ruby-lang.org To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 50323 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 11735 X-Redmine-Issue-Author: sikachu X-Redmine-Issue-Assignee: matz X-Redmine-Sender: shyouhei 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS5On0eaDyIJKkTZ1UZOcYXfllFM7AfsYsCQZ7 oZ54J5qNpPY5svb0iEs0yna35oQrBFKLp6/GkHPEzr+HvbUFsnV7u7pxTgxwR0ferMQ3Fp8msjGq6D pG+f3LyjcTh2RU6BH1F0+9OK3vxGczHIfMMfNPX4STads0PwNRx2zZI1Sg== X-ML-Name: ruby-core X-Mail-Count: 75631 Subject: [ruby-core:75631] [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 Shyouhei Urabe. Adam Doppelt wrote: > Getting input from a user? squish I guess you have never had a user from CJKV cultures. > Cleaning up an iffy array.join? squish This is a huge NO. It destroys JSON. > Pulling data from a web crawl? squish Also NO. It destroys <pre>. > Normalizing concatenated data? squish This could be OK depending on the "normalization" you want. > Squish squish squish. 60k hits on github for Ruby squish. Just squish it. Squish it into core, please. I had no pro et contra to the proposal until now. From what you said I started thinking squish can be a bad smell of indiscreet data treatment. I hope I'm wrong. ---------------------------------------- Feature #11735: Porting String#squish and String#squish! from Ruby on Rails' Active Support https://bugs.ruby-lang.org/issues/11735#change-58760 * 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/