tmpdir 0.1.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.document +2 -0
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/test.yml +10 -7
- data/Rakefile +1 -1
- data/lib/tmpdir.rb +18 -12
- data/tmpdir.gemspec +2 -2
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23db0dc38a62002db3cbbe9dc185ba6d39a571ff12c064552d62162a511ae280
|
4
|
+
data.tar.gz: a44a1139f82880434057a5206b73efbfcd7ddce39e6ebb5ae9b69d47d028f20a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 276895513eab16fa4e2ab9d78216f62b5438cf3a59d24e3be758dd64934bdd86db570590b41bb73480ae699781b2a2e1f36504ae4b34141f8503bca0d6c20001
|
7
|
+
data.tar.gz: bff0818e6786cdc7b5084f57d4f3b270192fc850aced926fc0a41c40fb50d4d8a18397515c486fe7a73f8838dd8b1594dfda806ae3dd8fc50391c224bd7ab026
|
data/.document
ADDED
data/.github/workflows/test.yml
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
name:
|
1
|
+
name: test
|
2
2
|
|
3
3
|
on: [push, pull_request]
|
4
4
|
|
@@ -7,18 +7,21 @@ jobs:
|
|
7
7
|
name: build (${{ matrix.ruby }} / ${{ matrix.os }})
|
8
8
|
strategy:
|
9
9
|
matrix:
|
10
|
-
ruby: [
|
11
|
-
os: [ ubuntu-latest, macos-latest ]
|
10
|
+
ruby: [ '3.1', '3.0', '2.7', head ]
|
11
|
+
os: [ ubuntu-latest, macos-latest, windows-latest ]
|
12
|
+
exclude:
|
13
|
+
- { os: windows-latest, ruby: head }
|
14
|
+
include:
|
15
|
+
- { os: windows-latest, ruby: mingw }
|
16
|
+
- { os: windows-latest, ruby: mswin }
|
12
17
|
runs-on: ${{ matrix.os }}
|
13
18
|
steps:
|
14
|
-
- uses: actions/checkout@
|
19
|
+
- uses: actions/checkout@v3
|
15
20
|
- name: Set up Ruby
|
16
21
|
uses: ruby/setup-ruby@v1
|
17
22
|
with:
|
18
23
|
ruby-version: ${{ matrix.ruby }}
|
19
24
|
- name: Install dependencies
|
20
|
-
run:
|
21
|
-
gem install bundler --no-document
|
22
|
-
bundle install
|
25
|
+
run: bundle install
|
23
26
|
- name: Run test
|
24
27
|
run: rake test
|
data/Rakefile
CHANGED
@@ -9,7 +9,7 @@ end
|
|
9
9
|
|
10
10
|
task :sync_tool do
|
11
11
|
require 'fileutils'
|
12
|
-
FileUtils.cp "../ruby/tool/lib/
|
12
|
+
FileUtils.cp "../ruby/tool/lib/core_assertions.rb", "./test/lib"
|
13
13
|
FileUtils.cp "../ruby/tool/lib/envutil.rb", "./test/lib"
|
14
14
|
FileUtils.cp "../ruby/tool/lib/find_executable.rb", "./test/lib"
|
15
15
|
end
|
data/lib/tmpdir.rb
CHANGED
@@ -19,9 +19,10 @@ class Dir
|
|
19
19
|
# Returns the operating system's temporary file path.
|
20
20
|
|
21
21
|
def self.tmpdir
|
22
|
-
tmp
|
23
|
-
|
24
|
-
|
22
|
+
['TMPDIR', 'TMP', 'TEMP', ['system temporary path', @@systmpdir], ['/tmp']*2, ['.']*2].find do |name, dir|
|
23
|
+
unless dir
|
24
|
+
next if !(dir = ENV[name]) or dir.empty?
|
25
|
+
end
|
25
26
|
dir = File.expand_path(dir)
|
26
27
|
stat = File.stat(dir) rescue next
|
27
28
|
case
|
@@ -32,12 +33,9 @@ class Dir
|
|
32
33
|
when stat.world_writable? && !stat.sticky?
|
33
34
|
warn "#{name} is world-writable: #{dir}"
|
34
35
|
else
|
35
|
-
|
36
|
-
break
|
36
|
+
break dir
|
37
37
|
end
|
38
|
-
end
|
39
|
-
raise ArgumentError, "could not find a temporary directory" unless tmp
|
40
|
-
tmp
|
38
|
+
end or raise ArgumentError, "could not find a temporary directory"
|
41
39
|
end
|
42
40
|
|
43
41
|
# Dir.mktmpdir creates a temporary directory.
|
@@ -69,7 +67,7 @@ class Dir
|
|
69
67
|
#
|
70
68
|
# Dir.mktmpdir {|dir|
|
71
69
|
# # use the directory...
|
72
|
-
# open("#{dir}/foo", "w") {
|
70
|
+
# open("#{dir}/foo", "w") { something using the file }
|
73
71
|
# }
|
74
72
|
#
|
75
73
|
# If a block is not given,
|
@@ -79,7 +77,7 @@ class Dir
|
|
79
77
|
# dir = Dir.mktmpdir
|
80
78
|
# begin
|
81
79
|
# # use the directory...
|
82
|
-
# open("#{dir}/foo", "w") {
|
80
|
+
# open("#{dir}/foo", "w") { something using the file }
|
83
81
|
# ensure
|
84
82
|
# # remove the directory.
|
85
83
|
# FileUtils.remove_entry dir
|
@@ -108,6 +106,7 @@ class Dir
|
|
108
106
|
end
|
109
107
|
end
|
110
108
|
|
109
|
+
# Temporary name generator
|
111
110
|
module Tmpname # :nodoc:
|
112
111
|
module_function
|
113
112
|
|
@@ -115,16 +114,23 @@ class Dir
|
|
115
114
|
Dir.tmpdir
|
116
115
|
end
|
117
116
|
|
118
|
-
|
117
|
+
# Unusable characters as path name
|
118
|
+
UNUSABLE_CHARS = "^,-.0-9A-Z_a-z~"
|
119
119
|
|
120
|
-
|
120
|
+
# Dedicated random number generator
|
121
|
+
RANDOM = Random.new
|
122
|
+
class << RANDOM # :nodoc:
|
123
|
+
# Maximum random number
|
121
124
|
MAX = 36**6 # < 0x100000000
|
125
|
+
|
126
|
+
# Returns new random string upto 6 bytes
|
122
127
|
def next
|
123
128
|
rand(MAX).to_s(36)
|
124
129
|
end
|
125
130
|
end
|
126
131
|
private_constant :RANDOM
|
127
132
|
|
133
|
+
# Generates and yields random names to create a temporary name
|
128
134
|
def create(basename, tmpdir=nil, max_try: nil, **opts)
|
129
135
|
origdir = tmpdir
|
130
136
|
tmpdir ||= tmpdir()
|
data/tmpdir.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "tmpdir"
|
3
|
-
spec.version = "0.1.
|
3
|
+
spec.version = "0.1.3"
|
4
4
|
spec.authors = ["Yukihiro Matsumoto"]
|
5
5
|
spec.email = ["matz@ruby-lang.org"]
|
6
6
|
|
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.description = %q{Extends the Dir class to manage the OS temporary file path.}
|
9
9
|
spec.homepage = "https://github.com/ruby/tmpdir"
|
10
10
|
spec.licenses = ["Ruby", "BSD-2-Clause"]
|
11
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.
|
11
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
|
12
12
|
|
13
13
|
spec.metadata["homepage_uri"] = spec.homepage
|
14
14
|
spec.metadata["source_code_uri"] = spec.homepage
|
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.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yukihiro Matsumoto
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fileutils
|
@@ -31,6 +31,8 @@ executables: []
|
|
31
31
|
extensions: []
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
|
+
- ".document"
|
35
|
+
- ".github/dependabot.yml"
|
34
36
|
- ".github/workflows/test.yml"
|
35
37
|
- ".gitignore"
|
36
38
|
- Gemfile
|
@@ -56,14 +58,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
56
58
|
requirements:
|
57
59
|
- - ">="
|
58
60
|
- !ruby/object:Gem::Version
|
59
|
-
version: 2.
|
61
|
+
version: 2.7.0
|
60
62
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
63
|
requirements:
|
62
64
|
- - ">="
|
63
65
|
- !ruby/object:Gem::Version
|
64
66
|
version: '0'
|
65
67
|
requirements: []
|
66
|
-
rubygems_version: 3.
|
68
|
+
rubygems_version: 3.4.0.dev
|
67
69
|
signing_key:
|
68
70
|
specification_version: 4
|
69
71
|
summary: Extends the Dir class to manage the OS temporary file path.
|