sys-filesystem 0.3.1 → 0.3.2
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 +9 -1
- data/MANIFEST +2 -2
- data/Rakefile +68 -49
- data/ext/sys/filesystem.c +2 -2
- data/sys-filesystem.gemspec +18 -34
- data/test/test_sys_filesystem.rb +1 -1
- data/test/test_sys_filesystem_unix.rb +233 -233
- data/test/test_sys_filesystem_windows.rb +1 -1
- metadata +3 -4
- data/doc/sys-filesystem.txt +0 -163
data/CHANGES
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
== 0.3.2 - 29-Dec-2009
|
2
|
+
* Source has been moved to github.
|
3
|
+
* Added the 'gem' task and removed build logic from the gemspec.
|
4
|
+
* Updated the install task.
|
5
|
+
* Minor correction to the manifest.
|
6
|
+
* Removed some junk build files that were inadvertently included in
|
7
|
+
the last gem.
|
8
|
+
|
1
9
|
== 0.3.1 - 5-Aug-2009
|
2
10
|
* Now compatible with Ruby 1.9.x.
|
3
11
|
* Changed license to Artistic 2.0
|
@@ -8,7 +16,7 @@
|
|
8
16
|
* Added support for OS X and FreeBSD thanks to an awesome patch by Nobuyoshi
|
9
17
|
Miyokawa.
|
10
18
|
* Added the Filesystem.mount_point method that takes a file and returns
|
11
|
-
the mount point
|
19
|
+
the mount point it's sitting on.
|
12
20
|
|
13
21
|
== 0.2.0 - 30-Dec-2008
|
14
22
|
* Added the Filesystem.mounts method for iterating over mount or volume
|
data/MANIFEST
CHANGED
@@ -6,8 +6,8 @@
|
|
6
6
|
* examples/example_stat.rb
|
7
7
|
* doc/sys-filesystem.txt
|
8
8
|
* ext/extconf.rb
|
9
|
-
* ext/filesystem.c
|
9
|
+
* ext/sys/filesystem.c
|
10
10
|
* lib/sys/filesystem.rb
|
11
11
|
* test/test_sys_filesystem.rb
|
12
12
|
* test/test_sys_filesystem_unix
|
13
|
-
* test/test_sys_filesystem_windows
|
13
|
+
* test/test_sys_filesystem_windows
|
data/Rakefile
CHANGED
@@ -4,73 +4,92 @@ require 'rake/testtask'
|
|
4
4
|
include Config
|
5
5
|
|
6
6
|
desc "Clean the build files for the sys-filesystem source for UNIX systems"
|
7
|
-
task :clean do
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
task :clean do |task|
|
8
|
+
Dir.chdir('examples') do
|
9
|
+
FileUtils.rm_rf('sys') if File.exists?('sys')
|
10
|
+
end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
12
|
+
unless Config::CONFIG['host_os'] =~ /mswin32|mingw|cygwin|windows|dos/i
|
13
|
+
file = 'sys/filesystem.' + CONFIG['DLEXT']
|
14
|
+
Dir.chdir('ext') do
|
15
|
+
sh 'make distclean' rescue nil
|
16
|
+
rm file if File.exists?(file)
|
17
|
+
rm_rf 'conftest.dSYM' if File.exists?('conftest.dSYM') # OS X weirdness
|
18
|
+
end
|
19
|
+
end
|
19
20
|
end
|
20
21
|
|
21
22
|
desc "Build the sys-filesystem library on UNIX systems (but don't install it)"
|
22
23
|
task :build => [:clean] do
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
24
|
+
unless Config::CONFIG['host_os'] =~ /mswin32|mingw|cygwin|windows|dos/i
|
25
|
+
file = 'filesystem.' + CONFIG['DLEXT']
|
26
|
+
Dir.chdir('ext') do
|
27
|
+
ruby 'extconf.rb'
|
28
|
+
sh 'make'
|
29
|
+
mv file, 'sys'
|
30
|
+
end
|
31
|
+
end
|
31
32
|
end
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
46
|
-
end
|
34
|
+
desc "Install the sys-filesystem library"
|
35
|
+
task :install do
|
36
|
+
unless Config::CONFIG['host_os'] =~ /mswin32|mingw|cygwin|windows|dos/i
|
37
|
+
install_dir = File.join(CONFIG['sitelibdir'], 'sys')
|
38
|
+
Dir.mkdir(install_dir) unless File.exists?(install_dir)
|
39
|
+
FileUtils.cp('lib/sys/filesystem.rb', install_dir, :verbose => true)
|
40
|
+
else
|
41
|
+
task :install => :build
|
42
|
+
Dir.chdir('ext') do
|
43
|
+
sh 'make install'
|
44
|
+
end
|
45
|
+
end
|
47
46
|
end
|
48
47
|
|
49
48
|
desc "Run the test suite"
|
50
49
|
Rake::TestTask.new("test") do |t|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
50
|
+
unless Config::CONFIG['host_os'] =~ /mswin32|mingw|cygwin|windows|dos/i
|
51
|
+
task :test => :build
|
52
|
+
t.libs << 'ext'
|
53
|
+
t.libs.delete('lib')
|
54
|
+
end
|
55
|
+
|
56
|
+
t.warning = true
|
57
|
+
t.verbose = true
|
58
|
+
t.test_files = FileList['test/test_sys_filesystem.rb']
|
59
59
|
end
|
60
60
|
|
61
61
|
task :test do
|
62
|
-
|
62
|
+
Rake.application[:clean].execute
|
63
63
|
end
|
64
64
|
|
65
65
|
desc "Run the example program"
|
66
66
|
task :example => [:build] do |t|
|
67
|
-
|
68
|
-
|
69
|
-
|
67
|
+
Dir.chdir('examples') do
|
68
|
+
Dir.mkdir('sys') unless File.exists?('sys')
|
69
|
+
end
|
70
|
+
|
71
|
+
FileUtils.cp('ext/sys/filesystem.' + Config::CONFIG['DLEXT'], 'examples/sys')
|
72
|
+
|
73
|
+
Dir.chdir('examples') do
|
74
|
+
ruby 'example_stat.rb'
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
desc "Build a gem"
|
79
|
+
task :gem => [:clean] do |t|
|
80
|
+
spec = eval(IO.read('sys-filesystem.gemspec'))
|
70
81
|
|
71
|
-
|
82
|
+
if Config::CONFIG['host_os'] =~ /mswin32|mingw|cygwin|windows|dos/i
|
83
|
+
spec.required_ruby_version = '>= 1.8.2'
|
84
|
+
spec.files -= Dir['ext/**/*']
|
85
|
+
spec.platform = Gem::Platform::CURRENT
|
86
|
+
spec.add_dependency('windows-pr', '>= 1.0.5')
|
87
|
+
else
|
88
|
+
spec.required_ruby_version = '>= 1.8.0'
|
89
|
+
spec.extensions = ['ext/extconf.rb']
|
90
|
+
spec.files -= Dir['lib/**/*']
|
91
|
+
spec.extra_rdoc_files << 'ext/sys/filesystem.c'
|
92
|
+
end
|
72
93
|
|
73
|
-
|
74
|
-
ruby 'example_stat.rb'
|
75
|
-
end
|
94
|
+
Gem::Builder.new(spec).build
|
76
95
|
end
|
data/ext/sys/filesystem.c
CHANGED
@@ -457,8 +457,8 @@ void Init_filesystem(){
|
|
457
457
|
|
458
458
|
/* Constants */
|
459
459
|
|
460
|
-
/* 0.3.
|
461
|
-
rb_define_const(cFilesys, "VERSION", rb_str_new2("0.3.
|
460
|
+
/* 0.3.2: The version of this library (a String) */
|
461
|
+
rb_define_const(cFilesys, "VERSION", rb_str_new2("0.3.2"));
|
462
462
|
|
463
463
|
/* 0x00000001: Read only file system */
|
464
464
|
rb_define_const(cStat, "RDONLY", INT2FIX(ST_RDONLY));
|
data/sys-filesystem.gemspec
CHANGED
@@ -1,41 +1,25 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
|
3
3
|
spec = Gem::Specification.new do |gem|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
4
|
+
gem.name = 'sys-filesystem'
|
5
|
+
gem.version = '0.3.2'
|
6
|
+
gem.author = 'Daniel J. Berger'
|
7
|
+
gem.email = 'djberg96@gmail.com'
|
8
|
+
gem.homepage = 'http://www.rubyforge.org/projects/sysutils'
|
9
|
+
gem.platform = Gem::Platform::RUBY
|
10
|
+
gem.summary = 'A Ruby interface for getting file system information.'
|
11
|
+
gem.test_file = 'test/test_sys_filesystem.rb'
|
12
|
+
gem.has_rdoc = true
|
13
|
+
gem.files = Dir['**/*'].reject{ |f| f.include?('git') }
|
14
|
+
gem.license = 'Artistic 2.0'
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
gem.extra_rdoc_files = ['CHANGES', 'README', 'MANIFEST']
|
17
|
+
gem.rubyforge_project = 'sysutils'
|
18
18
|
|
19
|
-
|
19
|
+
gem.add_development_dependency('test-unit', '>= 2.0.3')
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
if $PROGRAM_NAME == __FILE__
|
28
|
-
if RUBY_PLATFORM.match('mswin')
|
29
|
-
spec.required_ruby_version = '>= 1.8.2'
|
30
|
-
spec.files -= Dir['ext/**/*']
|
31
|
-
spec.platform = Gem::Platform::CURRENT
|
32
|
-
spec.add_dependency('windows-pr', '>= 0.6.0')
|
33
|
-
else
|
34
|
-
spec.required_ruby_version = '>= 1.8.0'
|
35
|
-
spec.extensions = ['ext/extconf.rb']
|
36
|
-
spec.files -= Dir['lib/**/*']
|
37
|
-
spec.extra_rdoc_files << 'ext/sys/filesystem.c'
|
38
|
-
end
|
39
|
-
|
40
|
-
Gem::Builder.new(spec).build
|
21
|
+
gem.description = <<-EOF
|
22
|
+
The sys-filesystem library provides an interface for gathering filesystem
|
23
|
+
information, such as disk space and mount point data.
|
24
|
+
EOF
|
41
25
|
end
|
data/test/test_sys_filesystem.rb
CHANGED
@@ -2,7 +2,7 @@ $LOAD_PATH.unshift File.dirname(File.expand_path(__FILE__))
|
|
2
2
|
|
3
3
|
require 'rbconfig'
|
4
4
|
|
5
|
-
if Config::CONFIG['host_os']
|
5
|
+
if Config::CONFIG['host_os'] =~ /mswin32|mingw|cygwin|windows|dos/i
|
6
6
|
require 'test_sys_filesystem_windows'
|
7
7
|
else
|
8
8
|
require 'test_sys_filesystem_unix'
|
@@ -12,237 +12,237 @@ require 'sys/filesystem'
|
|
12
12
|
include Sys
|
13
13
|
|
14
14
|
class TC_Sys_Filesystem_Unix < Test::Unit::TestCase
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
15
|
+
def self.startup
|
16
|
+
@@solaris = Config::CONFIG['host_os'] =~ /solaris/i
|
17
|
+
@@linux = Config::CONFIG['host_os'] =~ /linux/i
|
18
|
+
@@freebsd = Config::CONFIG['host_os'] =~ /freebsd/i
|
19
|
+
@@darwin = Config::CONFIG['host_os'] =~ /darwin/i
|
20
|
+
end
|
21
|
+
|
22
|
+
def setup
|
23
|
+
@dir = "/"
|
24
|
+
@stat = Filesystem.stat(@dir)
|
25
|
+
@mnt = Filesystem.mounts[0]
|
26
|
+
@size = 58720256
|
27
|
+
@array = []
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_version
|
31
|
+
assert_equal('0.3.2', Filesystem::VERSION)
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_stat_path
|
35
|
+
assert_respond_to(@stat, :path)
|
36
|
+
assert_equal("/", @stat.path)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_stat_block_size
|
40
|
+
assert_respond_to(@stat, :block_size)
|
41
|
+
assert_kind_of(Fixnum, @stat.block_size)
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_stat_fragment_size
|
45
|
+
assert_respond_to(@stat, :fragment_size)
|
46
|
+
assert_kind_of(Fixnum, @stat.fragment_size)
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_stat_blocks
|
50
|
+
assert_respond_to(@stat, :blocks)
|
51
|
+
assert_kind_of(Fixnum, @stat.blocks)
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_stat_blocks_free
|
55
|
+
assert_respond_to(@stat, :blocks_free)
|
56
|
+
assert_kind_of(Fixnum, @stat.blocks_free)
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_stat_blocks_available
|
60
|
+
assert_respond_to(@stat, :blocks_available)
|
61
|
+
assert_kind_of(Fixnum, @stat.blocks_available)
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_stat_files
|
65
|
+
assert_respond_to(@stat, :files)
|
66
|
+
assert_kind_of(Fixnum, @stat.files)
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_inodes_alias
|
70
|
+
assert_respond_to(@stat, :inodes)
|
71
|
+
assert_true(@stat.method(:inodes) == @stat.method(:files))
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_stat_files_free
|
75
|
+
assert_respond_to(@stat, :files_free)
|
76
|
+
assert_kind_of(Fixnum, @stat.files_free)
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_stat_inodes_free_alias
|
80
|
+
assert_respond_to(@stat, :inodes_free)
|
81
|
+
assert_true(@stat.method(:inodes_free) == @stat.method(:files_free))
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_stat_files_available
|
85
|
+
assert_respond_to(@stat, :files_available)
|
86
|
+
assert_kind_of(Fixnum, @stat.files_available)
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_stat_inodes_available_alias
|
90
|
+
assert_respond_to(@stat, :inodes_available)
|
91
|
+
assert_true(@stat.method(:inodes_available) == @stat.method(:files_available))
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_stat_filesystem_id
|
95
|
+
assert_respond_to(@stat, :filesystem_id)
|
96
|
+
assert_kind_of(Integer, @stat.filesystem_id)
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_stat_flags
|
100
|
+
assert_respond_to(@stat, :flags)
|
101
|
+
assert_kind_of(Fixnum, @stat.flags)
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_stat_name_max
|
105
|
+
assert_respond_to(@stat, :name_max)
|
106
|
+
assert_kind_of(Fixnum, @stat.name_max)
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_stat_base_type
|
110
|
+
omit_unless(@@solaris, "base_type test skipped except on Solaris")
|
111
|
+
|
112
|
+
assert_respond_to(@stat, :base_type)
|
113
|
+
assert_kind_of(String, @stat.base_type)
|
114
|
+
end
|
115
|
+
|
116
|
+
def test_stat_constants
|
117
|
+
assert_not_nil(Filesystem::Stat::RDONLY)
|
118
|
+
assert_not_nil(Filesystem::Stat::NOSUID)
|
119
|
+
|
120
|
+
omit_unless(@@solaris, "NOTRUNC test skipped except on Solaris")
|
121
|
+
|
122
|
+
assert_not_nil(Filesystem::Stat::NOTRUNC)
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_stat_expected_errors
|
126
|
+
assert_raises(ArgumentError){ Filesystem.stat }
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_fixnum_methods_basic
|
130
|
+
assert_respond_to(@size, :to_kb)
|
131
|
+
assert_respond_to(@size, :to_mb)
|
132
|
+
assert_respond_to(@size, :to_gb)
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_to_kb
|
136
|
+
assert_equal(57344, @size.to_kb)
|
137
|
+
end
|
138
|
+
|
139
|
+
def test_to_mb
|
140
|
+
assert_equal(56, @size.to_mb)
|
141
|
+
end
|
142
|
+
|
143
|
+
def test_to_gb
|
144
|
+
assert_equal(0, @size.to_gb)
|
145
|
+
end
|
146
|
+
|
147
|
+
# Filesystem::Mount tests
|
148
|
+
|
149
|
+
def test_mounts_with_no_block
|
150
|
+
assert_nothing_raised{ @array = Filesystem.mounts }
|
151
|
+
assert_kind_of(Filesystem::Mount, @array[0])
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_mounts_with_block
|
155
|
+
assert_nothing_raised{ Filesystem.mounts{ |m| @array << m } }
|
156
|
+
assert_kind_of(Filesystem::Mount, @array[0])
|
157
|
+
end
|
158
|
+
|
159
|
+
def test_mounts_high_iteration
|
160
|
+
assert_nothing_raised{ 1000.times{ @array = Filesystem.mounts } }
|
161
|
+
end
|
162
|
+
|
163
|
+
def test_mount_name
|
164
|
+
assert_respond_to(@mnt, :name)
|
165
|
+
assert_kind_of(String, @mnt.name)
|
166
|
+
end
|
167
|
+
|
168
|
+
def test_fsname_alias
|
169
|
+
assert_respond_to(@mnt, :fsname)
|
170
|
+
assert_true(@mnt.method(:fsname) == @mnt.method(:name))
|
171
|
+
end
|
172
|
+
|
173
|
+
def test_mount_point
|
174
|
+
assert_respond_to(@mnt, :mount_point)
|
175
|
+
assert_kind_of(String, @mnt.mount_point)
|
176
|
+
end
|
177
|
+
|
178
|
+
def test_dir_alias
|
179
|
+
assert_respond_to(@mnt, :dir)
|
180
|
+
assert_true(@mnt.method(:dir) == @mnt.method(:mount_point))
|
181
|
+
end
|
182
|
+
|
183
|
+
def test_mount_type
|
184
|
+
assert_respond_to(@mnt, :mount_type)
|
185
|
+
assert_kind_of(String, @mnt.mount_type)
|
186
|
+
end
|
187
|
+
|
188
|
+
def test_mount_options
|
189
|
+
assert_respond_to(@mnt, :options)
|
190
|
+
assert_kind_of(String, @mnt.options)
|
191
|
+
end
|
192
|
+
|
193
|
+
def test_opts_alias
|
194
|
+
assert_respond_to(@mnt, :opts)
|
195
|
+
assert_true(@mnt.method(:opts) == @mnt.method(:options))
|
196
|
+
end
|
197
|
+
|
198
|
+
def test_mount_time
|
199
|
+
assert_respond_to(@mnt, :mount_time)
|
200
|
+
|
201
|
+
if @@solaris
|
202
|
+
assert_kind_of(Time, @mnt.mount_time)
|
203
|
+
else
|
204
|
+
assert_nil(@mnt.mount_time)
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
def test_mount_dump_frequency
|
209
|
+
omit_if(@@solaris || @@freebsd || @@darwin, 'dump_frequency test skipped on this platform')
|
210
|
+
assert_respond_to(@mnt, :dump_frequency)
|
211
|
+
assert_kind_of(Fixnum, @mnt.dump_frequency)
|
212
|
+
end
|
213
|
+
|
214
|
+
def test_freq_alias
|
215
|
+
assert_respond_to(@mnt, :freq)
|
216
|
+
assert_true(@mnt.method(:freq) == @mnt.method(:dump_frequency))
|
217
|
+
end
|
218
|
+
|
219
|
+
def test_mount_pass_number
|
220
|
+
omit_if(@@solaris || @@freebsd || @@darwin, 'pass_number test skipped on this platform')
|
221
|
+
assert_respond_to(@mnt, :pass_number)
|
222
|
+
assert_kind_of(Fixnum, @mnt.pass_number)
|
223
|
+
end
|
224
|
+
|
225
|
+
def test_passno_alias
|
226
|
+
assert_respond_to(@mnt, :passno)
|
227
|
+
assert_true(@mnt.method(:passno) == @mnt.method(:pass_number))
|
228
|
+
end
|
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
|
+
|
236
|
+
def teardown
|
237
|
+
@dir = nil
|
238
|
+
@stat = nil
|
239
|
+
@array = nil
|
240
|
+
end
|
241
|
+
|
242
|
+
def self.shutdown
|
243
|
+
@@solaris = nil
|
244
|
+
@@linux = nil
|
245
|
+
@@freebsd = nil
|
246
|
+
@@darwin = nil
|
247
|
+
end
|
248
248
|
end
|
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.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
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: 2009-
|
12
|
+
date: 2009-12-30 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -22,7 +22,7 @@ dependencies:
|
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: 2.0.3
|
24
24
|
version:
|
25
|
-
description: "
|
25
|
+
description: " The sys-filesystem library provides an interface for gathering filesystem\n information, such as disk space and mount point data.\n"
|
26
26
|
email: djberg96@gmail.com
|
27
27
|
executables: []
|
28
28
|
|
@@ -35,7 +35,6 @@ extra_rdoc_files:
|
|
35
35
|
- ext/sys/filesystem.c
|
36
36
|
files:
|
37
37
|
- CHANGES
|
38
|
-
- doc/sys-filesystem.txt
|
39
38
|
- examples/example_stat.rb
|
40
39
|
- ext/extconf.rb
|
41
40
|
- ext/sys/filesystem.c
|
data/doc/sys-filesystem.txt
DELETED
@@ -1,163 +0,0 @@
|
|
1
|
-
= Description
|
2
|
-
A Ruby interface for getting filesystem information.
|
3
|
-
|
4
|
-
= Synopsis
|
5
|
-
require 'sys/filesystem'
|
6
|
-
include Sys
|
7
|
-
|
8
|
-
p Filesystem.stat("/") # => Sys::Filesystem::Stat object
|
9
|
-
|
10
|
-
Filesystem.mounts{ |mount|
|
11
|
-
p mount
|
12
|
-
}
|
13
|
-
|
14
|
-
= Constants
|
15
|
-
== Sys::Filesystem
|
16
|
-
VERSION
|
17
|
-
The version of this package, returned as a string.
|
18
|
-
|
19
|
-
== Sys::Filesystem::Stat
|
20
|
-
RDONLY
|
21
|
-
Read only filesystem.
|
22
|
-
|
23
|
-
See the +flags+ method for more information.
|
24
|
-
|
25
|
-
NOSUID
|
26
|
-
Filesystem does not support suid or sgid semantics.
|
27
|
-
|
28
|
-
See the +flags+ method for more information.
|
29
|
-
|
30
|
-
NOTRUNC
|
31
|
-
Filesystem does not truncate file names longer than +name_max+. Not
|
32
|
-
supported on all platforms.
|
33
|
-
|
34
|
-
See the +flags+ method for more information.
|
35
|
-
|
36
|
-
= Class Methods
|
37
|
-
=== Sys::Filesystem
|
38
|
-
Sys::Filesystem.stat(path)
|
39
|
-
Returns a Filesystem::Stat object containing information about the
|
40
|
-
+path+ filesystem.
|
41
|
-
|
42
|
-
Sys::Filesystem.mounts
|
43
|
-
Returns an array of Filesystem::Mount objects containing information
|
44
|
-
about the mount points available on your system.
|
45
|
-
|
46
|
-
In block form this method yields each Mount object in turn instead
|
47
|
-
of returning an array.
|
48
|
-
|
49
|
-
= Instance Methods
|
50
|
-
=== Sys::Filesystem::Mount
|
51
|
-
name
|
52
|
-
The name of the mounted resource.
|
53
|
-
|
54
|
-
On MS Windows this is the device mapping.
|
55
|
-
|
56
|
-
mount_time
|
57
|
-
The last time the volume was mounted.
|
58
|
-
|
59
|
-
On MS Windows this is your system's boot time.
|
60
|
-
|
61
|
-
mount_type
|
62
|
-
The type of mount, e.g. NFS, NTFS.
|
63
|
-
|
64
|
-
mount_point
|
65
|
-
The volume mount point.
|
66
|
-
|
67
|
-
On MS Windows this is the volume letter.
|
68
|
-
|
69
|
-
options
|
70
|
-
A list of comma separated options that denote properties of the volume.
|
71
|
-
|
72
|
-
pass_number
|
73
|
-
The number of the filesystem check, or nil if not present.
|
74
|
-
|
75
|
-
This is always nil on MS Windows.
|
76
|
-
|
77
|
-
frequency
|
78
|
-
The dump frequency in days, or nil if not present or supported.
|
79
|
-
|
80
|
-
This is always nil on MS Windows.
|
81
|
-
|
82
|
-
=== Sys::Filesystem::Stat
|
83
|
-
base_type
|
84
|
-
The filesystem type, e.g. UFS.
|
85
|
-
|
86
|
-
block_size
|
87
|
-
The preferred system block size.
|
88
|
-
|
89
|
-
blocks
|
90
|
-
The total number of +fragment_size+ blocks in the filesystem.
|
91
|
-
|
92
|
-
blocks_available
|
93
|
-
The number of free blocks available to unprivileged processes.
|
94
|
-
|
95
|
-
blocks_free
|
96
|
-
The total number of free blocks in the filesystem.
|
97
|
-
|
98
|
-
files
|
99
|
-
The total number of files/inodes that can be created.
|
100
|
-
|
101
|
-
files_free
|
102
|
-
The total number of free files/inodes on the file system.
|
103
|
-
|
104
|
-
filesystem_id
|
105
|
-
The filesystem identifier.
|
106
|
-
|
107
|
-
flags
|
108
|
-
A bit mask of flags. See the 'Constants' section for a list of flags.
|
109
|
-
|
110
|
-
fragment_size
|
111
|
-
The fragment size, i.e. fundamental file system block size.
|
112
|
-
|
113
|
-
inodes
|
114
|
-
Alias for +files+.
|
115
|
-
|
116
|
-
inodes_free
|
117
|
-
Alias for +files_free+.
|
118
|
-
|
119
|
-
inodes_available
|
120
|
-
Alias for +files_available+.
|
121
|
-
|
122
|
-
name_max
|
123
|
-
The maximum length of a file name permitted on the file system.
|
124
|
-
|
125
|
-
path
|
126
|
-
The path of the filesystem.
|
127
|
-
|
128
|
-
= Fixnum helper methods
|
129
|
-
Fixnum#to_gb
|
130
|
-
Returns a number in terms of gigabytes.
|
131
|
-
|
132
|
-
Fixnum#to_kb
|
133
|
-
Returns a number in terms of kilobytes
|
134
|
-
|
135
|
-
Fixnum#to_mb
|
136
|
-
Returns a number in terms of megabytes
|
137
|
-
|
138
|
-
== Known Bugs
|
139
|
-
None that I am aware of. Please log any bugs you find on the project
|
140
|
-
website at http://www.rubyforge.org/projects/sysutils.
|
141
|
-
|
142
|
-
== License
|
143
|
-
Artistic 2.0
|
144
|
-
|
145
|
-
== Copyright
|
146
|
-
Copyright 2002-2009, Daniel J. Berger
|
147
|
-
|
148
|
-
All Rights Reserved. This module is free software. It may be used,
|
149
|
-
redistributed and/or modified under the same terms as Ruby itself.
|
150
|
-
|
151
|
-
== Warranty
|
152
|
-
This library is provided "as is" and without any express or
|
153
|
-
implied warranties, including, without limitation, the implied
|
154
|
-
warranties of merchantability and fitness for a particular purpose.
|
155
|
-
|
156
|
-
== Acknowledgements
|
157
|
-
Mike Hall for his original source code.
|
158
|
-
|
159
|
-
== Author
|
160
|
-
Daniel J. Berger
|
161
|
-
|
162
|
-
== See Also
|
163
|
-
mount
|