libpath-ruby 0.2.1 → 0.2.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +33 -0
  3. data/README.md +25 -8
  4. data/examples/path_from_arg0.md +43 -43
  5. data/examples/path_from_arg0.rb +25 -23
  6. data/lib/libpath/constants/unix.rb +71 -71
  7. data/lib/libpath/constants/windows.rb +72 -72
  8. data/lib/libpath/constants.rb +18 -19
  9. data/lib/libpath/diagnostics/parameter_checking.rb +25 -25
  10. data/lib/libpath/diagnostics.rb +1 -1
  11. data/lib/libpath/exceptions/libpath_base_exception.rb +13 -13
  12. data/lib/libpath/exceptions/malformed_name_exception.rb +23 -22
  13. data/lib/libpath/exceptions.rb +3 -3
  14. data/lib/libpath/form/unix.rb +104 -103
  15. data/lib/libpath/form/windows.rb +200 -199
  16. data/lib/libpath/form.rb +18 -18
  17. data/lib/libpath/internal_/array.rb +53 -53
  18. data/lib/libpath/internal_/platform.rb +24 -24
  19. data/lib/libpath/internal_/string.rb +20 -17
  20. data/lib/libpath/internal_/unix/form.rb +117 -112
  21. data/lib/libpath/internal_/windows/drive.rb +62 -59
  22. data/lib/libpath/internal_/windows/form.rb +193 -188
  23. data/lib/libpath/libpath.rb +3 -0
  24. data/lib/libpath/path/unix.rb +114 -112
  25. data/lib/libpath/path/windows.rb +120 -118
  26. data/lib/libpath/path.rb +18 -20
  27. data/lib/libpath/util/unix.rb +258 -258
  28. data/lib/libpath/util/windows.rb +400 -400
  29. data/lib/libpath/util.rb +18 -19
  30. data/lib/libpath/version.rb +23 -23
  31. data/lib/libpath.rb +1 -1
  32. data/test/performance/benchmark_drive_letter.rb +50 -10
  33. data/test/performance/benchmark_gsub_string_or_regex.rb +27 -23
  34. data/test/performance/benchmark_rindex2.rb +56 -48
  35. data/test/performance/benchmark_split.rb +16 -10
  36. data/test/unit/compare/ts_all.rb +4 -4
  37. data/test/unit/equate/ts_all.rb +4 -4
  38. data/test/unit/equate/unix/ts_all.rb +4 -4
  39. data/test/unit/equate/windows/ts_all.rb +4 -4
  40. data/test/unit/exceptions/tc_libpath_base_exception.rb +10 -8
  41. data/test/unit/exceptions/tc_malformed_name_exception.rb +14 -12
  42. data/test/unit/exceptions/ts_all.rb +4 -4
  43. data/test/unit/form/tc_absolute_functions.rb +242 -240
  44. data/test/unit/form/ts_all.rb +4 -4
  45. data/test/unit/form/unix/tc_absolute_functions.rb +158 -155
  46. data/test/unit/form/unix/ts_all.rb +4 -4
  47. data/test/unit/form/windows/tc_absolute_functions.rb +628 -625
  48. data/test/unit/form/windows/ts_all.rb +4 -4
  49. data/test/unit/internal_/tc_array.rb +36 -32
  50. data/test/unit/internal_/ts_all.rb +4 -4
  51. data/test/unit/internal_/unix/form/tc_slash_functions.rb +38 -35
  52. data/test/unit/internal_/unix/form/ts_all.rb +4 -4
  53. data/test/unit/internal_/unix/tc_split_path.rb +387 -384
  54. data/test/unit/internal_/unix/ts_all.rb +4 -4
  55. data/test/unit/internal_/windows/form/tc_get_windows_volume.rb +157 -153
  56. data/test/unit/internal_/windows/form/tc_slash_functions.rb +39 -35
  57. data/test/unit/internal_/windows/form/ts_all.rb +4 -4
  58. data/test/unit/internal_/windows/tc_split_path.rb +874 -869
  59. data/test/unit/internal_/windows/ts_all.rb +4 -4
  60. data/test/unit/parse/ts_all.rb +4 -4
  61. data/test/unit/path/tc_path.rb +732 -732
  62. data/test/unit/path/ts_all.rb +4 -4
  63. data/test/unit/path/unix/tc_path.rb +544 -540
  64. data/test/unit/path/unix/ts_all.rb +4 -4
  65. data/test/unit/path/windows/tc_path.rb +608 -603
  66. data/test/unit/path/windows/ts_all.rb +4 -4
  67. data/test/unit/tc_version.rb +25 -22
  68. data/test/unit/ts_all.rb +4 -4
  69. data/test/unit/util/tc_combine_paths.rb +110 -105
  70. data/test/unit/util/tc_derive_relative_path.rb +8 -3
  71. data/test/unit/util/tc_make_path_canonical.rb +142 -138
  72. data/test/unit/util/ts_all.rb +4 -4
  73. data/test/unit/util/unix/tc_combine_paths.rb +38 -34
  74. data/test/unit/util/unix/tc_derive_relative_path.rb +80 -75
  75. data/test/unit/util/unix/tc_make_path_absolute.rb +74 -70
  76. data/test/unit/util/unix/tc_make_path_canonical.rb +95 -90
  77. data/test/unit/util/unix/ts_all.rb +4 -4
  78. data/test/unit/util/windows/tc_combine_paths.rb +82 -77
  79. data/test/unit/util/windows/tc_derive_relative_path.rb +98 -93
  80. data/test/unit/util/windows/tc_make_path_absolute.rb +105 -101
  81. data/test/unit/util/windows/tc_make_path_canonical.rb +158 -153
  82. data/test/unit/util/windows/ts_all.rb +4 -4
  83. metadata +9 -8
