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.
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 +74 -74
  7. data/lib/libpath/constants/windows.rb +75 -75
  8. data/lib/libpath/constants.rb +20 -20
  9. data/lib/libpath/diagnostics/parameter_checking.rb +27 -26
  10. data/lib/libpath/diagnostics.rb +1 -1
  11. data/lib/libpath/exceptions/libpath_base_exception.rb +20 -21
  12. data/lib/libpath/exceptions/malformed_name_exception.rb +27 -27
  13. data/lib/libpath/exceptions.rb +1 -1
  14. data/lib/libpath/form/unix.rb +118 -118
  15. data/lib/libpath/form/windows.rb +228 -214
  16. data/lib/libpath/form.rb +20 -21
  17. data/lib/libpath/internal_/array.rb +57 -57
  18. data/lib/libpath/internal_/platform.rb +30 -31
  19. data/lib/libpath/internal_/string.rb +25 -20
  20. data/lib/libpath/internal_/unix/form.rb +124 -119
  21. data/lib/libpath/internal_/windows/drive.rb +80 -75
  22. data/lib/libpath/internal_/windows/form.rb +205 -194
  23. data/lib/libpath/libpath.rb +4 -1
  24. data/lib/libpath/path/unix.rb +120 -118
  25. data/lib/libpath/path/windows.rb +126 -124
  26. data/lib/libpath/path.rb +21 -21
  27. data/lib/libpath/util/unix.rb +261 -261
  28. data/lib/libpath/util/windows.rb +403 -403
  29. data/lib/libpath/util.rb +20 -20
  30. data/lib/libpath/version.rb +25 -26
  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
@@ -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
- def test_LibPath_module_exists
13
+ def test_LibPath_module_exists
14
14
 
15
- assert defined?(::LibPath)
16
- end
15
+ assert defined?(::LibPath)
16
+ end
17
17
 
18
- def test_LibPath_Form_module_exists
18
+ def test_LibPath_Form_module_exists
19
19
 
20
- assert defined?(::LibPath::Form)
21
- end
20
+ assert defined?(::LibPath::Form)
21
+ end
22
22
 
23
- def test_LibPath_Form_Unix_module_exists
23
+ def test_LibPath_Form_Unix_module_exists
24
24
 
25
- assert defined?(::LibPath::Form::Unix)
26
- end
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
- include ::LibPath::Form::Unix
31
+ include ::LibPath::Form::Unix
32
32
 
33
- def test_with_nil
33
+ def test_with_nil
34
34
 
35
- if $DEBUG
35
+ if $DEBUG
36
36
 
37
- assert_raise(::ArgumentError) { classify_path(nil) }
38
- else
37
+ assert_raise(::ArgumentError) { classify_path(nil) }
38
+ else
39
39
 
40
- assert_nil classify_path(nil)
41
- end
42
- end
40
+ assert_nil classify_path(nil)
41
+ end
42
+ end
43
43
 
44
- def test_empty
44
+ def test_empty
45
45
 
46
- assert_nil classify_path('')
47
- end
46
+ assert_nil classify_path('')
47
+ end
48
48
 
49
- def test_absolute
49
+ def test_absolute
50
50
 
51
- assert_equal :absolute, classify_path('/')
51
+ assert_equal :absolute, classify_path('/')
52
52
 
53
- assert_equal :absolute, classify_path('/abc')
54
- end
53
+ assert_equal :absolute, classify_path('/abc')
54
+ end
55
55
 
56
- def test_homed
56
+ def test_homed
57
57
 
58
- assert_equal :homed, classify_path('~')
58
+ assert_equal :homed, classify_path('~')
59
59
 
60
- assert_equal :homed, classify_path('~/')
60
+ assert_equal :homed, classify_path('~/')
61
61
 
62
- assert_equal :homed, classify_path('~/abc')
63
- end
62
+ assert_equal :homed, classify_path('~/abc')
63
+ end
64
64
 
65
- def test_relative
65
+ def test_relative
66
66
 
67
- assert_equal :relative, classify_path('abc')
67
+ assert_equal :relative, classify_path('abc')
68
68
 
69
- assert_equal :relative, classify_path('~~')
70
- end
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
- include ::LibPath::Form::Unix
75
+ include ::LibPath::Form::Unix
76
76
 
77
- def test_with_nil
77
+ def test_with_nil
78
78
 
79
- assert name_is_malformed?(nil)
80
- end
79
+ assert name_is_malformed?(nil)
80
+ end
81
81
 
82
- def test_empty
82
+ def test_empty
83
83
 
84
- assert_false name_is_malformed?('')
85
- end
84
+ assert_false name_is_malformed?('')
85
+ end
86
86
 
