libpath-ruby 0.2.2 → 0.2.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +33 -0
- data/README.md +25 -8
- data/examples/path_from_arg0.md +43 -43
- data/examples/path_from_arg0.rb +25 -23
- data/lib/libpath/constants/unix.rb +74 -74
- data/lib/libpath/constants/windows.rb +75 -75
- data/lib/libpath/constants.rb +20 -20
- data/lib/libpath/diagnostics/parameter_checking.rb +27 -26
- data/lib/libpath/diagnostics.rb +1 -1
- data/lib/libpath/exceptions/libpath_base_exception.rb +20 -21
- data/lib/libpath/exceptions/malformed_name_exception.rb +27 -27
- data/lib/libpath/exceptions.rb +1 -1
- data/lib/libpath/form/unix.rb +118 -118
- data/lib/libpath/form/windows.rb +228 -214
- data/lib/libpath/form.rb +20 -21
- data/lib/libpath/internal_/array.rb +57 -57
- data/lib/libpath/internal_/platform.rb +30 -31
- data/lib/libpath/internal_/string.rb +25 -20
- data/lib/libpath/internal_/unix/form.rb +124 -119
- data/lib/libpath/internal_/windows/drive.rb +80 -75
- data/lib/libpath/internal_/windows/form.rb +205 -194
- data/lib/libpath/libpath.rb +4 -1
- data/lib/libpath/path/unix.rb +120 -118
- data/lib/libpath/path/windows.rb +126 -124
- data/lib/libpath/path.rb +21 -21
- data/lib/libpath/util/unix.rb +261 -261
- data/lib/libpath/util/windows.rb +403 -403
- data/lib/libpath/util.rb +20 -20
- data/lib/libpath/version.rb +25 -26
- data/lib/libpath.rb +1 -1
- data/test/performance/benchmark_drive_letter.rb +50 -10
- data/test/performance/benchmark_gsub_string_or_regex.rb +27 -23
- data/test/performance/benchmark_rindex2.rb +56 -48
- data/test/performance/benchmark_split.rb +16 -10
- data/test/unit/compare/ts_all.rb +4 -4
- data/test/unit/equate/ts_all.rb +4 -4
- data/test/unit/equate/unix/ts_all.rb +4 -4
- data/test/unit/equate/windows/ts_all.rb +4 -4
- data/test/unit/exceptions/tc_libpath_base_exception.rb +10 -8
- data/test/unit/exceptions/tc_malformed_name_exception.rb +14 -12
- data/test/unit/exceptions/ts_all.rb +4 -4
- data/test/unit/form/tc_absolute_functions.rb +242 -240
- data/test/unit/form/ts_all.rb +4 -4
- data/test/unit/form/unix/tc_absolute_functions.rb +158 -155
- data/test/unit/form/unix/ts_all.rb +4 -4
- data/test/unit/form/windows/tc_absolute_functions.rb +628 -625
- data/test/unit/form/windows/ts_all.rb +4 -4
- data/test/unit/internal_/tc_array.rb +36 -32
- data/test/unit/internal_/ts_all.rb +4 -4
- data/test/unit/internal_/unix/form/tc_slash_functions.rb +38 -35
- data/test/unit/internal_/unix/form/ts_all.rb +4 -4
- data/test/unit/internal_/unix/tc_split_path.rb +387 -384
- data/test/unit/internal_/unix/ts_all.rb +4 -4
- data/test/unit/internal_/windows/form/tc_get_windows_volume.rb +157 -153
- data/test/unit/internal_/windows/form/tc_slash_functions.rb +39 -35
- data/test/unit/internal_/windows/form/ts_all.rb +4 -4
- data/test/unit/internal_/windows/tc_split_path.rb +874 -869
- data/test/unit/internal_/windows/ts_all.rb +4 -4
- data/test/unit/parse/ts_all.rb +4 -4
- data/test/unit/path/tc_path.rb +732 -732
- data/test/unit/path/ts_all.rb +4 -4
- data/test/unit/path/unix/tc_path.rb +544 -540
- data/test/unit/path/unix/ts_all.rb +4 -4
- data/test/unit/path/windows/tc_path.rb +608 -603
- data/test/unit/path/windows/ts_all.rb +4 -4
- data/test/unit/tc_version.rb +25 -22
- data/test/unit/ts_all.rb +4 -4
- data/test/unit/util/tc_combine_paths.rb +110 -105
- data/test/unit/util/tc_derive_relative_path.rb +8 -3
- data/test/unit/util/tc_make_path_canonical.rb +142 -138
- data/test/unit/util/ts_all.rb +4 -4
- data/test/unit/util/unix/tc_combine_paths.rb +38 -34
- data/test/unit/util/unix/tc_derive_relative_path.rb +80 -75
- data/test/unit/util/unix/tc_make_path_absolute.rb +74 -70
- data/test/unit/util/unix/tc_make_path_canonical.rb +95 -90
- data/test/unit/util/unix/ts_all.rb +4 -4
- data/test/unit/util/windows/tc_combine_paths.rb +82 -77
- data/test/unit/util/windows/tc_derive_relative_path.rb +98 -93
- data/test/unit/util/windows/tc_make_path_absolute.rb +105 -101
- data/test/unit/util/windows/tc_make_path_canonical.rb +158 -153
- data/test/unit/util/windows/ts_all.rb +4 -4
- metadata +9 -8
@@ -10,260 +10,263 @@ require 'xqsr3/extensions/test/unit'
|
|
10
10
|
|
11
11
|
class Test_existence_of_namespace_LibPath_Form_Unix < Test::Unit::TestCase
|
12
12
|
|
13
|
-
|
13
|
+
def test_LibPath_module_exists
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
assert defined?(::LibPath)
|
16
|
+
end
|
17
17
|
|
18
|
-
|
18
|
+
def test_LibPath_Form_module_exists
|
19
19
|
|
20
|
-
|
21
|
-
|
20
|
+
assert defined?(::LibPath::Form)
|
21
|
+
end
|
22
22
|
|
23
|
-
|
23
|
+
def test_LibPath_Form_Unix_module_exists
|
24
24
|
|
25
|
-
|
26
|
-
|
25
|
+
assert defined?(::LibPath::Form::Unix)
|
26
|
+
end
|
27
27
|
end
|
28
28
|
|
29
29
|
class Test_classify_path_Unix < Test::Unit::TestCase
|
30
30
|
|
31
|
-
|
31
|
+
include ::LibPath::Form::Unix
|
32
32
|
|
33
|
-
|
33
|
+
def test_with_nil
|
34
34
|
|
35
|
-
|
35
|
+
if $DEBUG
|
36
36
|
|
37
|
-
|
38
|
-
|
37
|
+
assert_raise(::ArgumentError) { classify_path(nil) }
|
38
|
+
else
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
40
|
+
assert_nil classify_path(nil)
|
41
|
+
end
|
42
|
+
end
|
43
43
|
|
44
|
-
|
44
|
+
def test_empty
|
45
45
|
|
46
|
-
|
47
|
-
|
46
|
+
assert_nil classify_path('')
|
47
|
+
end
|
48
48
|
|
49
|
-
|
49
|
+
def test_absolute
|
50
50
|
|
51
|
-
|
51
|
+
assert_equal :absolute, classify_path('/')
|
52
52
|
|
53
|
-
|
54
|
-
|
53
|
+
assert_equal :absolute, classify_path('/abc')
|
54
|
+
end
|
55
55
|
|
56
|
-
|
56
|
+
def test_homed
|
57
57
|
|
58
|
-
|
58
|
+
assert_equal :homed, classify_path('~')
|
59
59
|
|
60
|
-
|
60
|
+
assert_equal :homed, classify_path('~/')
|
61
61
|
|
62
|
-
|
63
|
-
|
62
|
+
assert_equal :homed, classify_path('~/abc')
|
63
|
+
end
|
64
64
|
|
65
|
-
|
65
|
+
def test_relative
|
66
66
|
|
67
|
-
|
67
|
+
assert_equal :relative, classify_path('abc')
|
68
68
|
|
69
|
-
|
70
|
-
|
69
|
+
assert_equal :relative, classify_path('~~')
|
70
|
+
end
|
71
71
|
end
|
72
72
|
|
73
73
|
class Test_name_is_malformed_Unix < Test::Unit::TestCase
|
74
74
|
|
75
|
-
|
75
|
+
include ::LibPath::Form::Unix
|
76
76
|
|
77
|
-
|
77
|
+
def test_with_nil
|
78
78
|
|
79
|
-
|
80
|
-
|
79
|
+
assert name_is_malformed?(nil)
|
80
|
+
end
|
81
81
|
|
82
|
-
|
82
|
+
def test_empty
|
83
83
|
|
84
|
-
|
85
|
-
|
84
|
+
assert_false name_is_malformed?('')
|
85
|
+
end
|
86
86
|
|
87
|
-
|
87
|
+
def test_absolute_paths_from_root
|
88
88
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
89
|
+
assert_false name_is_malformed?('/')
|
90
|
+
assert_false name_is_malformed?('//')
|
91
|
+
assert_false name_is_malformed?('/abc')
|
92
|
+
end
|
93
93
|
|
94
|
-
|
94
|
+
def test_absolute_paths_from_home
|
95
95
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
96
|
+
assert_false name_is_malformed?('~')
|
97
|
+
assert_false name_is_malformed?('~/')
|
98
|
+
assert_false name_is_malformed?('~/abc')
|
99
|
+
end
|
100
100
|
|
101
|
-
|
101
|
+
def test_relative_paths
|
102
102
|
|
103
|
-
|
104
|
-
|
105
|
-
|
103
|
+
assert_false name_is_malformed?('abc')
|
104
|
+
assert_false name_is_malformed?('abc/')
|
105
|
+
assert_false name_is_malformed?('a/')
|
106
106
|
|
107
|
-
|
108
|
-
|
107
|
+
assert_false name_is_malformed?('~abc')
|
108
|
+
end
|
109
109
|
|
110
|
-
|
110
|
+
def test_innate_invalid_characters
|
111
111
|
|
112
|
-
|
113
|
-
|
114
|
-
|
112
|
+
assert name_is_malformed?("\0")
|
113
|
+
assert name_is_malformed?("a\0")
|
114
|
+
assert name_is_malformed?("\0a")
|
115
115
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
116
|
+
assert name_is_malformed?("\0", reject_shell_characters: true)
|
117
|
+
assert name_is_malformed?("a\0", reject_shell_characters: true)
|
118
|
+
assert name_is_malformed?("\0a", reject_shell_characters: true)
|
119
|
+
end
|
120
120
|
|
121
|
-
|
121
|
+
def test_shell_invalid_characters
|
122
122
|
|
123
|
-
|
124
|
-
|
125
|
-
|
123
|
+
assert_false name_is_malformed?('*')
|
124
|
+
assert_false name_is_malformed?('?')
|
125
|
+
assert_false name_is_malformed?('|')
|
126
126
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
127
|
+
assert name_is_malformed?('*', reject_shell_characters: true)
|
128
|
+
assert name_is_malformed?('?', reject_shell_characters: true)
|
129
|
+
assert name_is_malformed?('|', reject_shell_characters: true)
|
130
|
+
end
|
131
131
|
|
132
|
-
|
132
|
+
def test_path_name_separators
|
133
133
|
|
134
|
-
|
134
|
+
assert_false name_is_malformed?('/')
|
135
135
|
|
136
|
-
|
137
|
-
|
136
|
+
assert name_is_malformed?('/', reject_path_name_separators: true)
|
137
|
+
end
|
138
138
|
|
139
|
-
|
139
|
+
def test_path_separators
|
140
140
|
|
141
|
-
|
141
|
+
assert_false name_is_malformed?(':')
|
142
142
|
|
143
|
-
|
144
|
-
|
143
|
+
assert name_is_malformed?(':', reject_path_separators: true)
|
144
|
+
end
|
145
145
|
end
|
146
146
|
|
147
147
|
class Test_path_is_absolute_Unix < Test::Unit::TestCase
|
148
148
|
|
149
|
-
|
149
|
+
include ::LibPath::Form::Unix
|
150
150
|
|
151
|
-
|
151
|
+
if $DEBUG
|
152
152
|
|
153
|
-
|
153
|
+
def test_with_nil
|
154
154
|
|
155
|
-
|
156
|
-
|
157
|
-
|
155
|
+
assert_raise(::ArgumentError) { path_is_absolute?(nil) }
|
156
|
+
end
|
157
|
+
end
|
158
158
|
|
159
|
-
|
159
|
+
def test_empty
|
160
160
|
|
161
|
-
|
162
|
-
|
161
|
+
assert_false path_is_absolute?('')
|
162
|
+
end
|
163
163
|
|
164
|
-
|
164
|
+
def test_absolute_paths_from_root
|
165
165
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
166
|
+
assert path_is_absolute?('/')
|
167
|
+
assert path_is_absolute?('//')
|
168
|
+
assert path_is_absolute?('/abc')
|
169
|
+
end
|
170
170
|
|
171
|
-
|
171
|
+
def test_absolute_paths_from_home
|
172
172
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
173
|
+
assert path_is_absolute?('~')
|
174
|
+
assert path_is_absolute?('~/')
|
175
|
+
assert path_is_absolute?('~/abc')
|
176
|
+
end
|
177
177
|
|
178
|
-
|
178
|
+
def test_relative_paths
|
179
179
|
|
180
|
-
|
181
|
-
|
182
|
-
|
180
|
+
assert_false path_is_absolute?('abc')
|
181
|
+
assert_false path_is_absolute?('abc/')
|
182
|
+
assert_false path_is_absolute?('a/')
|
183
183
|
|
184
|
-
|
185
|
-
|
184
|
+
assert_false path_is_absolute?('~abc')
|
185
|
+
end
|
186
186
|
end
|
187
187
|
|
188
188
|
class Test_path_is_homed_Unix < Test::Unit::TestCase
|
189
189
|
|
190
|
-
|
190
|
+
include ::LibPath::Form::Unix
|
191
191
|
|
192
|
-
|
192
|
+
if $DEBUG
|
193
193
|
|
194
|
-
|
194
|
+
def test_with_nil
|
195
195
|
|
196
|
-
|
197
|
-
|
198
|
-
|
196
|
+
assert_raise(::ArgumentError) { path_is_homed?(nil) }
|
197
|
+
end
|
198
|
+
end
|
199
199
|
|
200
|
-
|
200
|
+
def test_empty
|
201
201
|
|
202
|
-
|
203
|
-
|
202
|
+
assert_false path_is_homed?('')
|
203
|
+
end
|
204
204
|
|
205
|
-
|
205
|
+
def test_absolute_paths_from_root
|
206
206
|
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
207
|
+
assert_false path_is_homed?('/')
|
208
|
+
assert_false path_is_homed?('//')
|
209
|
+
assert_false path_is_homed?('/abc')
|
210
|
+
end
|
211
211
|
|
212
|
-
|
212
|
+
def test_absolute_paths_from_home
|
213
213
|
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
214
|
+
assert path_is_homed?('~')
|
215
|
+
assert path_is_homed?('~/')
|
216
|
+
assert path_is_homed?('~/abc')
|
217
|
+
end
|
218
218
|
|
219
|
-
|
219
|
+
def test_relative_paths
|
220
220
|
|
221
|
-
|
222
|
-
|
223
|
-
|
221
|
+
assert_false path_is_homed?('abc')
|
222
|
+
assert_false path_is_homed?('abc/')
|
223
|
+
assert_false path_is_homed?('a/')
|
224
224
|
|
225
|
-
|
226
|
-
|
225
|
+
assert_false path_is_homed?('~abc')
|
226
|
+
end
|
227
227
|
end
|
228
228
|
|
229
229
|
class Test_path_is_rooted_Unix < Test::Unit::TestCase
|
230
230
|
|
231
|
-
|
231
|
+
include ::LibPath::Form::Unix
|
232
232
|
|
233
|
-
|
233
|
+
if $DEBUG
|
234
234
|
|
235
|
-
|
235
|
+
def test_with_nil
|
236
236
|
|
237
|
-
|
238
|
-
|
239
|
-
|
237
|
+
assert_raise(::ArgumentError) { path_is_rooted?(nil) }
|
238
|
+
end
|
239
|
+
end
|
240
240
|
|
241
|
-
|
241
|
+
def test_empty
|
242
242
|
|
243
|
-
|
244
|
-
|
243
|
+
assert_false path_is_rooted?('')
|
244
|
+
end
|
245
245
|
|
246
|
-
|
246
|
+
def test_absolute_paths_from_root
|
247
247
|
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
248
|
+
assert path_is_rooted?('/')
|
249
|
+
assert path_is_rooted?('//')
|
250
|
+
assert path_is_rooted?('/abc')
|
251
|
+
end
|
252
252
|
|
253
|
-
|
253
|
+
def test_absolute_paths_from_home
|
254
254
|
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
255
|
+
assert_false path_is_rooted?('~')
|
256
|
+
assert_false path_is_rooted?('~/')
|
257
|
+
assert_false path_is_rooted?('~/abc')
|
258
|
+
end
|
259
259
|
|
260
|
-
|
260
|
+
def test_relative_paths
|
261
261
|
|
262
|
-
|
263
|
-
|
264
|
-
|
262
|
+
assert_false path_is_rooted?('abc')
|
263
|
+
assert_false path_is_rooted?('abc/')
|
264
|
+
assert_false path_is_rooted?('a/')
|
265
265
|
|
266
|
-
|
267
|
-
|
266
|
+
assert_false path_is_rooted?('~abc')
|
267
|
+
end
|
268
268
|
end
|
269
269
|
|
270
|
+
|
271
|
+
# ############################## end of file ############################# #
|
272
|
+
|
@@ -7,16 +7,16 @@ this_dir = File.expand_path(File.dirname(__FILE__))
|
|
7
7
|
# all tc_*rb in current directory
|
8
8
|
Dir[File.join(this_dir, 'tc_*rb')].each do |file|
|
9
9
|
|
10
|
-
|
10
|
+
$stderr.puts "requiring file '#{file}'" if $DEBUG
|
11
11
|
|
12
|
-
|
12
|
+
require file
|
13
13
|
end
|
14
14
|
|
15
15
|
# all ts_*rb in immediate sub-directories
|
16
16
|
Dir[File.join(this_dir, '*', 'ts_*rb')].each do |file|
|
17
17
|
|
18
|
-
|
18
|
+
$stderr.puts "requiring file '#{file}'" if $DEBUG
|
19
19
|
|
20
|
-
|
20
|
+
require file
|
21
21
|
end
|
22
22
|
|