libpath-ruby 0.2.2 → 0.2.2.1
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 +71 -71
- data/lib/libpath/constants/windows.rb +72 -72
- data/lib/libpath/constants.rb +18 -19
- data/lib/libpath/diagnostics/parameter_checking.rb +25 -25
- data/lib/libpath/diagnostics.rb +1 -1
- data/lib/libpath/exceptions/libpath_base_exception.rb +13 -13
- data/lib/libpath/exceptions/malformed_name_exception.rb +23 -22
- data/lib/libpath/exceptions.rb +1 -1
- data/lib/libpath/form/unix.rb +104 -103
- data/lib/libpath/form/windows.rb +200 -199
- data/lib/libpath/form.rb +18 -18
- data/lib/libpath/internal_/array.rb +53 -53
- data/lib/libpath/internal_/platform.rb +24 -24
- data/lib/libpath/internal_/string.rb +18 -18
- data/lib/libpath/internal_/unix/form.rb +116 -116
- data/lib/libpath/internal_/windows/drive.rb +59 -59
- data/lib/libpath/internal_/windows/form.rb +189 -189
- data/lib/libpath/libpath.rb +3 -0
- data/lib/libpath/path/unix.rb +114 -112
- data/lib/libpath/path/windows.rb +120 -118
- data/lib/libpath/path.rb +18 -20
- data/lib/libpath/util/unix.rb +258 -258
- data/lib/libpath/util/windows.rb +400 -400
- data/lib/libpath/util.rb +18 -19
- data/lib/libpath/version.rb +23 -24
- 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
data/test/unit/path/tc_path.rb
CHANGED
@@ -12,767 +12,767 @@ require 'libpath/internal_/platform'
|
|
12
12
|
|
13
13
|
class Test_existence_of_namespace_LibPath_Path < Test::Unit::TestCase
|
14
14
|
|
15
|
-
|
15
|
+
def test_LibPath_module_exists
|
16
16
|
|
17
|
-
|
18
|
-
|
17
|
+
assert defined?(::LibPath)
|
18
|
+
end
|
19
19
|
|
20
|
-
|
20
|
+
def test_LibPath_Path_module_exists
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
assert defined?(::LibPath::Path)
|
23
|
+
end
|
24
24
|
|
25
|
-
|
25
|
+
def test_LibPath_Path_ParsedPath_class_exists
|
26
26
|
|
27
|
-
|
28
|
-
|
27
|
+
assert defined?(::LibPath::Path::ParsedPath)
|
28
|
+
end
|
29
29
|
end
|
30
30
|
|
31
31
|
class Test_LibPath_Path_ParsedPath < Test::Unit::TestCase
|
32
32
|
|
33
|
-
|
33
|
+
include ::LibPath::Path
|
34
34
|
|
35
|
-
|
35
|
+
def test_nil
|
36
36
|
|
37
|
-
|
38
|
-
|
37
|
+
assert_raise(::ArgumentError) { ParsedPath.new(nil) }
|
38
|
+
end
|
39
39
|
|
40
|
-
|
40
|
+
def test_empty
|
41
41
|
|
42
|
-
|
43
|
-
|
42
|
+
assert_raise(::ArgumentError) { ParsedPath.new('') }
|
43
|
+
end
|
44
44
|
|
45
|
-
|
45
|
+
def test_root
|
46
46
|
|
47
|
-
|
47
|
+
if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
|
48
48
|
|
49
|
-
|
49
|
+
pp = ParsedPath.new('C:\\')
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
51
|
+
assert_equal 'C:\\', pp.given_path
|
52
|
+
assert_equal 'C:\\', pp.absolute_path
|
53
|
+
assert_equal 'C:\\', pp.compare_path
|
54
|
+
assert_equal 'C:', pp.volume
|
55
|
+
assert_equal '\\', pp.directory
|
56
|
+
assert_equal 'C:\\', pp.directory_path
|
57
|
+
assert_equal 'C:\\', pp.dirname
|
58
|
+
assert_equal [ '\\' ], pp.directory_parts
|
59
59
|
|
60
|
-
|
61
|
-
|
60
|
+
volume = pp.volume
|
61
|
+
else
|
62
62
|
|
63
|
-
|
63
|
+
pp = ParsedPath.new('/')
|
64
64
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
65
|
+
assert_equal '/', pp.given_path
|
66
|
+
assert_equal '/', pp.absolute_path
|
67
|
+
assert_equal '/', pp.compare_path
|
68
|
+
assert_equal '/', pp.directory
|
69
|
+
assert_equal '/', pp.directory_path
|
70
|
+
assert_equal '/', pp.dirname
|
71
|
+
assert_equal [ '/' ], pp.directory_parts
|
72
72
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
73
|
+
volume = nil
|
74
|
+
end
|
75
|
+
assert_nil pp.file_full_name
|
76
|
+
assert_nil pp.basename
|
77
|
+
assert_nil pp.file_name_only
|
78
|
+
assert_nil pp.stem
|
79
|
+
assert_nil pp.file_extension
|
80
|
+
assert_nil pp.extension
|
81
|
+
assert_nil pp.search_directory
|
82
|
+
assert_nil pp.search_relative_path
|
83
|
+
assert_nil pp.search_relative_directory_path
|
84
|
+
assert_nil pp.search_relative_directory_parts
|
85
85
|
|
86
|
-
|
87
|
-
|
88
|
-
|
86
|
+
assert_equal pp.directory, pp.directory_parts.join
|
87
|
+
assert_equal pp.absolute_path, "#{volume}#{pp.directory_parts.join}#{pp.basename}"
|
88
|
+
end
|
89
89
|
|
90
|
-
|
90
|
+
def test_root_from_srd_1
|
91
91
|
|
92
|
-
|
92
|
+
if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
|
93
93
|
|
94
|
-
|
95
|
-
|
96
|
-
|
94
|
+
srd = 'C:/dir-1/dir-2'
|
95
|
+
|
96
|
+
pp = ParsedPath.new('C:\\', srd)
|
97
97
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
98
|
+
assert_equal 'C:\\', pp.given_path
|
99
|
+
assert_equal 'C:\\', pp.absolute_path
|
100
|
+
assert_equal 'C:\\', pp.compare_path
|
101
|
+
assert_equal 'C:', pp.volume
|
102
|
+
assert_equal '\\', pp.directory
|
103
|
+
assert_equal 'C:\\', pp.directory_path
|
104
|
+
assert_equal 'C:\\', pp.dirname
|
105
|
+
assert_equal [ '\\' ], pp.directory_parts
|
106
|
+
|
107
|
+
volume = pp.volume
|
108
|
+
else
|
109
109
|
|
110
|
-
|
110
|
+
srd = '/dir-1/dir-2'
|
111
111
|
|
112
|
-
|
112
|
+
pp = ParsedPath.new('/', srd)
|
113
113
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
114
|
+
assert_equal '/', pp.given_path
|
115
|
+
assert_equal '/', pp.absolute_path
|
116
|
+
assert_equal '/', pp.compare_path
|
117
|
+
assert_equal '/', pp.directory
|
118
|
+
assert_equal '/', pp.directory_path
|
119
|
+
assert_equal '/', pp.dirname
|
120
|
+
assert_equal [ '/' ], pp.directory_parts
|
121
|
+
|
122
|
+
volume = nil
|
123
|
+
end
|
124
|
+
assert_nil pp.file_full_name
|
125
|
+
assert_nil pp.basename
|
126
|
+
assert_nil pp.file_name_only
|
127
|
+
assert_nil pp.stem
|
128
|
+
assert_nil pp.file_extension
|
129
|
+
assert_nil pp.extension
|
130
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
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
131
|
+
if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
|
132
|
+
|
133
|
+
assert_equal 'C:\\dir-1\\dir-2\\', pp.search_directory
|
134
|
+
assert_equal '..\\..\\', pp.search_relative_path
|
135
|
+
assert_equal '..\\..\\', pp.search_relative_directory_path
|
136
|
+
assert_equal [ '..\\', '..\\' ], pp.search_relative_directory_parts
|
137
|
+
else
|
138
|
+
|
139
|
+
assert_equal '/dir-1/dir-2/', pp.search_directory
|
140
|
+
assert_equal '../../', pp.search_relative_path
|
141
|
+
assert_equal '../../', pp.search_relative_directory_path
|
142
|
+
assert_equal [ '../', '../' ], pp.search_relative_directory_parts
|
143
|
+
end
|
144
|
+
|
145
|
+
assert_equal pp.directory, pp.directory_parts.join
|
146
|
+
assert_equal pp.absolute_path, "#{volume}#{pp.directory_parts.join}#{pp.basename}"
|
147
|
+
end
|
148
|
+
|
149
|
+
def test_root_from_srd_2
|
150
|
+
|
151
|
+
if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
|
152
|
+
|
153
|
+
srd = 'C:/'
|
154
|
+
|
155
|
+
pp = ParsedPath.new('C:\\', srd)
|
156
|
+
|
157
|
+
assert_equal 'C:\\', pp.given_path
|
158
|
+
assert_equal 'C:\\', pp.absolute_path
|
159
|
+
assert_equal 'C:\\', pp.compare_path
|
160
|
+
assert_equal 'C:', pp.volume
|
161
|
+
assert_equal '\\', pp.directory
|
162
|
+
assert_equal 'C:\\', pp.directory_path
|
163
|
+
assert_equal 'C:\\', pp.dirname
|
164
|
+
assert_equal [ '\\' ], pp.directory_parts
|
165
|
+
|
166
|
+
volume = pp.volume
|
167
|
+
else
|
168
|
+
|
169
|
+
srd = '/'
|
170
|
+
|
171
|
+
pp = ParsedPath.new('/', srd)
|
172
|
+
|
173
|
+
assert_equal '/', pp.given_path
|
174
|
+
assert_equal '/', pp.absolute_path
|
175
|
+
assert_equal '/', pp.compare_path
|
176
|
+
assert_equal '/', pp.directory
|
177
|
+
assert_equal '/', pp.directory_path
|
178
|
+
assert_equal '/', pp.dirname
|
179
|
+
assert_equal [ '/' ], pp.directory_parts
|
180
|
+
|
181
|
+
volume = nil
|
182
|
+
end
|
183
|
+
assert_nil pp.file_full_name
|
184
|
+
assert_nil pp.basename
|
185
|
+
assert_nil pp.file_name_only
|
186
|
+
assert_nil pp.stem
|
187
|
+
assert_nil pp.file_extension
|
188
|
+
assert_nil pp.extension
|
189
|
+
|
190
|
+
if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
|
191
|
+
|
192
|
+
assert_equal 'C:\\', pp.search_directory
|
193
|
+
assert_equal '.\\', pp.search_relative_path
|
194
|
+
assert_equal '.\\', pp.search_relative_directory_path
|
195
|
+
assert_equal [ '.\\' ], pp.search_relative_directory_parts
|
196
|
+
else
|
197
|
+
|
198
|
+
assert_equal '/', pp.search_directory
|
199
|
+
assert_equal './', pp.search_relative_path
|
200
|
+
assert_equal './', pp.search_relative_directory_path
|
201
|
+
assert_equal [ './' ], pp.search_relative_directory_parts
|
202
|
+
end
|
203
|
+
|
204
|
+
assert_equal pp.directory, pp.directory_parts.join
|
205
|
+
assert_equal pp.absolute_path, "#{volume}#{pp.directory_parts.join}#{pp.basename}"
|
206
|
+
end
|
207
|
+
|
208
|
+
def test_rooted_one_dir
|
209
|
+
|
210
|
+
if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
|
211
|
+
|
212
|
+
pp = ParsedPath.new('G:\\abc\\')
|
213
|
+
|
214
|
+
assert_equal 'G:\\abc\\', pp.given_path
|
215
|
+
assert_equal 'G:\\abc\\', pp.absolute_path
|
216
|
+
assert_equal 'G:\\ABC\\', pp.compare_path
|
217
|
+
assert_equal '\\abc\\', pp.directory
|
218
|
+
assert_equal 'G:', pp.volume
|
219
|
+
assert_equal 'G:\\abc\\', pp.directory_path
|
220
|
+
assert_equal 'G:\\abc\\', pp.dirname
|
221
|
+
assert_equal [ '\\', 'abc\\' ], pp.directory_parts
|
222
|
+
|
223
|
+
volume = pp.volume
|
224
|
+
else
|
225
|
+
|
226
|
+
pp = ParsedPath.new('/abc//')
|
227
|
+
|
228
|
+
assert_equal '/abc//', pp.given_path
|
229
|
+
assert_equal '/abc/', pp.absolute_path
|
230
|
+
assert_equal '/abc/', pp.compare_path
|
231
|
+
assert_equal '/abc/', pp.directory
|
232
|
+
assert_equal '/abc/', pp.directory_path
|
233
|
+
assert_equal '/abc/', pp.dirname
|
234
|
+
assert_equal [ '/', 'abc/' ], pp.directory_parts
|
235
|
+
|
236
|
+
volume = nil
|
237
|
+
end
|
238
|
+
assert_nil pp.file_full_name
|
239
|
+
assert_nil pp.basename
|
240
|
+
assert_nil pp.file_name_only
|
241
|
+
assert_nil pp.stem
|
242
|
+
assert_nil pp.file_extension
|
243
|
+
assert_nil pp.extension
|
244
|
+
assert_nil pp.search_directory
|
245
|
+
assert_nil pp.search_relative_path
|
246
|
+
assert_nil pp.search_relative_directory_path
|
247
|
+
assert_nil pp.search_relative_directory_parts
|
248
|
+
|
249
|
+
assert_equal pp.directory, pp.directory_parts.join
|
250
|
+
assert_equal pp.absolute_path, "#{volume}#{pp.directory_parts.join}#{pp.basename}"
|
251
|
+
end
|
252
|
+
|
253
|
+
def test_rooted_one_dir_from_srd
|
254
|
+
|
255
|
+
if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
|
256
|
+
|
257
|
+
srd = 'G:/dir-1/dir-2'
|
258
|
+
|
259
|
+
pp = ParsedPath.new('G:\\\\abc\\\\', srd)
|
260
|
+
|
261
|
+
assert_equal 'G:\\\\abc\\\\', pp.given_path
|
262
|
+
assert_equal 'G:\\abc\\', pp.absolute_path
|
263
|
+
assert_equal 'G:\\ABC\\', pp.compare_path
|
264
|
+
assert_equal '\\abc\\', pp.directory
|
265
|
+
assert_equal 'G:', pp.volume
|
266
|
+
assert_equal 'G:\\abc\\', pp.directory_path
|
267
|
+
assert_equal 'G:\\abc\\', pp.dirname
|
268
|
+
assert_equal [ '\\', 'abc\\' ], pp.directory_parts
|
269
|
+
|
270
|
+
volume = pp.volume
|
271
|
+
else
|
272
|
+
|
273
|
+
srd = '/dir-1/dir-2'
|
274
|
+
|
275
|
+
pp = ParsedPath.new('//abc//', srd)
|
276
|
+
|
277
|
+
assert_equal '//abc//', pp.given_path
|
278
|
+
assert_equal '/abc/', pp.absolute_path
|
279
|
+
assert_equal '/abc/', pp.compare_path
|
280
|
+
assert_equal '/abc/', pp.directory
|
281
|
+
assert_equal '/abc/', pp.directory_path
|
282
|
+
assert_equal '/abc/', pp.dirname
|
283
|
+
assert_equal [ '/', 'abc/' ], pp.directory_parts
|
284
|
+
|
285
|
+
volume = nil
|
286
|
+
end
|
287
|
+
assert_nil pp.file_full_name
|
288
|
+
assert_nil pp.basename
|
289
|
+
assert_nil pp.file_name_only
|
290
|
+
assert_nil pp.stem
|
291
|
+
assert_nil pp.file_extension
|
292
|
+
assert_nil pp.extension
|
293
|
+
|
294
|
+
if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
|
295
|
+
|
296
|
+
assert_equal 'G:\\dir-1\\dir-2\\', pp.search_directory
|
297
|
+
assert_equal '..\\..\\abc\\', pp.search_relative_path
|
298
|
+
assert_equal '..\\..\\abc\\', pp.search_relative_directory_path
|
299
|
+
assert_equal [ '..\\', '..\\', 'abc\\' ], pp.search_relative_directory_parts
|
300
|
+
else
|
301
|
+
|
302
|
+
end
|
303
|
+
|
304
|
+
assert_equal pp.directory, pp.directory_parts.join
|
305
|
+
assert_equal pp.absolute_path, "#{volume}#{pp.directory_parts.join}#{pp.basename}"
|
306
|
+
end
|
307
|
+
|
308
|
+
def test_rooted_one_dir_with_trailing_dot
|
309
|
+
|
310
|
+
if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
|
311
|
+
|
312
|
+
pp = ParsedPath.new('G:\\abc\\.')
|
313
|
+
|
314
|
+
assert_equal 'G:\\abc\\.', pp.given_path
|
315
|
+
assert_equal 'G:\\abc\\', pp.absolute_path
|
316
|
+
assert_equal 'G:\\ABC\\', pp.compare_path
|
317
|
+
assert_equal 'G:', pp.volume
|
318
|
+
assert_equal '\\abc\\', pp.directory
|
319
|
+
assert_equal 'G:\\abc\\', pp.directory_path
|
320
|
+
assert_equal 'G:\\abc\\', pp.dirname
|
321
|
+
assert_equal [ '\\', 'abc\\' ], pp.directory_parts
|
322
|
+
|
323
|
+
volume = pp.volume
|
324
|
+
else
|
325
|
+
|
326
|
+
pp = ParsedPath.new('/abc/.')
|
327
|
+
|
328
|
+
assert_equal '/abc/.', pp.given_path
|
329
|
+
assert_equal '/abc/', pp.absolute_path
|
330
|
+
assert_equal '/abc/', pp.compare_path
|
331
|
+
assert_equal '/abc/', pp.directory
|
332
|
+
assert_equal '/abc/', pp.directory_path
|
333
|
+
assert_equal '/abc/', pp.dirname
|
334
|
+
assert_equal [ '/', 'abc/' ], pp.directory_parts
|
335
|
+
|
336
|
+
volume = nil
|
337
|
+
end
|
338
|
+
assert_nil pp.file_full_name
|
339
|
+
assert_nil pp.basename
|
340
|
+
assert_nil pp.file_name_only
|
341
|
+
assert_nil pp.stem
|
342
|
+
assert_nil pp.file_extension
|
343
|
+
assert_nil pp.extension
|
344
|
+
assert_nil pp.search_directory
|
345
|
+
assert_nil pp.search_relative_path
|
346
|
+
assert_nil pp.search_relative_directory_path
|
347
|
+
assert_nil pp.search_relative_directory_parts
|
348
|
+
|
349
|
+
assert_equal pp.directory, pp.directory_parts.join
|
350
|
+
assert_equal pp.absolute_path, "#{volume}#{pp.directory_parts.join}#{pp.basename}"
|
351
|
+
end
|
352
|
+
|
353
|
+
def test_rooted_one_file
|
354
|
+
|
355
|
+
if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
|
356
|
+
|
357
|
+
pp = ParsedPath.new('G:\\file.ext')
|
358
|
+
|
359
|
+
assert_equal 'G:\\file.ext', pp.given_path
|
360
|
+
assert_equal 'G:\\file.ext', pp.absolute_path
|
361
|
+
assert_equal 'G:\\FILE.EXT', pp.compare_path
|
362
|
+
assert_equal 'G:', pp.volume
|
363
|
+
assert_equal '\\', pp.directory
|
364
|
+
assert_equal 'G:\\', pp.directory_path
|
365
|
+
assert_equal 'G:\\', pp.dirname
|
366
|
+
assert_equal [ '\\' ], pp.directory_parts
|
367
|
+
|
368
|
+
volume = pp.volume
|
369
|
+
else
|
370
|
+
|
371
|
+
pp = ParsedPath.new('/file.ext')
|
372
|
+
|
373
|
+
assert_equal '/file.ext', pp.given_path
|
374
|
+
assert_equal '/file.ext', pp.absolute_path
|
375
|
+
assert_equal '/file.ext', pp.compare_path
|
376
|
+
assert_equal '/', pp.directory
|
377
|
+
assert_equal '/', pp.directory_path
|
378
|
+
assert_equal '/', pp.dirname
|
379
|
+
assert_equal [ '/' ], pp.directory_parts
|
380
|
+
|
381
|
+
volume = nil
|
382
|
+
end
|
383
|
+
assert_equal 'file.ext', pp.file_full_name
|
384
|
+
assert_equal 'file.ext', pp.basename
|
385
|
+
assert_equal 'file', pp.file_name_only
|
386
|
+
assert_equal 'file', pp.stem
|
387
|
+
assert_equal '.ext', pp.file_extension
|
388
|
+
assert_equal '.ext', pp.extension
|
389
|
+
assert_nil pp.search_directory
|
390
|
+
assert_nil pp.search_relative_path
|
391
|
+
assert_nil pp.search_relative_directory_path
|
392
|
+
assert_nil pp.search_relative_directory_parts
|
393
|
+
|
394
|
+
assert_equal pp.directory, pp.directory_parts.join
|
395
|
+
assert_equal pp.absolute_path, "#{volume}#{pp.directory_parts.join}#{pp.basename}"
|
396
|
+
end
|
397
|
+
|
398
|
+
def test_rooted_one_file_without_extension
|
399
|
+
|
400
|
+
if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
|
401
|
+
|
402
|
+
pp = ParsedPath.new('G:\\file')
|
403
|
+
|
404
|
+
assert_equal 'G:\\file', pp.given_path
|
405
|
+
assert_equal 'G:\\file', pp.absolute_path
|
406
|
+
assert_equal 'G:\\FILE', pp.compare_path
|
407
|
+
assert_equal 'G:', pp.volume
|
408
|
+
assert_equal '\\', pp.directory
|
409
|
+
assert_equal 'G:\\', pp.directory_path
|
410
|
+
assert_equal 'G:\\', pp.dirname
|
411
|
+
assert_equal [ '\\' ], pp.directory_parts
|
412
|
+
|
413
|
+
volume = pp.volume
|
414
|
+
else
|
415
|
+
|
416
|
+
pp = ParsedPath.new('/file')
|
417
|
+
|
418
|
+
assert_equal '/file', pp.given_path
|
419
|
+
assert_equal '/file', pp.absolute_path
|
420
|
+
assert_equal '/file', pp.compare_path
|
421
|
+
assert_equal '/', pp.directory
|
422
|
+
assert_equal '/', pp.directory_path
|
423
|
+
assert_equal '/', pp.dirname
|
424
|
+
assert_equal [ '/' ], pp.directory_parts
|
425
|
+
|
426
|
+
volume = nil
|
427
|
+
end
|
428
|
+
assert_equal 'file', pp.file_full_name
|
429
|
+
assert_equal 'file', pp.basename
|
430
|
+
assert_equal 'file', pp.file_name_only
|
431
|
+
assert_equal 'file', pp.stem
|
432
|
+
assert_nil pp.file_extension
|
433
|
+
assert_nil pp.extension
|
434
|
+
assert_nil pp.search_directory
|
435
|
+
assert_nil pp.search_relative_path
|
436
|
+
assert_nil pp.search_relative_directory_path
|
437
|
+
assert_nil pp.search_relative_directory_parts
|
438
|
+
|
439
|
+
assert_equal pp.directory, pp.directory_parts.join
|
440
|
+
assert_equal pp.absolute_path, "#{volume}#{pp.directory_parts.join}#{pp.basename}"
|
441
|
+
end
|
442
|
+
|
443
|
+
def test_rooted_one_file_without_stem
|
444
|
+
|
445
|
+
if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
|
446
|
+
|
447
|
+
pp = ParsedPath.new('H:\\.ext')
|
448
|
+
|
449
|
+
assert_equal 'H:\\.ext', pp.given_path
|
450
|
+
assert_equal 'H:\\.ext', pp.absolute_path
|
451
|
+
assert_equal 'H:\\.EXT', pp.compare_path
|
452
|
+
assert_equal 'H:', pp.volume
|
453
|
+
assert_equal '\\', pp.directory
|
454
|
+
assert_equal 'H:\\', pp.directory_path
|
455
|
+
assert_equal 'H:\\', pp.dirname
|
456
|
+
assert_equal [ '\\' ], pp.directory_parts
|
457
|
+
|
458
|
+
volume = pp.volume
|
459
|
+
else
|
460
|
+
|
461
|
+
pp = ParsedPath.new('/.ext')
|
462
|
+
|
463
|
+
assert_equal '/.ext', pp.given_path
|
464
|
+
assert_equal '/.ext', pp.absolute_path
|
465
|
+
assert_equal '/.ext', pp.compare_path
|
466
|
+
assert_equal '/', pp.directory
|
467
|
+
assert_equal '/', pp.directory_path
|
468
|
+
assert_equal '/', pp.dirname
|
469
|
+
assert_equal [ '/' ], pp.directory_parts
|
470
|
+
|
471
|
+
volume = nil
|
472
|
+
end
|
473
|
+
assert_equal '.ext', pp.file_full_name
|
474
|
+
assert_equal '.ext', pp.basename
|
475
|
+
assert_nil pp.file_name_only
|
476
|
+
assert_nil pp.stem
|
477
|
+
assert_equal '.ext', pp.file_extension
|
478
|
+
assert_equal '.ext', pp.extension
|
479
|
+
assert_nil pp.search_directory
|
480
|
+
assert_nil pp.search_relative_path
|
481
|
+
assert_nil pp.search_relative_directory_path
|
482
|
+
assert_nil pp.search_relative_directory_parts
|
483
|
+
|
484
|
+
assert_equal pp.directory, pp.directory_parts.join
|
485
|
+
assert_equal pp.absolute_path, "#{volume}#{pp.directory_parts.join}#{pp.basename}"
|
486
|
+
end
|
487
|
+
|
488
|
+
def test_rooted_one_long_path
|
489
|
+
|
490
|
+
if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
|
491
|
+
|
492
|
+
pp = ParsedPath.new('C:/dir-1/dir-2/dir-3/dir-4/./dir-5/dir-6/../file.ext')
|
493
|
+
|
494
|
+
assert_equal 'C:/dir-1/dir-2/dir-3/dir-4/./dir-5/dir-6/../file.ext', pp.given_path
|
495
|
+
assert_equal 'C:/dir-1/dir-2/dir-3/dir-4/dir-5/file.ext', pp.absolute_path
|
496
|
+
assert_equal 'C:/DIR-1/DIR-2/DIR-3/DIR-4/DIR-5/FILE.EXT', pp.compare_path
|
497
|
+
assert_equal 'C:', pp.volume
|
498
|
+
assert_equal '/dir-1/dir-2/dir-3/dir-4/dir-5/', pp.directory
|
499
|
+
assert_equal 'C:/dir-1/dir-2/dir-3/dir-4/dir-5/', pp.directory_path
|
500
|
+
assert_equal 'C:/dir-1/dir-2/dir-3/dir-4/dir-5/', pp.dirname
|
501
|
+
assert_equal [ '/', 'dir-1/', 'dir-2/', 'dir-3/', 'dir-4/', 'dir-5/' ], pp.directory_parts
|
502
|
+
|
503
|
+
volume = pp.volume
|
504
|
+
else
|
505
|
+
|
506
|
+
pp = ParsedPath.new('/dir-1/dir-2/dir-3/dir-4/./dir-5/dir-6/../file.ext')
|
507
|
+
|
508
|
+
assert_equal '/dir-1/dir-2/dir-3/dir-4/./dir-5/dir-6/../file.ext', pp.given_path
|
509
|
+
assert_equal '/dir-1/dir-2/dir-3/dir-4/dir-5/file.ext', pp.absolute_path
|
510
|
+
assert_equal '/dir-1/dir-2/dir-3/dir-4/dir-5/file.ext', pp.compare_path
|
511
|
+
assert_equal '/dir-1/dir-2/dir-3/dir-4/dir-5/', pp.directory
|
512
|
+
assert_equal '/dir-1/dir-2/dir-3/dir-4/dir-5/', pp.directory_path
|
513
|
+
assert_equal '/dir-1/dir-2/dir-3/dir-4/dir-5/', pp.dirname
|
514
|
+
assert_equal [ '/', 'dir-1/', 'dir-2/', 'dir-3/', 'dir-4/', 'dir-5/' ], pp.directory_parts
|
515
|
+
|
516
|
+
volume = nil
|
517
|
+
end
|
518
|
+
assert_equal 'file.ext', pp.file_full_name
|
519
|
+
assert_equal 'file.ext', pp.basename
|
520
|
+
assert_equal 'file', pp.file_name_only
|
521
|
+
assert_equal 'file', pp.stem
|
522
|
+
assert_equal '.ext', pp.file_extension
|
523
|
+
assert_equal '.ext', pp.extension
|
524
|
+
assert_nil pp.search_directory
|
525
|
+
assert_nil pp.search_relative_path
|
526
|
+
assert_nil pp.search_relative_directory_path
|
527
|
+
assert_nil pp.search_relative_directory_parts
|
528
|
+
|
529
|
+
assert_equal pp.directory, pp.directory_parts.join
|
530
|
+
assert_equal pp.absolute_path, "#{volume}#{pp.directory_parts.join}#{pp.basename}"
|
531
|
+
end
|
532
|
+
|
533
|
+
def test_rooted_one_long_path_with_short_directory_names
|
534
|
+
|
535
|
+
if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
|
536
|
+
|
537
|
+
pp = ParsedPath.new('C:/1/2/3/4/./5/6/../file.ext')
|
538
|
+
|
539
|
+
assert_equal 'C:/1/2/3/4/./5/6/../file.ext', pp.given_path
|
540
|
+
assert_equal 'C:/1/2/3/4/5/file.ext', pp.absolute_path
|
541
|
+
assert_equal 'C:/1/2/3/4/5/FILE.EXT', pp.compare_path
|
542
|
+
assert_equal 'C:', pp.volume
|
543
|
+
assert_equal '/1/2/3/4/5/', pp.directory
|
544
|
+
assert_equal 'C:/1/2/3/4/5/', pp.directory_path
|
545
|
+
assert_equal 'C:/1/2/3/4/5/', pp.dirname
|
546
|
+
assert_equal [ '/', '1/', '2/', '3/', '4/', '5/' ], pp.directory_parts
|
547
|
+
|
548
|
+
volume = pp.volume
|
549
|
+
else
|
550
|
+
|
551
|
+
pp = ParsedPath.new('/1/2/3/4/./5/6/../file.ext')
|
552
|
+
|
553
|
+
assert_equal '/1/2/3/4/./5/6/../file.ext', pp.given_path
|
554
|
+
assert_equal '/1/2/3/4/5/file.ext', pp.absolute_path
|
555
|
+
assert_equal '/1/2/3/4/5/file.ext', pp.compare_path
|
556
|
+
assert_equal '/1/2/3/4/5/', pp.directory
|
557
|
+
assert_equal '/1/2/3/4/5/', pp.directory_path
|
558
|
+
assert_equal '/1/2/3/4/5/', pp.dirname
|
559
|
+
assert_equal [ '/', '1/', '2/', '3/', '4/', '5/' ], pp.directory_parts
|
560
|
+
|
561
|
+
volume = nil
|
562
|
+
end
|
563
|
+
assert_equal 'file.ext', pp.file_full_name
|
564
|
+
assert_equal 'file.ext', pp.basename
|
565
|
+
assert_equal 'file', pp.file_name_only
|
566
|
+
assert_equal 'file', pp.stem
|
567
|
+
assert_equal '.ext', pp.file_extension
|
568
|
+
assert_equal '.ext', pp.extension
|
569
|
+
assert_nil pp.search_directory
|
570
|
+
assert_nil pp.search_relative_path
|
571
|
+
assert_nil pp.search_relative_directory_path
|
572
|
+
assert_nil pp.search_relative_directory_parts
|
573
|
+
|
574
|
+
assert_equal pp.directory, pp.directory_parts.join
|
575
|
+
assert_equal pp.absolute_path, "#{volume}#{pp.directory_parts.join}#{pp.basename}"
|
576
|
+
end
|
577
|
+
|
578
|
+
def test_unrooted_one_file
|
579
|
+
|
580
|
+
if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
|
581
|
+
|
582
|
+
pwd = '/some-directory'
|
583
|
+
|
584
|
+
pp = ParsedPath.new('file.ext', pwd: pwd)
|
585
|
+
|
586
|
+
assert_equal 'file.ext', pp.given_path
|
587
|
+
assert_equal '/some-directory\\file.ext', pp.absolute_path
|
588
|
+
assert_equal '/SOME-DIRECTORY\\FILE.EXT', pp.compare_path
|
589
|
+
assert_nil pp.volume
|
590
|
+
assert_equal '/some-directory\\', pp.directory
|
591
|
+
assert_equal '/some-directory\\', pp.directory_path
|
592
|
+
assert_equal '/some-directory\\', pp.dirname
|
593
|
+
assert_equal [ '/', 'some-directory\\' ], pp.directory_parts
|
594
|
+
|
595
|
+
volume = pp.volume
|
596
|
+
else
|
597
|
+
|
598
|
+
pwd = '/some-directory'
|
599
|
+
|
600
|
+
pp = ParsedPath.new('file.ext', pwd: pwd)
|
601
|
+
|
602
|
+
assert_equal 'file.ext', pp.given_path
|
603
|
+
assert_equal '/some-directory/file.ext', pp.absolute_path
|
604
|
+
assert_equal '/some-directory/file.ext', pp.compare_path
|
605
|
+
assert_equal '/some-directory/', pp.directory
|
606
|
+
assert_equal '/some-directory/', pp.directory_path
|
607
|
+
assert_equal '/some-directory/', pp.dirname
|
608
|
+
assert_equal [ '/', 'some-directory/' ], pp.directory_parts
|
609
|
+
|
610
|
+
volume = nil
|
611
|
+
end
|
612
|
+
assert_equal 'file.ext', pp.file_full_name
|
613
|
+
assert_equal 'file.ext', pp.basename
|
614
|
+
assert_equal 'file', pp.file_name_only
|
615
|
+
assert_equal 'file', pp.stem
|
616
|
+
assert_equal '.ext', pp.file_extension
|
617
|
+
assert_equal '.ext', pp.extension
|
618
|
+
assert_nil pp.search_directory
|
619
|
+
assert_nil pp.search_relative_path
|
620
|
+
assert_nil pp.search_relative_directory_path
|
621
|
+
assert_nil pp.search_relative_directory_parts
|
622
|
+
|
623
|
+
assert_equal pp.directory, pp.directory_parts.join
|
624
|
+
assert_equal pp.absolute_path, "#{volume}#{pp.directory_parts.join}#{pp.basename}"
|
625
|
+
end
|
626
|
+
|
627
|
+
def test_unrooted_one_file_from_srd
|
628
|
+
|
629
|
+
if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
|
630
|
+
|
631
|
+
pwd = '/some-directory'
|
632
|
+
srd = '/dir-1/dir-2/'
|
633
|
+
|
634
|
+
pp = ParsedPath.new('file.ext', pwd: pwd)
|
635
|
+
|
636
|
+
assert_equal 'file.ext', pp.given_path
|
637
|
+
assert_equal '/some-directory\\file.ext', pp.absolute_path
|
638
|
+
assert_equal '/SOME-DIRECTORY\\FILE.EXT', pp.compare_path
|
639
|
+
assert_nil pp.volume
|
640
|
+
assert_equal '/some-directory\\', pp.directory
|
641
|
+
assert_equal '/some-directory\\', pp.directory_path
|
642
|
+
assert_equal '/some-directory\\', pp.dirname
|
643
|
+
assert_equal [ '/', 'some-directory\\' ], pp.directory_parts
|
644
|
+
|
645
|
+
volume = pp.volume
|
646
|
+
else
|
647
|
+
|
648
|
+
pwd = '/some-directory'
|
649
|
+
srd = '/dir-1/dir-2/'
|
650
|
+
|
651
|
+
pp = ParsedPath.new('file.ext', pwd: pwd)
|
652
|
+
|
653
|
+
assert_equal 'file.ext', pp.given_path
|
654
|
+
assert_equal '/some-directory/file.ext', pp.absolute_path
|
655
|
+
assert_equal '/some-directory/file.ext', pp.compare_path
|
656
|
+
assert_equal '/some-directory/', pp.directory
|
657
|
+
assert_equal '/some-directory/', pp.directory_path
|
658
|
+
assert_equal '/some-directory/', pp.dirname
|
659
|
+
assert_equal [ '/', 'some-directory/' ], pp.directory_parts
|
660
|
+
|
661
|
+
volume = nil
|
662
|
+
end
|
663
|
+
assert_equal 'file.ext', pp.file_full_name
|
664
|
+
assert_equal 'file.ext', pp.basename
|
665
|
+
assert_equal 'file', pp.file_name_only
|
666
|
+
assert_equal 'file', pp.stem
|
667
|
+
assert_equal '.ext', pp.file_extension
|
668
|
+
assert_equal '.ext', pp.extension
|
669
|
+
assert_nil pp.search_directory
|
670
|
+
assert_nil pp.search_relative_path
|
671
|
+
assert_nil pp.search_relative_directory_path
|
672
|
+
assert_nil pp.search_relative_directory_parts
|
673
|
+
|
674
|
+
assert_equal pp.directory, pp.directory_parts.join
|
675
|
+
assert_equal pp.absolute_path, "#{volume}#{pp.directory_parts.join}#{pp.basename}"
|
676
|
+
end
|
677
|
+
|
678
|
+
def test_unrooted_dir_file
|
679
|
+
|
680
|
+
if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
|
681
|
+
|
682
|
+
pwd = '/some-directory'
|
683
|
+
|
684
|
+
pp = ParsedPath.new('sub-dir/file.ext', pwd: pwd)
|
685
|
+
|
686
|
+
assert_equal 'sub-dir/file.ext', pp.given_path
|
687
|
+
assert_equal '/some-directory\\sub-dir/file.ext', pp.absolute_path
|
688
|
+
assert_equal '/SOME-DIRECTORY\\SUB-DIR/FILE.EXT', pp.compare_path
|
689
|
+
assert_nil pp.volume
|
690
|
+
assert_equal '/some-directory\\sub-dir/', pp.directory
|
691
|
+
assert_equal '/some-directory\\sub-dir/', pp.directory_path
|
692
|
+
assert_equal '/some-directory\\sub-dir/', pp.dirname
|
693
|
+
assert_equal [ '/', 'some-directory\\', 'sub-dir/' ], pp.directory_parts
|
694
|
+
|
695
|
+
volume = pp.volume
|
696
|
+
else
|
697
|
+
|
698
|
+
pwd = '/some-directory'
|
699
|
+
|
700
|
+
pp = ParsedPath.new('sub-dir/file.ext', pwd: pwd)
|
701
|
+
|
702
|
+
assert_equal 'sub-dir/file.ext', pp.given_path
|
703
|
+
assert_equal '/some-directory/sub-dir/file.ext', pp.absolute_path
|
704
|
+
assert_equal '/some-directory/sub-dir/file.ext', pp.compare_path
|
705
|
+
assert_equal '/some-directory/sub-dir/', pp.directory
|
706
|
+
assert_equal '/some-directory/sub-dir/', pp.directory_path
|
707
|
+
assert_equal '/some-directory/sub-dir/', pp.dirname
|
708
|
+
assert_equal [ '/', 'some-directory/', 'sub-dir/' ], pp.directory_parts
|
709
|
+
|
710
|
+
volume = nil
|
711
|
+
end
|
712
|
+
assert_equal 'file.ext', pp.file_full_name
|
713
|
+
assert_equal 'file.ext', pp.basename
|
714
|
+
assert_equal 'file', pp.file_name_only
|
715
|
+
assert_equal 'file', pp.stem
|
716
|
+
assert_equal '.ext', pp.file_extension
|
717
|
+
assert_equal '.ext', pp.extension
|
718
|
+
assert_nil pp.search_directory
|
719
|
+
assert_nil pp.search_relative_path
|
720
|
+
assert_nil pp.search_relative_directory_path
|
721
|
+
assert_nil pp.search_relative_directory_parts
|
722
|
+
|
723
|
+
assert_equal pp.directory, pp.directory_parts.join
|
724
|
+
assert_equal pp.absolute_path, "#{volume}#{pp.directory_parts.join}#{pp.basename}"
|
725
|
+
end
|
726
|
+
|
727
|
+
def test_unrooted_dir_file_2
|
728
|
+
|
729
|
+
locator = Object.new
|
730
|
+
|
731
|
+
if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
|
732
|
+
|
733
|
+
locator.define_singleton_method(:pwd) { '/some-directory' }
|
734
|
+
|
735
|
+
pp = ParsedPath.new('sub-dir/file.ext', locator: locator)
|
736
|
+
|
737
|
+
assert_equal 'sub-dir/file.ext', pp.given_path
|
738
|
+
assert_equal '/some-directory\\sub-dir/file.ext', pp.absolute_path
|
739
|
+
assert_equal '/SOME-DIRECTORY\\SUB-DIR/FILE.EXT', pp.compare_path
|
740
|
+
assert_nil pp.volume
|
741
|
+
assert_equal '/some-directory\\sub-dir/', pp.directory
|
742
|
+
assert_equal '/some-directory\\sub-dir/', pp.directory_path
|
743
|
+
assert_equal '/some-directory\\sub-dir/', pp.dirname
|
744
|
+
assert_equal [ '/', 'some-directory\\', 'sub-dir/' ], pp.directory_parts
|
745
|
+
|
746
|
+
volume = pp.volume
|
747
|
+
else
|
748
|
+
|
749
|
+
locator.define_singleton_method(:pwd) { '/some-directory' }
|
750
|
+
|
751
|
+
pp = ParsedPath.new('sub-dir/file.ext', locator: locator)
|
752
|
+
|
753
|
+
assert_equal 'sub-dir/file.ext', pp.given_path
|
754
|
+
assert_equal '/some-directory/sub-dir/file.ext', pp.absolute_path
|
755
|
+
assert_equal '/some-directory/sub-dir/file.ext', pp.compare_path
|
756
|
+
assert_equal '/some-directory/sub-dir/', pp.directory
|
757
|
+
assert_equal '/some-directory/sub-dir/', pp.directory_path
|
758
|
+
assert_equal '/some-directory/sub-dir/', pp.dirname
|
759
|
+
assert_equal [ '/', 'some-directory/', 'sub-dir/' ], pp.directory_parts
|
760
|
+
|
761
|
+
volume = nil
|
762
|
+
end
|
763
|
+
assert_equal 'file.ext', pp.file_full_name
|
764
|
+
assert_equal 'file.ext', pp.basename
|
765
|
+
assert_equal 'file', pp.file_name_only
|
766
|
+
assert_equal 'file', pp.stem
|
767
|
+
assert_equal '.ext', pp.file_extension
|
768
|
+
assert_equal '.ext', pp.extension
|
769
|
+
assert_nil pp.search_directory
|
770
|
+
assert_nil pp.search_relative_path
|
771
|
+
assert_nil pp.search_relative_directory_path
|
772
|
+
assert_nil pp.search_relative_directory_parts
|
773
|
+
|
774
|
+
assert_equal pp.directory, pp.directory_parts.join
|
775
|
+
assert_equal pp.absolute_path, "#{volume}#{pp.directory_parts.join}#{pp.basename}"
|
776
|
+
end
|
777
777
|
end
|
778
778
|
|