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 31A1C1A600A0 for ; Fri, 24 Jun 2016 16:27:29 +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 4303EB5D8DA for ; Fri, 24 Jun 2016 17:02:20 +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 B183618CC80A for ; Fri, 24 Jun 2016 17:02:20 +0900 (JST) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id A655A120502; Fri, 24 Jun 2016 17:02:19 +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 9B6491204E7 for ; Fri, 24 Jun 2016 17:02:16 +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=k01BUgy8tYL0EJkXcvYgPeBfSDM=; b=KeogaXdM6l+l9xoLqh CNkZHamdLLjmy4T4Q6dbtVaQsmJPuDnkaLcEd4BzL9IgB4GPAdm7Wt0KuEK9dDBr APwrXbl2p0j0P3ZPeoQGm217blU1tBWiBwrG0OuJ32AP0Q1QRNixef1zTMpt3CID Whh37ggFRoI1uKYU++JvLxmlg= Received: by filter0906p1mdw1.sendgrid.net with SMTP id filter0906p1mdw1.1086.576CE90328 2016-06-24 08:02:11.368359968 +0000 UTC Received: from herokuapp.com (ec2-54-157-1-211.compute-1.amazonaws.com [54.157.1.211]) by ismtpd0002p1iad1.sendgrid.net (SG) with ESMTP id 1QkwRuPbQPeOJuVZ5d0EAw Fri, 24 Jun 2016 08:02:11.063 +0000 (UTC) Date: Fri, 24 Jun 2016 08:02:11 +0000 From: shyouhei@ruby-lang.org To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 50852 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS5bNjJXtxVHQIB5PS1cJ5XfZSJ33PvIap4x0E GNB1XNRK50z7bwZ1O2aQapJ3z59j2uKxQame24/Y8+LfmSHWeJpSp6mW30ZP2/+G0ofC8UtCMNza8c T1Wz+kVnXvXkd1Qui+EZhq/woyzRebqUv5R0GvflU6Jwj/qL8lghcTeerw== X-ML-Name: ruby-core X-Mail-Count: 76134 Subject: [ruby-core:76134] [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. I don't stop you to do what you want. But you are requesting it into core. There are so many miserably misused APIs around the world. Isn't it just another example of such thing? Isn't it "too easy to fail"? For instance is it OK say that applying this method to user input wont introduce SQL injection or that sort of things? ---------------------------------------- Feature #11735: Porting String#squish and String#squish! from Ruby on Rails' Active Support https://bugs.ruby-lang.org/issues/11735#change-59339 * 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/