win32-file 0.5.5 → 0.5.6

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.
data/CHANGES CHANGED
@@ -1,3 +1,12 @@
1
+ == 0.5.6 - 30-Sep-2008
2
+ * The File.long_path and File.short_path methods now return the full path
3
+ instead of just the basename of the path. I really have no idea why I was
4
+ doing that before, but it's fixed now.
5
+ * Fixed error handling in the File#compressed= and File#sparse= methods.
6
+ * All tests were renamed and refactored to use test-unix 2.x, which is now
7
+ a pre-requisite for this library.
8
+ * Some gemspec updates, including a rubyforge project.
9
+
1
10
  == 0.5.5 - 22-Nov-2007
2
11
  * Fixed a bug in the File.dirname method with regards to relative paths.
3
12
  Thanks go to an Laust Rud for the spot.
@@ -136,4 +145,4 @@
136
145
  * Documentation additions
137
146
 
138
147
  == 0.1.0 - 29-Oct-2003
139
- * Initial release
148
+ * Initial release
data/MANIFEST CHANGED
@@ -5,9 +5,9 @@
5
5
  * win32-file.gemspec
6
6
  * lib/win32/file.rb
7
7
  * test/sometestfile.txt
8
- * test/tc_file_attributes.rb
9
- * test/tc_file_constants.rb
10
- * test/tc_file_encryption.rb
11
- * test/tc_file_path.rb
12
- * test/tc_file_security.rb
13
- * test/tc_file_stat.rb
8
+ * test/test_win32_file_attributes.rb
9
+ * test/test_win32_file_constants.rb
10
+ * test/test_win32_file_encryption.rb
11
+ * test/test_win32_file_path.rb
12
+ * test/test_win32_file_security.rb
13
+ * test/test_win32_file_stat.rb
data/Rakefile CHANGED
@@ -3,11 +3,14 @@ require 'rake/testtask'
3
3
  require 'rbconfig'
4
4
  include Config
5
5
 
6
+ desc 'Clean any text files that may have been left over from tests'
6
7
  task :clean do
7
- rm 'sometestfile.txt' if File.exists? 'sometestfile.txt'
8
+ Dir['test/*'].each{ |file|
9
+ rm file if File.extname(file) == '.txt'
10
+ }
8
11
  end
9
12
 
10
- desc 'Install the win32-file package (non-gem)'
13
+ desc 'Install the win32-file library (non-gem)'
11
14
  task :install do
12
15
  sitelibdir = CONFIG['sitelibdir']
13
16
  installdir = File.join(sitelibdir, 'win32')
@@ -17,7 +20,7 @@ task :install do
17
20
  FileUtils.cp(file, installdir, :verbose => true)
18
21
  end
19
22
 
20
- desc 'Install the win32-file package as a gem'
23
+ desc 'Install the win32-file library as a gem'
21
24
  task :install_gem => [:clean] do
22
25
  ruby 'win32-file.gemspec'
23
26
  file = Dir['win32-file*.gem'].first
@@ -25,44 +28,42 @@ task :install_gem => [:clean] do
25
28
  end
26
29
 
27
30
  Rake::TestTask.new("test") do |t|
28
- t.libs << 'test'
29
31
  t.verbose = true
30
32
  t.warning = true
31
- t.test_files = FileList['test/tc*']
32
33
  end
33
34
 
34
35
  Rake::TestTask.new("test_attributes") do |t|
35
36
  t.verbose = true
36
37
  t.warning = true
37
- t.test_files = FileList['test/tc_file_attributes.rb']
38
+ t.test_files = FileList['test/test_win32_file_attributes.rb']
38
39
  end
39
40
 
40
41
  Rake::TestTask.new("test_constants") do |t|
41
42
  t.verbose = true
42
43
  t.warning = true
43
- t.test_files = FileList['test/tc_file_constants.rb']
44
+ t.test_files = FileList['test/test_win32_file_constants.rb']
44
45
  end
45
46
 
46
47
  Rake::TestTask.new("test_encryption") do |t|
47
48
  t.verbose = true
48
49
  t.warning = true
49
- t.test_files = FileList['test/tc_file_encryption.rb']
50
+ t.test_files = FileList['test/test_win32_file_encryption.rb']
50
51
  end
51
52
 
52
53
  Rake::TestTask.new("test_path") do |t|
53
54
  t.verbose = true
54
55
  t.warning = true
55
- t.test_files = FileList['test/tc_file_path.rb']
56
+ t.test_files = FileList['test/test_win32_file_path.rb']
56
57
  end
57
58
 
58
59
  Rake::TestTask.new("test_security") do |t|
59
60
  t.verbose = true
60
61
  t.warning = true
61
- t.test_files = FileList['test/tc_file_security.rb']
62
+ t.test_files = FileList['test/test_win32_file_security.rb']
62
63
  end
63
64
 
64
65
  Rake::TestTask.new("test_stat") do |t|
65
66
  t.verbose = true
66
67
  t.warning = true
67
- t.test_files = FileList['test/tc_file_stat.rb']
68
- end
68
+ t.test_files = FileList['test/test_win32_file_stat.rb']
69
+ end
@@ -3,12 +3,13 @@ require 'windows/limits'
3
3
  require 'win32/file/stat'
4
4
 
5
5
  class File
6
- # Some of these are courtesy of win32-file-stat
7
6
  include Windows::Error
8
7
  include Windows::File
9
8
  include Windows::Security
10
9
  include Windows::Limits
11
10
  include Windows::DeviceIO
11
+ include Windows::Handle
12
+
12
13
  extend Windows::Error
13
14
  extend Windows::File
14
15
  extend Windows::Path
@@ -16,10 +17,11 @@ class File
16
17
  extend Windows::MSVCRT::Buffer
17
18
  extend Windows::Limits
18
19
 
19
- VERSION = '0.5.5'
20
- MAX_PATH = 260
20
+ # The version of the win32-file library
21
+ VERSION = '0.5.6'
21
22
 
22
23
  # Abbreviated attribute constants for convenience
24
+
23
25
  ARCHIVE = FILE_ATTRIBUTE_ARCHIVE
24
26
  COMPRESSED = FILE_ATTRIBUTE_COMPRESSED
25
27
  HIDDEN = FILE_ATTRIBUTE_HIDDEN
@@ -32,6 +34,7 @@ class File
32
34
  CONTENT_INDEXED = 0x0002000
33
35
 
34
36
  # Custom Security rights
37
+
35
38
  FULL = STANDARD_RIGHTS_ALL | FILE_READ_DATA | FILE_WRITE_DATA |
36
39
  FILE_APPEND_DATA | FILE_READ_EA | FILE_WRITE_EA | FILE_EXECUTE |
37
40
  FILE_DELETE_CHILD | FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES
@@ -313,9 +316,9 @@ class File
313
316
  memcpy(ace_buf, ace_ptr.unpack('L').first, ace_buf.size)
314
317
 
