win32-file 0.6.3 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -26,7 +26,7 @@ class TC_Win32_File_Attributes < Test::Unit::TestCase
26
26
  end
27
27
 
28
28
  def test_version
29
- assert_equal('0.6.2', File::WIN32_FILE_VERSION)
29
+ assert_equal('0.6.4', File::WIN32_FILE_VERSION)
30
30
  end
31
31
 
32
32
  def test_is_directory
@@ -11,188 +11,224 @@ require 'test/unit'
11
11
  require 'win32/file'
12
12
 
13
13
  class TC_Win32_File_Path < Test::Unit::TestCase
14
- def self.startup
15
- Dir.chdir(File.dirname(File.expand_path(File.basename(__FILE__))))
16
- @@file = File.join(Dir.pwd, 'path_test.txt')
17
- File.open(@@file, 'w'){ |fh| fh.puts "This is a path test." }
18
- end
14
+ def self.startup
15
+ Dir.chdir(File.dirname(File.expand_path(File.basename(__FILE__))))
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
19
 
20
- def setup
21
- @long_file = File.join(Dir.pwd, 'path_test.txt')
22
- @short_file = File.join(Dir.pwd, 'PATH_T~1.TXT')
23
- end
20
+ def setup
21
+ @long_file = File.join(Dir.pwd, 'path_test.txt')
22
+ @short_file = File.join(Dir.pwd, 'PATH_T~1.TXT')
23
+ end
24
24
 
25
- def test_basename_basic
26
- assert_respond_to(File, :basename)
27
- assert_nothing_raised{ File.basename("C:\\foo") }
28
- assert_kind_of(String, File.basename("C:\\foo"))
29
- end
25
+ test "basename method basic functionality" do
26
+ assert_respond_to(File, :basename)
27
+ assert_nothing_raised{ File.basename("C:\\foo") }
28
+ assert_kind_of(String, File.basename("C:\\foo"))
29
+ end
30
30
 
31
- def test_basename_standard_paths
32
- assert_equal("baz.txt", File.basename("C:\\foo\\bar\\baz.txt"))
33
- assert_equal("baz", File.basename("C:\\foo\\bar\\baz.txt", ".txt"))
34
- assert_equal("baz.txt", File.basename("C:\\foo\\bar\\baz.txt", ".zip"))
35
- assert_equal("bar", File.basename("C:\\foo\\bar"))
36
- assert_equal("bar", File.basename("C:\\foo\\bar\\"))
37
- assert_equal("foo", File.basename("C:\\foo"))
38
- assert_equal("C:\\", File.basename("C:\\"))
39
- end
31
+ test "basename method handles standard paths" do
32
+ assert_equal("baz.txt", File.basename("C:\\foo\\bar\\baz.txt"))
33
+ assert_equal("baz", File.basename("C:\\foo\\bar\\baz.txt", ".txt"))
34
+ assert_equal("baz.txt", File.basename("C:\\foo\\bar\\baz.txt", ".zip"))
35
+ assert_equal("bar", File.basename("C:\\foo\\bar"))
36
+ assert_equal("bar", File.basename("C:\\foo\\bar\\"))
37
+ assert_equal("foo", File.basename("C:\\foo"))
38
+ assert_equal("C:\\", File.basename("C:\\"))
39
+ end
40
40
 