@@ -2,154 +2,159 @@
2
2
 
3
3
  $:.unshift File.join(File.dirname(__FILE__), *(['..'] * 4), 'lib')
4
4
 
5
+
5
6
  require 'libpath/util/windows'
6
7
 
7
8
  require 'test/unit'
8
9
 
10
+
9
11
  class Test_LibPath_Util_Windows_derive_relative_path < Test::Unit::TestCase
10
12
 
11
- M = ::LibPath::Util::Windows
13
+ M = ::LibPath::Util::Windows
12
14
 
13
- def test_nils_and_empties
15
+ def test_nils_and_empties
14
16
 
15
- # to get nowhere from nowhere, go nowhere
16
- assert_nil M.derive_relative_path(nil, nil)
17
- assert_nil M.derive_relative_path('', nil)
18
- assert_equal '', M.derive_relative_path('', '')
19
- assert_equal '', M.derive_relative_path(nil, '')
17
+ # to get nowhere from nowhere, go nowhere
18
+ assert_nil M.derive_relative_path(nil, nil)
19
+ assert_nil M.derive_relative_path('', nil)
20
+ assert_equal '', M.derive_relative_path('', '')
21
+ assert_equal '', M.derive_relative_path(nil, '')
20
22
 
21
- # to get somewhere from nowhere, just go there
22
- assert_equal 'abc', M.derive_relative_path(nil, 'abc')
23
- assert_equal 'abc', M.derive_relative_path('', 'abc')
23
+ # to get somewhere from nowhere, just go there
24
+ assert_equal 'abc', M.derive_relative_path(nil, 'abc')
25
+ assert_equal 'abc', M.derive_relative_path('', 'abc')
24
26
 
25
- # to get nowhere from anywhere else, go nowhere
26
- assert_nil M.derive_relative_path('dir', nil)
27
- assert_equal '', M.derive_relative_path('dir', '')
28
- end
27
+ # to get nowhere from anywhere else, go nowhere
28
+ assert_nil M.derive_relative_path('dir', nil)
29
+ assert_equal '', M.derive_relative_path('dir', '')
30
+ end
29
31
 
30
- def test_same_location
32
+ def test_same_location
31
33
 
32
- assert_equal '.', M.derive_relative_path('.', '.')
33
- assert_equal '.', M.derive_relative_path('..', '..')
34
+ assert_equal '.', M.derive_relative_path('.', '.')
35
+ assert_equal '.', M.derive_relative_path('..', '..')
34
36
 
35
- assert_equal '.', M.derive_relative_path('abc', 'abc')
36
- assert_equal './', M.derive_relative_path('abc/', 'abc/')
37
- assert_equal './', M.derive_relative_path('abc', 'abc/')
37
+ assert_equal '.', M.derive_relative_path('abc', 'abc')
38
+ assert_equal './', M.derive_relative_path('abc/', 'abc/')
39
+ assert_equal './', M.derive_relative_path('abc', 'abc/')
38
40
 
39
- assert_equal './', M.derive_relative_path('/', '/')
41
+ assert_equal './', M.derive_relative_path('/', '/')
40
42
 
41
- assert_equal '.', M.derive_relative_path('./abc', 'abc')
42
- assert_equal '.', M.derive_relative_path('./abc/', 'abc')
43
- assert_equal './', M.derive_relative_path('./abc', 'abc/')
44
- assert_equal './', M.derive_relative_path('./abc/', 'abc/')
43
+ assert_equal '.', M.derive_relative_path('./abc', 'abc')
44
+ assert_equal '.', M.derive_relative_path('./abc/', 'abc')
45
+ assert_equal './', M.derive_relative_path('./abc', 'abc/')
46
+ assert_equal './', M.derive_relative_path('./abc/', 'abc/')
45
47
 
46
- assert_equal '.', M.derive_relative_path('/abc', '/abc')
47
- assert_equal '.', M.derive_relative_path('/abc/', '/abc')
48
- assert_equal './', M.derive_relative_path('/abc/', '/abc/')
49
- end
48
+ assert_equal '.', M.derive_relative_path('/abc', '/abc')
49
+ assert_equal '.', M.derive_relative_path('/abc/', '/abc')
50
+ assert_equal './', M.derive_relative_path('/abc/', '/abc/')
51
+ end
50
52
 
51
- def test_from_here
53
+ def test_from_here
52
54
 
53
- assert_equal 'abc', M.derive_relative_path('.', 'abc')
54
- end
55
+ assert_equal 'abc', M.derive_relative_path('.', 'abc')
56
+ end
55
57
 
56
- def test_ones_above
58
+ def test_ones_above
57
59
 
58
- assert_equal '..\\', M.derive_relative_path('.', '..')
60
+ assert_equal '..\\', M.derive_relative_path('.', '..')
59
61
 
60
- assert_equal '../', M.derive_relative_path('/abc/', '/')
62
+ assert_equal '../', M.derive_relative_path('/abc/', '/')
61
63
 
62
- assert_equal '..\\', M.derive_relative_path('abc/def', 'abc')
64
+ assert_equal '..\\', M.derive_relative_path('abc/def', 'abc')
63
65
 
64
- assert_equal '..\\', M.derive_relative_path('abc/def/ghi', 'abc/def')
65
- assert_equal '../', M.derive_relative_path('abc/def/ghi', 'abc/def/')
66
+ assert_equal '..\\', M.derive_relative_path('abc/def/ghi', 'abc/def')
67
+ assert_equal '../', M.derive_relative_path('abc/def/ghi', 'abc/def/')
66
68
 
