tmpdir 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 23db0dc38a62002db3cbbe9dc185ba6d39a571ff12c064552d62162a511ae280
4
- data.tar.gz: a44a1139f82880434057a5206b73efbfcd7ddce39e6ebb5ae9b69d47d028f20a
3
+ metadata.gz: 9572f0043f9ac0057c01f47404fa7ef1fc380807cfc362c5f66a4ec9fd80f5cd
4
+ data.tar.gz: a3d8d5fe9f6cd2b54f3bc2c32cbc0fbb0ddfed898658049da9e7e588de8298c2
5
5
  SHA512:
6
- metadata.gz: 276895513eab16fa4e2ab9d78216f62b5438cf3a59d24e3be758dd64934bdd86db570590b41bb73480ae699781b2a2e1f36504ae4b34141f8503bca0d6c20001
7
- data.tar.gz: bff0818e6786cdc7b5084f57d4f3b270192fc850aced926fc0a41c40fb50d4d8a18397515c486fe7a73f8838dd8b1594dfda806ae3dd8fc50391c224bd7ab026
6
+ metadata.gz: d261987f369e87a27b22cf75d11cd880dd59d2ff7b25aa4030b345d27cccb2b34721d0b75243705feb97ea3ebbd70e973caae9e11602485c919da7aca02d6303
7
+ data.tar.gz: 9257c8f6160e0e8da8722dd4266afb09bdb7aedc972d9b149f18c169f028266daf59406c1eaac2651a4bd31768b5b83d862b7bbf93395ba8369701f3037e4e47
@@ -3,11 +3,18 @@ name: test
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: [ '3.1', '3.0', '2.7', head ]
17
+ ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
11
18
  os: [ ubuntu-latest, macos-latest, windows-latest ]
12
19
  exclude:
13
20
  - { os: windows-latest, ruby: head }
@@ -16,7 +23,7 @@ jobs:
16
23
  - { os: windows-latest, ruby: mswin }
17
24
  runs-on: ${{ matrix.os }}
18
25
  steps:
19
- - uses: actions/checkout@v3
26
+ - uses: actions/checkout@v4
20
27
  - name: Set up Ruby
21
28
  uses: ruby/setup-ruby@v1
22
29
  with:
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ /Gemfile.lock
data/Gemfile CHANGED
@@ -4,3 +4,4 @@ gemspec
4
4
 
5
5
  gem "rake"
6
6
  gem "test-unit"
7
+ gem "test-unit-ruby-core"
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/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,20 @@ end
13
13
 
14
14
  class Dir
15
15
 
16
- @@systmpdir ||= defined?(Etc.systmpdir) ? Etc.systmpdir : '/tmp'
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
- ['TMPDIR', 'TMP', 'TEMP', ['system temporary path', @@systmpdir], ['/tmp']*2, ['.']*2].find do |name, dir|
27
+ ['TMPDIR', 'TMP', 'TEMP', ['system temporary path', SYSTMPDIR], ['/tmp']*2, ['.']*2].find do |name, dir|
23
28
  unless dir
24
- next if !(dir = ENV[name]) or dir.empty?
29
+ next if !(dir = ENV[name] rescue next) or dir.empty?
25
30
  end
26
31
  dir = File.expand_path(dir)
27
32
  stat = File.stat(dir) rescue next
@@ -118,16 +123,17 @@ class Dir
118
123
  UNUSABLE_CHARS = "^,-.0-9A-Z_a-z~"
119
124
 
120
125
  # Dedicated random number generator
121
- RANDOM = Random.new
126
+ RANDOM = Object.new
122
127
  class << RANDOM # :nodoc:
123
128
  # Maximum random number
124
129
  MAX = 36**6 # < 0x100000000
125
130
 
126
131
  # Returns new random string upto 6 bytes
127
132
  def next
128
- rand(MAX).to_s(36)
133
+ (::Random.urandom(4).unpack1("L")%MAX).to_s(36)
129
134
  end
130
135
  end
136
+ RANDOM.freeze
131
137
  private_constant :RANDOM
132
138
 
133
139
  # Generates and yields random names to create a temporary name
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"
3
+ spec.version = "0.2.0"
4
4
  spec.authors = ["Yukihiro Matsumoto"]
5
5
  spec.email = ["matz@ruby-lang.org"]
6
6
 
@@ -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>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
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.1.3
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: 2022-12-05 00:00:00.000000000 Z
11
+ date: 2023-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fileutils
@@ -36,7 +36,6 @@ files:
36
36
  - ".github/workflows/test.yml"
37
37
  - ".gitignore"
38
38
  - Gemfile
39
- - Gemfile.lock
40
39
  - README.md
41
40
  - Rakefile
42
41
  - bin/console
@@ -65,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
64
  - !ruby/object:Gem::Version
66
65
  version: '0'
67
66
  requirements: []
68
- rubygems_version: 3.4.0.dev
67
+ rubygems_version: 3.5.0.dev
69
68
  signing_key:
70
69
  specification_version: 4
71
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