41
- def test_basename_unc_paths
42
- assert_equal("baz.txt", File.basename("\\\\foo\\bar\\baz.txt"))
43
- assert_equal("baz", File.basename("\\\\foo\\bar\\baz"))
44
- assert_equal("\\\\foo", File.basename("\\\\foo"))
45
- assert_equal("\\\\foo\\bar", File.basename("\\\\foo\\bar"))
46
- end
47
-
48
- def test_basename_unix_style_paths
49
- assert_equal("bar", File.basename("/foo/bar"))
50
- assert_equal("bar.txt", File.basename("/foo/bar.txt"))
51
- assert_equal("bar.txt", File.basename("bar.txt"))
52
- assert_equal("bar", File.basename("/bar"))
53
- assert_equal("bar", File.basename("/bar/"))
54
- assert_equal("baz", File.basename("//foo/bar/baz"))
55
- assert_equal("\\\\foo", File.basename("//foo"))
56
- assert_equal("\\\\foo\\bar", File.basename("//foo/bar"))
57
- end
41
+ test "basename method handles unc paths" do
42
+ assert_equal("baz.txt", File.basename("\\\\foo\\bar\\baz.txt"))
43
+ assert_equal("baz", File.basename("\\\\foo\\bar\\baz"))
44
+ assert_equal("\\\\foo", File.basename("\\\\foo"))
45
+ assert_equal("\\\\foo\\bar", File.basename("\\\\foo\\bar"))
46
+ end
47
+
48
+ test "basename method handles forward slashes in standard unix paths" do
49
+ assert_equal("bar", File.basename("/foo/bar"))
50
+ assert_equal("bar.txt", File.basename("/foo/bar.txt"))
51
+ assert_equal("bar.txt", File.basename("bar.txt"))
52
+ assert_equal("bar", File.basename("/bar"))
53
+ assert_equal("bar", File.basename("/bar/"))
54
+ assert_equal("baz", File.basename("//foo/bar/baz"))
55
+ end
56
+
57
+ test "basename method handles forward slashes in unc unix paths" do
58
+ assert_equal("\\\\foo", File.basename("//foo"))
59
+ assert_equal("\\\\foo\\bar", File.basename("//foo/bar"))
60
+ end
58
61
 
59
- def test_basename_with_forward_slashes
60
- assert_equal("bar", File.basename("C:/foo/bar"))
61
- assert_equal("bar", File.basename("C:/foo/bar/"))
62
- assert_equal("foo", File.basename("C:/foo"))
63
- assert_equal("C:\\", File.basename("C:/"))
64
- assert_equal("bar", File.basename("C:/foo/bar//"))
65
- end
62
+ test "basename method handles forward slashes in windows paths" do
63
+ assert_equal("bar", File.basename("C:/foo/bar"))
64
+ assert_equal("bar", File.basename("C:/foo/bar/"))
65
+ assert_equal("foo", File.basename("C:/foo"))
66
+ assert_equal("C:\\", File.basename("C:/"))
67
+ assert_equal("bar", File.basename("C:/foo/bar//"))
68
+ end
66
69
 
67
- def test_basename_edge_cases
68
- assert_equal("", File.basename(""))
69
- assert_equal(".", File.basename("."))
70
- assert_equal("..", File.basename(".."))
71
- assert_equal("foo", File.basename("//foo/"))
72
- end
70
+ test "basename handles edge cases as expected" do
71
+ assert_equal("", File.basename(""))
72
+ assert_equal(".", File.basename("."))
73
+ assert_equal("..", File.basename(".."))
74
+ assert_equal("foo", File.basename("//foo/"))
75
+ end
76
+
77
+ test "basename handles path names with suffixes" do
78
+ assert_equal("bar", File.basename("bar.txt", ".txt"))
79
+ assert_equal("bar", File.basename("/foo/bar.txt", ".txt"))
80
+ assert_equal("bar.txt", File.basename("bar.txt", ".exe"))
81
+ assert_equal("bar.txt", File.basename("bar.txt.exe", ".exe"))
82
+ assert_equal("bar.txt.exe", File.basename("bar.txt.exe", ".txt"))
83
+ assert_equal("bar", File.basename("bar.txt", ".*"))
84
+ assert_equal("bar.txt", File.basename("bar.txt.exe", ".*"))
85
+ end
73
86
 