67
- assert_equal '..\\', M.derive_relative_path('abc/def/./ghi', 'abc/def')
68
- assert_equal '..\\', M.derive_relative_path('abc/def/ghi/jkl/..', 'abc/def')
69
+ assert_equal '..\\', M.derive_relative_path('abc/def/./ghi', 'abc/def')
70
+ assert_equal '..\\', M.derive_relative_path('abc/def/ghi/jkl/..', 'abc/def')
69
71
 
70
- assert_equal '..\\../', M.derive_relative_path('/abc/def/', '/')
71
- #assert_equal '..\\../', M.derive_relative_path('/abc/def/', '/', make_path_canonical: true)
72
+ assert_equal '..\\../', M.derive_relative_path('/abc/def/', '/')
73
+ #assert_equal '..\\../', M.derive_relative_path('/abc/def/', '/', make_path_canonical: true)
72
74
 
73
- assert_equal '..\\..\\', M.derive_relative_path('abc/def/ghi/jkl/', 'abc/def')
75
+ assert_equal '..\\..\\', M.derive_relative_path('abc/def/ghi/jkl/', 'abc/def')
74
76
 
75
- assert_equal '..\\..\\', M.derive_relative_path('C:\\dir-1\\dir-2\\', 'C:\\')
77
+ assert_equal '..\\..\\', M.derive_relative_path('C:\\dir-1\\dir-2\\', 'C:\\')
76
78
 
77
- assert_equal '..\\..\\', M.derive_relative_path('\\dir1\\dir2\\dir3\\dir4', '\\dir1\\dir2')
78
- assert_equal '..\\..\\', M.derive_relative_path('/dir1/dir2/dir3/dir4', '/dir1/dir2')
79
- end
79
+ assert_equal '..\\..\\', M.derive_relative_path('\\dir1\\dir2\\dir3\\dir4', '\\dir1\\dir2')
80
+ assert_equal '..\\..\\', M.derive_relative_path('/dir1/dir2/dir3/dir4', '/dir1/dir2')
81
+ end
80
82
 
81
- def test_ones_below
83
+ def test_ones_below
82
84
 
83
- assert_equal 'dir-1\\', M.derive_relative_path('..', '.', pwd: '/dir-1/')
85
+ assert_equal 'dir-1\\', M.derive_relative_path('..', '.', pwd: '/dir-1/')
84
86
 
85
- assert_equal '..\\', M.derive_relative_path('.', '..', pwd: '/dir-1/')
87
+ assert_equal '..\\', M.derive_relative_path('.', '..', pwd: '/dir-1/')
86
88
 
87
- assert_equal 'def', M.derive_relative_path('abc', 'abc/def')
88
- assert_equal 'def\\', M.derive_relative_path('abc', 'abc/def/')
89
- assert_equal 'def\\', M.derive_relative_path('abc', 'abc\\def\\')
89
+ assert_equal 'def', M.derive_relative_path('abc', 'abc/def')
90
+ assert_equal 'def\\', M.derive_relative_path('abc', 'abc/def/')
91
+ assert_equal 'def\\', M.derive_relative_path('abc', 'abc\\def\\')
90
92
 
91
- assert_equal 'def\\ghi', M.derive_relative_path('abc', 'abc/def/ghi')
92
- assert_equal 'def\\ghi\\', M.derive_relative_path('abc', 'abc/def/ghi/')
93
- end
93
+ assert_equal 'def\\ghi', M.derive_relative_path('abc', 'abc/def/ghi')
94
+ assert_equal 'def\\ghi\\', M.derive_relative_path('abc', 'abc/def/ghi/')
95
+ end
94
96
 
95
- def test_ones_across
97
+ def test_ones_across
96
98
 
97
- assert_equal '..\\e-1', M.derive_relative_path('abc/d-1', 'abc/e-1')
98
- assert_equal '..\\e-1', M.derive_relative_path('abc/d-1/', 'abc/e-1')
99
+ assert_equal '..\\e-1', M.derive_relative_path('abc/d-1', 'abc/e-1')
100
+ assert_equal '..\\e-1', M.derive_relative_path('abc/d-1/', 'abc/e-1')
99
101
 
100
- assert_equal '..\\e-1\\e-2', M.derive_relative_path('abc/d-1/', 'abc/e-1/e-2')
101
- assert_equal '..\\..\\e-1\\e-2', M.derive_relative_path('abc/d-1/d-2/', 'abc/e-1/e-2')
102
- end
102
+ assert_equal '..\\e-1\\e-2', M.derive_relative_path('abc/d-1/', 'abc/e-1/e-2')
103
+ assert_equal '..\\..\\e-1\\e-2', M.derive_relative_path('abc/d-1/d-2/', 'abc/e-1/e-2')
104
+ end
103
105
 
104
- def test_simple_cases
106
+ def test_simple_cases
105
107
 
106
- assert_equal 'def', M.derive_relative_path('\\abc', '\\abc\\def')
107
- assert_equal 'def', M.derive_relative_path('/abc', '/abc/def')
108
- end
108
+ assert_equal 'def', M.derive_relative_path('\\abc', '\\abc\\def')
109
+ assert_equal 'def', M.derive_relative_path('/abc', '/abc/def')
110
+ end
109
111
 
110
- def test_absolute_path_cases
112
+ def test_absolute_path_cases
111
113
 
112
- assert_equal '..\\..\\def', M.derive_relative_path('/abc/ghi', '/def')
114
+ assert_equal '..\\..\\def', M.derive_relative_path('/abc/ghi', '/def')
113
115
 
