win32-dir 0.4.7 → 0.4.8
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.
- checksums.yaml +4 -4
- data/CHANGES +3 -0
- data/lib/win32/dir.rb +16 -6
- 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: 09b52a947373ea7bb57b6daf0cc831f8e46d864a
|
4
|
+
data.tar.gz: d93f71ab02fb811c3b9ab5e7f61302479cad9a8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8db28589b375acc51ed21bd4301163309dda8ebda843f7a1982bfbfefdca06603a14a2f5fad581943e5b1fa5130c52b6b0dd7246322764c37706932ca2185517
|
7
|
+
data.tar.gz: 79324ed4a740c9e1d23f9dc0c331f972792d47faf5fc37fa74d2649285ee22b88d860ef4ac5113a0186e387aeaaabdb27efb457cad0a055ee4601714cebffb2b
|
data/CHANGES
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
== 0.4.8 - 27-Apr-2014
|
2
|
+
* More closely mimic Ruby's stringiness checks for overrided methods.
|
3
|
+
|
1
4
|
== 0.4.7 - 26-Apr-2014
|
2
5
|
* All arguments to methods are now interpolated so that they'll use whatever
|
3
6
|
to_str implemenation the argument provides instead of assuming String
|
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.8'
|
12
12
|
|
13
13
|
# CSIDL constants
|
14
14
|
csidl = Hash[
|
@@ -113,9 +113,9 @@ class Dir
|
|
113
113
|
#
|
114
114
|
def glob(glob_pattern, flags = 0, &block)
|
115
115
|
if glob_pattern.is_a?(Array)
|
116
|
-
temp = glob_pattern.map!{ |pattern|
|
116
|
+
temp = glob_pattern.map!{ |pattern| string_check(pattern).tr("\\", "/") }
|
117
117
|
else
|
118
|
-
temp =
|
118
|
+
temp = string_check(glob_pattern).tr("\\", "/")
|
119
119
|
end
|
120
120
|
|
121
121
|
old_glob(temp, flags, &block)
|
@@ -192,8 +192,8 @@ class Dir
|
|
192
192
|
# Dir.create_junction('C:/to', 'C:/from')
|
193
193
|
#
|
194
194
|
def self.create_junction(to, from)
|
195
|
-
to =
|
196
|
-
from =
|
195
|
+
to = string_check(to).wincode
|
196
|
+
from = string_check(from).wincode
|
197
197
|
|
198
198
|
from_path = (0.chr * 1024).encode('UTF-16LE')
|
199
199
|
|
@@ -292,7 +292,7 @@ class Dir
|
|
292
292
|
def self.read_junction(junction)
|
293
293
|
return false unless Dir.junction?("#{junction}")
|
294
294
|
|
295
|
-
junction =
|
295
|
+
junction = string_check(junction).wincode
|
296
296
|
|
297
297
|
junction_path = (0.chr * 1024).encode('UTF-16LE')
|
298
298
|
|
@@ -399,6 +399,16 @@ class Dir
|
|
399
399
|
|
400
400
|
private
|
401
401
|
|
402
|
+
class << self
|
403
|
+
# Simulate MRI's contortions for a stringiness check.
|
404
|
+
def string_check(arg)
|
405
|
+
return arg if arg.is_a?(String)
|
406
|
+
return arg.send(:to_str) if arg.respond_to?(:to_str, true) # MRI honors it, even if private
|
407
|
+
return arg.to_path if arg.respond_to?(:to_path)
|
408
|
+
raise TypeError
|
409
|
+
end
|
410
|
+
end
|
411
|
+
|
402
412
|
# Macro from Windows header file, used by the create_junction method.
|
403
413
|
def self.CTL_CODE(device, function, method, access)
|
404
414
|
((device) << 16) | ((access) << 14) | ((function) << 2) | (method)
|
data/test/test_win32_dir.rb
CHANGED
@@ -26,7 +26,7 @@ class TC_Win32_Dir < Test::Unit::TestCase
|
|
26
26
|
end
|
27
27
|
|
28
28
|
test "version number is set to expected value" do
|
29
|
-
assert_equal('0.4.
|
29
|
+
assert_equal('0.4.8', Dir::VERSION)
|
30
30
|
end
|
31
31
|
|
32
32
|
test 'glob handles backslashes' do
|
@@ -60,6 +60,10 @@ class TC_Win32_Dir < Test::Unit::TestCase
|
|
60
60
|
assert_true(Dir.glob([pattern1, pattern2]).size > 0)
|
61
61
|
end
|
62
62
|
|
63
|
+
test "glob requires a stringy argument" do
|
64
|
+
assert_raise(TypeError){ Dir.glob(nil) }
|
65
|
+
end
|
66
|
+
|
63
67
|
test 'ref handles backslashes' do
|
64
68
|
pattern = "C:\\Program Files\\Common Files\\System\\*.dll"
|
65
69
|
assert_nothing_raised{ Dir[pattern] }
|
@@ -105,6 +109,11 @@ class TC_Win32_Dir < Test::Unit::TestCase
|
|
105
109
|
assert_equal(Dir.entries(@@from), Dir.entries(@ascii_to))
|
106
110
|
end
|
107
111
|
|
112
|
+
test "create_junction requires stringy arguments" do
|
113
|
+
assert_raise(TypeError){ Dir.create_junction(nil, @@from) }
|
114
|
+
assert_raise(TypeError){ Dir.create_junction(@ascii_to, nil) }
|
115
|
+
end
|
116
|
+
|
108
117
|
test "read_junction works as expected with ascii characters" do
|
109
118
|
assert_nothing_raised{ Dir.create_junction(@ascii_to, @@from) }
|
110
119
|
assert_true(File.exists?(@ascii_to))
|
@@ -129,6 +138,11 @@ class TC_Win32_Dir < Test::Unit::TestCase
|
|
129
138
|
assert_equal(Dir.read_junction(@ascii_to), @@from)
|
130
139
|
end
|
131
140
|
|
141
|
+
test "read_junction requires a stringy argument" do
|
142
|
+
assert_raise(TypeError){ Dir.read_junction(nil) }
|
143
|
+
assert_raise(TypeError){ Dir.read_junction([]) }
|
144
|
+
end
|
145
|
+
|
132
146
|
test "junction? method returns boolean value" do
|
133
147
|
assert_respond_to(Dir, :junction?)
|
134
148
|
assert_nothing_raised{ Dir.create_junction(@ascii_to, @@from) }
|
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.8
|
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: 2014-04-
|
12
|
+
date: 2014-04-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ffi
|