74
- def test_basename_with_suffixes
75
- assert_equal("bar", File.basename("bar.txt", ".txt"))
76
- assert_equal("bar", File.basename("/foo/bar.txt", ".txt"))
77
- assert_equal("bar.txt", File.basename("bar.txt", ".exe"))
78
- assert_equal("bar.txt", File.basename("bar.txt.exe", ".exe"))
79
- assert_equal("bar.txt.exe", File.basename("bar.txt.exe", ".txt"))
80
- assert_equal("bar", File.basename("bar.txt", ".*"))
81
- assert_equal("bar.txt", File.basename("bar.txt.exe", ".*"))
82
- end
83
-
84
- def test_basename_does_not_modify_argument
85
- path = "C:\\foo\\bar"
86
- assert_nothing_raised{ File.basename(path) }
87
- assert_equal("C:\\foo\\bar", path)
88
- end
87
+ test "basename method does not modify its argument" do
88
+ path = "C:\\foo\\bar"
89
+ assert_nothing_raised{ File.basename(path) }
90
+ assert_equal("C:\\foo\\bar", path)
91
+ end
89
92
 
90
- def test_dirname_basic
91
- assert_respond_to(File, :dirname)
92
- assert_nothing_raised{ File.dirname("C:\\foo") }
93
- assert_kind_of(String, File.dirname("C:\\foo"))
94
- end
95
-
96
- def test_dirname_standard_paths
97
- assert_equal("C:\\foo", File.dirname("C:\\foo\\bar.txt"))
98
- assert_equal("C:\\foo", File.dirname("C:\\foo\\bar"))
99
- assert_equal("C:\\", File.dirname("C:\\foo"))
100
- assert_equal("C:\\", File.dirname("C:\\"))
101
- assert_equal(".", File.dirname("foo"))
102
- end
93
+ test "dirname basic functionality" do
94
+ assert_respond_to(File, :dirname)
95
+ assert_nothing_raised{ File.dirname("C:\\foo") }
96
+ assert_kind_of(String, File.dirname("C:\\foo"))
97
+ end
98
+
99
+ test "dirname handles standard windows paths as expected" do
100
+ assert_equal("C:\\foo", File.dirname("C:\\foo\\bar.txt"))
101
+ assert_equal("C:\\foo", File.dirname("C:\\foo\\bar"))
102
+ assert_equal("C:\\", File.dirname("C:\\foo"))
103
+ assert_equal("C:\\", File.dirname("C:\\"))
104
+ assert_equal(".", File.dirname("foo"))
105
+ end
103
106
 
104
- def test_dirname_unc_paths
105
- assert_equal("\\\\foo\\bar", File.dirname("\\\\foo\\bar\\baz"))
106
- assert_equal("\\\\foo\\bar", File.dirname("\\\\foo\\bar"))
107
- assert_equal("\\\\foo", File.dirname("\\\\foo"))
108
- assert_equal("\\\\", File.dirname("\\\\"))
109
- end
107
+ test "dirname handles unc windows paths as expected" do
108
+ assert_equal("\\\\foo\\bar", File.dirname("\\\\foo\\bar\\baz"))
109
+ assert_equal("\\\\foo\\bar", File.dirname("\\\\foo\\bar"))
110
+ assert_equal("\\\\foo", File.dirname("\\\\foo"))
111
+ assert_equal("\\\\", File.dirname("\\\\"))
112
+ end
110
113
 