114
- assert_equal '..\\..\\def', M.derive_relative_path('ghi', '/def', pwd: 'C:/abc')
116
+ assert_equal '..\\..\\def', M.derive_relative_path('ghi', '/def', pwd: 'C:/abc')
115
117
 
116
- assert_equal '..\\def', M.derive_relative_path('abc', '\\\\?\\C:/def', pwd: '\\\\?\\C:/')
118
+ assert_equal '..\\def', M.derive_relative_path('abc', '\\\\?\\C:/def', pwd: '\\\\?\\C:/')
117
119
 
118
- assert_equal '..\\..\abc', M.derive_relative_path('\\\\?\\UNC\\10.11.12.13:4567\\share/def/ghi', '\\\\?\\UNC\\10.11.12.13:4567\\share\abc')
119
- assert_equal '..\\def\\ghi', M.derive_relative_path('\\\\?\\UNC\\10.11.12.13:4567\\share\\abc', '\\\\?\\UNC\\10.11.12.13:4567\\share/def/ghi')
120
- end
120
+ assert_equal '..\\..\abc', M.derive_relative_path('\\\\?\\UNC\\10.11.12.13:4567\\share/def/ghi', '\\\\?\\UNC\\10.11.12.13:4567\\share\abc')
121
+ assert_equal '..\\def\\ghi', M.derive_relative_path('\\\\?\\UNC\\10.11.12.13:4567\\share\\abc', '\\\\?\\UNC\\10.11.12.13:4567\\share/def/ghi')
122
+ end
121
123
 
122
- def test_mixed
124
+ def test_mixed
123
125
 
124
- assert_equal 'D:\\dir-1\\dir-3', M.derive_relative_path('C:\\dir-1\\dir-2', '/dir-1/dir-3', pwd: 'D:')
126
+ assert_equal 'D:\\dir-1\\dir-3', M.derive_relative_path('C:\\dir-1\\dir-2', '/dir-1/dir-3', pwd: 'D:')
125
127
 
126
- assert_equal '..\\dir-3', M.derive_relative_path('C:\\dir-1\\dir-2', '/dir-1/dir-3', pwd: 'C:')
128
+ assert_equal '..\\dir-3', M.derive_relative_path('C:\\dir-1\\dir-2', '/dir-1/dir-3', pwd: 'C:')
127
129
 
128
- assert_equal '..\\dir-3', M.derive_relative_path('C:\\dir-1\\dir-2', 'dir-3', pwd: 'C:\\dir-1')
129
- end
130
+ assert_equal '..\\dir-3', M.derive_relative_path('C:\\dir-1\\dir-2', 'dir-3', pwd: 'C:\\dir-1')
131
+ end
130
132
 
131
- def test_both_relative
133
+ def test_both_relative
132
134
 
133
- assert_equal '..\\def', M.derive_relative_path('abc', 'def', pwd: '/')
134
- end
135
+ assert_equal '..\\def', M.derive_relative_path('abc', 'def', pwd: '/')
136
+ end
135
137
 
136
- def test_different_drives
138
+ def test_different_drives
137
139
 
138
- assert_equal 'B:\\abc', M.derive_relative_path('A:\\abc', 'B:\\abc')
139
- end
140
+ assert_equal 'B:\\abc', M.derive_relative_path('A:\\abc', 'B:\\abc')
141
+ end
140
142
 
141
- def test_same_drives
143
+ def test_same_drives
142
144
 
143
- assert_equal '.', M.derive_relative_path('A:\\abc', 'A:\\abc')
144
- assert_equal '.', M.derive_relative_path('A:\\.\abc', 'A:\\abc')
145
- end
145
+ assert_equal '.', M.derive_relative_path('A:\\abc', 'A:\\abc')
146
+ assert_equal '.', M.derive_relative_path('A:\\.\abc', 'A:\\abc')
147
+ end
146
148
 
147
- def test_cases_from_Path
149
+ def test_cases_from_Path
148
150
 
149
- srd = 'C:\\dir-1\\dir-2\\dir-C\\dir-D'
150
- target = 'C:/dir-1/dir-2/dir-3/dir-4/./dir-5/dir-6/../file.ext'
151
+ srd = 'C:\\dir-1\\dir-2\\dir-C\\dir-D'
152
+ target = 'C:/dir-1/dir-2/dir-3/dir-4/./dir-5/dir-6/../file.ext'
151
153
 
152
- assert_equal '..\\..\\dir-3\\dir-4\\dir-5\\file.ext', M.derive_relative_path(srd, target)
153
- end
154
+ assert_equal '..\\..\\dir-3\\dir-4\\dir-5\\file.ext', M.derive_relative_path(srd, target)
155
+ end
154
156
  end
155
157
 
158
+
159
+ # ############################## end of file ############################# #
160
+
@@ -2,162 +2,166 @@
2
2
 
3
3
  $:.unshift File.join(File.dirname(__FILE__), *(['..'] * 4), 'lib')
4
4
 
5
+
5
6
  require 'libpath/util/windows'
6
7
 
7
8
  require 'test/unit'
8
9
 
9
- class Test_LibPath_Util_Windows_make_path_absolute < Test::Unit::TestCase
10
10
 
11
- F = ::LibPath::Util::Windows
11
+ class Test_LibPath_Util_Windows_make_path_absolute < Test::Unit::TestCase
12
12
 
13
- def test_nil
13
+ F = ::LibPath::Util::Windows
14
14
 
15
- if $DEBUG
15
+ def test_nil
16
16
 
17
- assert_raise(::ArgumentError) { F.make_path_absolute(nil) }
18
- else
17
+ if $DEBUG
19
18
 
