sys-filesystem 0.2.0-x86-mswin32-60 → 0.3.0-x86-mswin32-60
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 +6 -0
- data/README +13 -4
- data/Rakefile +4 -0
- data/lib/sys/filesystem.rb +17 -2
- data/sys-filesystem.gemspec +1 -1
- data/test/test_sys_filesystem_unix.rb +19 -5
- data/test/test_sys_filesystem_windows.rb +7 -1
- metadata +2 -2
data/CHANGES
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
== 0.3.0 - 26-Feb-2009
|
2
|
+
* Added support for OS X and FreeBSD thanks to an awesome patch by Nobuyoshi
|
3
|
+
Miyokawa.
|
4
|
+
* Added the Filesystem.mount_point method that takes a file and returns
|
5
|
+
the mount point its sitting on.
|
6
|
+
|
1
7
|
== 0.2.0 - 30-Dec-2008
|
2
8
|
* Added the Filesystem.mounts method for iterating over mount or volume
|
3
9
|
information.
|
data/README
CHANGED
@@ -13,7 +13,8 @@
|
|
13
13
|
require 'sys/filesystem'
|
14
14
|
include Sys
|
15
15
|
|
16
|
-
|
16
|
+
# Display information about a particular filesystem.
|
17
|
+
p Filesystem.stat('/')
|
17
18
|
|
18
19
|
# Sample output
|
19
20
|
|
@@ -33,11 +34,15 @@
|
|
33
34
|
@blocks_free = 20301129
|
34
35
|
>
|
35
36
|
|
37
|
+
# Describe all mount points on the system
|
36
38
|
Filesystem.mounts{ |mount| p mount }
|
39
|
+
|
40
|
+
# Find the mount point of any particular file
|
41
|
+
puts Filesystem.mount_point('/home/djberge/some_file.txt') => '/home'
|
37
42
|
|
38
43
|
= Notes
|
39
44
|
=== MS Windows
|
40
|
-
This is a pure Ruby implementation using the windows-pr
|
45
|
+
This is a pure Ruby implementation using the windows-pr library, which in
|
41
46
|
turn wraps native Windows functions.
|
42
47
|
=== UNIX
|
43
48
|
This is a C extension that wraps statvfs, etc.
|
@@ -54,11 +59,15 @@
|
|
54
59
|
Suggestions welcome.
|
55
60
|
|
56
61
|
= Acknowledgements
|
57
|
-
Mike Hall, for ideas and code that I borrowed from his 'filesystem'
|
62
|
+
Mike Hall, for ideas and code that I borrowed from his 'filesystem'
|
63
|
+
library.
|
64
|
+
|
58
65
|
Park Heesob, for implementation and API ideas for the MS Windows version.
|
66
|
+
|
67
|
+
Nobuyoshi Miyokawa, for adding FreeBSD and OS X support.
|
59
68
|
|
60
69
|
= Copyright
|
61
|
-
(C) 2003-
|
70
|
+
(C) 2003-2009 Daniel J. Berger
|
62
71
|
All Rights Reserved
|
63
72
|
|
64
73
|
= Warranty
|
data/Rakefile
CHANGED
@@ -58,6 +58,10 @@ Rake::TestTask.new("test") do |t|
|
|
58
58
|
t.test_files = FileList['test/test_sys_filesystem.rb']
|
59
59
|
end
|
60
60
|
|
61
|
+
task :test do
|
62
|
+
Rake.application[:clean].execute
|
63
|
+
end
|
64
|
+
|
61
65
|
desc "Run the example program"
|
62
66
|
task :example => [:build] do |t|
|
63
67
|
Dir.chdir('examples') do
|
data/lib/sys/filesystem.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'windows/error'
|
2
|
+
require 'windows/path'
|
2
3
|
require 'windows/filesystem'
|
3
4
|
require 'windows/volume'
|
4
5
|
require 'windows/handle'
|
@@ -20,6 +21,7 @@ module Sys
|
|
20
21
|
extend Windows::Error
|
21
22
|
extend Windows::FileSystem
|
22
23
|
extend Windows::Volume
|
24
|
+
extend Windows::Path
|
23
25
|
|
24
26
|
# Error typically raised if any of the Sys::Filesystem methods fail.
|
25
27
|
class Error < StandardError; end
|
@@ -39,7 +41,7 @@ module Sys
|
|
39
41
|
NAMED_STREAMS = 0x00040000
|
40
42
|
READ_ONLY_VOLUME = 0x00080000
|
41
43
|
|
42
|
-
VERSION = '0.2.
|
44
|
+
VERSION = '0.2.1'
|
43
45
|
|
44
46
|
class Mount
|
45
47
|
# The name of the volume. This is the device mapping.
|
@@ -235,10 +237,23 @@ module Sys
|
|
235
237
|
mounts # Nil if the block form was used.
|
236
238
|
end
|
237
239
|
|
240
|
+
# Returns the mount point for the given +file+. For MS Windows this
|
241
|
+
# means the root of the path.
|
242
|
+
#
|
243
|
+
# Example:
|
244
|
+
#
|
245
|
+
# File.mount_point("C:\\Documents and Settings") # => "C:\\'
|
246
|
+
#
|
247
|
+
def self.mount_point(file)
|
248
|
+
file = file.tr(File::SEPARATOR, File::ALT_SEPARATOR)
|
249
|
+
PathStripToRoot(file)
|
250
|
+
file[/^[^\0]*/]
|
251
|
+
end
|
252
|
+
|
238
253
|
# Returns a Filesystem::Stat object that contains information about the
|
239
254
|
# +path+ file system.
|
240
255
|
#
|
241
|
-
#
|
256
|
+
# Examples:
|
242
257
|
#
|
243
258
|
# File.stat("C:\\")
|
244
259
|
# File.stat("C:\\Documents and Settings\\some_user")
|
data/sys-filesystem.gemspec
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
|
3
3
|
spec = Gem::Specification.new do |gem|
|
4
4
|
gem.name = 'sys-filesystem'
|
5
|
-
gem.version = '0.
|
5
|
+
gem.version = '0.3.0'
|
6
6
|
gem.author = 'Daniel J. Berger'
|
7
7
|
gem.email = 'djberg96@gmail.com'
|
8
8
|
gem.homepage = 'http://www.rubyforge.org/projects/sysutils'
|
@@ -15,6 +15,8 @@ class TC_Sys_Filesystem_Unix < Test::Unit::TestCase
|
|
15
15
|
def self.startup
|
16
16
|
@@solaris = Config::CONFIG['host_os'] =~ /solaris/i
|
17
17
|
@@linux = Config::CONFIG['host_os'] =~ /linux/i
|
18
|
+
@@freebsd = Config::CONFIG['host_os'] =~ /freebsd/i
|
19
|
+
@@darwin = Config::CONFIG['host_os'] =~ /darwin/i
|
18
20
|
end
|
19
21
|
|
20
22
|
def setup
|
@@ -26,7 +28,7 @@ class TC_Sys_Filesystem_Unix < Test::Unit::TestCase
|
|
26
28
|
end
|
27
29
|
|
28
30
|
def test_version
|
29
|
-
assert_equal('0.
|
31
|
+
assert_equal('0.3.0', Filesystem::VERSION)
|
30
32
|
end
|
31
33
|
|
32
34
|
def test_stat_path
|
@@ -105,7 +107,8 @@ class TC_Sys_Filesystem_Unix < Test::Unit::TestCase
|
|
105
107
|
end
|
106
108
|
|
107
109
|
def test_stat_base_type
|
108
|
-
omit_unless(@@solaris, "
|
110
|
+
omit_unless(@@solaris, "base_type test skipped except on Solaris")
|
111
|
+
|
109
112
|
assert_respond_to(@stat, :base_type)
|
110
113
|
assert_kind_of(String, @stat.base_type)
|
111
114
|
end
|
@@ -113,7 +116,9 @@ class TC_Sys_Filesystem_Unix < Test::Unit::TestCase
|
|
113
116
|
def test_stat_constants
|
114
117
|
assert_not_nil(Filesystem::Stat::RDONLY)
|
115
118
|
assert_not_nil(Filesystem::Stat::NOSUID)
|
119
|
+
|
116
120
|
omit_unless(@@solaris, "NOTRUNC test skipped except on Solaris")
|
121
|
+
|
117
122
|
assert_not_nil(Filesystem::Stat::NOTRUNC)
|
118
123
|
end
|
119
124
|
|
@@ -192,15 +197,16 @@ class TC_Sys_Filesystem_Unix < Test::Unit::TestCase
|
|
192
197
|
|
193
198
|
def test_mount_time
|
194
199
|
assert_respond_to(@mnt, :mount_time)
|
200
|
+
|
195
201
|
if @@solaris
|
196
|
-
assert_kind_of(
|
202
|
+
assert_kind_of(Time, @mnt.mount_time)
|
197
203
|
else
|
198
204
|
assert_nil(@mnt.mount_time)
|
199
205
|
end
|
200
206
|
end
|
201
207
|
|
202
208
|
def test_mount_dump_frequency
|
203
|
-
omit_if(@@solaris, 'dump_frequency test skipped on
|
209
|
+
omit_if(@@solaris || @@freebsd || @@darwin, 'dump_frequency test skipped on this platform')
|
204
210
|
assert_respond_to(@mnt, :dump_frequency)
|
205
211
|
assert_kind_of(Fixnum, @mnt.dump_frequency)
|
206
212
|
end
|
@@ -211,7 +217,7 @@ class TC_Sys_Filesystem_Unix < Test::Unit::TestCase
|
|
211
217
|
end
|
212
218
|
|
213
219
|
def test_mount_pass_number
|
214
|
-
omit_if(@@solaris, 'pass_number test skipped on
|
220
|
+
omit_if(@@solaris || @@freebsd || @@darwin, 'pass_number test skipped on this platform')
|
215
221
|
assert_respond_to(@mnt, :pass_number)
|
216
222
|
assert_kind_of(Fixnum, @mnt.pass_number)
|
217
223
|
end
|
@@ -221,6 +227,12 @@ class TC_Sys_Filesystem_Unix < Test::Unit::TestCase
|
|
221
227
|
assert_true(@mnt.method(:passno) == @mnt.method(:pass_number))
|
222
228
|
end
|
223
229
|
|
230
|
+
def test_mount_point_singleton
|
231
|
+
assert_respond_to(Filesystem, :mount_point)
|
232
|
+
assert_nothing_raised{ Filesystem.mount_point(Dir.pwd) }
|
233
|
+
assert_kind_of(String, Filesystem.mount_point(Dir.pwd))
|
234
|
+
end
|
235
|
+
|
224
236
|
def teardown
|
225
237
|
@dir = nil
|
226
238
|
@stat = nil
|
@@ -230,5 +242,7 @@ class TC_Sys_Filesystem_Unix < Test::Unit::TestCase
|
|
230
242
|
def self.shutdown
|
231
243
|
@@solaris = nil
|
232
244
|
@@linux = nil
|
245
|
+
@@freebsd = nil
|
246
|
+
@@darwin = nil
|
233
247
|
end
|
234
248
|
end
|
@@ -22,7 +22,7 @@ class TC_Sys_Filesystem_Windows < Test::Unit::TestCase
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def test_version
|
25
|
-
assert_equal('0.
|
25
|
+
assert_equal('0.3.0', Filesystem::VERSION)
|
26
26
|
end
|
27
27
|
|
28
28
|
def test_stat_path
|
@@ -93,6 +93,12 @@ class TC_Sys_Filesystem_Windows < Test::Unit::TestCase
|
|
93
93
|
assert_kind_of(String, @stat.base_type)
|
94
94
|
end
|
95
95
|
|
96
|
+
def test_mount_point_singleton
|
97
|
+
assert_respond_to(Filesystem, :mount_point)
|
98
|
+
assert_nothing_raised{ Filesystem.mount_point(Dir.pwd) }
|
99
|
+
assert_kind_of(String, Filesystem.mount_point(Dir.pwd))
|
100
|
+
end
|
101
|
+
|
96
102
|
def test_constants
|
97
103
|
assert_not_nil(Filesystem::CASE_SENSITIVE_SEARCH)
|
98
104
|
assert_not_nil(Filesystem::CASE_PRESERVED_NAMES)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sys-filesystem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: x86-mswin32-60
|
6
6
|
authors:
|
7
7
|
- Daniel J. Berger
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-02-26 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|