111
- def test_dirname_forward_slashes
112
- assert_equal("C:\\foo", File.dirname("C:/foo/bar.txt"))
113
- assert_equal("C:\\foo", File.dirname("C:/foo/bar"))
114
- assert_equal("C:\\", File.dirname("C:/foo"))
115
- assert_equal("C:\\", File.dirname("C:/"))
116
- assert_equal("\\\\foo\\bar", File.dirname("//foo/bar/baz"))
117
- assert_equal("\\\\foo\\bar", File.dirname("//foo/bar"))
118
- assert_equal("\\\\foo", File.dirname("//foo"))
119
- assert_equal("\\\\", File.dirname("//"))
120
- assert_equal(".", File.dirname("./foo"))
121
- assert_equal(".\\foo", File.dirname("./foo/bar"))
122
- end
123
-
124
- def test_dirname_edge_cases
125
- assert_equal(".", File.dirname(""))
126
- assert_equal(".", File.dirname("."))
127
- assert_equal(".", File.dirname("."))
128
- assert_equal(".", File.dirname("./"))
129
- assert_raises(TypeError){ File.dirname(nil) }
130
- end
114
+ test "dirname handles forward slashes in standard windows path names" do
115
+ assert_equal("C:\\foo", File.dirname("C:/foo/bar.txt"))
116
+ assert_equal("C:\\foo", File.dirname("C:/foo/bar"))
117
+ assert_equal("C:\\", File.dirname("C:/foo"))
118
+ assert_equal("C:\\", File.dirname("C:/"))
119
+ end
120
+
121
+ test "dirname handles forward slashes in unc windows path names" do
122
+ assert_equal("\\\\foo\\bar", File.dirname("//foo/bar/baz"))
123
+ assert_equal("\\\\foo\\bar", File.dirname("//foo/bar"))
124
+ assert_equal("\\\\foo", File.dirname("//foo"))
125
+ assert_equal("\\\\", File.dirname("//"))
126
+ end
127
+
128
+ test "dirname handles forward slashes in relative path names" do
129
+ assert_equal(".", File.dirname("./foo"))
130
+ assert_equal(".\\foo", File.dirname("./foo/bar"))
131
+ end
132
+
133
+ test "dirname handles various edge cases as expected" do
134
+ assert_equal(".", File.dirname(""))
135
+ assert_equal(".", File.dirname("."))
136
+ assert_equal(".", File.dirname("."))
137
+ assert_equal(".", File.dirname("./"))
138
+ assert_raises(TypeError){ File.dirname(nil) }
139
+ end
131
140
 
132
- def test_dirname_does_not_modify_argument
133
- path = "C:\\foo\\bar"
134
- assert_nothing_raised{ File.dirname(path) }
135
- assert_equal("C:\\foo\\bar", path)
136
- end
141
+ test "dirname method does not modify its argument" do
142
+ path = "C:\\foo\\bar"
143
+ assert_nothing_raised{ File.dirname(path) }
144
+ assert_equal("C:\\foo\\bar", path)
145
+ end
137
146
 
138
- def test_split_basic
139
- assert_respond_to(File, :split)
140
- assert_nothing_raised{ File.split("C:\\foo\\bar") }
141
- assert_kind_of(Array, File.split("C:\\foo\\bar"))
142
- end
147
+ test "split method basic functionality" do
148
+ assert_respond_to(File, :split)
149
+ assert_nothing_raised{ File.split("C:\\foo\\bar") }
150
+ assert_kind_of(Array, File.split("C:\\foo\\bar"))
151
+ end
143
152
 
144
- def test_split_standard_paths
145
- assert_equal(["C:\\foo", "bar"], File.split("C:\\foo\\bar"))
146
- assert_equal([".", "foo"], File.split("foo"))
147
- end
148
-
149
- def test_split_forward_slashes
150
- assert_equal(["C:\\foo", "bar"], File.split("C:/foo/bar"))
151
- assert_equal([".", "foo"], File.split("foo"))
152
- end
153
+ test "split method handles standard windows path names" do
154
+ assert_equal(["C:\\foo", "bar"], File.split("C:\\foo\\bar"))
155
+ assert_equal([".", "foo"], File.split("foo"))
156
+ end
157
+
158
+ test "split method handles windows paths with forward slashes" do
159
+ assert_equal(["C:\\foo", "bar"], File.split("C:/foo/bar"))
160
+ assert_equal([".", "foo"], File.split("foo"))
161
+ end
153
162
 
