tmpdir 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.document +2 -0
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/test.yml +17 -7
- data/.gitignore +1 -0
- data/Gemfile +1 -0
- data/Rakefile +0 -7
- data/lib/tmpdir.rb +25 -13
- data/tmpdir.gemspec +3 -3
- metadata +6 -5
- data/Gemfile.lock +0 -23
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9572f0043f9ac0057c01f47404fa7ef1fc380807cfc362c5f66a4ec9fd80f5cd
|
|
4
|
+
data.tar.gz: a3d8d5fe9f6cd2b54f3bc2c32cbc0fbb0ddfed898658049da9e7e588de8298c2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d261987f369e87a27b22cf75d11cd880dd59d2ff7b25aa4030b345d27cccb2b34721d0b75243705feb97ea3ebbd70e973caae9e11602485c919da7aca02d6303
|
|
7
|
+
data.tar.gz: 9257c8f6160e0e8da8722dd4266afb09bdb7aedc972d9b149f18c169f028266daf59406c1eaac2651a4bd31768b5b83d862b7bbf93395ba8369701f3037e4e47
|
data/.document
ADDED
data/.github/workflows/test.yml
CHANGED
|
@@ -1,24 +1,34 @@
|
|
|
1
|
-
name:
|
|
1
|
+
name: test
|
|
2
2
|
|
|
3
3
|
on: [push, pull_request]
|
|
4
4
|
|
|
5
5
|
jobs:
|
|
6
|
+
ruby-versions:
|
|
7
|
+
uses: ruby/actions/.github/workflows/ruby_versions.yml@master
|
|
8
|
+
with:
|
|
9
|
+
engine: cruby
|
|
10
|
+
min_version: 2.7
|
|
11
|
+
|
|
6
12
|
build:
|
|
13
|
+
needs: ruby-versions
|
|
7
14
|
name: build (${{ matrix.ruby }} / ${{ matrix.os }})
|
|
8
15
|
strategy:
|
|
9
16
|
matrix:
|
|
10
|
-
ruby:
|
|
11
|
-
os: [ ubuntu-latest, macos-latest ]
|
|
17
|
+
ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
|
|
18
|
+
os: [ ubuntu-latest, macos-latest, windows-latest ]
|
|
19
|
+
exclude:
|
|
20
|
+
- { os: windows-latest, ruby: head }
|
|
21
|
+
include:
|
|
22
|
+
- { os: windows-latest, ruby: mingw }
|
|
23
|
+
- { os: windows-latest, ruby: mswin }
|
|
12
24
|
runs-on: ${{ matrix.os }}
|
|
13
25
|
steps:
|
|
14
|
-
- uses: actions/checkout@
|
|
26
|
+
- uses: actions/checkout@v4
|
|
15
27
|
- name: Set up Ruby
|
|
16
28
|
uses: ruby/setup-ruby@v1
|
|
17
29
|
with:
|
|
18
30
|
ruby-version: ${{ matrix.ruby }}
|
|
19
31
|
- name: Install dependencies
|
|
20
|
-
run:
|
|
21
|
-
gem install bundler --no-document
|
|
22
|
-
bundle install
|
|
32
|
+
run: bundle install
|
|
23
33
|
- name: Run test
|
|
24
34
|
run: rake test
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/Rakefile
CHANGED
|
@@ -7,11 +7,4 @@ Rake::TestTask.new(:test) do |t|
|
|
|
7
7
|
t.test_files = FileList["test/**/test_*.rb"]
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
task :sync_tool do
|
|
11
|
-
require 'fileutils'
|
|
12
|
-
FileUtils.cp "../ruby/tool/lib/test/unit/core_assertions.rb", "./test/lib"
|
|
13
|
-
FileUtils.cp "../ruby/tool/lib/envutil.rb", "./test/lib"
|
|
14
|
-
FileUtils.cp "../ruby/tool/lib/find_executable.rb", "./test/lib"
|
|
15
|
-
end
|
|
16
|
-
|
|
17
10
|
task :default => :test
|
data/lib/tmpdir.rb
CHANGED
|
@@ -13,15 +13,21 @@ end
|
|
|
13
13
|
|
|
14
14
|
class Dir
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
# Class variables are inaccessible from non-main Ractor.
|
|
17
|
+
# And instance variables too, in Ruby 3.0.
|
|
18
|
+
|
|
19
|
+
# System-wide temporary directory path
|
|
20
|
+
SYSTMPDIR = (defined?(Etc.systmpdir) ? Etc.systmpdir.freeze : '/tmp')
|
|
21
|
+
private_constant :SYSTMPDIR
|
|
17
22
|
|
|
18
23
|
##
|
|
19
24
|
# Returns the operating system's temporary file path.
|
|
20
25
|
|
|
21
26
|
def self.tmpdir
|
|
22
|
-
tmp
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
['TMPDIR', 'TMP', 'TEMP', ['system temporary path', SYSTMPDIR], ['/tmp']*2, ['.']*2].find do |name, dir|
|
|
28
|
+
unless dir
|
|
29
|
+
next if !(dir = ENV[name] rescue next) or dir.empty?
|
|
30
|
+
end
|
|
25
31
|
dir = File.expand_path(dir)
|
|
26
32
|
stat = File.stat(dir) rescue next
|
|
27
33
|
case
|
|
@@ -32,12 +38,9 @@ class Dir
|
|
|
32
38
|
when stat.world_writable? && !stat.sticky?
|
|
33
39
|
warn "#{name} is world-writable: #{dir}"
|
|
34
40
|
else
|
|
35
|
-
|
|
36
|
-
break
|
|
41
|
+
break dir
|
|
37
42
|
end
|
|
38
|
-
end
|
|
39
|
-
raise ArgumentError, "could not find a temporary directory" unless tmp
|
|
40
|
-
tmp
|
|
43
|
+
end or raise ArgumentError, "could not find a temporary directory"
|
|
41
44
|
end
|
|
42
45
|
|
|
43
46
|
# Dir.mktmpdir creates a temporary directory.
|
|
@@ -69,7 +72,7 @@ class Dir
|
|
|
69
72
|
#
|
|
70
73
|
# Dir.mktmpdir {|dir|
|
|
71
74
|
# # use the directory...
|
|
72
|
-
# open("#{dir}/foo", "w") {
|
|
75
|
+
# open("#{dir}/foo", "w") { something using the file }
|
|
73
76
|
# }
|
|
74
77
|
#
|
|
75
78
|
# If a block is not given,
|
|
@@ -79,7 +82,7 @@ class Dir
|
|
|
79
82
|
# dir = Dir.mktmpdir
|
|
80
83
|
# begin
|
|
81
84
|
# # use the directory...
|
|
82
|
-
# open("#{dir}/foo", "w") {
|
|
85
|
+
# open("#{dir}/foo", "w") { something using the file }
|
|
83
86
|
# ensure
|
|
84
87
|
# # remove the directory.
|
|
85
88
|
# FileUtils.remove_entry dir
|
|
@@ -108,6 +111,7 @@ class Dir
|
|
|
108
111
|
end
|
|
109
112
|
end
|
|
110
113
|
|
|
114
|
+
# Temporary name generator
|
|
111
115
|
module Tmpname # :nodoc:
|
|
112
116
|
module_function
|
|
113
117
|
|
|
@@ -115,16 +119,24 @@ class Dir
|
|
|
115
119
|
Dir.tmpdir
|
|
116
120
|
end
|
|
117
121
|
|
|
122
|
+
# Unusable characters as path name
|
|
118
123
|
UNUSABLE_CHARS = "^,-.0-9A-Z_a-z~"
|
|
119
124
|
|
|
120
|
-
|
|
125
|
+
# Dedicated random number generator
|
|
126
|
+
RANDOM = Object.new
|
|
127
|
+
class << RANDOM # :nodoc:
|
|
128
|
+
# Maximum random number
|
|
121
129
|
MAX = 36**6 # < 0x100000000
|
|
130
|
+
|
|
131
|
+
# Returns new random string upto 6 bytes
|
|
122
132
|
def next
|
|
123
|
-
|
|
133
|
+
(::Random.urandom(4).unpack1("L")%MAX).to_s(36)
|
|
124
134
|
end
|
|
125
135
|
end
|
|
136
|
+
RANDOM.freeze
|
|
126
137
|
private_constant :RANDOM
|
|
127
138
|
|
|
139
|
+
# Generates and yields random names to create a temporary name
|
|
128
140
|
def create(basename, tmpdir=nil, max_try: nil, **opts)
|
|
129
141
|
origdir = tmpdir
|
|
130
142
|
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.
|
|
3
|
+
spec.version = "0.2.0"
|
|
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
|
|
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
|
|
|
16
16
|
# Specify which files should be added to the gem when it is released.
|
|
17
17
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
18
18
|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
19
|
-
`git ls-files -z 2
|
|
19
|
+
`git ls-files -z 2>#{IO::NULL}`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
20
20
|
end
|
|
21
21
|
spec.bindir = "exe"
|
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
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.
|
|
4
|
+
version: 0.2.0
|
|
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: 2023-11-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: fileutils
|
|
@@ -31,10 +31,11 @@ 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
|
|
37
|
-
- Gemfile.lock
|
|
38
39
|
- README.md
|
|
39
40
|
- Rakefile
|
|
40
41
|
- bin/console
|
|
@@ -56,14 +57,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
56
57
|
requirements:
|
|
57
58
|
- - ">="
|
|
58
59
|
- !ruby/object:Gem::Version
|
|
59
|
-
version: 2.
|
|
60
|
+
version: 2.7.0
|
|
60
61
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
62
|
requirements:
|
|
62
63
|
- - ">="
|
|
63
64
|
- !ruby/object:Gem::Version
|
|
64
65
|
version: '0'
|
|
65
66
|
requirements: []
|
|
66
|
-
rubygems_version: 3.
|
|
67
|
+
rubygems_version: 3.5.0.dev
|
|
67
68
|
signing_key:
|
|
68
69
|
specification_version: 4
|
|
69
70
|
summary: Extends the Dir class to manage the OS temporary file path.
|
data/Gemfile.lock
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
PATH
|
|
2
|
-
remote: .
|
|
3
|
-
specs:
|
|
4
|
-
tmpdir (0.1.0)
|
|
5
|
-
|
|
6
|
-
GEM
|
|
7
|
-
remote: https://rubygems.org/
|
|
8
|
-
specs:
|
|
9
|
-
power_assert (1.1.5)
|
|
10
|
-
rake (12.3.3)
|
|
11
|
-
test-unit (3.3.5)
|
|
12
|
-
power_assert
|
|
13
|
-
|
|
14
|
-
PLATFORMS
|
|
15
|
-
ruby
|
|
16
|
-
|
|
17
|
-
DEPENDENCIES
|
|
18
|
-
rake
|
|
19
|
-
test-unit
|
|
20
|
-
tmpdir!
|
|
21
|
-
|
|
22
|
-
BUNDLED WITH
|
|
23
|
-
2.1.4
|