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 9F35719C02F7 for ; Wed, 25 Nov 2015 04:05:46 +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 535FAB5D82F for ; Wed, 25 Nov 2015 04:36:50 +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 4AA3218CC7E2 for ; Wed, 25 Nov 2015 04:36:50 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 7FB4312049A; Wed, 25 Nov 2015 04:36:47 +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 A1DB612044D for ; Wed, 25 Nov 2015 04:36:44 +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=7I+Od4H8y8ESH7Gp2a9oxLvkToI=; b=x3F6gI9+NErbD41zJs PrTXWEo0vPq+aAYGcYobY4LIWAimiHgdevxvL8Od/9LxWK7U3pS7+d5H44wzT0S0 K4r3tIM/spybU6roYTP8idV5kFuskqCbJ1ugV2JnS7yB4drHNBl9aWRYE84ttsb6 a8e/C8MJTqpSAg/X+IHjtnyXo= Received: by filter0800p1mdw1.sendgrid.net with SMTP id filter0800p1mdw1.2574.5654BC4251 2015-11-24 19:36:34.5760583 +0000 UTC Received: from herokuapp.com (ec2-54-221-85-98.compute-1.amazonaws.com [54.221.85.98]) by ismtpd0003p1iad1.sendgrid.net (SG) with ESMTP id gfd0hQ_GRvaQJO_ENGMN8w for ; Tue, 24 Nov 2015 19:36:34.401 +0000 (UTC) Date: Tue, 24 Nov 2015 19:36:34 +0000 From: s@sikac.hu To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Redmine-MailingListIntegration-Message-Ids: 46333 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 11735 X-Redmine-Issue-Author: sikachu X-Redmine-Sender: sikachu 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS5yFOLrThhFVSRoBpayw51+iRiLc9gbEVVTzm Ts1wvoLvgHhGCPqwTzQ8+it/sjDHGCYu3x4jTojjC4I6yc6dG/O+smro4M49Gnool6IXLfCzUJPR0u 3F9WBTIMVKl9KfAQ7DjPqKpLN7oPL8ZCDl1a X-ML-Name: ruby-core X-Mail-Count: 71658 Subject: [ruby-core:71658] [Ruby trunk - Feature #11735] [Open] 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: , Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #11735 has been reported by Prem Sichanugrist. ---------------------------------------- Feature #11735: Porting String#squish and String#squish! from Ruby on Rails' Active Support https://bugs.ruby-lang.org/issues/11735 * Author: Prem Sichanugrist * Status: Open * Priority: Normal * Assignee: ---------------------------------------- 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. 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: ~~~ <<-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: ~~~ 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/