20
- assert_nil F.make_path_absolute(nil)
21
- end
22
- end
19
+ assert_raise(::ArgumentError) { F.make_path_absolute(nil) }
20
+ else
23
21
 
24
- def test_empty
22
+ assert_nil F.make_path_absolute(nil)
23
+ end
24
+ end
25
25
 
26
- assert_equal '', F.make_path_absolute('')
27
- end
26
+ def test_empty
28
27
 
29
- def test_absolute_paths
28
+ assert_equal '', F.make_path_absolute('')
29
+ end
30
30
 
31
- assert_equal 'C:\\', F.make_path_absolute('\\', pwd: 'C:/Users/libpath-tester')
32
- assert_equal 'C:\\.', F.make_path_absolute('\\.', pwd: 'C:/Users/libpath-tester')
33
- assert_equal 'C:\\a', F.make_path_absolute('\\a', pwd: 'C:/Users/libpath-tester')
34
- assert_equal 'C:\\a\\.', F.make_path_absolute('\\a\\.', pwd: 'C:/Users/libpath-tester')
31
+ def test_absolute_paths
35
32
 
36
- assert_equal 'C:/', F.make_path_absolute('/', pwd: 'C:/Users/libpath-tester')
37
- assert_equal 'C:/.', F.make_path_absolute('/.', pwd: 'C:/Users/libpath-tester')
38
- assert_equal 'C:/a', F.make_path_absolute('/a', pwd: 'C:/Users/libpath-tester')
39
- assert_equal 'C:/a/.', F.make_path_absolute('/a/.', pwd: 'C:/Users/libpath-tester')
33
+ assert_equal 'C:\\', F.make_path_absolute('\\', pwd: 'C:/Users/libpath-tester')
34
+ assert_equal 'C:\\.', F.make_path_absolute('\\.', pwd: 'C:/Users/libpath-tester')
35
+ assert_equal 'C:\\a', F.make_path_absolute('\\a', pwd: 'C:/Users/libpath-tester')
36
+ assert_equal 'C:\\a\\.', F.make_path_absolute('\\a\\.', pwd: 'C:/Users/libpath-tester')
40
37
 
41
- assert_equal 'G:\\abc\\', F.make_path_absolute('G:\\abc\\')
42
- assert_equal 'G:\\abc\\', F.make_path_absolute('G:\\\\abc\\\\')
43
- assert_equal 'G:\\abc\\', F.make_path_absolute('G:\\\\abc\\\\', pwd: 'C:/Users/libpath-tester')
44
- end
38
+ assert_equal 'C:/', F.make_path_absolute('/', pwd: 'C:/Users/libpath-tester')
39
+ assert_equal 'C:/.', F.make_path_absolute('/.', pwd: 'C:/Users/libpath-tester')
40
+ assert_equal 'C:/a', F.make_path_absolute('/a', pwd: 'C:/Users/libpath-tester')
41
+ assert_equal 'C:/a/.', F.make_path_absolute('/a/.', pwd: 'C:/Users/libpath-tester')
45
42
 
46
- def test_absolute_paths_with_canonicalisation
43
+ assert_equal 'G:\\abc\\', F.make_path_absolute('G:\\abc\\')
44
+ assert_equal 'G:\\abc\\', F.make_path_absolute('G:\\\\abc\\\\')
45
+ assert_equal 'G:\\abc\\', F.make_path_absolute('G:\\\\abc\\\\', pwd: 'C:/Users/libpath-tester')
46
+ end
47
47
 
48
- pwd = 'X:\\some-dir'
48
+ def test_absolute_paths_with_canonicalisation
49
49
 
50
- options = { make_canonical: true }
50
+ pwd = 'X:\\some-dir'
51
51
 
52
- assert_equal 'X:/', F.make_path_absolute('/', **options, pwd: pwd)
53
- assert_equal 'X:/', F.make_path_absolute('/.', **options, pwd: pwd)
54
- assert_equal 'X:/a', F.make_path_absolute('/a', **options, pwd: pwd)
55
- assert_equal 'X:/a/', F.make_path_absolute('/a/.', **options, pwd: pwd)
56
- end
52
+ options = { make_canonical: true }
57
53
 
58
- def test_relative_path_with_fixed_pwd
54
+ assert_equal 'X:/', F.make_path_absolute('/', **options, pwd: pwd)
55
+ assert_equal 'X:/', F.make_path_absolute('/.', **options, pwd: pwd)
56
+ assert_equal 'X:/a', F.make_path_absolute('/a', **options, pwd: pwd)
57
+ assert_equal 'X:/a/', F.make_path_absolute('/a/.', **options, pwd: pwd)
58
+ end
59
59
 
60
- pwd = 'X:\\some-path\\\\or-other'
60
+ def test_relative_path_with_fixed_pwd
61
61
 
62
- assert_equal 'X:\\some-path\\or-other\\.', F.make_path_absolute('.', pwd: pwd)
63
- assert_equal 'X:\\some-path\\or-other\\', F.make_path_absolute('.', pwd: pwd, make_canonical: true)
62
+ pwd = 'X:\\some-path\\\\or-other'
64
63
 
65
- assert_equal 'X:\\some-path\\or-other\\abc', F.make_path_absolute('abc', pwd: pwd)
66
- assert_equal 'X:\\some-path\\or-other\\abc', F.make_path_absolute('abc', pwd: pwd, make_canonical: true)
64
+ assert_equal 'X:\\some-path\\or-other\\.', F.make_path_absolute('.', pwd: pwd)
65
+ assert_equal 'X:\\some-path\\or-other\\', F.make_path_absolute('.', pwd: pwd, make_canonical: true)
67
66
 
