From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on starla X-Spam-Level: X-Spam-Status: No, score=0.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_BL_SPAMCOP_NET,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 Received: from nue.mailmanlists.eu (nue.mailmanlists.eu [94.130.110.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 36FEA1F5CB for ; Fri, 4 Oct 2024 02:16:55 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (1024-bit key; unprotected) header.d=ml.ruby-lang.org header.i=@ml.ruby-lang.org header.a=rsa-sha256 header.s=mail header.b=ctRGzceP; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.a=rsa-sha256 header.s=s1 header.b=aVALSs/n; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ml.ruby-lang.org; s=mail; t=1728008182; bh=VyuGCOyB3buPBuVOzJnA57QCAURAjM+4x1Snrp8XEG4=; h=Date:References:To:Reply-To:Subject:List-Id:List-Archive: List-Help:List-Owner:List-Post:List-Subscribe:List-Unsubscribe: From:Cc:From; b=ctRGzcePU1D45Q9fuyOjrJSrvk35iLkIrXwrqIAOgv3B3nl75P0DfMaGCfd3u6R+4 neoRvLIeGWAZ9bZjuVcQPBBuVWIT5K4wesIxPy2zzutDlw1nuh2luMuNn/eeNgv+Le zU8ME/o1biacLuuTI6Go55i8PiNc7LwJGkjie+NY= Received: from nue.mailmanlists.eu (localhost [IPv6:::1]) by nue.mailmanlists.eu (Postfix) with ESMTP id 6E38843F78 for ; Fri, 4 Oct 2024 02:16:22 +0000 (UTC) Authentication-Results: nue.mailmanlists.eu; dkim=pass (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.a=rsa-sha256 header.s=s1 header.b=aVALSs/n; dkim-atps=neutral Received: from s.wrqvtzvf.outbound-mail.sendgrid.net (s.wrqvtzvf.outbound-mail.sendgrid.net [149.72.126.143]) by nue.mailmanlists.eu (Postfix) with ESMTPS id 79CE843F23 for ; Fri, 4 Oct 2024 02:16:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ruby-lang.org; h=from:references:subject:mime-version:content-type: content-transfer-encoding:list-id:to:cc:content-type:from:subject:to; s=s1; bh=zEFgGZlQMvy0yRDYo66oStvFAesqXIKCp3YKsnZhSQs=; b=aVALSs/nY94603Ltb5aLSktwy9pg51vrnppdjNb0Y/sSeOempvWKcuwSMvI81aUp1ZjR qiJ/FK3mJlN4TiGTZp3CIi4zhuuRoNGHNbjFCxxHybZs8sV8Zj3fCf2aZAOgtV6FJ0CH78 0K94NjfCxkcmfJ2vnbQOMnvlb11RtZYnaZb+BDpvgfGzfop7io+vofx8M/r5z+vOXHLD7/ 20b0vP5iRu684Wwdid6rJGgEvR4ZbftXoT17JeDrIcH1SDb91coy9Mi9MfxUeV1is/VZkX j+n4eKARVT9kuOVcgaqe2dlwcHedW/rcRk57692T0teGcmygw5C7NftKoOs5JZmA== Received: by recvd-d66cff667-t2ksw with SMTP id recvd-d66cff667-t2ksw-1-66FF4FE9-2 2024-10-04 02:16:09.971096731 +0000 UTC m=+1844249.938587354 Received: from herokuapp.com (unknown) by geopod-ismtpd-24 (SG) with ESMTP id 9c7JMQIpSTG7V3t_30m5Ag for ; Fri, 04 Oct 2024 02:16:09.908 +0000 (UTC) Date: Fri, 04 Oct 2024 02:16:10 +0000 (UTC) Message-ID: References: Mime-Version: 1.0 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Feature X-Redmine-Issue-Id: 17297 X-Redmine-Issue-Author: schneems X-Redmine-Issue-Assignee: akr X-Redmine-Issue-Priority: Normal X-Redmine-Sender: hsbt 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-Redmine-MailingListIntegration-Message-Ids: 96075 X-SG-EID: =?us-ascii?Q?u001=2ESNtsfy=2FRYrUmxOeGSN+Ah1new64UppKFg8YOAgra6KK6sIhqEP6LswYh4?= =?us-ascii?Q?tCf2AhAD20FCmXanLCSpdJ9Heq83FKB1eeA=2FIRz?= =?us-ascii?Q?=2FUFVHcMb3GMHf3YQnvPRpQfkx+czXCu8sImgTnS?= =?us-ascii?Q?hoB3xzR4lomrSeONmSpWenpMuXj8vLESRY1OQkH?= =?us-ascii?Q?g+AeXdM0bPB8UYIdl3PmD1GGKPGQsaG7h6mCQ8d?= =?us-ascii?Q?CJSIGZpsXRS6xqjIfyYuoyVqbs0X3RTK2qCdVIR?= =?us-ascii?Q?D6S=2Fs+Lz6qF4AwFWSZ22IF6GUg=3D=3D?= To: ruby-core@ml.ruby-lang.org X-Entity-ID: u001.I8uzylDtAfgbeCOeLBYDww== Message-ID-Hash: LW3MW5AOPD3BQYRZJL76GZXJKGQAOKEH X-Message-ID-Hash: LW3MW5AOPD3BQYRZJL76GZXJKGQAOKEH X-MailFrom: bounces+313651-b711-ruby-core=ml.ruby-lang.org@em5188.ruby-lang.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list Reply-To: Ruby developers Subject: [ruby-core:119439] [Ruby master Feature#17297] Feature: Introduce Pathname.mktmpdir List-Id: Ruby developers Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: "hsbt (Hiroshi SHIBATA) via ruby-core" Cc: "hsbt (Hiroshi SHIBATA)" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Issue #17297 has been updated by hsbt (Hiroshi SHIBATA). Status changed from Assigned to Closed This feature request has been approved by @akr. I merged https://github.com/ruby/ruby/pull/3709 now. ---------------------------------------- Feature #17297: Feature: Introduce Pathname.mktmpdir https://bugs.ruby-lang.org/issues/17297#change-110059 * Author: schneems (Richard Schneeman) * Status: Closed * Assignee: akr (Akira Tanaka) ---------------------------------------- When I want to create a tmpdir I often want to manipulate it as a pathname. By introducing Pathname.mktmpdir I can get this behavior. Currently I must: ```ruby Dir.mktmpdir do |dir| dir = Pathname(dir) # ... code end ``` I would like to be able to instead: ```ruby Pathname.mktmpdir do |dir| # ... code end ``` Diff: ``` $ git diff master diff --git a/ext/pathname/lib/pathname.rb b/ext/pathname/lib/pathname.rb index e6fb90277d..ec32e7d611 100644 --- a/ext/pathname/lib/pathname.rb +++ b/ext/pathname/lib/pathname.rb @@ -597,3 +597,20 @@ def rmtree end end +class Pathname # * tmpdir * + # Creates a tmp directory and wraps the returned path in a Pathname object. + # + # See Dir.mktmpdir + def self.mktmpdir + require 'tmpdir' unless defined?(Dir.mktmpdir) + if block_given? + Dir.mktmpdir do |dir| + dir = self.new(dir) + yield dir + end + else + self.new(Dir.mktmpdir) + end + end +end + diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb index 43cef4849f..8edcccf666 100644 --- a/test/pathname/test_pathname.rb +++ b/test/pathname/test_pathname.rb @@ -1272,6 +1272,14 @@ def test_s_glob_3args } end + def test_mktmpdir + Pathname.mktmpdir do |dir| + assert_equal Pathname(dir), dir + assert dir.directory? + assert dir.exist? + end + end + def test_s_getwd wd = Pathname.getwd assert_kind_of(Pathname, wd) ``` Github link: https://github.com/ruby/ruby/pull/3709 -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/