154
- def test_split_unix_paths
155
- assert_equal(["\\foo","bar"], File.split("/foo/bar"))
156
- assert_equal(["\\", "foo"], File.split("/foo"))
157
- assert_equal([".", "foo"], File.split("foo"))
158
- end
163
+ test "split method handles standard unix paths as expected" do
164
+ assert_equal(["\\foo","bar"], File.split("/foo/bar"))
165
+ assert_equal(["\\", "foo"], File.split("/foo"))
166
+ assert_equal([".", "foo"], File.split("foo"))
167
+ end
159
168
 
160
- def test_split_unc_paths
161
- assert_equal(["\\\\foo\\bar", "baz"], File.split("\\\\foo\\bar\\baz"))
162
- assert_equal(["\\\\foo\\bar", ""], File.split("\\\\foo\\bar"))
163
- assert_equal(["\\\\foo", ""], File.split("\\\\foo"))
164
- assert_equal(["\\\\", ""], File.split("\\\\"))
165
- end
169
+ test "split method handles unc paths as expected" do
170
+ assert_equal(["\\\\foo\\bar", "baz"], File.split("\\\\foo\\bar\\baz"))
171
+ assert_equal(["\\\\foo\\bar", ""], File.split("\\\\foo\\bar"))
172
+ assert_equal(["\\\\foo", ""], File.split("\\\\foo"))
173
+ assert_equal(["\\\\", ""], File.split("\\\\"))
174
+ end
166
175
 
167
- def test_split_edge_cases
168
- assert_equal(["C:\\", ""], File.split("C:\\"))
169
- assert_equal(["", ""], File.split(""))
170
- end
176
+ test "split method handles various edge cases as expected" do
177
+ assert_equal(["C:\\", ""], File.split("C:\\"))
178
+ assert_equal(["", ""], File.split(""))
179
+ end
171
180
 
172
- def test_split_does_not_modify_arguments
173
- path = "C:\\foo\\bar"
174
- assert_nothing_raised{ File.split(path) }
175
- assert_equal("C:\\foo\\bar", path)
176
- end
181
+ test "split method does not modify its arguments" do
182
+ path = "C:\\foo\\bar"
183
+ assert_nothing_raised{ File.split(path) }
184
+ assert_equal("C:\\foo\\bar", path)
185
+ end
177
186
 
178
- def test_long_path
179
- assert_respond_to(File, :long_path)
180
- assert_equal(@long_file, File.long_path(@short_file))
181
- assert_equal('PATH_T~1.TXT', File.basename(@short_file))
182
- end
187
+ test "long_path method works as expected" do
188
+ assert_respond_to(File, :long_path)
189
+ assert_equal(@long_file, File.long_path(@short_file))
190
+ assert_equal('PATH_T~1.TXT', File.basename(@short_file))
191
+ end
183
192
 
184
- def test_short_path
185
- assert_respond_to(File, :short_path)
186
- assert_equal('path_test.txt', File.basename(@long_file))
187
- end
193
+ test "short_path method works as expected" do
194
+ assert_respond_to(File, :short_path)
195
+ assert_equal('path_test.txt', File.basename(@long_file))
196
+ end
197
+
198
+ test "join method works as expected" do
199
+ assert_respond_to(File, :join)
200
+ end
201
+
202
+ test "join handles multiple arguments as expected" do
203
+ assert_equal("C:\\foo\\bar", File.join("C:", "foo", "bar"))
204
+ assert_equal("foo\\bar", File.join("foo", "bar"))
205
+ end
206
+
207
+ test "join handles multiple arguments as expected with unc paths" do
208
+ assert_equal("\\\\foo", File.join("\\\\foo"))
209
+ assert_equal("\\\\foo\\bar", File.join("\\\\foo", "bar"))
210
+ end
211
+
212
+ test "join does not normalize paths" do
213
+ assert_equal("C:\\.\\foo\\..", File.join("C:", ".", "foo", ".."))
214
+ end
215
+
216
+ test "join with no arguments returns an empty string" do
217
+ assert_equal('', File.join)
218
+ end
219
+
220
+ test "join with one argument returns the argument" do
221
+ assert_equal('foo', File.join('foo'))
222
+ assert_equal('c:', File.join('c:'))
223
+ end
188
224
 
