file-temp 1.6.0 → 1.7.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: 75e2f5bc74f512cad14b4b8c48e2d4ec6ea79f581df34bd3d98cf3867f9745e5
4
- data.tar.gz: 731f4cbb1c1096ff23d070f06cefde7c3bc93790ad8be7e63ddbbbc5137f434c
3
+ metadata.gz: 720ea1ce81f51967d708b7cff1756ec572337149a9312f38639654db1cb053ed
4
+ data.tar.gz: 5e2076ee4cc854a014789b26c1a21a520a1aa83af301de9e0e0677953da2c423
5
5
  SHA512:
6
- metadata.gz: 3700145f748426eb5770c6e984f35c856c55bd12f3edc3d55fb2c41f45f198ba1925cf5c4a1a2885a92dc9b31e58444464c7d3ad6f4295f71bfd88a8d41aff68
7
- data.tar.gz: 523dfae153d35f178178f8f36a9e14c184d2a4c65a75f7c2ce9a8f1ac42a322750506c8c775d277a46f6eeb8a317318bda09e1544fdb2e0aab21895c3007ad34
6
+ metadata.gz: fe66533b78b824b96cb75e03632ef5dc94ee4df4bedbb1f717d1fdb0c3a00bcd8b768bdc645d6453fd4b8ba5ff5ea739a38d128c472d9da95fc14f1cd5b104ec
7
+ data.tar.gz: 249034641f45d4523ea15ee6c64195fdae53ec0727305bd11fed655463c2a89dbb92510f1c281bdadd3357039777b15255f35da7d08f756ed6d5241d5689acba
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,8 @@
1
+ = 1.7.0 - 1-Jul-2020
2
+ * Replaced test-unit with rspec, and updated the tests.
3
+ * Updated ffi dependency to 1.1.x.
4
+ * Removed some archiving options from the Rakefile that I wasn't using.
5
+
1
6
  = 1.6.0 - 9-May-2020
2
7
  * Added an +options+ argument that is passed along as options to the the
3
8
  underlying File.new constructor.
@@ -10,4 +10,4 @@
10
10
  * lib/file/java/temp.rb
11
11
  * lib/file/unix/temp.rb
12
12
  * lib/file/windows/temp.rb
13
- * test/test_file_temp.rb
13
+ * spec/file_temp_spec.rb
@@ -2,7 +2,7 @@
2
2
  The file-temp library is an alternate way to handle tempfile generation.
3
3
 
4
4
  == Requirements
5
- * ffi 1.0.0 or later
5
+ * ffi 1.1.0 or later
6
6
 
7
7
  == Installation
8
8
  gem install file-temp
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'rake'
2
2
  require 'rake/clean'
3
- require 'rake/testtask'
3
+ require 'rspec/core/rake_task'
4
4
 
5
5
  CLEAN.include('**/*.tar', '**/*.zip', '**/*.gz', '**/*.bz2')
6
6
  CLEAN.include('**/*.rbc', '**/*.gem', '**/*.tmp')
@@ -21,43 +21,7 @@ namespace 'gem' do
21
21
  end
22
22
  end
23
23
 
24
- # Export the contents of the library to an archive. Note that this requires
25
- # presence of the .gitattributes file in order to prevent the .git contents
26
- # from being included.
27
- #
28
- # It also appears that I must add a trailing slash to the prefix manually.
29
- # As of git 1.6.4.3 it does not automaticaly add it, despite what the docs
30
- # say.
31
- #
32
- namespace 'export' do
33
- spec = eval(IO.read('file-temp.gemspec'))
34
- file = 'file-temp-' + spec.version.to_s
35
- pref = file + '/' # Git does not add the trailing slash, despite what the docs say.
24
+ desc 'Run the test suite for the file-temp library'
25
+ RSpec::Core::RakeTask.new(:spec)
36
26
 