68
- assert_equal 'X:\\some-path\\or-other\\./abc', F.make_path_absolute('./abc', pwd: pwd)
69
- assert_equal 'X:\\some-path\\or-other\\abc', F.make_path_absolute('./abc', pwd: pwd, make_canonical: true)
67
+ assert_equal 'X:\\some-path\\or-other\\abc', F.make_path_absolute('abc', pwd: pwd)
68
+ assert_equal 'X:\\some-path\\or-other\\abc', F.make_path_absolute('abc', pwd: pwd, make_canonical: true)
70
69
 
71
- assert_equal 'X:\\some-path\\or-other\\./abc/', F.make_path_absolute('./abc/', pwd: pwd)
72
- assert_equal 'X:\\some-path\\or-other\\abc/', F.make_path_absolute('./abc/', pwd: pwd, make_canonical: true)
70
+ assert_equal 'X:\\some-path\\or-other\\./abc', F.make_path_absolute('./abc', pwd: pwd)
71
+ assert_equal 'X:\\some-path\\or-other\\abc', F.make_path_absolute('./abc', pwd: pwd, make_canonical: true)
73
72
 
74
- assert_equal 'X:\\some-path\\or-other\\def/../abc', F.make_path_absolute('def/../abc', pwd: pwd)
75
- assert_equal 'X:\\some-path\\or-other\\abc', F.make_path_absolute('def/../abc', pwd: pwd, make_canonical: true)
73
+ assert_equal 'X:\\some-path\\or-other\\./abc/', F.make_path_absolute('./abc/', pwd: pwd)
74
+ assert_equal 'X:\\some-path\\or-other\\abc/', F.make_path_absolute('./abc/', pwd: pwd, make_canonical: true)
76
75
 
77
- assert_equal 'X:\\some-path\\or-other\\def/../abc/', F.make_path_absolute('def/../abc/', pwd: pwd)
78
- assert_equal 'X:\\some-path\\or-other\\abc/', F.make_path_absolute('def/../abc/', pwd: pwd, make_canonical: true)
79
- end
76
+ assert_equal 'X:\\some-path\\or-other\\def/../abc', F.make_path_absolute('def/../abc', pwd: pwd)
77
+ assert_equal 'X:\\some-path\\or-other\\abc', F.make_path_absolute('def/../abc', pwd: pwd, make_canonical: true)
80
78
 
81
- def test_relative_path_with_fixed_home
79
+ assert_equal 'X:\\some-path\\or-other\\def/../abc/', F.make_path_absolute('def/../abc/', pwd: pwd)
80
+ assert_equal 'X:\\some-path\\or-other\\abc/', F.make_path_absolute('def/../abc/', pwd: pwd, make_canonical: true)
81
+ end
82
82
 
83
- home = 'X:\\Documents and Settings\\libpath-tester'
83
+ def test_relative_path_with_fixed_home
84
84
 
85
- assert_equal 'X:\\Documents and Settings\\libpath-tester', F.make_path_absolute('~', home: home)
86
- assert_equal 'X:\\Documents and Settings\\libpath-tester', F.make_path_absolute('~', home: home, make_canonical: true)
85
+ home = 'X:\\Documents and Settings\\libpath-tester'
87
86
 
88
- assert_equal 'X:\\Documents and Settings\\libpath-tester/.', F.make_path_absolute('~/.', home: home)
89
- assert_equal 'X:\\Documents and Settings\\libpath-tester/', F.make_path_absolute('~/.', home: home, make_canonical: true)
87
+ assert_equal 'X:\\Documents and Settings\\libpath-tester', F.make_path_absolute('~', home: home)
88
+ assert_equal 'X:\\Documents and Settings\\libpath-tester', F.make_path_absolute('~', home: home, make_canonical: true)
90
89
 
91
- assert_equal 'X:\\Documents and Settings\\libpath-tester\\.', F.make_path_absolute('~\\.', home: home)
92
- assert_equal 'X:\\Documents and Settings\\libpath-tester\\', F.make_path_absolute('~\\.', home: home, make_canonical: true)
90
+ assert_equal 'X:\\Documents and Settings\\libpath-tester/.', F.make_path_absolute('~/.', home: home)
91
+ assert_equal 'X:\\Documents and Settings\\libpath-tester/', F.make_path_absolute('~/.', home: home, make_canonical: true)
93
92
 
94
- assert_equal 'X:\\Documents and Settings\\libpath-tester/abc', F.make_path_absolute('~/abc', home: home)
95
- assert_equal 'X:\\Documents and Settings\\libpath-tester/abc', F.make_path_absolute('~/abc', home: home, make_canonical: true)
93
+ assert_equal 'X:\\Documents and Settings\\libpath-tester\\.', F.make_path_absolute('~\\.', home: home)
94
+ assert_equal 'X:\\Documents and Settings\\libpath-tester\\', F.make_path_absolute('~\\.', home: home, make_canonical: true)
96
95
 
97
- assert_equal 'X:\\Documents and Settings\\libpath-tester/./abc', F.make_path_absolute('~/./abc', home: home)
98
- assert_equal 'X:\\Documents and Settings\\libpath-tester/abc', F.make_path_absolute('~/./abc', home: home, make_canonical: true)
96
+ assert_equal 'X:\\Documents and Settings\\libpath-tester/abc', F.make_path_absolute('~/abc', home: home)
97
+ assert_equal 'X:\\Documents and Settings\\libpath-tester/abc', F.make_path_absolute('~/abc', home: home, make_canonical: true)
99
98
 
