win32-dir 0.4.4 → 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES +5 -0
- data/lib/win32/dir.rb +26 -10
- data/test/test_win32_dir.rb +15 -1
- data/win32-dir.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc264e17d1f2e530579a3a8fcc10b3551a3614f9
|
4
|
+
data.tar.gz: 33499544ea2cd22078cc9270de270cb66a19d1f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa1143644ec25286a8e5da0842e549c4d43435b8322f9c266ee153ff06c3122adb4c1469f500687881b85476b05111636b7c88a7d5b87f3f90c9127cdf41207c
|
7
|
+
data.tar.gz: c18966592a496f45d5338a3c3772d30692975d96031914f7522f586dc42fb0a369e9489ec374de9ec3cf6ebff440663c92e64e4bc78baf909faa2ff1fcd7151d
|
data/CHANGES
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
== 0.4.5 - 23-Sep-2013
|
2
|
+
* Yet another encoding fix, this time one that affected JRuby.
|
3
|
+
* Fixed the Dir[] and Dir.glob methods so they match the spec. Thanks go
|
4
|
+
to Chris Westbrook for the spot.
|
5
|
+
|
1
6
|
== 0.4.4 - 22-Sep-2013
|
2
7
|
* Yet another encoding fix. Thanks go to Rob Reynolds for the patch.
|
3
8
|
|
data/lib/win32/dir.rb
CHANGED
@@ -8,7 +8,7 @@ class Dir
|
|
8
8
|
extend Dir::Functions
|
9
9
|
|
10
10
|
# The version of the win32-dir library.
|
11
|
-
VERSION = '0.4.
|
11
|
+
VERSION = '0.4.5'
|
12
12
|
|
13
13
|
# CSIDL constants
|
14
14
|
csidl = Hash[
|
@@ -93,7 +93,11 @@ class Dir
|
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
|
-
|
96
|
+
begin
|
97
|
+
Dir.const_set(key, path.encode(Encoding.default_external)) if path
|
98
|
+
rescue Encoding::UndefinedConversionError
|
99
|
+
Dir.const_set(key, path.encode('UTF-8')) if path
|
100
|
+
end
|
97
101
|
}
|
98
102
|
|
99
103
|
# Set Dir::MYDOCUMENTS to the same as Dir::PERSONAL if undefined
|
@@ -108,8 +112,13 @@ class Dir
|
|
108
112
|
# backslashes in path names.
|
109
113
|
#
|
110
114
|
def glob(glob_pattern, flags = 0, &block)
|
111
|
-
|
112
|
-
|
115
|
+
if glob_pattern.is_a?(Array)
|
116
|
+
temp = glob_pattern.map!{ |pattern| pattern.tr("\\", "/") }
|
117
|
+
else
|
118
|
+
temp = glob_pattern.tr("\\", "/")
|
119
|
+
end
|
120
|
+
|
121
|
+
old_glob(temp, flags, &block)
|
113
122
|
end
|
114
123
|
|
115
124
|
alias old_ref []
|
@@ -117,9 +126,9 @@ class Dir
|
|
117
126
|
# Same as the standard MRI Dir[] method except that it handles
|
118
127
|
# backslashes in path names.
|
119
128
|
#
|
120
|
-
def [](
|
121
|
-
|
122
|
-
old_ref(
|
129
|
+
def [](*glob_patterns)
|
130
|
+
temp = glob_patterns.map!{ |pattern| pattern.tr("\\", "/") }
|
131
|
+
old_ref(*temp)
|
123
132
|
end
|
124
133
|
|
125
134
|
# JRuby normalizes the path by default.
|
@@ -160,8 +169,11 @@ class Dir
|
|
160
169
|
if GetLongPathNameW(path2, path3, path3.size) == 0
|
161
170
|
raise SystemCallError.new("GetLongPathNameW", FFI.errno)
|
162
171
|
end
|
163
|
-
|
164
|
-
|
172
|
+
begin
|
173
|
+
path3.strip.encode(Encoding.default_external)
|
174
|
+
rescue Encoding::UndefinedConversionError
|
175
|
+
path3.strip.encode('UTF-8')
|
176
|
+
end
|
165
177
|
end
|
166
178
|
|
167
179
|
alias :pwd :getwd
|
@@ -347,7 +359,11 @@ class Dir
|
|
347
359
|
jname = jname.bytes.to_a.pack('C*')
|
348
360
|
jname = jname.force_encoding("UTF-16LE")
|
349
361
|
raise "Junction name came back as #{jname}" unless jname[0..3] == "\\??\\".encode("UTF-16LE")
|
350
|
-
|
362
|
+
begin
|
363
|
+
File.expand_path(jname[4..-1].encode(Encoding.default_external))
|
364
|
+
rescue Encoding::UndefinedConversionError
|
365
|
+
File.expand_path(jname[4..-1].encode('UTF-8'))
|
366
|
+
end
|
351
367
|
end
|
352
368
|
|
353
369
|
# Returns whether or not +path+ is empty. Returns false if +path+ is not
|
data/test/test_win32_dir.rb
CHANGED
@@ -25,7 +25,7 @@ class TC_Win32_Dir < Test::Unit::TestCase
|
|
25
25
|
end
|
26
26
|
|
27
27
|
test "version number is set to expected value" do
|
28
|
-
assert_equal('0.4.
|
28
|
+
assert_equal('0.4.5', Dir::VERSION)
|
29
29
|
end
|
30
30
|
|
31
31
|
test 'glob handles backslashes' do
|
@@ -34,6 +34,13 @@ class TC_Win32_Dir < Test::Unit::TestCase
|
|
34
34
|
assert_true(Dir.glob(pattern).size > 0)
|
35
35
|
end
|
36
36
|
|
37
|
+
test 'glob handles multiple strings' do
|
38
|
+
pattern1 = "C:\\Program Files\\Common Files\\System\\*.dll"
|
39
|
+
pattern2 = "C:\\Windows\\*.exe"
|
40
|
+
assert_nothing_raised{ Dir.glob([pattern1, pattern2]) }
|
41
|
+
assert_true(Dir.glob([pattern1, pattern2]).size > 0)
|
42
|
+
end
|
43
|
+
|
37
44
|
test 'glob still observes flags' do
|
38
45
|
assert_nothing_raised{ Dir.glob('*', File::FNM_DOTMATCH ) }
|
39
46
|
assert_true(Dir.glob('*', File::FNM_DOTMATCH).include?('.'))
|
@@ -51,6 +58,13 @@ class TC_Win32_Dir < Test::Unit::TestCase
|
|
51
58
|
assert_true(Dir[pattern].size > 0)
|
52
59
|
end
|
53
60
|
|
61
|
+
test 'ref handles multiple arguments' do
|
62
|
+
pattern1 = "C:\\Program Files\\Common Files\\System\\*.dll"
|
63
|
+
pattern2 = "C:\\Windows\\*.exe"
|
64
|
+
assert_nothing_raised{ Dir[pattern1, pattern2] }
|
65
|
+
assert_true(Dir[pattern1, pattern2].size > 0)
|
66
|
+
end
|
67
|
+
|
54
68
|
test "create_junction basic functionality" do
|
55
69
|
assert_respond_to(Dir, :create_junction)
|
56
70
|
end
|
data/win32-dir.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: win32-dir
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel J. Berger
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-09-
|
12
|
+
date: 2013-09-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ffi
|