tmpdir 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rdoc_options +3 -0
- data/BSDL +22 -0
- data/COPYING +56 -0
- data/docs/dir.rb +6 -0
- data/lib/tmpdir.rb +20 -5
- metadata +10 -13
- data/.github/dependabot.yml +0 -6
- data/.github/workflows/test.yml +0 -34
- data/.gitignore +0 -9
- data/Gemfile +0 -7
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/tmpdir.gemspec +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1180516b6bd6658a8a32cfefe017af10eb41ed5fa78312d7dd27163b032f1632
|
4
|
+
data.tar.gz: d7d4ebda12343e82d2fbfb1f750597692df607672bad6d3134637f94679a96b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 965aed93f89f7553bc5c780176119d397aa0b32a203b6f8913806a4e8925887cbe1f0cae96e073547cdf6f102a9c0b2d475fb323097ae9ec3e4e0bba63ba85ff
|
7
|
+
data.tar.gz: a48a3973178e8047b1aa139660f2808811e739e6aef1825c316093c1da9c85b8248290a125e0e2f9cd381aca8d39caa250e02d190b23be40f555d3e97fb70086
|
data/.rdoc_options
ADDED
data/BSDL
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (C) 1993-2013 Yukihiro Matsumoto. All rights reserved.
|
2
|
+
|
3
|
+
Redistribution and use in source and binary forms, with or without
|
4
|
+
modification, are permitted provided that the following conditions
|
5
|
+
are met:
|
6
|
+
1. Redistributions of source code must retain the above copyright
|
7
|
+
notice, this list of conditions and the following disclaimer.
|
8
|
+
2. Redistributions in binary form must reproduce the above copyright
|
9
|
+
notice, this list of conditions and the following disclaimer in the
|
10
|
+
documentation and/or other materials provided with the distribution.
|
11
|
+
|
12
|
+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
13
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
14
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
15
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
16
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
17
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
18
|
+
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
19
|
+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
20
|
+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
21
|
+
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
22
|
+
SUCH DAMAGE.
|
data/COPYING
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
|
2
|
+
You can redistribute it and/or modify it under either the terms of the
|
3
|
+
2-clause BSDL (see the file BSDL), or the conditions below:
|
4
|
+
|
5
|
+
1. You may make and give away verbatim copies of the source form of the
|
6
|
+
software without restriction, provided that you duplicate all of the
|
7
|
+
original copyright notices and associated disclaimers.
|
8
|
+
|
9
|
+
2. You may modify your copy of the software in any way, provided that
|
10
|
+
you do at least ONE of the following:
|
11
|
+
|
12
|
+
a. place your modifications in the Public Domain or otherwise
|
13
|
+
make them Freely Available, such as by posting said
|
14
|
+
modifications to Usenet or an equivalent medium, or by allowing
|
15
|
+
the author to include your modifications in the software.
|
16
|
+
|
17
|
+
b. use the modified software only within your corporation or
|
18
|
+
organization.
|
19
|
+
|
20
|
+
c. give non-standard binaries non-standard names, with
|
21
|
+
instructions on where to get the original software distribution.
|
22
|
+
|
23
|
+
d. make other distribution arrangements with the author.
|
24
|
+
|
25
|
+
3. You may distribute the software in object code or binary form,
|
26
|
+
provided that you do at least ONE of the following:
|
27
|
+
|
28
|
+
a. distribute the binaries and library files of the software,
|
29
|
+
together with instructions (in the manual page or equivalent)
|
30
|
+
on where to get the original distribution.
|
31
|
+
|
32
|
+
b. accompany the distribution with the machine-readable source of
|
33
|
+
the software.
|
34
|
+
|
35
|
+
c. give non-standard binaries non-standard names, with
|
36
|
+
instructions on where to get the original software distribution.
|
37
|
+
|
38
|
+
d. make other distribution arrangements with the author.
|
39
|
+
|
40
|
+
4. You may modify and include the part of the software into any other
|
41
|
+
software (possibly commercial). But some files in the distribution
|
42
|
+
are not written by the author, so that they are not under these terms.
|
43
|
+
|
44
|
+
For the list of those files and their copying conditions, see the
|
45
|
+
file LEGAL.
|
46
|
+
|
47
|
+
5. The scripts and library files supplied as input to or produced as
|
48
|
+
output from the software do not automatically fall under the
|
49
|
+
copyright of the software, but belong to whomever generated them,
|
50
|
+
and may be sold commercially, and may be aggregated with this
|
51
|
+
software.
|
52
|
+
|
53
|
+
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
54
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
55
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
56
|
+
PURPOSE.
|
data/docs/dir.rb
ADDED
data/lib/tmpdir.rb
CHANGED
@@ -22,6 +22,9 @@ class Dir
|
|
22
22
|
|
23
23
|
##
|
24
24
|
# Returns the operating system's temporary file path.
|
25
|
+
#
|
26
|
+
# require 'tmpdir'
|
27
|
+
# Dir.tmpdir # => "/tmp"
|
25
28
|
|
26
29
|
def self.tmpdir
|
27
30
|
['TMPDIR', 'TMP', 'TEMP', ['system temporary path', SYSTMPDIR], ['/tmp']*2, ['.']*2].find do |name, dir|
|
@@ -33,7 +36,9 @@ class Dir
|
|
33
36
|
case
|
34
37
|
when !stat.directory?
|
35
38
|
warn "#{name} is not a directory: #{dir}"
|
36
|
-
when !
|
39
|
+
when !File.writable?(dir)
|
40
|
+
# We call File.writable?, not stat.writable?, because you can't tell if a dir is actually
|
41
|
+
# writable just from stat; OS mechanisms other than user/group/world bits can affect this.
|
37
42
|
warn "#{name} is not writable: #{dir}"
|
38
43
|
when stat.world_writable? && !stat.sticky?
|
39
44
|
warn "#{name} is world-writable: #{dir}"
|
@@ -45,6 +50,11 @@ class Dir
|
|
45
50
|
|
46
51
|
# Dir.mktmpdir creates a temporary directory.
|
47
52
|
#
|
53
|
+
# require 'tmpdir'
|
54
|
+
# Dir.mktmpdir {|dir|
|
55
|
+
# # use the directory
|
56
|
+
# }
|
57
|
+
#
|
48
58
|
# The directory is created with 0700 permission.
|
49
59
|
# Application should not change the permission to make the temporary directory accessible from other users.
|
50
60
|
#
|
@@ -99,9 +109,10 @@ class Dir
|
|
99
109
|
yield path.dup
|
100
110
|
ensure
|
101
111
|
unless base
|
102
|
-
|
112
|
+
base = File.dirname(path)
|
113
|
+
stat = File.stat(base)
|
103
114
|
if stat.world_writable? and !stat.sticky?
|
104
|
-
raise ArgumentError, "parent directory is world writable but not sticky"
|
115
|
+
raise ArgumentError, "parent directory is world writable but not sticky: #{base}"
|
105
116
|
end
|
106
117
|
end
|
107
118
|
FileUtils.remove_entry path
|
@@ -139,7 +150,11 @@ class Dir
|
|
139
150
|
# Generates and yields random names to create a temporary name
|
140
151
|
def create(basename, tmpdir=nil, max_try: nil, **opts)
|
141
152
|
origdir = tmpdir
|
142
|
-
|
153
|
+
if tmpdir
|
154
|
+
raise ArgumentError, "empty parent path" if tmpdir.empty?
|
155
|
+
else
|
156
|
+
tmpdir = tmpdir()
|
157
|
+
end
|
143
158
|
n = nil
|
144
159
|
prefix, suffix = basename
|
145
160
|
prefix = (String.try_convert(prefix) or
|
@@ -158,7 +173,7 @@ class Dir
|
|
158
173
|
n ||= 0
|
159
174
|
n += 1
|
160
175
|
retry if !max_try or n < max_try
|
161
|
-
raise "cannot generate temporary name using
|
176
|
+
raise "cannot generate temporary name using '#{basename}' under '#{tmpdir}'"
|
162
177
|
end
|
163
178
|
path
|
164
179
|
end
|
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.3.0
|
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:
|
11
|
+
date: 2024-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fileutils
|
@@ -32,16 +32,13 @@ extensions: []
|
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
34
|
- ".document"
|
35
|
-
- ".
|
36
|
-
-
|
37
|
-
-
|
38
|
-
- Gemfile
|
35
|
+
- ".rdoc_options"
|
36
|
+
- BSDL
|
37
|
+
- COPYING
|
39
38
|
- README.md
|
40
39
|
- Rakefile
|
41
|
-
-
|
42
|
-
- bin/setup
|
40
|
+
- docs/dir.rb
|
43
41
|
- lib/tmpdir.rb
|
44
|
-
- tmpdir.gemspec
|
45
42
|
homepage: https://github.com/ruby/tmpdir
|
46
43
|
licenses:
|
47
44
|
- Ruby
|
@@ -49,7 +46,7 @@ licenses:
|
|
49
46
|
metadata:
|
50
47
|
homepage_uri: https://github.com/ruby/tmpdir
|
51
48
|
source_code_uri: https://github.com/ruby/tmpdir
|
52
|
-
post_install_message:
|
49
|
+
post_install_message:
|
53
50
|
rdoc_options: []
|
54
51
|
require_paths:
|
55
52
|
- lib
|
@@ -64,8 +61,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
61
|
- !ruby/object:Gem::Version
|
65
62
|
version: '0'
|
66
63
|
requirements: []
|
67
|
-
rubygems_version: 3.5.
|
68
|
-
signing_key:
|
64
|
+
rubygems_version: 3.5.11
|
65
|
+
signing_key:
|
69
66
|
specification_version: 4
|
70
67
|
summary: Extends the Dir class to manage the OS temporary file path.
|
71
68
|
test_files: []
|
data/.github/dependabot.yml
DELETED
data/.github/workflows/test.yml
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
name: test
|
2
|
-
|
3
|
-
on: [push, pull_request]
|
4
|
-
|
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
|
-
|
12
|
-
build:
|
13
|
-
needs: ruby-versions
|
14
|
-
name: build (${{ matrix.ruby }} / ${{ matrix.os }})
|
15
|
-
strategy:
|
16
|
-
matrix:
|
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 }
|
24
|
-
runs-on: ${{ matrix.os }}
|
25
|
-
steps:
|
26
|
-
- uses: actions/checkout@v4
|
27
|
-
- name: Set up Ruby
|
28
|
-
uses: ruby/setup-ruby@v1
|
29
|
-
with:
|
30
|
-
ruby-version: ${{ matrix.ruby }}
|
31
|
-
- name: Install dependencies
|
32
|
-
run: bundle install
|
33
|
-
- name: Run test
|
34
|
-
run: rake test
|
data/.gitignore
DELETED
data/Gemfile
DELETED
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "tmpdir"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start(__FILE__)
|
data/bin/setup
DELETED
data/tmpdir.gemspec
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
Gem::Specification.new do |spec|
|
2
|
-
spec.name = "tmpdir"
|
3
|
-
spec.version = "0.2.0"
|
4
|
-
spec.authors = ["Yukihiro Matsumoto"]
|
5
|
-
spec.email = ["matz@ruby-lang.org"]
|
6
|
-
|
7
|
-
spec.summary = %q{Extends the Dir class to manage the OS temporary file path.}
|
8
|
-
spec.description = %q{Extends the Dir class to manage the OS temporary file path.}
|
9
|
-
spec.homepage = "https://github.com/ruby/tmpdir"
|
10
|
-
spec.licenses = ["Ruby", "BSD-2-Clause"]
|
11
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
|
12
|
-
|
13
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
14
|
-
spec.metadata["source_code_uri"] = spec.homepage
|
15
|
-
|
16
|
-
# Specify which files should be added to the gem when it is released.
|
17
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
18
|
-
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
19
|
-
`git ls-files -z 2>#{IO::NULL}`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
|
-
end
|
21
|
-
spec.bindir = "exe"
|
22
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
-
spec.require_paths = ["lib"]
|
24
|
-
|
25
|
-
spec.add_dependency "fileutils"
|
26
|
-
end
|