100
- assert_equal 'X:\\Documents and Settings\\libpath-tester/./abc/', F.make_path_absolute('~/./abc/', home: home)
101
- assert_equal 'X:\\Documents and Settings\\libpath-tester/abc/', F.make_path_absolute('~/./abc/', home: home, make_canonical: true)
99
+ assert_equal 'X:\\Documents and Settings\\libpath-tester/./abc', F.make_path_absolute('~/./abc', home: home)
100
+ assert_equal 'X:\\Documents and Settings\\libpath-tester/abc', F.make_path_absolute('~/./abc', home: home, make_canonical: true)
102
101
 
103
- assert_equal 'X:\\Documents and Settings\\libpath-tester/def/../abc', F.make_path_absolute('~/def/../abc', home: home)
104
- assert_equal 'X:\\Documents and Settings\\libpath-tester/abc', F.make_path_absolute('~/def/../abc', home: home, make_canonical: true)
102
+ assert_equal 'X:\\Documents and Settings\\libpath-tester/./abc/', F.make_path_absolute('~/./abc/', home: home)
103
+ assert_equal 'X:\\Documents and Settings\\libpath-tester/abc/', F.make_path_absolute('~/./abc/', home: home, make_canonical: true)
105
104
 
106
- assert_equal 'X:\\Documents and Settings\\libpath-tester/def/../abc/', F.make_path_absolute('~/def/../abc/', home: home)
107
- assert_equal 'X:\\Documents and Settings\\libpath-tester/abc/', F.make_path_absolute('~/def/../abc/', home: home, make_canonical: true)
108
- end
105
+ assert_equal 'X:\\Documents and Settings\\libpath-tester/def/../abc', F.make_path_absolute('~/def/../abc', home: home)
106
+ assert_equal 'X:\\Documents and Settings\\libpath-tester/abc', F.make_path_absolute('~/def/../abc', home: home, make_canonical: true)
109
107
 
110
- def test_relative_path_with_fixed_home_2
108
+ assert_equal 'X:\\Documents and Settings\\libpath-tester/def/../abc/', F.make_path_absolute('~/def/../abc/', home: home)
109
+ assert_equal 'X:\\Documents and Settings\\libpath-tester/abc/', F.make_path_absolute('~/def/../abc/', home: home, make_canonical: true)
110
+ end
111
111
 
112
- home = 'X:\\Documents and Settings\\libpath-tester\\'
112
+ def test_relative_path_with_fixed_home_2
113
113
 
114
- assert_equal 'X:\\Documents and Settings\\libpath-tester\\', F.make_path_absolute('~', home: home)
115
- assert_equal 'X:\\Documents and Settings\\libpath-tester\\', F.make_path_absolute('~', home: home, make_canonical: true)
114
+ home = 'X:\\Documents and Settings\\libpath-tester\\'
116
115
 
117
- assert_equal 'X:\\Documents and Settings\\libpath-tester\\', F.make_path_absolute('~/', home: home)
118
- assert_equal 'X:\\Documents and Settings\\libpath-tester\\', F.make_path_absolute('~/', home: home, make_canonical: true)
116
+ assert_equal 'X:\\Documents and Settings\\libpath-tester\\', F.make_path_absolute('~', home: home)
117
+ assert_equal 'X:\\Documents and Settings\\libpath-tester\\', F.make_path_absolute('~', home: home, make_canonical: true)
119
118
 
120
- assert_equal 'X:\\Documents and Settings\\libpath-tester\\.', F.make_path_absolute('~/.', home: home)
121
- assert_equal 'X:\\Documents and Settings\\libpath-tester\\', F.make_path_absolute('~/.', home: home, make_canonical: true)
119
+ assert_equal 'X:\\Documents and Settings\\libpath-tester\\', F.make_path_absolute('~/', home: home)
120
+ assert_equal 'X:\\Documents and Settings\\libpath-tester\\', F.make_path_absolute('~/', home: home, make_canonical: true)
122
121
 
123
- assert_equal 'X:\\Documents and Settings\\libpath-tester\\abc', F.make_path_absolute('~/abc', home: home)
124
- assert_equal 'X:\\Documents and Settings\\libpath-tester\\abc', F.make_path_absolute('~/abc', home: home, make_canonical: true)
122
+ assert_equal 'X:\\Documents and Settings\\libpath-tester\\.', F.make_path_absolute('~/.', home: home)
123
+ assert_equal 'X:\\Documents and Settings\\libpath-tester\\', F.make_path_absolute('~/.', home: home, make_canonical: true)
125
124
 
126
- assert_equal 'X:\\Documents and Settings\\libpath-tester\\./abc', F.make_path_absolute('~/./abc', home: home)
127
- assert_equal 'X:\\Documents and Settings\\libpath-tester\\abc', F.make_path_absolute('~/./abc', home: home, make_canonical: true)
125
+ assert_equal 'X:\\Documents and Settings\\libpath-tester\\abc', F.make_path_absolute('~/abc', home: home)
126
+ assert_equal 'X:\\Documents and Settings\\libpath-tester\\abc', F.make_path_absolute('~/abc', home: home, make_canonical: true)
128
127
 
129
- assert_equal 'X:\\Documents and Settings\\libpath-tester\\./abc/', F.make_path_absolute('~/./abc/', home: home)
130
- assert_equal 'X:\\Documents and Settings\\libpath-tester\\abc/', F.make_path_absolute('~/./abc/', home: home, make_canonical: true)
128
+ assert_equal 'X:\\Documents and Settings\\libpath-tester\\./abc', F.make_path_absolute('~/./abc', home: home)
129
+ assert_equal 'X:\\Documents and Settings\\libpath-tester\\abc', F.make_path_absolute('~/./abc', home: home, make_canonical: true)
131
130
 