37
- desc 'Export to a .tar.gz file'
38
- task :gzip => [:clean] do
39
- file += '.tar'
40
- sh "git archive --prefix #{pref} --output #{file} master"
41
- sh "gzip #{file}"
42
- end
43
-
44
- desc 'Export to a .tar.bz2 file'
45
- task :bzip2 => [:clean] do
46
- file += '.tar'
47
- sh "git archive --prefix #{pref} --output #{file} master"
48
- sh "bzip2 -f #{file}"
49
- end
50
-
51
- desc 'Export to a .zip file'
52
- task :zip => [:clean] do
53
- file += '.zip'
54
- sh "git archive --prefix #{pref} --output #{file} --format zip master"
55
- end
56
- end
57
-
58
- Rake::TestTask.new do |t|
59
- t.verbose = true
60
- t.warning = true
61
- end
62
-
63
- task :default => :test
27
+ task :default => :spec
@@ -2,20 +2,20 @@ require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'file-temp'
5
- spec.version = '1.6.0'
5
+ spec.version = '1.7.0'
6
6
  spec.author = 'Daniel J. Berger'
7
7
  spec.license = 'Apache-2.0'
8
8
  spec.email = 'djberg96@gmail.com'
9
9
  spec.homepage = 'http://github.com/djberg96/file-temp'
10
10
  spec.summary = 'An alternative way to generate temp files'
11
- spec.test_file = 'test/test_file_temp.rb'
11
+ spec.test_file = 'spec/file_temp_spec.rb'
12
12
  spec.files = Dir['**/*'].delete_if{ |item| item.include?('git') }
13
13
  spec.cert_chain = Dir['certs/*']
14
14
 
15
15
  spec.extra_rdoc_files = ['CHANGES.rdoc', 'README.rdoc', 'MANIFEST.rdoc']
16
16
 
17
- spec.add_dependency('ffi', '>= 1.0.0')
18
- spec.add_development_dependency('test-unit')
17
+ spec.add_dependency('ffi', '~> 1.1')
18
+ spec.add_development_dependency('rspec', '~> 3.9')
19
19
  spec.add_development_dependency('rake')
20
20
 