315
318
  if ace_buf.unpack('CCS').first == ACCESS_ALLOWED_ACE_TYPE
316
- name = 0.chr * MAX_PATH
319
+ name = 0.chr * MAXPATH
317
320
  name_size = [name.size].pack('L')
318
- domain = 0.chr * MAX_PATH
321
+ domain = 0.chr * MAXPATH
319
322
  domain_size = [domain.size].pack('L')
320
323
  snu_ptr = 0.chr * 4
321
324
 
@@ -488,7 +491,7 @@ class File
488
491
  file
489
492
  end
490
493
 
491
- # Returns +file+ in long format. For example, if 'SOMEFI~1.TXT'
494
+ # Returns +path+ in long format. For example, if 'SOMEFI~1.TXT'
492
495
  # was the argument provided, and the short representation for
493
496
  # 'somefile.txt', then this method would return 'somefile.txt'.
494
497
  #
@@ -496,23 +499,23 @@ class File
496
499
  # from working as expected. In that case, you will get back the file
497
500
  # name in 8.3 format.
498
501
  #
499
- def long_path(file)
500
- buf = 0.chr * MAX_PATH
501
- if GetLongPathName(file, buf, buf.size) == 0
502
+ def long_path(path)
503
+ buf = 0.chr * MAXPATH
504
+ if GetLongPathName(path, buf, buf.size) == 0
502
505
  raise ArgumentError, get_last_error
503
506
  end
504
- File.basename(buf.split(0.chr).first.strip)
507
+ buf.split(0.chr).first
505
508
  end
506
509
 
507
- # Returns 'file_name' in 8.3 format. For example, 'c:\documentation.doc'
510
+ # Returns +path+ in 8.3 format. For example, 'c:\documentation.doc'
508
511
  # would be returned as 'c:\docume~1.doc'.
509
512
  #
510
- def short_path(file)
511
- buf = 0.chr * MAX_PATH
512
- if GetShortPathName(file, buf, buf.size) == 0
513
+ def short_path(path)
514
+ buf = 0.chr * MAXPATH
515
+ if GetShortPathName(path, buf, buf.size) == 0
513
516
  raise ArgumentError, get_last_error
514
517
  end
515
- File.basename(buf.split(0.chr).first.strip)
518
+ buf.split(0.chr).first
516
519
  end
517
520
 
518
521
  # Splits the given string into a directory and a file component and
@@ -796,6 +799,7 @@ class File
796
799
  in_buf = [in_buf].pack('L')
797
800
  bytes = [0].pack('L')
798
801
 