87
- def test_absolute_paths_from_root
87
+ def test_absolute_paths_from_root
88
88
 
89
- assert_false name_is_malformed?('/')
90
- assert_false name_is_malformed?('//')
91
- assert_false name_is_malformed?('/abc')
92
- end
89
+ assert_false name_is_malformed?('/')
90
+ assert_false name_is_malformed?('//')
91
+ assert_false name_is_malformed?('/abc')
92
+ end
93
93
 
94
- def test_absolute_paths_from_home
94
+ def test_absolute_paths_from_home
95
95
 
96
- assert_false name_is_malformed?('~')
97
- assert_false name_is_malformed?('~/')
98
- assert_false name_is_malformed?('~/abc')
99
- end
96
+ assert_false name_is_malformed?('~')
97
+ assert_false name_is_malformed?('~/')
98
+ assert_false name_is_malformed?('~/abc')
99
+ end
100
100
 
101
- def test_relative_paths
101
+ def test_relative_paths
102
102
 
103
- assert_false name_is_malformed?('abc')
104
- assert_false name_is_malformed?('abc/')
105
- assert_false name_is_malformed?('a/')
103
+ assert_false name_is_malformed?('abc')
104
+ assert_false name_is_malformed?('abc/')
105
+ assert_false name_is_malformed?('a/')
106
106
 
107
- assert_false name_is_malformed?('~abc')
108
- end
107
+ assert_false name_is_malformed?('~abc')
108
+ end
109
109
 
110
- def test_innate_invalid_characters
110
+ def test_innate_invalid_characters
111
111
 
112
- assert name_is_malformed?("\0")
113
- assert name_is_malformed?("a\0")
114
- assert name_is_malformed?("\0a")
112
+ assert name_is_malformed?("\0")
113
+ assert name_is_malformed?("a\0")
114
+ assert name_is_malformed?("\0a")
115
115
 
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
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
- def test_shell_invalid_characters
121
+ def test_shell_invalid_characters
122
122
 
123
- assert_false name_is_malformed?('*')
124
- assert_false name_is_malformed?('?')
125
- assert_false name_is_malformed?('|')
123
+ assert_false name_is_malformed?('*')
124
+ assert_false name_is_malformed?('?')
125
+ assert_false name_is_malformed?('|')
126
126
 
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
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
- def test_path_name_separators
132
+ def test_path_name_separators
133
133
 
134
- assert_false name_is_malformed?('/')
134
+ assert_false name_is_malformed?('/')
135
135
 
136
- assert name_is_malformed?('/', reject_path_name_separators: true)
137
- end
136
+ assert name_is_malformed?('/', reject_path_name_separators: true)
137
+ end
138
138
 
139
- def test_path_separators
139
+ def test_path_separators
140
140
 
141
- assert_false name_is_malformed?(':')
141
+ assert_false name_is_malformed?(':')
142
142
 
143
- assert name_is_malformed?(':', reject_path_separators: true)
144
- end
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
- include ::LibPath::Form::Unix
149
+ include ::LibPath::Form::Unix
150
150
 
151
- if $DEBUG
151
+ if $DEBUG
152
152
 
153
- def test_with_nil
153
+ def test_with_nil
154
154
 
155
- assert_raise(::ArgumentError) { path_is_absolute?(nil) }
156
- end
157
- end
155
+ assert_raise(::ArgumentError) { path_is_absolute?(nil) }
156
+ end
157
+ end
158
158
 
159
- def test_empty
159
+ def test_empty
160
160
 
161
- assert_false path_is_absolute?('')
162
- end
161
+ assert_false path_is_absolute?('')
162
+ end
163
163
 
164
- def test_absolute_paths_from_root
164
+ def test_absolute_paths_from_root
165
165
 
166
- assert path_is_absolute?('/')
167
- assert path_is_absolute?('//')
168
- assert path_is_absolute?('/abc')
169
- end
166
+ assert path_is_absolute?('/')
167
+ assert path_is_absolute?('//')
168
+ assert path_is_absolute?('/abc')
169
+ end
170
170
 
171
- def test_absolute_paths_from_home
171
+ def test_absolute_paths_from_home
172
172
 
173
- assert path_is_absolute?('~')
174
- assert path_is_absolute?('~/')
175
- assert path_is_absolute?('~/abc')
176
- end
173
+ assert path_is_absolute?('~')
174
+ assert path_is_absolute?('~/')
175
+ assert path_is_absolute?('~/abc')
176
+ end
177
177
 
178
- def test_relative_paths
178
+ def test_relative_paths
179
179
 
