win32-file 0.6.5 → 0.6.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 +5 -0
- data/Rakefile +3 -0
- data/lib/win32/file.rb +14 -3
- data/test/test_win32_file_attributes.rb +1 -1
- data/test/test_win32_file_path.rb +15 -3
- data/win32-file.gemspec +1 -1
- metadata +3 -3
data/CHANGES
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
== 0.6.6 - 3-Sep-2010
|
2
|
+
* Fixed a bug in the custom File.dirname where trailing slashes were
|
3
|
+
affecting the result. Trailing slashes are now ignored.
|
4
|
+
* Added a global test task and a default rake task. Both run all tests.
|
5
|
+
|
1
6
|
== 0.6.5 - 19-Jul-2010
|
2
7
|
* Removed debug print statement (oops!).
|
3
8
|
|
data/Rakefile
CHANGED
data/lib/win32/file.rb
CHANGED
@@ -19,7 +19,7 @@ class File
|
|
19
19
|
extend Windows::Handle
|
20
20
|
|
21
21
|
# The version of the win32-file library
|
22
|
-
WIN32_FILE_VERSION = '0.6.
|
22
|
+
WIN32_FILE_VERSION = '0.6.6'
|
23
23
|
|
24
24
|
# Abbreviated attribute constants for convenience
|
25
25
|
|
@@ -514,6 +514,11 @@ class File
|
|
514
514
|
#
|
515
515
|
def dirname(file)
|
516
516
|
raise TypeError unless file.is_a?(String)
|
517
|
+
|
518
|
+
# Short circuit for empty paths
|
519
|
+
return '.' if file.empty?
|
520
|
+
|
521
|
+
# Temporarily convert to wide-byte
|
517
522
|
file = multi_to_wide(file)
|
518
523
|
|
519
524
|
# Convert slashes to backslashes for the Windows API functions
|
@@ -521,10 +526,16 @@ class File
|
|
521
526
|
|
522
527
|
# Return a root path as-is.
|
523
528
|
return wide_to_multi(file) if PathIsRootW(file)
|
524
|
-
|
525
|
-
# Remove trailing
|
529
|
+
|
530
|
+
# Remove trailing slashes if present
|
531
|
+
while result = PathRemoveBackslashW(file)
|
532
|
+
break unless result.empty?
|
533
|
+
end
|
534
|
+
|
535
|
+
# Remove trailing file name if present
|
526
536
|
PathRemoveFileSpecW(file)
|
527
537
|
|
538
|
+
# Return to multi-byte
|
528
539
|
file = wide_to_multi(file)
|
529
540
|
|
530
541
|
# Empty paths, short relative paths
|
@@ -133,9 +133,8 @@ class TC_Win32_File_Path < Test::Unit::TestCase
|
|
133
133
|
test "dirname handles various edge cases as expected" do
|
134
134
|
assert_equal(".", File.dirname(""))
|
135
135
|
assert_equal(".", File.dirname("."))
|
136
|
-
assert_equal(".", File.dirname("
|
136
|
+
assert_equal(".", File.dirname(".."))
|
137
137
|
assert_equal(".", File.dirname("./"))
|
138
|
-
assert_raises(TypeError){ File.dirname(nil) }
|
139
138
|
end
|
140
139
|
|
141
140
|
test "dirname method does not modify its argument" do
|
@@ -143,7 +142,20 @@ class TC_Win32_File_Path < Test::Unit::TestCase
|
|
143
142
|
assert_nothing_raised{ File.dirname(path) }
|
144
143
|
assert_equal("C:\\foo\\bar", path)
|
145
144
|
end
|
146
|
-
|
145
|
+
|
146
|
+
test "dirname method ignores trailing slashes" do
|
147
|
+
assert_equal("C:\\foo\\bar", File.dirname("C:/foo/bar/baz/"))
|
148
|
+
assert_equal("C:\\foo\\bar", File.dirname("C:/foo/bar/baz//"))
|
149
|
+
assert_equal("C:\\foo\\bar", File.dirname("C:/foo/bar/baz///"))
|
150
|
+
assert_equal("C:\\foo\\bar", File.dirname("C:\\foo\\bar\\baz\\"))
|
151
|
+
assert_equal("\\\\foo\\bar", File.dirname("\\\\foo\\bar\\baz\\"))
|
152
|
+
end
|
153
|
+
|
154
|
+
test "argument to dirname must be a string" do
|
155
|
+
assert_raises(TypeError){ File.dirname(nil) }
|
156
|
+
assert_raises(TypeError){ File.dirname(['foo', 'bar']) }
|
157
|
+
end
|
158
|
+
|
147
159
|
test "split method basic functionality" do
|
148
160
|
assert_respond_to(File, :split)
|
149
161
|
assert_nothing_raised{ File.split("C:\\foo\\bar") }
|
data/win32-file.gemspec
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 6
|
8
|
-
-
|
9
|
-
version: 0.6.
|
8
|
+
- 6
|
9
|
+
version: 0.6.6
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Daniel J. Berger
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-09-03 00:00:00 -06:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|