189
- def teardown
190
- @short_file = nil
191
- @long_file = nil
192
- end
225
+ def teardown
226
+ @short_file = nil
227
+ @long_file = nil
228
+ end
193
229
 
194
- def self.shutdown
195
- File.delete(@@file) if File.exists?(@@file)
196
- @@file = nil
197
- end
230
+ def self.shutdown
231
+ File.delete(@@file) if File.exists?(@@file)
232
+ @@file = nil
233
+ end
198
234
  end
data/win32-file.gemspec CHANGED
@@ -1,34 +1,32 @@
1
1
  require 'rubygems'
2
2
 
3
- spec = Gem::Specification.new do |gem|
4
- gem.name = 'win32-file'
5
- gem.version = '0.6.3'
6
- gem.authors = ['Daniel J. Berger', 'Park Heesob']
7
- gem.license = 'Artistic 2.0'
8
- gem.email = 'djberg96@gmail.com'
9
- gem.homepage = 'http://www.rubyforge.org/projects/win32utils'
10
- gem.platform = Gem::Platform::RUBY
11
- gem.summary = 'Extra or redefined methods for the File class on Windows.'
12
- gem.test_files = Dir['test/test*']
13
- gem.has_rdoc = true
14
- gem.files = Dir['**/*'].reject{ |f| f.include?('CVS') }
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'win32-file'
5
+ spec.version = '0.6.4'
6
+ spec.authors = ['Daniel J. Berger', 'Park Heesob']
7
+ spec.license = 'Artistic 2.0'
8
+ spec.email = 'djberg96@gmail.com'
9
+ spec.homepage = 'http://www.rubyforge.org/projects/win32utils'
10
+ spec.platform = Gem::Platform::RUBY
11
+ spec.summary = 'Extra or redefined methods for the File class on Windows.'
12
+ spec.test_files = Dir['test/test*']
13
+ spec.has_rdoc = true
14
+ spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
15
15
 
16
- gem.rubyforge_project = 'win32utils'
17
- gem.extra_rdoc_files = ['README', 'CHANGES', 'MANIFEST']
16
+ spec.rubyforge_project = 'win32utils'
17
+ spec.extra_rdoc_files = ['README', 'CHANGES', 'MANIFEST']
18
18
 
19
- gem.add_dependency('win32-api', '>= 1.4.5')
20
- gem.add_dependency('win32-file-stat', '>= 1.3.2')
21
- gem.add_dependency('windows-pr', '>= 1.0.8')
19
+ spec.add_dependency('win32-api', '>= 1.2.1')
20
+ spec.add_dependency('win32-file-stat', '>= 1.3.2')
21
+ spec.add_dependency('windows-pr', '>= 1.0.8')
22
22
 
23
- gem.add_development_dependency('test-unit', '>= 2.0.3')
23
+ spec.add_development_dependency('test-unit', '>= 2.0.7')
24
24
 
25
- gem.description = <<-EOF
26
- The win32-file library adds several methods to the core File class which
27
- are specific to MS Windows, such as the ability to set and retrieve file
28
- attributes. In addition, several core methods have been redefined in
29
- order to work properly on MS Windows, such as File.blksize. See the
30
- README file for more details.
31
- EOF
25
+ spec.description = <<-EOF
26
+ The win32-file library adds several methods to the core File class which
27
+ are specific to MS Windows, such as the ability to set and retrieve file
28
+ attributes. In addition, several core methods have been redefined in
29
+ order to work properly on MS Windows, such as File.blksize. See the
30
+ README file for more details.
31
+ EOF
32
32
  end
33
-
34
- Gem::Builder.new(spec).build