180
- assert_false path_is_absolute?('abc')
181
- assert_false path_is_absolute?('abc/')
182
- assert_false path_is_absolute?('a/')
180
+ assert_false path_is_absolute?('abc')
181
+ assert_false path_is_absolute?('abc/')
182
+ assert_false path_is_absolute?('a/')
183
183
 
184
- assert_false path_is_absolute?('~abc')
185
- end
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
- include ::LibPath::Form::Unix
190
+ include ::LibPath::Form::Unix
191
191
 
192
- if $DEBUG
192
+ if $DEBUG
193
193
 
194
- def test_with_nil
194
+ def test_with_nil
195
195
 
196
- assert_raise(::ArgumentError) { path_is_homed?(nil) }
197
- end
198
- end
196
+ assert_raise(::ArgumentError) { path_is_homed?(nil) }
197
+ end
198
+ end
199
199
 
200
- def test_empty
200
+ def test_empty
201
201
 
202
- assert_false path_is_homed?('')
203
- end
202
+ assert_false path_is_homed?('')
203
+ end
204
204
 
205
- def test_absolute_paths_from_root
205
+ def test_absolute_paths_from_root
206
206
 
207
- assert_false path_is_homed?('/')
208
- assert_false path_is_homed?('//')
209
- assert_false path_is_homed?('/abc')
210
- end
207
+ assert_false path_is_homed?('/')
208
+ assert_false path_is_homed?('//')
209
+ assert_false path_is_homed?('/abc')
210
+ end
211
211
 
212
- def test_absolute_paths_from_home
212
+ def test_absolute_paths_from_home
213
213
 
214
- assert path_is_homed?('~')
215
- assert path_is_homed?('~/')
216
- assert path_is_homed?('~/abc')
217
- end
214
+ assert path_is_homed?('~')
215
+ assert path_is_homed?('~/')
216
+ assert path_is_homed?('~/abc')
217
+ end
218
218
 
219
- def test_relative_paths
219
+ def test_relative_paths
220
220
 
221
- assert_false path_is_homed?('abc')
222
- assert_false path_is_homed?('abc/')
223
- assert_false path_is_homed?('a/')
221
+ assert_false path_is_homed?('abc')
222
+ assert_false path_is_homed?('abc/')
223
+ assert_false path_is_homed?('a/')
224
224
 
225
- assert_false path_is_homed?('~abc')
226
- end
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
- include ::LibPath::Form::Unix
231
+ include ::LibPath::Form::Unix
232
232
 
233
- if $DEBUG
233
+ if $DEBUG
234
234
 
235
- def test_with_nil
235
+ def test_with_nil
236
236
 
237
- assert_raise(::ArgumentError) { path_is_rooted?(nil) }
238
- end
239
- end
237
+ assert_raise(::ArgumentError) { path_is_rooted?(nil) }
238
+ end
239
+ end
240
240
 
241
- def test_empty
241
+ def test_empty
242
242
 
243
- assert_false path_is_rooted?('')
244
- end
243
+ assert_false path_is_rooted?('')
244
+ end
245
245
 
246
- def test_absolute_paths_from_root
246
+ def test_absolute_paths_from_root
247
247
 
248
- assert path_is_rooted?('/')
249
- assert path_is_rooted?('//')
250
- assert path_is_rooted?('/abc')
251
- end
248
+ assert path_is_rooted?('/')
249
+ assert path_is_rooted?('//')
250
+ assert path_is_rooted?('/abc')
251
+ end
252
252
 
253
- def test_absolute_paths_from_home
253
+ def test_absolute_paths_from_home
254
254
 
255
- assert_false path_is_rooted?('~')
256
- assert_false path_is_rooted?('~/')
257
- assert_false path_is_rooted?('~/abc')
258
- end
255
+ assert_false path_is_rooted?('~')
256
+ assert_false path_is_rooted?('~/')
257
+ assert_false path_is_rooted?('~/abc')
258
+ end
259
259
 
260
- def test_relative_paths
260
+ def test_relative_paths
261
261
 
262
- assert_false path_is_rooted?('abc')
263
- assert_false path_is_rooted?('abc/')
264
- assert_false path_is_rooted?('a/')
262
+ assert_false path_is_rooted?('abc')
263
+ assert_false path_is_rooted?('abc/')
264
+ assert_false path_is_rooted?('a/')
265
265
 
266
- assert_false path_is_rooted?('~abc')
267
- end
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
- $stderr.puts "requiring file '#{file}'" if $DEBUG
10
+ $stderr.puts "requiring file '#{file}'" if $DEBUG
11
11
 
12
- require file
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
- $stderr.puts "requiring file '#{file}'" if $DEBUG
18
+ $stderr.puts "requiring file '#{file}'" if $DEBUG
19
19
 
20
- require file
20
+ require file
21
21
  end
22
22