tmpdir 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tmpdir.rb +16 -8
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57a97ebf7b14e2f44e7b803b0f9dbec79dbeeab9e7073dd3d606fe9713a175fe
|
4
|
+
data.tar.gz: b3fbfc28c8a3296b6aa0f933e8238f6582ab2d8a5d61dcda9315faee74083478
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 762bd5a660ee67f4defedb07775e0a1de30d4d3366b48dd6540726890f65181e698a8d4374c0ffccf93e1011bc097b7deeb8e185fb6d830f2e7ae9d53ee02ab9
|
7
|
+
data.tar.gz: 35ff31c1db12fa6eeb58fba94fde58d487f5e69c251bff2e6f39f315865667d03ee7fb56df70edaddae0dea1ed0acf61348627edd35849111b93c652e04542dd
|
data/lib/tmpdir.rb
CHANGED
@@ -16,10 +16,6 @@ class Dir
|
|
16
16
|
# Class variables are inaccessible from non-main Ractor.
|
17
17
|
# And instance variables too, in Ruby 3.0.
|
18
18
|
|
19
|
-
# System-wide temporary directory path
|
20
|
-
SYSTMPDIR = (defined?(Etc.systmpdir) ? Etc.systmpdir.freeze : '/tmp')
|
21
|
-
private_constant :SYSTMPDIR
|
22
|
-
|
23
19
|
##
|
24
20
|
# Returns the operating system's temporary file path.
|
25
21
|
#
|
@@ -27,7 +23,7 @@ class Dir
|
|
27
23
|
# Dir.tmpdir # => "/tmp"
|
28
24
|
|
29
25
|
def self.tmpdir
|
30
|
-
|
26
|
+
Tmpname::TMPDIR_CANDIDATES.find do |name, dir|
|
31
27
|
unless dir
|
32
28
|
next if !(dir = ENV[name] rescue next) or dir.empty?
|
33
29
|
end
|
@@ -98,13 +94,13 @@ class Dir
|
|
98
94
|
# FileUtils.remove_entry dir
|
99
95
|
# end
|
100
96
|
#
|
101
|
-
def self.mktmpdir(prefix_suffix=nil, *rest, **options)
|
97
|
+
def self.mktmpdir(prefix_suffix=nil, *rest, **options, &block)
|
102
98
|
base = nil
|
103
99
|
path = Tmpname.create(prefix_suffix || "d", *rest, **options) {|path, _, _, d|
|
104
100
|
base = d
|
105
101
|
mkdir(path, 0700)
|
106
102
|
}
|
107
|
-
if
|
103
|
+
if block
|
108
104
|
begin
|
109
105
|
yield path.dup
|
110
106
|
ensure
|
@@ -126,6 +122,18 @@ class Dir
|
|
126
122
|
module Tmpname # :nodoc:
|
127
123
|
module_function
|
128
124
|
|
125
|
+
# System-wide temporary directory path
|
126
|
+
systmpdir = (defined?(Etc.systmpdir) ? Etc.systmpdir.freeze : '/tmp')
|
127
|
+
|
128
|
+
# Temporary directory candidates consisting of environment variable
|
129
|
+
# names or description and path pairs.
|
130
|
+
TMPDIR_CANDIDATES = [
|
131
|
+
'TMPDIR', 'TMP', 'TEMP',
|
132
|
+
['system temporary path', systmpdir],
|
133
|
+
%w[/tmp /tmp],
|
134
|
+
%w[. .],
|
135
|
+
].each(&:freeze).freeze
|
136
|
+
|
129
137
|
def tmpdir
|
130
138
|
Dir.tmpdir
|
131
139
|
end
|
@@ -149,8 +157,8 @@ class Dir
|
|
149
157
|
|
150
158
|
# Generates and yields random names to create a temporary name
|
151
159
|
def create(basename, tmpdir=nil, max_try: nil, **opts)
|
152
|
-
origdir = tmpdir
|
153
160
|
if tmpdir
|
161
|
+
origdir = tmpdir = File.path(tmpdir)
|
154
162
|
raise ArgumentError, "empty parent path" if tmpdir.empty?
|
155
163
|
else
|
156
164
|
tmpdir = tmpdir()
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tmpdir
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yukihiro Matsumoto
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fileutils
|
@@ -46,7 +46,7 @@ licenses:
|
|
46
46
|
metadata:
|
47
47
|
homepage_uri: https://github.com/ruby/tmpdir
|
48
48
|
source_code_uri: https://github.com/ruby/tmpdir
|
49
|
-
post_install_message:
|
49
|
+
post_install_message:
|
50
50
|
rdoc_options: []
|
51
51
|
require_paths:
|
52
52
|
- lib
|
@@ -62,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
62
62
|
version: '0'
|
63
63
|
requirements: []
|
64
64
|
rubygems_version: 3.5.11
|
65
|
-
signing_key:
|
65
|
+
signing_key:
|
66
66
|
specification_version: 4
|
67
67
|
summary: Extends the Dir class to manage the OS temporary file path.
|
68
68
|
test_files: []
|