802
+ # We can't use get_osfhandle here because we need specific attributes
799
803
  handle = CreateFile(
800
804
  self.path,
801
805
  FILE_READ_DATA | FILE_WRITE_DATA,
@@ -809,20 +813,24 @@ class File
809
813
  if handle == INVALID_HANDLE_VALUE
810
814
  raise ArgumentError, get_last_error
811
815
  end
816
+
817
+ begin
818
+ bool = DeviceIoControl(
819
+ handle,
820
+ FSCTL_SET_COMPRESSION(),
821
+ in_buf,
822
+ in_buf.length,
823
+ 0,
824
+ 0,
825
+ bytes,
826
+ 0
827
+ )
812
828
 
813
- val = DeviceIoControl(
814
- handle,
815
- FSCTL_SET_COMPRESSION(),
816
- in_buf,
817
- in_buf.length,
818
- 0,
819
- 0,
820
- bytes,
821
- 0
822
- )
823
-
824
- if val == 0
825
- raise ArgumentError, get_last_error
829
+ unless bool
830
+ raise ArgumentError, get_last_error
831
+ end
832
+ ensure
833
+ CloseHandle(handle)
826
834
  end
827
835
 
828
836
  self
@@ -969,19 +977,23 @@ class File
969
977
  raise ArgumentError, get_last_error
970
978
  end
971
979
 
972
- val = DeviceIoControl(
973
- handle,
974
- FSCTL_SET_SPARSE(),
975
- 0,
976
- 0,
977
- 0,
978
- 0,
979
- bytes,
980
- 0
981
- )
980
+ begin
981
+ bool = DeviceIoControl(
982
+ handle,
983
+ FSCTL_SET_SPARSE(),
984
+ 0,
985
+ 0,
986
+ 0,
987
+ 0,
988
+ bytes,
989
+ 0
990
+ )
982
991
 
983
- if val == 0
984
- raise ArgumentError, get_last_error
992
+ unless bool == 0
993
+ raise ArgumentError, get_last_error
994
+ end
995
+ ensure
996
+ CloseHandle(handle)
985
997
  end
986
998
 
987
999
  self
@@ -1,63 +1,72 @@
1
1
  #############################################################################
2
- # tc_file_attributes.rb
2
+ # test_win32_file_attributes.rb
3
3
  #
4
4
  # Test case for the attribute related methods of win32-file. You should run
5
5
  # this via the 'rake test' or 'rake test_attributes' task.
6
6
  #############################################################################
7
+ require 'rubygems'
8
+ gem 'test-unit'
9
+
7
10
  require 'test/unit'
8
11
  require 'win32/file'
9
12
 
10
13
  class TC_Win32_File_Attributes < Test::Unit::TestCase
11
14
  include Windows::File
15
+ extend Windows::File
16
+
17
+ def self.startup
18
+ Dir.chdir('test') unless File.basename(Dir.pwd) == 'test'
19
+ @@file = File.join(Dir.pwd, 'test_file.txt')
20
+ File.open(@@file, 'w'){ |fh| fh.puts "This is a test." }
21
+ end
22
+
12
23
  def setup
13
- @dir = File.dirname(File.expand_path(__FILE__))
14
- @file = File.join(@dir, 'sometestfile.txt')
15
- @fh = File.open(@file)
16
- @attr = GetFileAttributes(@file)
24
+ @fh = File.open(@@file)
25
+ @attr = GetFileAttributes(@@file)
17
26
  end
18
27
 
19
28
  def test_version
20
- assert_equal('0.5.5', File::VERSION)
29
+ assert_equal('0.5.6', File::VERSION)
21
30
  end
22
31
 
23
32
  def test_temporary
24
33
  assert_respond_to(File, :temporary?)
25
- assert_nothing_raised{ File.temporary?(@file) }
26
- assert_equal(false, File.temporary?(@file))
34
+ assert_nothing_raised{ File.temporary?(@@file) }
35
+ assert_equal(false, File.temporary?(@@file))
27
36
  end
28
37
 
29
38
  def test_temporary_instance
30
39
  assert_respond_to(@fh, :temporary=)
31
40
  assert_nothing_raised{ @fh.temporary = true }
32
- assert(File.temporary?(@file))
41
+ assert(File.temporary?(@@file))
33
42
  end
34
43
 
35
44
  def test_temporary_expected_errors
36
45
  assert_raises(ArgumentError){ File.temporary? }
37
- assert_raises(ArgumentError){ File.temporary?(@file, 'foo') }
46
+ assert_raises(ArgumentError){ File.temporary?(@@file, 'foo') }
38
47
  end
39
48
 
40
49
  def test_system
41
50
  assert_respond_to(File, :system?)
42
- assert_nothing_raised{ File.system?(@file) }
43
- assert_equal(false, File.system?(@file))
51
+ assert_nothing_raised{ File.system?(@@file) }
52
+ assert_equal(false, File.system?(@@file))
44
53
  end
45
54
 
46
55
  def test_system_instance
47
56
  assert_respond_to(@fh, :system=)
48
57
  assert_nothing_raised{ @fh.system = true }
49
- assert(File.system?(@file))
58
+ assert(File.system?(@@file))
50
59
  end
51
60
 
52
61
  def test_system_expected_errors
53
62
  assert_raises(ArgumentError){ File.system? }
54
- assert_raises(ArgumentError){ File.system?(@file, 'foo') }
63
+ assert_raises(ArgumentError){ File.system?(@@file, 'foo') }
55
64
  end
56
65
 
57
66
  def test_sparse
58
67
  assert_respond_to(File, :sparse?)
59
- assert_nothing_raised{ File.sparse?(@file) }
60
- assert_equal(false, File.sparse?(@file))
68
+ assert_nothing_raised{ File.sparse?(@@file) }
69
+ assert_equal(false, File.sparse?(@@file))
61
70
  end
62
71
 
63
72
  # I don't actually test assignment here since making a file a sparse
@@ -68,181 +77,203 @@ class TC_Win32_File_Attributes < Test::Unit::TestCase
68
77
 
69
78
  def test_sparse_file_expected_errors
70
79
  assert_raises(ArgumentError){ File.sparse? }
71
- assert_raises(ArgumentError){ File.sparse?(@file, 'foo') }
80
+ assert_raises(ArgumentError){ File.sparse?(@@file, 'foo') }
72
81
  end
73
82
 
74
83
  def test_reparse_point
75
84
  assert_respond_to(File, :reparse_point?)
76
- assert_nothing_raised{ File.reparse_point?(@file) }
77
- assert_equal(false, File.reparse_point?(@file))
85
+ assert_nothing_raised{ File.reparse_point?(@@file) }
86
+ assert_equal(false, File.reparse_point?(@@file))
78
87
  end
79
88
 
80
89
  def test_reparse_point_expected_errors
81
90
  assert_raises(ArgumentError){ File.reparse_point? }
82
- assert_raises(ArgumentError){ File.reparse_point?(@file, 'foo') }
91
+ assert_raises(ArgumentError){ File.reparse_point?(@@file, 'foo') }
83
92
  end
84
93
 
85
94
  def test_readonly
86
95
  assert_respond_to(File, :readonly?)
87
- assert_respond_to(File, :read_only?) # alias
88
- assert_nothing_raised{ File.read_only?(@file) }
89
- assert_equal(false, File.read_only?(@file))
96
+ assert_nothing_raised{ File.readonly?(@@file) }
97
+ assert_equal(false, File.readonly?(@@file))
98
+ end
99
+
100
+ def test_read_only_alias
101
+ assert_respond_to(File, :read_only?)
102
+ assert_equal(true, File.method(:readonly?) == File.method(:read_only?))
90
103
  end
91
104
 
92
105
  def test_readonly_instance
93
106
  assert_respond_to(@fh, :readonly=)
94
107
  assert_nothing_raised{ @fh.readonly = true }
95
- assert(File.readonly?(@file))
108
+ assert(File.readonly?(@@file))
96
109
  end
97
110
 
98
111
  def test_read_only_expected_errors
99
112
  assert_raises(ArgumentError){ File.read_only? }
100
- assert_raises(ArgumentError){ File.read_only?(@file, 'foo') }
113
+ assert_raises(ArgumentError){ File.read_only?(@@file, 'foo') }
101
114
  end
102
115
 
103
116
  def test_offline
104
117
  assert_respond_to(File, :offline?)
105
- assert_nothing_raised{ File.offline?(@file) }
106
- assert_equal(false, File.offline?(@file))
118
+ assert_nothing_raised{ File.offline?(@@file) }
119
+ assert_equal(false, File.offline?(@@file))
107
120
  end
108
121
 
109
122
  def test_offline_instance
110
123
  assert_respond_to(@fh, :offline=)
111
124
  assert_nothing_raised{ @fh.offline = true }
112
- assert(File.offline?(@file))
125
+ assert(File.offline?(@@file))
113
126
  end
114
127
 
115
128
  def test_offline_expected_errors
116
129
  assert_raises(ArgumentError){ File.offline? }
117
- assert_raises(ArgumentError){ File.offline?(@file, 'foo') }
130
+ assert_raises(ArgumentError){ File.offline?(@@file, 'foo') }
118
131
  end
119
132
 
120
133
  def test_normal
121
134
  assert_respond_to(File, :normal?)
122
- assert_nothing_raised{ File.normal?(@file) }
123
- assert_equal(false, File.normal?(@file))
135
+ assert_nothing_raised{ File.normal?(@@file) }
136
+ assert_equal(false, File.normal?(@@file))
124
137
  end
125
138
 
126
139
  def test_normal_instance
127
140
  assert_respond_to(@fh, :normal=)
128
141
  assert_nothing_raised{ @fh.normal = true }
129
- assert(File.normal?(@file))
142
+ assert(File.normal?(@@file))
130
143
  end
131
144
 
132
145
  def test_normal_expected_errors
133
146
  assert_raises(ArgumentError){ File.normal? }
134
- assert_raises(ArgumentError){ File.normal?(@file, 'foo') }
147
+ assert_raises(ArgumentError){ File.normal?(@@file, 'foo') }
135
148
  assert_raises(ArgumentError){ @fh.normal = false }
136
149
  end
137
150
 
138
151
  def test_hidden
139
152
  assert_respond_to(File, :hidden?)
140
- assert_nothing_raised{ File.hidden?(@file) }
141
- assert_equal(false, File.hidden?(@file))
153
+ assert_nothing_raised{ File.hidden?(@@file) }
154
+ assert_equal(false, File.hidden?(@@file))
142
155
  end
143
156
 
144
157
  def test_hidden_instance
145
158
  assert_respond_to(@fh, :hidden=)
146
159
  assert_nothing_raised{ @fh.hidden = true }
147
- assert(File.hidden?(@file))
160
+ assert(File.hidden?(@@file))
148
161
  end
149
162
 
150
163
  def test_hidden_expected_errors
151
164
  assert_raises(ArgumentError){ File.hidden? }
152
- assert_raises(ArgumentError){ File.hidden?(@file, 'foo') }
165
+ assert_raises(ArgumentError){ File.hidden?(@@file, 'foo') }
153
166
  end
154
167
 
155
168
  def test_encrypted
156
169
  assert_respond_to(File, :encrypted?)
157
- assert_nothing_raised{ File.encrypted?(@file) }
158
- assert_equal(false, File.encrypted?(@file))
170
+ assert_nothing_raised{ File.encrypted?(@@file) }
171
+ assert_equal(false, File.encrypted?(@@file))
159
172
  end
160
173
 
161
174
  def test_encrypted_expected_errors
162
175
  assert_raises(ArgumentError){ File.encrypted? }
163
- assert_raises(ArgumentError){ File.encrypted?(@file, 'foo') }
176
+ assert_raises(ArgumentError){ File.encrypted?(@@file, 'foo') }
164
177
  end
165
178
 
166
179
  def test_indexed
167
180
  assert_respond_to(File, :indexed?)
181
+ assert_nothing_raised{ File.indexed?(@@file) }
182
+ assert_equal(true, File.indexed?(@@file))
183
+ end
184
+
185
+ def test_content_indexed_alias
168
186
  assert_respond_to(File, :content_indexed?)
169
- assert_nothing_raised{ File.indexed?(@file) }
170
- assert_equal(true, File.indexed?(@file))
187
+ assert(File.method(:content_indexed?) == File.method(:indexed?))
171
188
  end
172
189
 
173
190
  def test_indexed_instance
174
191
  assert_respond_to(@fh, :indexed=)
175
192
  assert_nothing_raised{ @fh.indexed = true }
176
- assert(File.indexed?(@file))
193
+ assert(File.indexed?(@@file))
177
194
  end
178
195
 
179
196
  def test_indexed_expected_errors
180
197
  assert_raises(ArgumentError){ File.indexed? }
181
- assert_raises(ArgumentError){ File.indexed?(@file, 'foo') }
198
+ assert_raises(ArgumentError){ File.indexed?(@@file, 'foo') }
182
199
  end
183
200
 
184
201
  def test_compressed
185
202
  assert_respond_to(File, :compressed?)
186
- assert_nothing_raised{ File.compressed?(@file) }
187
- assert_equal(false, File.compressed?(@file))
203
+ assert_nothing_raised{ File.compressed?(@@file) }
204
+ assert_equal(false, File.compressed?(@@file))
188
205
  end
189
206
 
190
207
  # We have to explicitly reset the compressed attribute to false as
191
208
  # the last of these assertions.
192
209
  def test_compressed_instance
193
210
  assert_respond_to(@fh, :compressed=)
211
+ assert_equal(false, File.compressed?(@@file))
212
+
194
213
  assert_nothing_raised{ @fh.compressed = true }
195
- assert(File.compressed?(@file))
214
+ assert_equal(true, File.compressed?(@@file))
215
+
196
216
  assert_nothing_raised{ @fh.compressed = false }
197
- assert_equal(false, File.compressed?(@file))
217
+ assert_equal(false, File.compressed?(@@file))
198
218
  end
199
219
 
200
220
  def test_compressed_expected_errors
201
221
  assert_raises(ArgumentError){ File.compressed? }
202
- assert_raises(ArgumentError){ File.compressed?(@file, 'foo') }
222
+ assert_raises(ArgumentError){ File.compressed?(@@file, 'foo') }
203
223
  end
204
224
 
205
225
  def test_archive
206
226
  assert_respond_to(File, :archive?)
207
- assert_nothing_raised{ File.archive?(@file) }
208
- assert_equal(true, File.archive?(@file))
227
+ assert_nothing_raised{ File.archive?(@@file) }
228
+ assert_equal(true, File.archive?(@@file))
209
229
  end
210
230
 
211
231
  def test_archive_instance
212
232
  assert_respond_to(@fh, :archive=)
213
233
  assert_nothing_raised{ @fh.archive = false }
214
- assert_equal(false, File.archive?(@file))
234
+ assert_equal(false, File.archive?(@@file))
215
235
  end
216
236
 
217
237
  def test_archive_expected_errors
218
238
  assert_raises(ArgumentError){ File.archive? }
219
- assert_raises(ArgumentError){ File.archive?(@file, 'foo') }
239
+ assert_raises(ArgumentError){ File.archive?(@@file, 'foo') }
220
240
  end
221
241
 
222
242
  def test_attributes
223
243
  assert_respond_to(File, :attributes)
224
- assert_kind_of(Array, File.attributes(@file))
225
- assert_equal(['archive', 'indexed'], File.attributes(@file))
244
+ assert_kind_of(Array, File.attributes(@@file))
245
+ assert_equal(['archive', 'indexed'], File.attributes(@@file))
226
246
  end
227
247
 
228
248
  def test_set_attributes
229
249
  assert_respond_to(File, :set_attributes)
230
- assert_respond_to(File, :set_attr) # alias
231
- assert_nothing_raised{ File.set_attributes(@file, File::HIDDEN) }
232
- assert(File.hidden?(@file))
250
+ assert_nothing_raised{ File.set_attributes(@@file, File::HIDDEN) }
251
+ assert(File.hidden?(@@file))
252
+ end
253
+
254
+ def test_set_attr_alias
255
+ assert_respond_to(File, :set_attr)
256
+ assert(File.method(:set_attr) == File.method(:set_attributes))
233
257
  end
234
258
 
235
259
  def test_remove_attributes
236
260
  assert_respond_to(File, :remove_attributes)
237
- assert_respond_to(File, :unset_attr) # alias
238
- assert_nothing_raised{ File.remove_attributes(@file, File::ARCHIVE) }
239
- assert_equal(false, File.archive?(@file))
261
+ assert_nothing_raised{ File.remove_attributes(@@file, File::ARCHIVE) }
262
+ assert_equal(false, File.archive?(@@file))
240
263
  end
241
264
 
265
+ def test_unset_attr_alias
266
+ assert_respond_to(File, :unset_attr)
267
+ assert(File.method(:unset_attr) == File.method(:remove_attributes))
268
+ end
269
+
242
270
  def teardown
243
- SetFileAttributes(@file, @attr)
244
- @file = nil
245
- @dir = nil
271
+ SetFileAttributes(@@file, @attr)
246
272
  @fh.close
247
273
  end
274
+
275
+ def self.shutdown
276
+ File.delete(@@file)
277
+ @@file = nil
278
+ end
248
279
  end
@@ -1,5 +1,5 @@
1
1
  #############################################################################
2
- # tc_file_constants.rb
2
+ # test_win32_file_constants.rb
3
3
  #
4
4
  # Test case for the path related methods of win32-file. Run this test via
5
5
  # the 'rake test' or 'rake test_constants' task.
@@ -1,33 +1,44 @@
1
1
  #############################################################################
2
- # tc_file_encryption.rb
2
+ # test_win32_file_encryption.rb
3
3
  #
4
4
  # Test case for the encryption related methods of win32-file. You should
5
5
  # run this test via the 'rake test' or 'rake test_encryption' task.
6
6
  #
7
7
  # Note: These tests may fail based on the security setup of your system.
8
8
  #############################################################################
9
+ require 'rubygems'
10
+ gem 'test-unit'
11
+
9
12
  require 'test/unit'
10
13
  require 'win32/file'
11
14
 
12
15
  class TC_Win32_File_Encryption < Test::Unit::TestCase
16
+ def self.startup
17
+ Dir.chdir('test') unless File.basename(Dir.pwd) == 'test'
18
+ @@file = File.join(Dir.pwd, 'encryption_test.txt')
19
+ File.open(@@file, 'w'){ |fh| fh.puts "This is an encryption test." }
20
+ end
21
+
13
22
  def setup
14
- @dir = File.dirname(File.expand_path(__FILE__))
15
- @file = File.join(@dir, 'sometestfile.txt')
16
- @msg = '=> Ignore. May not work due to security setup of your system.'
23
+ @msg = '=> Ignore. May not work due to security setup of your system.'
17
24
  end
18
25
 
19
26
  def test_encrypt
20
27
  assert_respond_to(File, :encrypt)
21
- assert_nothing_raised(@msg){ File.encrypt(@file) }
28
+ assert_nothing_raised(@msg){ File.encrypt(@@file) }
22
29
  end
23
30
 
24
31
  def test_decrypt
25
32
  assert_respond_to(File, :decrypt)
26
- assert_nothing_raised(@msg){ File.decrypt(@file) }
33
+ assert_nothing_raised(@msg){ File.decrypt(@@file) }
27
34
  end
28
35
 
29
36
  def teardown
30
- @file = nil
31
- @dir = nil
37
+ @msg = nil
38
+ end
39
+
40
+ def self.shutdown
41
+ File.delete(@@file) if File.exists?(@@file)
42
+ @@file = nil
32
43
  end
33
- end
44
+ end
@@ -1,25 +1,34 @@
1
1
  #############################################################################
2
- # tc_file_path.rb
2
+ # test_win32_file_path.rb
3
3
  #
4
4
  # Test case for the path related methods of win32-file. You should run this
5
5
  # test via the 'rake test' or 'rake test_path' task.
6
6
  #############################################################################
7
+ require 'rubygems'
8
+ gem 'test-unit'
9
+
7
10
  require 'test/unit'
8
11
  require 'win32/file'
9
12
 
10
13
  class TC_Win32_File_Path < Test::Unit::TestCase
14
+ def self.startup
15
+ Dir.chdir('test') unless File.basename(Dir.pwd) == 'test'
16
+ @@file = File.join(Dir.pwd, 'path_test.txt')
17
+ File.open(@@file, 'w'){ |fh| fh.puts "This is a path test." }
18
+ end
19
+
11
20
  def setup
12
- @dir = File.dirname(File.expand_path(__FILE__))
13
- @long_file = File.join(@dir, 'sometestfile.txt')
14
- @short_file = File.join(@dir, 'SOMETE~1.TXT')
21
+ @long_file = File.join(Dir.pwd, 'path_test.txt')
22
+ @short_file = File.join(Dir.pwd, 'PATH_T~1.TXT')
15
23
  end
16
24
 
17
- def test_basename
25
+ def test_basename_basic
18
26
  assert_respond_to(File, :basename)
19
27
  assert_nothing_raised{ File.basename("C:\\foo") }
20
28
  assert_kind_of(String, File.basename("C:\\foo"))
29
+ end
21
30
 
22
- # Standard paths
31
+ def test_basename_standard_paths
23
32
  assert_equal("baz.txt", File.basename("C:\\foo\\bar\\baz.txt"))
24
33
  assert_equal("baz", File.basename("C:\\foo\\bar\\baz.txt", ".txt"))
25
34
  assert_equal("baz.txt", File.basename("C:\\foo\\bar\\baz.txt", ".zip"))
@@ -27,14 +36,16 @@ class TC_Win32_File_Path < Test::Unit::TestCase
27
36
  assert_equal("bar", File.basename("C:\\foo\\bar\\"))
28
37
  assert_equal("foo", File.basename("C:\\foo"))
29
38
  assert_equal("C:\\", File.basename("C:\\"))
39
+ end
30
40
 
31
- # UNC paths
41
+ def test_basename_unc_paths
32
42
  assert_equal("baz.txt", File.basename("\\\\foo\\bar\\baz.txt"))
33
43
  assert_equal("baz", File.basename("\\\\foo\\bar\\baz"))
34
44
  assert_equal("\\\\foo", File.basename("\\\\foo"))
35
45
  assert_equal("\\\\foo\\bar", File.basename("\\\\foo\\bar"))
46
+ end
36
47
 
37
- # Unix style paths
48
+ def test_basename_unix_style_paths
38
49
  assert_equal("bar", File.basename("/foo/bar"))
39
50
  assert_equal("bar.txt", File.basename("/foo/bar.txt"))
40
51
  assert_equal("bar.txt", File.basename("bar.txt"))
@@ -43,21 +54,24 @@ class TC_Win32_File_Path < Test::Unit::TestCase
43
54
  assert_equal("baz", File.basename("//foo/bar/baz"))
44
55
  assert_equal("//foo", File.basename("//foo"))
45
56
  assert_equal("//foo/bar", File.basename("//foo/bar"))
57
+ end
46
58
 
47
- # Forward slashes
59
+ def test_basename_with_forward_slashes
48
60
  assert_equal("bar", File.basename("C:/foo/bar"))
49
61
  assert_equal("bar", File.basename("C:/foo/bar/"))
50
62
  assert_equal("foo", File.basename("C:/foo"))
51
63
  assert_equal("C:/", File.basename("C:/"))
52
64
  assert_equal("bar", File.basename("C:/foo/bar\\\\"))
65
+ end
53
66
 
54
- # Edge cases
67
+ def test_basename_edge_cases
55
68
  assert_equal("", File.basename(""))
56
69
  assert_equal(".", File.basename("."))
57
70
  assert_equal("..", File.basename(".."))
58
71
  assert_equal("foo", File.basename("//foo/"))
72
+ end
59
73
 
60
- # Suffixes
74
+ def test_basename_with_suffixes
61
75
  assert_equal("bar", File.basename("bar.txt", ".txt"))
62
76
  assert_equal("bar", File.basename("/foo/bar.txt", ".txt"))
63
77
  assert_equal("bar.txt", File.basename("bar.txt", ".exe"))
@@ -65,32 +79,36 @@ class TC_Win32_File_Path < Test::Unit::TestCase
65
79
  assert_equal("bar.txt.exe", File.basename("bar.txt.exe", ".txt"))
66
80
  assert_equal("bar", File.basename("bar.txt", ".*"))
67
81
  assert_equal("bar.txt", File.basename("bar.txt.exe", ".*"))
82
+ end
68
83
 
69
- # Ensure original path not modified
84
+ def test_basename_does_not_modify_argument
70
85
  path = "C:\\foo\\bar"
71
86
  assert_nothing_raised{ File.basename(path) }
72
87
  assert_equal("C:\\foo\\bar", path)
73
88
  end
74
89
 
75
- def test_dirname
90
+ def test_dirname_basic
76
91
  assert_respond_to(File, :dirname)
77
92
  assert_nothing_raised{ File.dirname("C:\\foo") }
78
93
  assert_kind_of(String, File.dirname("C:\\foo"))
94
+ end
79
95
 
80
- # Standard Paths
96
+ def test_dirname_standard_paths
81
97
  assert_equal("C:\\foo", File.dirname("C:\\foo\\bar.txt"))
82
98
  assert_equal("C:\\foo", File.dirname("C:\\foo\\bar"))
83
99
  assert_equal("C:\\", File.dirname("C:\\foo"))
84
100
  assert_equal("C:\\", File.dirname("C:\\"))
85
101
  assert_equal(".", File.dirname("foo"))
102
+ end
86
103
 
87
- # UNC paths
104
+ def test_dirname_unc_paths
88
105
  assert_equal("\\\\foo\\bar", File.dirname("\\\\foo\\bar\\baz"))
89
106
  assert_equal("\\\\foo\\bar", File.dirname("\\\\foo\\bar"))
90
107
  assert_equal("\\\\foo", File.dirname("\\\\foo"))
91
108
  assert_equal("\\\\", File.dirname("\\\\"))
109
+ end
92
110
 
93
- # Forward slashes
111
+ def test_dirname_forward_slashes
94
112
  assert_equal("C:/foo", File.dirname("C:/foo/bar.txt"))
95
113
  assert_equal("C:/foo", File.dirname("C:/foo/bar"))
96
114
  assert_equal("C:/", File.dirname("C:/foo"))
@@ -101,49 +119,57 @@ class TC_Win32_File_Path < Test::Unit::TestCase
101
119
  assert_equal("//", File.dirname("//"))
102
120
  assert_equal(".", File.dirname("./foo"))
103
121
  assert_equal("./foo", File.dirname("./foo/bar"))
122
+ end
104
123
 
105
- # Edge cases
124
+ def test_dirname_edge_cases
106
125
  assert_equal(".", File.dirname(""))
107
126
  assert_equal(".", File.dirname("."))
108
127
  assert_equal(".", File.dirname("."))
109
128
  assert_equal(".", File.dirname("./"))
110
129
  assert_raises(TypeError){ File.dirname(nil) }
130
+ end
111
131
 
112
- # Ensure original path not modified
132
+ def test_dirname_does_not_modify_argument
113
133
  path = "C:\\foo\\bar"
114
134
  assert_nothing_raised{ File.dirname(path) }
115
135
  assert_equal("C:\\foo\\bar", path)
116
136
  end
117
137
 
118
- def test_split
138
+ def test_split_basic
119
139
  assert_respond_to(File, :split)
120
140
  assert_nothing_raised{ File.split("C:\\foo\\bar") }
121
141
  assert_kind_of(Array, File.split("C:\\foo\\bar"))
142
+ end
122
143
 
123
- # Standard Paths
144
+ def test_split_standard_paths
124
145
  assert_equal(["C:\\foo", "bar"], File.split("C:\\foo\\bar"))
125
146
  assert_equal([".", "foo"], File.split("foo"))
147
+ end
126
148
 
127
- # Forward slashes
149
+ def test_split_forward_slashes
128
150
  assert_equal(["C:/foo", "bar"], File.split("C:/foo/bar"))
129
151
  assert_equal([".", "foo"], File.split("foo"))
152
+ end
130
153
 
131
- # Unix paths
154
+ def test_split_unix_paths
132
155
  assert_equal(["/foo","bar"], File.split("/foo/bar"))
133
156
  assert_equal(["/", "foo"], File.split("/foo"))
134
157
  assert_equal([".", "foo"], File.split("foo"))
158
+ end
135
159
 
136
- # UNC paths
160
+ def test_split_unc_paths
137
161
  assert_equal(["\\\\foo\\bar", "baz"], File.split("\\\\foo\\bar\\baz"))
138
162
  assert_equal(["\\\\foo\\bar", ""], File.split("\\\\foo\\bar"))
139
163
  assert_equal(["\\\\foo", ""], File.split("\\\\foo"))
140
164
  assert_equal(["\\\\", ""], File.split("\\\\"))
165
+ end
141
166
 
142
- # Edge cases
167
+ def test_split_edge_cases
143
168
  assert_equal(["C:\\", ""], File.split("C:\\"))
144
169
  assert_equal(["", ""], File.split(""))
170
+ end
145
171
 
146
- # Ensure original path not modified
172
+ def test_split_does_not_modify_arguments
147
173
  path = "C:\\foo\\bar"
148
174
  assert_nothing_raised{ File.split(path) }
149
175
  assert_equal("C:\\foo\\bar", path)
@@ -151,19 +177,22 @@ class TC_Win32_File_Path < Test::Unit::TestCase
151
177
 
152
178
  def test_long_path
153
179
  assert_respond_to(File, :long_path)
154
- assert_equal('sometestfile.txt', File.long_path(@short_file))
155
- assert_equal('SOMETE~1.TXT', File.basename(@short_file))
180
+ assert_equal(@long_file, File.long_path(@short_file))
181
+ assert_equal('PATH_T~1.TXT', File.basename(@short_file))
156
182
  end
157
183
 
158
184
  def test_short_path
159
185
  assert_respond_to(File, :short_path)
160
- assert_equal('SOMETE~1.TXT', File.short_path(@long_file))
161
- assert_equal('sometestfile.txt', File.basename(@long_file))
186
+ assert_equal('path_test.txt', File.basename(@long_file))
162
187
  end
163
188
 
164
189
  def teardown
165
190
  @short_file = nil
166
191
  @long_file = nil
167
- @dir = nil
168
192
  end
169
- end
193
+
194
+ def self.shutdown
195
+ File.delete(@@file) if File.exists?(@@file)
196
+ @@file = nil
197
+ end
198
+ end
@@ -0,0 +1,66 @@
1
+ ##############################################################################
2
+ # test_win32_file_security.rb
3
+ #
4
+ # Test case for security related methods of win32-file. You should use the
5
+ # 'rake test' or 'rake test_security' task to run this.
6
+ #
7
+ # Note that I've removed some tests that looked for explicit security
8
+ # accounts, since it's impossible to determine how any given system is setup.
9
+ ##############################################################################
10
+ require 'rubygems'
11
+ gem 'test-unit'
12
+
13
+ require 'test/unit'
14
+ require 'win32/file'
15
+ require 'socket'
16
+
17
+ class TC_Win32_File_Security < Test::Unit::TestCase
18
+ def self.startup
19
+ Dir.chdir('test') unless File.basename(Dir.pwd) == 'test'
20
+ @@host = Socket.gethostname
21
+ @@file = File.join(Dir.pwd, 'security_test.txt')
22
+ File.open(@@file, 'w'){ |fh| fh.puts "This is a security test." }
23
+ end
24
+
25
+ def setup
26
+ @perms = nil
27
+ end
28
+
29
+ # This will fail if there is no "Users" builtin. Not to worry.
30
+ def test_get_permissions
31
+ assert_respond_to(File, :get_permissions)
32
+ assert_nothing_raised{ File.get_permissions(@@file) }
33
+ assert_kind_of(Hash, File.get_permissions(@@file))
34
+ end
35
+
36
+ def test_get_permissions_with_host
37
+ assert_nothing_raised{ File.get_permissions(@@file, @@host) }
38
+ assert_kind_of(Hash, File.get_permissions(@@file))
39
+ end
40
+
41
+ def test_set_permissions
42
+ assert_respond_to(File, :set_permissions)
43
+ assert_nothing_raised{ @perms = File.get_permissions(@@file) }
44
+ assert_nothing_raised{ File.set_permissions(@@file, @perms) }
45
+ end
46
+
47
+ def test_securities
48
+ assert_respond_to(File, :securities)
49
+ assert_nothing_raised{ @perms = File.get_permissions(@@file) }
50
+
51
+ @perms.each{ |acct, mask|
52
+ assert_nothing_raised{ File.securities(mask) }
53
+ assert_kind_of(Array, File.securities(mask))
54
+ }
55
+ end
56
+
57
+ def teardown
58
+ @perms = nil
59
+ end
60
+
61
+ def self.shutdown
62
+ File.delete(@@file) if File.exists?(@@file)
63
+ @@file = nil
64
+ @@host = nil
65
+ end
66
+ end
@@ -1,61 +1,79 @@
1
1
  #####################################################################
2
- # tc_file_stat.rb
2
+ # test_win32_file_stat.rb
3
3
  #
4
4
  # Test case for stat related methods of win32-file. You should run
5
5
  # this via the 'rake test' or 'rake test_stat' task.
6
6
  #####################################################################
7
+ require 'rubygems'
8
+ gem 'test-unit'
9
+
7
10
  require 'test/unit'
8
11
  require 'win32/file'
9
12
 
10
13
  class TC_Win32_File_Stat < Test::Unit::TestCase
11
- def setup
12
- @dir = File.dirname(File.expand_path(__FILE__))
13
- @file = File.join(@dir, 'sometestfile.txt')
14
+ include Windows::Volume
15
+ extend Windows::Volume
16
+
17
+ def self.startup
18
+ Dir.chdir('test') unless File.basename(Dir.pwd) == 'test'
19
+ @@file = File.join(Dir.pwd, 'stat_test.txt')
20
+ File.open(@@file, 'w'){ |fh| fh.puts "This is a test." }
21
+
22
+ # Find a block device
23
+ 'A'.upto('Z'){ |volume|
24
+ volume += ":\\"
25
+ case GetDriveType(volume)
26
+ when DRIVE_REMOVABLE, DRIVE_CDROM, DRIVE_RAMDISK
27
+ @@block_dev = volume
28
+ break
29
+ end
30
+ }
14
31
  end
15
-
16
- # Although I don't perform a test against a file > 2gb here (since I
17
- # don't feel like distributing a 2gb file), it works in my own tests.
32
+
33
+ # Although I don't perform a test against a file it works in my own tests.
18
34
  def test_size
19
35
  assert_respond_to(File, :size)
20
- assert_equal(17, File.size(@file))
36
+ assert_equal(17, File.size(@@file))
21
37
  end
22
38
 
23
39
  def test_blksize
24
40
  msg = "+The blksize may be different - ignore+"
25
41
  assert_respond_to(File, :blksize)
26
42
  assert_kind_of(Fixnum, File.blksize("C:\\Program Files\\Windows NT"))
27
- assert_kind_of(Fixnum, File.blksize(@file))
28
- assert_equal(4096, File.blksize(@file), msg)
43
+ assert_kind_of(Fixnum, File.blksize(@@file))
44
+ assert_equal(4096, File.blksize(@@file), msg)
29
45
  end
30
46
 
31
47
  def test_blksize_expected_errors
32
48
  assert_raises(ArgumentError){ File.blksize }
33
- assert_raises(ArgumentError){ File.blksize(@file, "foo") }
49
+ assert_raises(ArgumentError){ File.blksize(@@file, "foo") }
34
50
  end
35
51
 
36
52
  # The test for a block device will fail unless the D: drive is a CDROM.
37
53
  def test_blockdev
38
54
  assert_respond_to(File, :blockdev?)
39
55
  assert_nothing_raised{ File.blockdev?("C:\\") }
40
- assert_equal(true, File.blockdev?("D:\\"), '+Will fail unless CDROM+')
41
56
  assert_equal(false, File.blockdev?("NUL"))
57
+
58
+ omit_unless(File.exists?("D:\\"), "No media in device - skipping")
59
+ assert_equal(true, File.blockdev?(@@block_dev))
42
60
  end
43
61
 
44
62
  def test_blockdev_expected_errors
45
63
  assert_raises(ArgumentError){ File.blockdev? }
46
- assert_raises(ArgumentError){ File.blockdev?(@file, "foo") }
64
+ assert_raises(ArgumentError){ File.blockdev?(@@file, "foo") }
47
65
  end
48
66
 
49
67
  def test_chardev
50
68
  assert_respond_to(File, :chardev?)
51
69
  assert_nothing_raised{ File.chardev?("NUL") }
52
70
  assert_equal(true, File.chardev?("NUL"))
53
- assert_equal(false, File.chardev?("C:\\"))
71
+ assert_equal(false, File.chardev?(@@file))
54
72
  end
55
73
 
56
74
  def test_chardev_expected_errors
57
75
  assert_raises(ArgumentError){ File.chardev? }
58
- assert_raises(ArgumentError){ File.chardev?(@file, "foo") }
76
+ assert_raises(ArgumentError){ File.chardev?(@@file, "foo") }
59
77
  end
60
78
 
61
79
  # Ensure that not only does the File class respond to the stat method,
@@ -64,8 +82,8 @@ class TC_Win32_File_Stat < Test::Unit::TestCase
64
82
  #
65
83
  def test_stat_class
66
84
  assert_respond_to(File, :stat)
67
- assert_kind_of(File::Stat, File.stat(@file))
68
- assert_equal(false, File.stat(@file).hidden?)
85
+ assert_kind_of(File::Stat, File.stat(@@file))
86
+ assert_equal(false, File.stat(@@file).hidden?)
69
87
  end
70
88
 
71
89
  # This was added after it was discovered that lstat is not aliased
@@ -73,20 +91,21 @@ class TC_Win32_File_Stat < Test::Unit::TestCase
73
91
  #
74
92
  def test_lstat_class
75
93
  assert_respond_to(File, :lstat)
76
- assert_kind_of(File::Stat, File.lstat(@file))
77
- assert_equal(false, File.stat(@file).hidden?)
94
+ assert_kind_of(File::Stat, File.lstat(@@file))
95
+ assert_equal(false, File.stat(@@file).hidden?)
78
96
  end
79
97
 
80
98
  def test_stat_instance
81
- File.open(@file){ |f|
99
+ File.open(@@file){ |f|
82
100
  assert_respond_to(f, :stat)
83
101
  assert_kind_of(File::Stat, f.stat)
84
102
  assert_equal(false, f.stat.hidden?)
85
103
  }
86
104
  end
87
105
 
88
- def teardown
89
- @file = nil
90
- @dir = nil
106
+ def self.shutdown
107
+ File.delete(@@file) if File.exists?(@@file)
108
+ @@file = nil
109
+ @@block_dev = nil
91
110
  end
92
111
  end
@@ -2,20 +2,22 @@ require "rubygems"
2
2
 
3
3
  spec = Gem::Specification.new do |gem|
4
4
  gem.name = "win32-file"
5
- gem.version = "0.5.5"
6
- gem.author = "Daniel J. Berger"
5
+ gem.version = "0.5.6"
6
+ gem.authors = ["Daniel J. Berger", "Park Heesob"]
7
7
  gem.email = "djberg96@gmail.com"
8
8
  gem.homepage = "http://www.rubyforge.org/projects/win32utils"
9
9
  gem.platform = Gem::Platform::RUBY
10
10
  gem.summary = "Extra or redefined methods for the File class on Windows."
11
11
  gem.description = "Extra or redefined methods for the File class on Windows."
12
- gem.test_files = Dir["test/tc*"]
12
+ gem.test_files = Dir["test/test*"]
13
13
  gem.has_rdoc = true
14
14
  gem.files = Dir["lib/win32/*.rb"] + Dir["test/*"] + Dir["[A-Z]*"]
15
15
  gem.files.reject! { |fn| fn.include? "CVS" }
16
16
  gem.require_path = "lib"
17
17
  gem.extra_rdoc_files = ["README", "CHANGES"]
18
18
  gem.add_dependency("win32-file-stat", ">= 1.2.0")
19
+ gem.add_dependency("test-unit", ">= 2.0.0")
20
+ gem.rubyforge_project = "win32utils"
19
21
  end
20
22
 
21
23
  if $0 == __FILE__
metadata CHANGED
@@ -1,19 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: win32-file
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
8
+ - Park Heesob
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
12
 
12
- date: 2007-11-22 00:00:00 -07:00
13
+ date: 2008-09-30 00:00:00 -06:00
13
14
  default_executable:
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
17
  name: win32-file-stat
18
+ type: :runtime
17
19
  version_requirement:
18
20
  version_requirements: !ruby/object:Gem::Requirement
19
21
  requirements:
@@ -21,6 +23,16 @@ dependencies:
21
23
  - !ruby/object:Gem::Version
22
24
  version: 1.2.0
23
25
  version:
26
+ - !ruby/object:Gem::Dependency
27
+ name: test-unit
28
+ type: :runtime
29
+ version_requirement:
30
+ version_requirements: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: 2.0.0
35
+ version:
24
36
  description: Extra or redefined methods for the File class on Windows.
25
37
  email: djberg96@gmail.com
26
38
  executables: []
@@ -32,16 +44,13 @@ extra_rdoc_files:
32
44
  - CHANGES
33
45
  files:
34
46
  - lib/win32/file.rb
35
- - test/CVS
36
- - test/sometestfile.txt
37
- - test/tc_file_attributes.rb
38
- - test/tc_file_constants.rb
39
- - test/tc_file_encryption.rb
40
- - test/tc_file_path.rb
41
- - test/tc_file_security.rb
42
- - test/tc_file_stat.rb
47
+ - test/test_win32_file_attributes.rb
48
+ - test/test_win32_file_constants.rb
49
+ - test/test_win32_file_encryption.rb
50
+ - test/test_win32_file_path.rb
51
+ - test/test_win32_file_security.rb
52
+ - test/test_win32_file_stat.rb
43
53
  - CHANGES
44
- - CVS
45
54
  - lib
46
55
  - MANIFEST
47
56
  - Rakefile
@@ -69,15 +78,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
78
  version:
70
79
  requirements: []
71
80
 
72
- rubyforge_project:
73
- rubygems_version: 0.9.5
81
+ rubyforge_project: win32utils
82
+ rubygems_version: 1.3.0
74
83
  signing_key:
75
84
  specification_version: 2
76
85
  summary: Extra or redefined methods for the File class on Windows.
77
86
  test_files:
78
- - test/tc_file_attributes.rb
79
- - test/tc_file_constants.rb
80
- - test/tc_file_encryption.rb
81
- - test/tc_file_path.rb
82
- - test/tc_file_security.rb
83
- - test/tc_file_stat.rb
87
+ - test/test_win32_file_attributes.rb
88
+ - test/test_win32_file_constants.rb
89
+ - test/test_win32_file_encryption.rb
90
+ - test/test_win32_file_path.rb
91
+ - test/test_win32_file_security.rb
92
+ - test/test_win32_file_stat.rb
@@ -1 +0,0 @@
1
- This is a test.
@@ -1,51 +0,0 @@
1
- #####################################################################
2
- # tc_file_security.rb
3
- #
4
- # Test case for security related methods of win32-file. You should
5
- # use the 'rake test' or 'rake test_security' task to run this.
6
- #####################################################################
7
- require 'test/unit'
8
- require 'win32/file'
9
- require 'socket'
10
-
11
- class TC_Win32_File_Security < Test::Unit::TestCase
12
- def setup
13
- @host = Socket.gethostname
14
- @dir = File.dirname(File.expand_path(__FILE__))
15
- @file = File.join(@dir, 'sometestfile.txt')
16
- @perms = nil
17
- end
18
-
19
- # This will fail if there is no "Users" builtin. Not to worry.
20
- def test_get_permissions
21
- assert_respond_to(File, :get_permissions)
22
- assert_nothing_raised{ File.get_permissions(@file) }
23
- assert_nothing_raised{ File.get_permissions(@file, @host) }
24
- assert_kind_of(Hash, File.get_permissions(@file))
25
- assert(File.get_permissions(@file).has_key?('BUILTIN\\Users'))
26
- assert(File.get_permissions(@file).has_key?('BUILTIN\\Administrators'))
27
- end
28
-
29
- def test_set_permissions
30
- assert_respond_to(File, :set_permissions)
31
- assert_nothing_raised{ @perms = File.get_permissions(@file) }
32
- assert_nothing_raised{ File.set_permissions(@file, @perms) }
33
- end
34
-
35
- def test_securities
36
- assert_respond_to(File, :securities)
37
- assert_nothing_raised{ @perms = File.get_permissions(@file) }
38
-
39
- @perms.each{ |acct, mask|
40
- assert_nothing_raised{ File.securities(mask) }
41
- assert_kind_of(Array, File.securities(mask))
42
- }
43
- end
44
-
45
- def teardown
46
- @file = nil
47
- @host = nil
48
- @perms = nil
49
- @dir = nil
50
- end
51
- end