ptools 1.3.3-universal-mingw32 → 1.4.1-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +3 -1
- data.tar.gz.sig +0 -0
- data/{CHANGES → CHANGES.md} +61 -29
- data/Gemfile +1 -1
- data/MANIFEST.md +27 -0
- data/{README → README.md} +30 -26
- data/Rakefile +32 -80
- data/certs/djberg96_pub.pem +22 -17
- data/lib/ptools.rb +32 -38
- data/ptools.gemspec +15 -9
- data/spec/binary_spec.rb +59 -0
- data/spec/constants_spec.rb +33 -0
- data/spec/head_spec.rb +41 -0
- data/spec/image_spec.rb +51 -0
- data/{test → spec}/img/test.gif +0 -0
- data/spec/img/test.ico +0 -0
- data/{test → spec}/img/test.jpg +0 -0
- data/{test → spec}/img/test.png +0 -0
- data/spec/nlconvert_spec.rb +104 -0
- data/spec/sparse_spec.rb +43 -0
- data/spec/tail_spec.rb +107 -0
- data/spec/touch_spec.rb +47 -0
- data/{.gemtest → spec/txt/empty.txt} +0 -0
- data/{test → spec}/txt/english.txt +0 -0
- data/spec/txt/english.utf16 +0 -0
- data/{test → spec}/txt/korean.txt +0 -0
- data/spec/wc_spec.rb +65 -0
- data/spec/whereis_spec.rb +87 -0
- data/spec/which_spec.rb +112 -0
- metadata +64 -68
- metadata.gz.sig +0 -0
- data/MANIFEST +0 -20
- data/test/test_binary.rb +0 -65
- data/test/test_constants.rb +0 -38
- data/test/test_head.rb +0 -48
- data/test/test_image.rb +0 -57
- data/test/test_is_sparse.rb +0 -53
- data/test/test_nlconvert.rb +0 -110
- data/test/test_null.rb +0 -40
- data/test/test_tail.rb +0 -124
- data/test/test_touch.rb +0 -53
- data/test/test_wc.rb +0 -73
- data/test/test_whereis.rb +0 -98
- data/test/test_which.rb +0 -126
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ptools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: universal-mingw32
|
6
6
|
authors:
|
7
7
|
- Daniel J. Berger
|
@@ -10,27 +10,32 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
13
|
+
MIIEcDCCAtigAwIBAgIBATANBgkqhkiG9w0BAQsFADA/MREwDwYDVQQDDAhkamJl
|
14
14
|
cmc5NjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYDY29t
|
15
|
-
|
15
|
+
MB4XDTE4MDMxODE1MjIwN1oXDTI4MDMxNTE1MjIwN1owPzERMA8GA1UEAwwIZGpi
|
16
16
|
ZXJnOTYxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2Nv
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
17
|
+
bTCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBALgfaroVM6CI06cxr0/h
|
18
|
+
A+j+pc8fgpRgBVmHFaFunq28GPC3IvW7Nvc3Y8SnAW7pP1EQIbhlwRIaQzJ93/yj
|
19
|
+
u95KpkP7tA9erypnV7dpzBkzNlX14ACaFD/6pHoXoe2ltBxk3CCyyzx70mTqJpph
|
20
|
+
75IB03ni9a8yqn8pmse+s83bFJOAqddSj009sGPcQO+QOWiNxqYv1n5EHcvj2ebO
|
21
|
+
6hN7YTmhx7aSia4qL/quc4DlIaGMWoAhvML7u1fmo53CYxkKskfN8MOecq2vfEmL
|
22
|
+
iLu+SsVVEAufMDDFMXMJlvDsviolUSGMSNRTujkyCcJoXKYYxZSNtIiyd9etI0X3
|
23
|
+
ctu0uhrFyrMZXCedutvXNjUolD5r9KGBFSWH1R9u2I3n3SAyFF2yzv/7idQHLJJq
|
24
|
+
74BMnx0FIq6fCpu5slAipvxZ3ZkZpEXZFr3cIBtO1gFvQWW7E/Y3ijliWJS1GQFq
|
25
|
+
058qERadHGu1yu1dojmFRo6W2KZvY9al2yIlbkpDrD5MYQIDAQABo3cwdTAJBgNV
|
26
|
+
HRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUFZsMapgzJimzsbaBG2Tm8j5e
|
27
|
+
AzgwHQYDVR0RBBYwFIESZGpiZXJnOTZAZ21haWwuY29tMB0GA1UdEgQWMBSBEmRq
|
28
|
+
YmVyZzk2QGdtYWlsLmNvbTANBgkqhkiG9w0BAQsFAAOCAYEAW2tnYixXQtKxgGXq
|
29
|
+
/3iSWG2bLwvxS4go3srO+aRXZHrFUMlJ5W0mCxl03aazxxKTsVVpZD8QZxvK91OQ
|
30
|
+
h9zr9JBYqCLcCVbr8SkmYCi/laxIZxsNE5YI8cC8vvlLI7AMgSfPSnn/Epq1GjGY
|
31
|
+
6L1iRcEDtanGCIvjqlCXO9+BmsnCfEVehqZkQHeYczA03tpOWb6pon2wzvMKSsKH
|
32
|
+
ks0ApVdstSLz1kzzAqem/uHdG9FyXdbTAwH1G4ZPv69sQAFAOCgAqYmdnzedsQtE
|
33
|
+
1LQfaQrx0twO+CZJPcRLEESjq8ScQxWRRkfuh2VeR7cEU7L7KqT10mtUwrvw7APf
|
34
|
+
DYoeCY9KyjIBjQXfbj2ke5u1hZj94Fsq9FfbEQg8ygCgwThnmkTrrKEiMSs3alYR
|
35
|
+
ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
|
36
|
+
WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
|
32
37
|
-----END CERTIFICATE-----
|
33
|
-
date:
|
38
|
+
date: 2020-12-29 00:00:00.000000000 Z
|
34
39
|
dependencies:
|
35
40
|
- !ruby/object:Gem::Dependency
|
36
41
|
name: rake
|
@@ -47,33 +52,33 @@ dependencies:
|
|
47
52
|
- !ruby/object:Gem::Version
|
48
53
|
version: '0'
|
49
54
|
- !ruby/object:Gem::Dependency
|
50
|
-
name:
|
55
|
+
name: rspec
|
51
56
|
requirement: !ruby/object:Gem::Requirement
|
52
57
|
requirements:
|
53
|
-
- - "
|
58
|
+
- - "~>"
|
54
59
|
- !ruby/object:Gem::Version
|
55
|
-
version:
|
60
|
+
version: '3.9'
|
56
61
|
type: :development
|
57
62
|
prerelease: false
|
58
63
|
version_requirements: !ruby/object:Gem::Requirement
|
59
64
|
requirements:
|
60
|
-
- - "
|
65
|
+
- - "~>"
|
61
66
|
- !ruby/object:Gem::Version
|
62
|
-
version:
|
67
|
+
version: '3.9'
|
63
68
|
- !ruby/object:Gem::Dependency
|
64
69
|
name: win32-file
|
65
70
|
requirement: !ruby/object:Gem::Requirement
|
66
71
|
requirements:
|
67
72
|
- - ">="
|
68
73
|
- !ruby/object:Gem::Version
|
69
|
-
version: 0
|
74
|
+
version: '0'
|
70
75
|
type: :runtime
|
71
76
|
prerelease: false
|
72
77
|
version_requirements: !ruby/object:Gem::Requirement
|
73
78
|
requirements:
|
74
79
|
- - ">="
|
75
80
|
- !ruby/object:Gem::Version
|
76
|
-
version: 0
|
81
|
+
version: '0'
|
77
82
|
description: |2
|
78
83
|
The ptools (power tools) library provides several handy methods to
|
79
84
|
Ruby's core File class, such as File.which for finding executables,
|
@@ -81,41 +86,45 @@ description: |2
|
|
81
86
|
email: djberg96@gmail.com
|
82
87
|
executables: []
|
83
88
|
extensions: []
|
84
|
-
extra_rdoc_files:
|
85
|
-
- README
|
86
|
-
- CHANGES
|
87
|
-
- MANIFEST
|
89
|
+
extra_rdoc_files: []
|
88
90
|
files:
|
89
|
-
-
|
90
|
-
- CHANGES
|
91
|
+
- CHANGES.md
|
91
92
|
- Gemfile
|
92
|
-
- MANIFEST
|
93
|
-
- README
|
93
|
+
- MANIFEST.md
|
94
|
+
- README.md
|
94
95
|
- Rakefile
|
95
96
|
- certs/djberg96_pub.pem
|
96
97
|
- lib/ptools.rb
|
97
98
|
- ptools.gemspec
|
98
|
-
-
|
99
|
-
-
|
100
|
-
-
|
101
|
-
-
|
102
|
-
- test
|
103
|
-
- test
|
104
|
-
- test
|
105
|
-
- test
|
106
|
-
-
|
107
|
-
-
|
108
|
-
-
|
109
|
-
-
|
110
|
-
-
|
111
|
-
-
|
112
|
-
-
|
113
|
-
-
|
114
|
-
-
|
99
|
+
- spec/binary_spec.rb
|
100
|
+
- spec/constants_spec.rb
|
101
|
+
- spec/head_spec.rb
|
102
|
+
- spec/image_spec.rb
|
103
|
+
- spec/img/test.gif
|
104
|
+
- spec/img/test.ico
|
105
|
+
- spec/img/test.jpg
|
106
|
+
- spec/img/test.png
|
107
|
+
- spec/nlconvert_spec.rb
|
108
|
+
- spec/sparse_spec.rb
|
109
|
+
- spec/tail_spec.rb
|
110
|
+
- spec/touch_spec.rb
|
111
|
+
- spec/txt/empty.txt
|
112
|
+
- spec/txt/english.txt
|
113
|
+
- spec/txt/english.utf16
|
114
|
+
- spec/txt/korean.txt
|
115
|
+
- spec/wc_spec.rb
|
116
|
+
- spec/whereis_spec.rb
|
117
|
+
- spec/which_spec.rb
|
115
118
|
homepage: https://github.com/djberg96/ptools
|
116
119
|
licenses:
|
117
|
-
- Artistic
|
118
|
-
metadata:
|
120
|
+
- Artistic-2.0
|
121
|
+
metadata:
|
122
|
+
homepage_uri: https://github.com/djberg96/ptools
|
123
|
+
bug_tracker_uri: https://github.com/djberg96/ptools/issues
|
124
|
+
changelog_uri: https://github.com/djberg96/ptools/blob/master/CHANGES.md
|
125
|
+
documentation_uri: https://github.com/djberg96/ptools/wiki
|
126
|
+
source_code_uri: https://github.com/djberg96/ptools
|
127
|
+
wiki_uri: https://github.com/djberg96/ptools/wiki
|
119
128
|
post_install_message:
|
120
129
|
rdoc_options: []
|
121
130
|
require_paths:
|
@@ -131,21 +140,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
140
|
- !ruby/object:Gem::Version
|
132
141
|
version: '0'
|
133
142
|
requirements: []
|
134
|
-
|
135
|
-
rubygems_version: 2.4.8
|
143
|
+
rubygems_version: 3.0.3
|
136
144
|
signing_key:
|
137
145
|
specification_version: 4
|
138
146
|
summary: Extra methods for the File class
|
139
|
-
test_files:
|
140
|
-
- test/test_binary.rb
|
141
|
-
- test/test_constants.rb
|
142
|
-
- test/test_head.rb
|
143
|
-
- test/test_image.rb
|
144
|
-
- test/test_is_sparse.rb
|
145
|
-
- test/test_nlconvert.rb
|
146
|
-
- test/test_null.rb
|
147
|
-
- test/test_tail.rb
|
148
|
-
- test/test_touch.rb
|
149
|
-
- test/test_wc.rb
|
150
|
-
- test/test_whereis.rb
|
151
|
-
- test/test_which.rb
|
147
|
+
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|
data/MANIFEST
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
* CHANGES
|
2
|
-
* README
|
3
|
-
* MANIFEST
|
4
|
-
* Rakefile
|
5
|
-
* ptools.gemspec
|
6
|
-
* certs/djberg96_pub.pem
|
7
|
-
* lib/ptools.rb
|
8
|
-
* test/test_constants.rb
|
9
|
-
* test/test_head.rb
|
10
|
-
* test/test_image.rb
|
11
|
-
* test/test_nlconvert.rb
|
12
|
-
* test/test_null.rb
|
13
|
-
* test/test_tail.rb
|
14
|
-
* test/test_touch.rb
|
15
|
-
* test/test_wc.rb
|
16
|
-
* test/test_which.rb
|
17
|
-
* test/test_whereis.rb
|
18
|
-
* test/img/test.gif
|
19
|
-
* test/img/test.jpg
|
20
|
-
* test/img/test.png
|
data/test/test_binary.rb
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
#####################################################################
|
2
|
-
# test_binary.rb
|
3
|
-
#
|
4
|
-
# Test case for the File.binary? method. You should run this test
|
5
|
-
# via the 'rake test_binary' task.
|
6
|
-
#####################################################################
|
7
|
-
require 'rubygems'
|
8
|
-
require 'test-unit'
|
9
|
-
require 'ptools'
|
10
|
-
|
11
|
-
class TC_Ptools_Binary < Test::Unit::TestCase
|
12
|
-
def self.startup
|
13
|
-
if File::ALT_SEPARATOR
|
14
|
-
@@bin_file = File.join(ENV['windir'], 'notepad.exe')
|
15
|
-
else
|
16
|
-
@@bin_file = '/bin/ls'
|
17
|
-
end
|
18
|
-
|
19
|
-
@@dirname = File.dirname(__FILE__)
|
20
|
-
end
|
21
|
-
|
22
|
-
def setup
|
23
|
-
@txt_file = File.join(@@dirname, 'txt', 'english.txt')
|
24
|
-
@uni_file = File.join(@@dirname, 'txt', 'korean.txt')
|
25
|
-
@png_file = File.join(@@dirname, 'img', 'test.png')
|
26
|
-
@jpg_file = File.join(@@dirname, 'img', 'test.jpg')
|
27
|
-
@gif_file = File.join(@@dirname, 'img', 'test.gif')
|
28
|
-
end
|
29
|
-
|
30
|
-
test "File.binary? basic functionality" do
|
31
|
-
assert_respond_to(File, :binary?)
|
32
|
-
assert_nothing_raised{ File.binary?(@txt_file) }
|
33
|
-
end
|
34
|
-
|
35
|
-
test "File.binary? returns true for binary files" do
|
36
|
-
assert_true(File.binary?(@@bin_file))
|
37
|
-
end
|
38
|
-
|
39
|
-
test "File.binary? returns false for text files" do
|
40
|
-
assert_false(File.binary?(@txt_file))
|
41
|
-
assert_false(File.binary?(@uni_file))
|
42
|
-
end
|
43
|
-
|
44
|
-
test "File.binary? returns false for image files" do
|
45
|
-
assert_false(File.binary?(@png_file))
|
46
|
-
assert_false(File.binary?(@jpg_file))
|
47
|
-
assert_false(File.binary?(@gif_file))
|
48
|
-
end
|
49
|
-
|
50
|
-
test "File.binary? raises an error if the file cannot be found" do
|
51
|
-
assert_raise_kind_of(SystemCallError){ File.binary?('bogus') }
|
52
|
-
end
|
53
|
-
|
54
|
-
test "File.binary? only accepts one argument" do
|
55
|
-
assert_raise_kind_of(ArgumentError){ File.binary?(@txt_file, @@bin_file) }
|
56
|
-
end
|
57
|
-
|
58
|
-
def teardown
|
59
|
-
@txt_file = nil
|
60
|
-
@uni_file = nil
|
61
|
-
@png_file = nil
|
62
|
-
@jpg_file = nil
|
63
|
-
@gif_file = nil
|
64
|
-
end
|
65
|
-
end
|
data/test/test_constants.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
#####################################################################
|
2
|
-
# test_constants.rb
|
3
|
-
#
|
4
|
-
# Tests the constants that have been defined for our package. This
|
5
|
-
# test case should be run via the 'rake test_constants' task.
|
6
|
-
#####################################################################
|
7
|
-
require 'rubygems'
|
8
|
-
require 'test-unit'
|
9
|
-
require 'rbconfig'
|
10
|
-
require 'ptools'
|
11
|
-
|
12
|
-
class TC_Ptools_Constants < Test::Unit::TestCase
|
13
|
-
def self.startup
|
14
|
-
@@windows = File::ALT_SEPARATOR
|
15
|
-
end
|
16
|
-
|
17
|
-
test "PTOOLS_VERSION constant is set to expected value" do
|
18
|
-
assert_equal('1.3.3', File::PTOOLS_VERSION)
|
19
|
-
end
|
20
|
-
|
21
|
-
test "IMAGE_EXT constant is set to array of values" do
|
22
|
-
assert_equal(%w[.bmp .gif .jpeg .jpg .png], File::IMAGE_EXT.sort)
|
23
|
-
end
|
24
|
-
|
25
|
-
test "WINDOWS constant is defined on MS Windows" do
|
26
|
-
omit_unless(@@windows, "Skipping on Unix systems")
|
27
|
-
assert_not_nil(File::MSWINDOWS)
|
28
|
-
end
|
29
|
-
|
30
|
-
test "WIN32EXTS constant is defiend on MS Windows" do
|
31
|
-
omit_unless(@@windows, "Skipping on Unix systems")
|
32
|
-
assert_not_nil(File::WIN32EXTS)
|
33
|
-
end
|
34
|
-
|
35
|
-
def self.shutdown
|
36
|
-
@@windows = nil
|
37
|
-
end
|
38
|
-
end
|
data/test/test_head.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
######################################################################
|
2
|
-
# test_head.rb
|
3
|
-
#
|
4
|
-
# Test case for the File.head method. This test should be run via
|
5
|
-
# the 'rake test_head' task.
|
6
|
-
######################################################################
|
7
|
-
require 'test-unit'
|
8
|
-
require 'ptools'
|
9
|
-
|
10
|
-
class TC_FileHead < Test::Unit::TestCase
|
11
|
-
def self.startup
|
12
|
-
Dir.chdir('test') if File.exist?('test')
|
13
|
-
File.open('test_file1.txt', 'w'){ |fh| 25.times{ |n| fh.puts "line#{n+1}" } }
|
14
|
-
end
|
15
|
-
|
16
|
-
def setup
|
17
|
-
@test_file = 'test_file1.txt'
|
18
|
-
@expected_head1 = ["line1\n","line2\n","line3\n","line4\n","line5\n"]
|
19
|
-
@expected_head1.push("line6\n","line7\n","line8\n","line9\n","line10\n")
|
20
|
-
@expected_head2 = ["line1\n","line2\n","line3\n","line4\n","line5\n"]
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_head_basic
|
24
|
-
assert_respond_to(File, :head)
|
25
|
-
assert_nothing_raised{ File.head(@test_file) }
|
26
|
-
assert_nothing_raised{ File.head(@test_file, 5) }
|
27
|
-
assert_nothing_raised{ File.head(@test_file){} }
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_head_expected_results
|
31
|
-
assert_kind_of(Array, File.head(@test_file))
|
32
|
-
assert_equal(@expected_head1, File.head(@test_file))
|
33
|
-
assert_equal(@expected_head2, File.head(@test_file, 5))
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_head_expected_errors
|
37
|
-
assert_raises(ArgumentError){ File.head(@test_file, 5, "foo") }
|
38
|
-
assert_raises(Errno::ENOENT){ File.head("bogus") }
|
39
|
-
end
|
40
|
-
|
41
|
-
def teardown
|
42
|
-
@test_file = nil
|
43
|
-
end
|
44
|
-
|
45
|
-
def self.shutdown
|
46
|
-
File.delete('test_file1.txt') if File.exist?('test_file1.txt')
|
47
|
-
end
|
48
|
-
end
|
data/test/test_image.rb
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
#####################################################################
|
2
|
-
# test_image.rb
|
3
|
-
#
|
4
|
-
# Test case for the File.image? method. You should run this test
|
5
|
-
# via the 'rake test:image' task.
|
6
|
-
#####################################################################
|
7
|
-
require 'test-unit'
|
8
|
-
require 'ptools'
|
9
|
-
|
10
|
-
class TC_Ptools_Image < Test::Unit::TestCase
|
11
|
-
def self.startup
|
12
|
-
Dir.chdir('test') if File.exist?('test')
|
13
|
-
end
|
14
|
-
|
15
|
-
def setup
|
16
|
-
@txt_file = File.join(Dir.pwd, 'txt', 'english.txt')
|
17
|
-
@uni_file = File.join(Dir.pwd, 'txt', 'korean.txt')
|
18
|
-
@jpg_file = File.join(Dir.pwd, 'img', 'test.jpg')
|
19
|
-
@png_file = File.join(Dir.pwd, 'img', 'test.png')
|
20
|
-
@gif_file = File.join(Dir.pwd, 'img', 'test.gif')
|
21
|
-
end
|
22
|
-
|
23
|
-
test "image? method basic functionality" do
|
24
|
-
assert_respond_to(File, :image?)
|
25
|
-
assert_nothing_raised{ File.image?(@txt_file) }
|
26
|
-
assert_boolean(File.image?(@txt_file))
|
27
|
-
end
|
28
|
-
|
29
|
-
test "image? method returns false for a text file" do
|
30
|
-
assert_false(File.image?(@txt_file))
|
31
|
-
assert_false(File.image?(@uni_file))
|
32
|
-
end
|
33
|
-
|
34
|
-
test "image? method returns true for a gif" do
|
35
|
-
assert_true(File.image?(@gif_file))
|
36
|
-
end
|
37
|
-
|
38
|
-
test "image? method returns true for a jpeg" do
|
39
|
-
assert_true(File.image?(@jpg_file))
|
40
|
-
end
|
41
|
-
|
42
|
-
test "image? method returns true for a png" do
|
43
|
-
assert_true(File.image?(@png_file))
|
44
|
-
end
|
45
|
-
|
46
|
-
test "image? method raises an error if the file does not exist" do
|
47
|
-
assert_raises(Errno::ENOENT, ArgumentError){ File.image?('bogus') }
|
48
|
-
end
|
49
|
-
|
50
|
-
def teardown
|
51
|
-
@txt_file = nil
|
52
|
-
@uni_file = nil
|
53
|
-
@jpg_file = nil
|
54
|
-
@png_file = nil
|
55
|
-
@gif_file = nil
|
56
|
-
end
|
57
|
-
end
|
data/test/test_is_sparse.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
#####################################################################
|
2
|
-
# test_is_sparse.rb
|
3
|
-
#
|
4
|
-
# Test case for the File.sparse? method. You should run this test
|
5
|
-
# via the 'rake test:is_sparse' task.
|
6
|
-
#####################################################################
|
7
|
-
require 'test-unit'
|
8
|
-
require 'ptools'
|
9
|
-
|
10
|
-
class TC_IsSparse < Test::Unit::TestCase
|
11
|
-
def self.startup
|
12
|
-
Dir.chdir("test") if File.exist?("test")
|
13
|
-
@@win = File::ALT_SEPARATOR
|
14
|
-
@@osx = RbConfig::CONFIG['host_os'] =~ /darwin|osx/i
|
15
|
-
system("dd of=test_sparse bs=1k seek=5120 count=0 2>/dev/null") unless @@win
|
16
|
-
end
|
17
|
-
|
18
|
-
def setup
|
19
|
-
@sparse_file = 'test_sparse'
|
20
|
-
@non_sparse_file = File.expand_path(File.basename(__FILE__))
|
21
|
-
end
|
22
|
-
|
23
|
-
test "is_sparse basic functionality" do
|
24
|
-
omit_if(@@win, "File.sparse? tests skipped on MS Windows")
|
25
|
-
omit_if(@@osx, "File.sparse? tests skipped on OS X")
|
26
|
-
|
27
|
-
assert_respond_to(File, :sparse?)
|
28
|
-
assert_nothing_raised{ File.sparse?(@sparse_file) }
|
29
|
-
assert_boolean(File.sparse?(@sparse_file))
|
30
|
-
end
|
31
|
-
|
32
|
-
test "is_sparse returns the expected results" do
|
33
|
-
omit_if(@@win, "File.sparse? tests skipped on MS Windows")
|
34
|
-
omit_if(@@osx, "File.sparse? tests skipped on OS X")
|
35
|
-
|
36
|
-
assert_true(File.sparse?(@sparse_file))
|
37
|
-
assert_false(File.sparse?(@non_sparse_file))
|
38
|
-
end
|
39
|
-
|
40
|
-
test "is_sparse only accepts one argument" do
|
41
|
-
omit_if(@@win, "File.sparse? tests skipped on MS Windows")
|
42
|
-
assert_raise(ArgumentError){ File.sparse?(@sparse_file, @sparse_file) }
|
43
|
-
end
|
44
|
-
|
45
|
-
def teardown
|
46
|
-
@sparse_file = nil
|
47
|
-
@non_sparse_file = nil
|
48
|
-
end
|
49
|
-
|
50
|
-
def self.shutdown
|
51
|
-
File.delete('test_sparse') if File.exist?('test_sparse')
|
52
|
-
end
|
53
|
-
end
|