132
- assert_equal 'X:\\Documents and Settings\\libpath-tester\\def/../abc', F.make_path_absolute('~/def/../abc', home: home)
133
- assert_equal 'X:\\Documents and Settings\\libpath-tester\\abc', F.make_path_absolute('~/def/../abc', home: home, make_canonical: true)
131
+ assert_equal 'X:\\Documents and Settings\\libpath-tester\\./abc/', F.make_path_absolute('~/./abc/', home: home)
132
+ assert_equal 'X:\\Documents and Settings\\libpath-tester\\abc/', F.make_path_absolute('~/./abc/', home: home, make_canonical: true)
134
133
 
135
- assert_equal 'X:\\Documents and Settings\\libpath-tester\\def/../abc/', F.make_path_absolute('~/def/../abc/', home: home)
136
- assert_equal 'X:\\Documents and Settings\\libpath-tester\\abc/', F.make_path_absolute('~/def/../abc/', home: home, make_canonical: true)
137
- end
134
+ assert_equal 'X:\\Documents and Settings\\libpath-tester\\def/../abc', F.make_path_absolute('~/def/../abc', home: home)
135
+ assert_equal 'X:\\Documents and Settings\\libpath-tester\\abc', F.make_path_absolute('~/def/../abc', home: home, make_canonical: true)
138
136
 
139
- def test_nonhome_tilde_with_fixed_pwd
137
+ assert_equal 'X:\\Documents and Settings\\libpath-tester\\def/../abc/', F.make_path_absolute('~/def/../abc/', home: home)
138
+ assert_equal 'X:\\Documents and Settings\\libpath-tester\\abc/', F.make_path_absolute('~/def/../abc/', home: home, make_canonical: true)
139
+ end
140
140
 
141
- pwd = 'X:\\some-other-path\\'
141
+ def test_nonhome_tilde_with_fixed_pwd
142
142
 
143
- assert_equal 'X:\\some-other-path\\~.', F.make_path_absolute('~.', pwd: pwd)
144
- assert_equal 'X:\\some-other-path\\~.', F.make_path_absolute('~.', pwd: pwd, make_canonical: true)
143
+ pwd = 'X:\\some-other-path\\'
145
144
 
146
- assert_equal 'X:\\some-other-path\\~abc', F.make_path_absolute('~abc', pwd: pwd)
147
- assert_equal 'X:\\some-other-path\\~abc', F.make_path_absolute('~abc', pwd: pwd, make_canonical: true)
145
+ assert_equal 'X:\\some-other-path\\~.', F.make_path_absolute('~.', pwd: pwd)
146
+ assert_equal 'X:\\some-other-path\\~.', F.make_path_absolute('~.', pwd: pwd, make_canonical: true)
148
147
 
149
- assert_equal 'X:\\some-other-path\\~./abc', F.make_path_absolute('~./abc', pwd: pwd)
150
- assert_equal 'X:\\some-other-path\\~./abc', F.make_path_absolute('~./abc', pwd: pwd, make_canonical: true)
148
+ assert_equal 'X:\\some-other-path\\~abc', F.make_path_absolute('~abc', pwd: pwd)
149
+ assert_equal 'X:\\some-other-path\\~abc', F.make_path_absolute('~abc', pwd: pwd, make_canonical: true)
151
150
 
152
- assert_equal 'X:\\some-other-path\\~./abc/', F.make_path_absolute('~./abc/', pwd: pwd)
153
- assert_equal 'X:\\some-other-path\\~./abc/', F.make_path_absolute('~./abc/', pwd: pwd, make_canonical: true)
151
+ assert_equal 'X:\\some-other-path\\~./abc', F.make_path_absolute('~./abc', pwd: pwd)
152
+ assert_equal 'X:\\some-other-path\\~./abc', F.make_path_absolute('~./abc', pwd: pwd, make_canonical: true)
154
153
 
155
- assert_equal 'X:\\some-other-path\\~def/../abc', F.make_path_absolute('~def/../abc', pwd: pwd)
156
- assert_equal 'X:\\some-other-path\\abc', F.make_path_absolute('~def/../abc', pwd: pwd, make_canonical: true)
154
+ assert_equal 'X:\\some-other-path\\~./abc/', F.make_path_absolute('~./abc/', pwd: pwd)
155
+ assert_equal 'X:\\some-other-path\\~./abc/', F.make_path_absolute('~./abc/', pwd: pwd, make_canonical: true)
157
156
 
158
- assert_equal 'X:\\some-other-path\\~def/../abc/', F.make_path_absolute('~def/../abc/', pwd: pwd)
159
- assert_equal 'X:\\some-other-path\\abc/', F.make_path_absolute('~def/../abc/', pwd: pwd, make_canonical: true)
160
- end
157
+ assert_equal 'X:\\some-other-path\\~def/../abc', F.make_path_absolute('~def/../abc', pwd: pwd)
158
+ assert_equal 'X:\\some-other-path\\abc', F.make_path_absolute('~def/../abc', pwd: pwd, make_canonical: true)
161
159
 
160
+ assert_equal 'X:\\some-other-path\\~def/../abc/', F.make_path_absolute('~def/../abc/', pwd: pwd)
161
+ assert_equal 'X:\\some-other-path\\abc/', F.make_path_absolute('~def/../abc/', pwd: pwd, make_canonical: true)
162
+ end
162
163
  end
163
164
 
165
+
166
+ # ############################## end of file ############################# #
167
+