21
21
  spec.metadata = {
@@ -1,6 +1,6 @@
1
1
  class File::Temp < File
2
2
  # The version of the file-temp library
3
- VERSION = '1.6.0'.freeze
3
+ VERSION = '1.7.0'.freeze
4
4
  end
5
5
 
6
6
  if RUBY_PLATFORM == 'java'
@@ -0,0 +1,159 @@
1
+ ######################################################################
2
+ # file_temp_spec.rb
3
+ #
4
+ # Test suite for the file-temp library. These tests should be run
5
+ # via the 'rake spec' task.
6
+ ######################################################################
7
+ require 'rspec'
8
+ require 'file/temp'
9
+
10
+ RSpec.describe File::Temp do
11
+ let(:windows) { File::ALT_SEPARATOR }
12
+ let(:osx) { RbConfig::CONFIG['host_os'] =~ /darwin/i }
13
+
14
+ before do
15
+ @dir = File::Temp::TMPDIR
16
+ @template = 'file-temp-test-XXXXX'
17
+ @fh = nil
18
+
19
+ # Because Dir[] doesn't work right with backslashes
20
+ @dir = @dir.tr("\\", "/") if windows
21
+ end
22
+
23
+ context "constants" do
24
+ example "library version is set to expected value" do
25
+ expect( File::Temp::VERSION).to eq('1.7.0')
26
+ expect(File::Temp::VERSION).to be_frozen
27
+ end
28
+
29
+ example "TMPDIR constant is defined" do
30
+ expect(File::Temp::TMPDIR).to be_kind_of(String)
31
+ expect(File::Temp::TMPDIR.size).to be > 0
32
+ end
33
+ end
34
+
35
+ context "threads" do
36
+ example "library works as expected with multiple threads" do
37
+ threads = []
38
+ expect{ 100.times{ threads << Thread.new{ File::Temp.new }}}.not_to raise_error
39
+ expect{ threads.each{ |t| t.join }.not_to raise_error }
40
+ end
41
+ end
42
+
43
+ context "constructor" do
44
+ example "constructor works as expected with default auto delete option" do
45
+ expect{
46
+ @fh = File::Temp.new
47
+ @fh.print "hello"
48
+ @fh.close
49
+ }.not_to raise_error
50
+ end
51
+
52
+ example "constructor works as expected with false auto delete option" do
53
+ expect{
54
+ @fh = File::Temp.new(:delete => false)
55
+ @fh.print "hello"
56
+ @fh.close
57
+ }.not_to raise_error
58
+ end
59
+
60
+ example "constructor accepts and uses an optional template as expected" do
61
+ expect{ File::Temp.new(:delete => false, :template => 'temp_foo_XXXXXX').close }.not_to raise_error
62
+ expect(Dir["#{@dir}/temp_foo*"].length).to be >= 1
63
+ end
64
+
65
+ example "constructor with false auto delete and block works as expected" do
66
+ expect{
67
+ File::Temp.open(:delete => false, :template => 'temp_foo_XXXXXX'){ |fh| fh.puts "hello" }
68
+ }.not_to raise_error
69
+ expect(Dir["#{@dir}/temp_foo*"].length).to be >= 1
70
+ end
71
+
72
+ example "constructor accepts a maximum of three arguments" do
73
+ expect{
74
+ @fh = File::Temp.new(
75
+ :delete => true,
76
+ :template => 'temp_bar_XXXXX',
77
+ :directory => Dir.pwd,
78
+ :bogus => 1
79
+ )
80
+ }.to raise_error(ArgumentError)
81
+ end
82
+ end
83
+
84
+ context "template" do
85
+ example "template argument must be a string" do
86
+ expect{ @fh = File::Temp.new(:delete => false, :template => 1) }.to raise_error(TypeError)
87
+ end
88
+
89
+ example "an error is raised if a custom template is invalid" do
90
+ skip "skipped on OSX" if osx
91
+ expect{ File::Temp.new(:delete => false, :template => 'xx') }.to raise_error(Errno::EINVAL)
92
+ end
93
+ end
94
+
95
+ context "temp_name" do
96
+ example "temp_name basic functionality" do
97
+ expect(File::Temp).to respond_to(:temp_name)
98
+ expect{ File::Temp.temp_name }.not_to raise_error
99
+ expect(File::Temp.temp_name).to be_kind_of(String)
100
+ end
101
+
102
+ example "temp_name returns expected value" do
103
+ if windows
104
+ expect( File.extname(File::Temp.temp_name)).to match(/^.*?\d*?tmp/)
105
+ else
106
+ expect( File.extname(File::Temp.temp_name)).to eq('.tmp')
107
+ end
108
+ end
109
+ end
110
+
111
+ context "path" do
112
+ example "temp path basic functionality" do
113
+ @fh = File::Temp.new
114
+ expect(@fh).to respond_to(:path)
115
+ end
116
+
117
+ example "temp path is nil if delete option is true" do
118
+ @fh = File::Temp.new
119
+ expect(@fh.path).to be_nil
120
+ end
121
+
122
+ example "temp path is not nil if delete option is false" do
123
+ @fh = File::Temp.new(delete: false)
124
+ expect(@fh.path).not_to be_nil
125
+ end
126
+ end
127
+
128
+ context "ffi" do
129
+ example "ffi functions are private" do
130
+ methods = File::Temp.methods(false).map(&:to_s)
131
+ expect(methods).not_to include('_fileno')
132
+ expect(methods).not_to include('mkstemp')
133
+ expect(methods).not_to include('_umask')
134
+ expect(methods).not_to include('fclose')
135
+ expect(methods).not_to include('strerror')
136
+ expect(methods).not_to include('tmpnam')
137
+ expect(methods).not_to include('CloseHandle')
138
+ expect(methods).not_to include('CreateFileA')
139
+ expect(methods).not_to include('DeleteFileA')
140
+ expect(methods).not_to include('GetTempPathA')
141
+ expect(methods).not_to include('GetTempFileNameA')
142
+ end
143
+ end
144
+
145
+ after do
146
+ @dir = nil
147
+ @template = nil
148
+ @fh.close if @fh && !@fh.closed?
149
+ @fh = nil
150
+
151
+ Dir["temp_*"].each{ |f| File.delete(f) }
152
+ Dir["rb_file_temp_*"].each{ |f| File.delete(f) }
153
+
154
+ Dir.chdir(File::Temp::TMPDIR) do
155
+ Dir["temp_*"].each{ |f| File.delete(f) }
156
+ Dir["rb_file_temp_*"].each{ |f| File.delete(f) }
157
+ end
158
+ end
159
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: file-temp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
@@ -41,30 +41,30 @@ dependencies:
41
41
  name: ffi
42
42
  requirement: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - ">="
44
+ - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: 1.0.0
46
+ version: '1.1'
47
47
  type: :runtime
48
48
  prerelease: false
49
49
  version_requirements: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - ">="
51
+ - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: 1.0.0
53
+ version: '1.1'
54
54
  - !ruby/object:Gem::Dependency
55
- name: test-unit
55
+ name: rspec
56
56
  requirement: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - ">="
58
+ - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '0'
60
+ version: '3.9'
61
61
  type: :development
62
62
  prerelease: false
63
63
  version_requirements: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - ">="
65
+ - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '0'
67
+ version: '3.9'
68
68
  - !ruby/object:Gem::Dependency
69
69
  name: rake
70
70
  requirement: !ruby/object:Gem::Requirement
@@ -92,9 +92,9 @@ extra_rdoc_files:
92
92
  - MANIFEST.rdoc
93
93
  files:
94
94
  - LICENSE
95
- - test
96
- - test/test_file_temp.rb
97
95
  - file-temp.gemspec
96
+ - spec
97
+ - spec/file_temp_spec.rb
98
98
  - Rakefile
99
99
  - certs
100
100
  - certs/djberg96_pub.pem
@@ -141,4 +141,4 @@ signing_key:
141
141
  specification_version: 4
142
142
  summary: An alternative way to generate temp files
143
143
  test_files:
144
- - test/test_file_temp.rb
144
+ - spec/file_temp_spec.rb
metadata.gz.sig CHANGED
Binary file
@@ -1,138 +0,0 @@
1
- ######################################################################
2
- # test_file_temp.rb
3
- #
4
- # Test suite for the file-temp library. These tests should be run
5
- # via the 'rake test' task.
6
- ######################################################################
7
- require 'rubygems'
8
- require 'test-unit'
9
- require 'file/temp'
10
-
11
- class TC_File_Temp < Test::Unit::TestCase
12
- WINDOWS = File::ALT_SEPARATOR
13
- OSX = RbConfig::CONFIG['host_os'] =~ /darwin/i
14
-
15
- def setup
16
- @dir = File::Temp::TMPDIR
17
- @template = 'file-temp-test-XXXXX'
18
- @fh = nil
19
-
20
- # Because Dir[] doesn't work right with backslashes
21
- @dir = @dir.tr("\\", "/") if WINDOWS
22
- end
23
-
24
- test "library version is set to expected value" do
25
- assert_equal('1.6.0', File::Temp::VERSION)
26
- assert_true(File::Temp::VERSION.frozen?)
27
- end
28
-
29
- # Fails with JRuby, not sure why.
30
- test "library works as expected with multiple threads" do
31
- threads = []
32
- assert_nothing_raised{ 100.times{ threads << Thread.new{ File::Temp.new }}}
33
- assert_nothing_raised{ threads.each{ |t| t.join } }
34
- end
35
-
36
- test "TMPDIR constant is defined" do
37
- assert_not_nil(File::Temp::TMPDIR)
38
- assert_kind_of(String, File::Temp::TMPDIR)
39
- end
40
-
41
- test "constructor works as expected with default auto delete option" do
42
- assert_nothing_raised{
43
- @fh = File::Temp.new
44
- @fh.print "hello"
45
- @fh.close
46
- }
47
- end
48
-
49
- test "constructor works as expected with false auto delete option" do
50
- assert_nothing_raised{
51
- @fh = File::Temp.new(:delete => false)
52
- @fh.print "hello"
53
- @fh.close
54
- }
55
- end
56
-
57
- test "constructor accepts and uses an optional template as expected" do
58
- assert_nothing_raised{ File::Temp.new(:delete => false, :template => 'temp_foo_XXXXXX').close }
59
- assert_true(Dir["#{@dir}/temp_foo*"].length >= 1)
60
- end
61
-
62
- test "constructor with false auto delete and block works as expected" do
63
- assert_nothing_raised{ File::Temp.open(:delete => false, :template => 'temp_foo_XXXXXX'){ |fh| fh.puts "hello" } }
64
- assert_true(Dir["#{@dir}/temp_foo*"].length >= 1)
65
- end
66
-
67
- test "template argument must be a string" do
68
- assert_raise(TypeError, ArgumentError){ @fh = File::Temp.new(:delete => false, :template => 1) }
69
- end
70
-
71
- test "an error is raised if a custom template is invalid" do
72
- omit_if(OSX)
73
- assert_raise(Errno::EINVAL){ File::Temp.new(:delete => false, :template => 'xx') }
74
- end
75
-
76
- test "constructor accepts a maximum of three arguments" do
77
- assert_raise(ArgumentError){ @fh = File::Temp.new(:delete => true, :template => 'temp_bar_XXXXX', :directory => Dir.pwd, :bogus => 1) }
78
- end
79
-
80
- test "temp_name basic functionality" do
81
- assert_respond_to(File::Temp, :temp_name)
82
- assert_nothing_raised{ File::Temp.temp_name }
83
- assert_kind_of(String, File::Temp.temp_name)
84
- end
85
-
86
- test "temp_name returns expected value" do
87
- if File::ALT_SEPARATOR
88
- assert_match(/^.*?\d*?tmp/, File.extname(File::Temp.temp_name))
89
- else
90
- assert_equal('.tmp', File.extname(File::Temp.temp_name))
91
- end
92
- end
93
-
94
- test "temp path basic functionality" do
95
- @fh = File::Temp.new
96
- assert_respond_to(@fh, :path)
97
- end
98
-
99
- test "temp path is nil if delete option is true" do
100
- @fh = File::Temp.new
101
- assert_nil(@fh.path)
102
- end
103
-
104
- test "temp path is not nil if delete option is false" do
105
- @fh = File::Temp.new(delete: false)
106
- assert_not_nil(@fh.path)
107
- end
108
-
109
- test "ffi functions are private" do
110
- methods = File::Temp.methods(false).map{ |e| e.to_s }
111
- assert_false(methods.include?('_fileno'))
112
- assert_false(methods.include?('mkstemp'))
113
- assert_false(methods.include?('_umask'))
114
- assert_false(methods.include?('fclose'))
115
- assert_false(methods.include?('strerror'))
116
- assert_false(methods.include?('tmpnam'))
117
- assert_false(methods.include?('CloseHandle'))
118
- assert_false(methods.include?('CreateFileA'))
119
- assert_false(methods.include?('DeleteFileA'))
120
- assert_false(methods.include?('GetTempPathA'))
121
- assert_false(methods.include?('GetTempFileNameA'))
122
- end
123
-
124
- def teardown
125
- @dir = nil
126
- @template = nil
127
- @fh.close if @fh && !@fh.closed?
128
- @fh = nil
129
-
130
- Dir["temp_*"].each{ |f| File.delete(f) }
131
- Dir["rb_file_temp_*"].each{ |f| File.delete(f) }
132
-
133
- Dir.chdir(File::Temp::TMPDIR) do
134
- Dir["temp_*"].each{ |f| File.delete(f) }
135
- Dir["rb_file_temp_*"].each{ |f| File.delete(f) }
136
- end
137
- end
138
- end