recls-ruby 2.11.0.3 → 2.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +24 -27
- data/README.md +1 -242
- data/examples/find_files_and_directories.md +30 -33
- data/examples/find_files_and_directories.recursive.md +254 -255
- data/examples/show_hidden_files.md +1 -4
- data/examples/show_hidden_files.rb +1 -1
- data/examples/show_readonly_files.md +1 -4
- data/examples/show_readonly_files.rb +1 -1
- data/lib/recls/api.rb +73 -76
- data/lib/recls/combine_paths_1.rb +23 -26
- data/lib/recls/combine_paths_2plus.rb +29 -32
- data/lib/recls/entry.rb +273 -277
- data/lib/recls/file_search.rb +193 -194
- data/lib/recls/flags.rb +45 -48
- data/lib/recls/foreach.rb +98 -105
- data/lib/recls/obsolete.rb +79 -80
- data/lib/recls/recls.rb +22 -16
- data/lib/recls/stat.rb +134 -137
- data/lib/recls/util.rb +92 -95
- data/lib/recls/version.rb +17 -22
- data/lib/recls/ximpl/os.rb +44 -46
- data/lib/recls/ximpl/unix.rb +35 -39
- data/lib/recls/ximpl/util.rb +596 -598
- data/lib/recls/ximpl/windows.rb +137 -141
- data/lib/recls.rb +9 -10
- data/test/scratch/test_display_parts.rb +33 -33
- data/test/scratch/test_entry.rb +6 -6
- data/test/scratch/test_files_and_directories.rb +8 -8
- data/test/scratch/test_foreach.rb +10 -10
- data/test/scratch/test_module_function.rb +33 -33
- data/test/scratch/test_pattern_arrays.rb +5 -5
- data/test/scratch/test_show_dev_and_ino.rb +1 -1
- data/test/scratch/test_show_hidden.rb +3 -3
- data/test/unit/tc_recls_entries.rb +31 -31
- data/test/unit/tc_recls_entry.rb +19 -19
- data/test/unit/tc_recls_file_search.rb +32 -32
- data/test/unit/tc_recls_module.rb +25 -25
- data/test/unit/tc_recls_util.rb +161 -161
- data/test/unit/tc_recls_ximpl_util.rb +676 -676
- data/test/unit/test_all_separately.sh +1 -1
- data/test/unit/ts_all.rb +4 -4
- metadata +7 -7
data/test/unit/tc_recls_util.rb
CHANGED
@@ -4,234 +4,234 @@
|
|
4
4
|
|
5
5
|
$:.unshift File.join(File.dirname(__FILE__), '../..', 'lib')
|
6
6
|
|
7
|
+
|
7
8
|
require 'recls/util'
|
8
9
|
|
9
10
|
require 'test/unit'
|
10
11
|
|
11
|
-
|
12
12
|
class Test_combine_paths < Test::Unit::TestCase
|
13
13
|
|
14
|
-
|
14
|
+
def test_nil_nil
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
assert_raise(::ArgumentError) { Recls.combine_paths(nil, nil) }
|
17
|
+
end
|
18
18
|
|
19
|
-
|
19
|
+
def test_origin_nil
|
20
20
|
|
21
|
-
|
21
|
+
strings = [
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
'abc',
|
24
|
+
'abc/def',
|
25
|
+
'abc/def/ghi.ext',
|
26
|
+
]
|
27
27
|
|
28
|
-
|
28
|
+
strings.each do |s|
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
assert_equal s, Recls.combine_paths(nil, s)
|
31
|
+
end
|
32
|
+
end
|
33
33
|
|
34
|
-
|
34
|
+
def test_path_nil
|
35
35
|
|
36
|
-
|
36
|
+
strings = [
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
'abc',
|
39
|
+
'abc/def',
|
40
|
+
'abc/def/ghi.ext',
|
41
|
+
]
|
42
42
|
|
43
|
-
|
43
|
+
strings.each do |s|
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
45
|
+
assert_equal s, Recls.combine_paths(s, nil)
|
46
|
+
end
|
47
|
+
end
|
48
48
|
|
49
|
-
|
49
|
+
def test_both_relative
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
51
|
+
assert_equal 'abc/def', Recls.combine_paths('abc', 'def')
|
52
|
+
assert_equal 'abc/def', Recls.combine_paths('abc/', 'def')
|
53
|
+
assert_equal 'abc/def/ghi', Recls.combine_paths('abc/def', 'ghi')
|
54
|
+
assert_equal 'abc/def/ghi', Recls.combine_paths('abc/def/', 'ghi')
|
55
|
+
assert_equal 'abc/def/ghi', Recls.combine_paths('abc', 'def/ghi')
|
56
|
+
assert_equal 'abc/def/ghi', Recls.combine_paths('abc/', 'def/ghi')
|
57
|
+
assert_equal 'abc/./def/ghi', Recls.combine_paths('abc/.', 'def/ghi')
|
58
|
+
assert_equal 'abc/./def/ghi', Recls.combine_paths('abc/./', 'def/ghi')
|
59
|
+
if RUBY_VERSION >= '2'
|
60
|
+
assert_equal 'abc/./def/ghi', Recls.combine_paths('abc/.', 'def/ghi', clean_path: false)
|
61
|
+
assert_equal 'abc/./def/ghi', Recls.combine_paths('abc/./', 'def/ghi', clean: false)
|
62
|
+
assert_equal 'abc/def/ghi', Recls.combine_paths('abc/.', 'def/ghi', clean_path: true)
|
63
|
+
assert_equal 'abc/def/ghi', Recls.combine_paths('abc/./', 'def/ghi', clean: true)
|
64
|
+
assert_equal 'abc/def/ghi', Recls.combine_paths('abc/./.', 'def/ghi', clean_path: true)
|
65
|
+
assert_equal 'abc/../def/ghi', Recls.combine_paths('abc/..', 'def/ghi')
|
66
|
+
assert_equal 'def/ghi', Recls.combine_paths('abc/..', 'def/ghi', clean_path: true)
|
67
|
+
end
|
68
|
+
end
|
69
69
|
|
70
|
-
|
70
|
+
def test_multiple_relative
|
71
71
|
|
72
|
-
|
73
|
-
|
74
|
-
|
72
|
+
if RUBY_VERSION >= '2'
|
73
|
+
assert_equal 'a/b/c/d/e/f/g', Recls.combine_paths('a', 'b', 'c', 'd/e/f/', 'g', clean: false)
|
74
|
+
assert_equal 'a/b/c/d/e/f/g', Recls.combine_paths('a', 'b', 'c', 'd/e/f/', 'g', clean: true)
|
75
75
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
76
|
+
assert_equal 'a/b/c/../d/e/f/g', Recls.combine_paths('a', 'b', 'c', '..', 'd/e/f/', 'g', clean: false)
|
77
|
+
assert_equal 'a/b/d/e/f/g', Recls.combine_paths('a', 'b', 'c', '..', 'd/e/f/', 'g/', clean: true)
|
78
|
+
assert_equal 'a/b/d/e/f/g/', Recls.combine_paths('a', 'b', 'c', '..', 'd/e/f/', 'g/', canonicalise: true)
|
79
|
+
end
|
80
|
+
end
|
81
81
|
|
82
|
-
|
82
|
+
def test_various_absolute_placings
|
83
83
|
|
84
|
-
|
84
|
+
assert_equal '/a/b/c/d/e/f/g', Recls.combine_paths('/', 'a', 'b', 'c', 'd/e', 'f/g')
|
85
85
|
|
86
|
-
|
86
|
+
assert_equal '/b/c/d/e/f/g', Recls.combine_paths('/', 'a', '/b', 'c', 'd/e', 'f/g')
|
87
87
|
|
88
|
-
|
88
|
+
assert_equal '/c/d/e/f/g', Recls.combine_paths('/', 'a', 'b', '/c', 'd/e', 'f/g')
|
89
89
|
|
90
|
-
|
90
|
+
assert_equal '/d/e/f/g', Recls.combine_paths('/', 'a', 'b', 'c', '/d/e', 'f/g')
|
91
91
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
92
|
+
assert_equal '/f/g', Recls.combine_paths('/', 'a', 'b', 'c', 'd/e', '/f/g')
|
93
|
+
assert_equal '/f/g/', Recls.combine_paths('/', 'a', 'b', 'c', 'd/e', '/f/g/')
|
94
|
+
if RUBY_VERSION >= '2'
|
95
|
+
assert_equal '/f/g', Recls.combine_paths('/', 'a', 'b', 'c', 'd/e', '/f/g/', clean: true)
|
96
|
+
assert_equal '/f/g/', Recls.combine_paths('/', 'a', 'b', 'c', 'd/e', '/f/g/', canonicalise: true)
|
97
|
+
end
|
98
|
+
end
|
99
99
|
end
|
100
100
|
|
101
101
|
class Test_canonicalise_path < Test::Unit::TestCase
|
102
102
|
|
103
|
-
|
103
|
+
def test_nil
|
104
104
|
|
105
|
-
|
106
|
-
|
105
|
+
assert_nil(Recls.canonicalise_path(nil))
|
106
|
+
end
|
107
107
|
|
108
|
-
|
108
|
+
def test_empty
|
109
109
|
|
110
|
-
|
111
|
-
|
110
|
+
assert_equal('', Recls.canonicalise_path(''))
|
111
|
+
end
|
112
112
|
|
113
|
-
|
113
|
+
def test_dots_directories
|
114
114
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
115
|
+
assert_equal('.', Recls.canonicalise_path('.'))
|
116
|
+
assert_equal('./', Recls.canonicalise_path('./'))
|
117
|
+
assert_equal('.', Recls.canonicalise_path('././.'))
|
118
|
+
assert_equal('./', Recls.canonicalise_path('./././'))
|
119
119
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
120
|
+
assert_equal('..', Recls.canonicalise_path('..'))
|
121
|
+
assert_equal('../', Recls.canonicalise_path('../'))
|
122
|
+
assert_equal('..', Recls.canonicalise_path('../.'))
|
123
|
+
assert_equal('../', Recls.canonicalise_path('.././'))
|
124
|
+
end
|
125
125
|
|
126
|
-
|
126
|
+
def test_files_only
|
127
127
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
128
|
+
assert_equal('a', Recls.canonicalise_path('a'))
|
129
|
+
assert_equal('file', Recls.canonicalise_path('file'))
|
130
|
+
assert_equal('file.ext', Recls.canonicalise_path('file.ext'))
|
131
|
+
end
|
132
132
|
|
133
|
-
|
133
|
+
def test_zero_parts
|
134
134
|
|
135
|
-
|
135
|
+
if Recls::Ximpl::OS::OS_IS_WINDOWS
|
136
136
|
|
137
|
-
|
137
|
+
assert_equal('H:', Recls.canonicalise_path('H:'))
|
138
138
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
139
|
+
assert_equal('\\\\server', Recls.canonicalise_path('\\\\server'))
|
140
|
+
assert_equal('\\\\server\\', Recls.canonicalise_path('\\\\server\\'))
|
141
|
+
assert_equal('\\\\server\\share', Recls.canonicalise_path('\\\\server\\share'))
|
142
|
+
assert_equal('\\\\server\\share/', Recls.canonicalise_path('\\\\server\\share/'))
|
143
|
+
end
|
144
|
+
end
|
145
145
|
|
146
|
-
|
146
|
+
def test_canonicalised_directories_one_level
|
147
147
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
148
|
+
assert_equal('abc', Recls.canonicalise_path('abc'))
|
149
|
+
assert_equal('abc/', Recls.canonicalise_path('abc/'))
|
150
|
+
assert_equal('/abc', Recls.canonicalise_path('/abc'))
|
151
|
+
assert_equal('/abc/', Recls.canonicalise_path('/abc/'))
|
152
|
+
end
|
153
153
|
|
154
|
-
|
154
|
+
def test_canonicalised_directories_two_levels
|
155
155
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
156
|
+
assert_equal('abc/def', Recls.canonicalise_path('abc/def'))
|
157
|
+
assert_equal('abc/def/', Recls.canonicalise_path('abc/def/'))
|
158
|
+
assert_equal('/abc/def', Recls.canonicalise_path('/abc/def'))
|
159
|
+
assert_equal('/abc/def/', Recls.canonicalise_path('/abc/def/'))
|
160
|
+
end
|
161
161
|
|
162
|
-
|
162
|
+
def test_uncanonicalised_directories_one_level
|
163
163
|
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
164
|
+
assert_equal('.', Recls.canonicalise_path('.'))
|
165
|
+
assert_equal('./', Recls.canonicalise_path('./'))
|
166
|
+
assert_equal('/', Recls.canonicalise_path('/.'))
|
167
|
+
assert_equal('/', Recls.canonicalise_path('/./'))
|
168
168
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
169
|
+
assert_equal('..', Recls.canonicalise_path('..'))
|
170
|
+
assert_equal('../', Recls.canonicalise_path('../'))
|
171
|
+
assert_equal('/', Recls.canonicalise_path('/..'))
|
172
|
+
assert_equal('/', Recls.canonicalise_path('/../'))
|
173
|
+
end
|
174
174
|
|
175
|
-
|
175
|
+
def test_single_canonicalisation
|
176
176
|
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
177
|
+
assert_equal('dir.1/', Recls.canonicalise_path('dir.1/'))
|
178
|
+
assert_equal('dir.1/', Recls.canonicalise_path('dir.1/./'))
|
179
|
+
assert_equal('dir.1/', Recls.canonicalise_path('./dir.1/./'))
|
180
|
+
assert_equal('dir.1/', Recls.canonicalise_path('./dir.1/.'))
|
181
|
+
end
|
182
182
|
|
183
|
-
|
183
|
+
def test_double_canonicalisation
|
184
184
|
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
185
|
+
assert_equal('dir.1/dir.2/', Recls.canonicalise_path('dir.1/dir.2/'))
|
186
|
+
assert_equal('dir.1/dir.2/', Recls.canonicalise_path('dir.1/dir.2/dir.3/../'))
|
187
|
+
assert_equal('dir.1/dir.2/', Recls.canonicalise_path('dir.1/dir.2/dir.3/../'))
|
188
|
+
assert_equal('dir.1/dir.2/', Recls.canonicalise_path('dir.1/dir.3/../dir.2/'))
|
189
|
+
assert_equal('dir.1/dir.2/', Recls.canonicalise_path('dir.3/../dir.1/dir.2/'))
|
190
190
|
|
191
|
-
|
192
|
-
|
191
|
+
assert_equal('../dir.1/dir.2/', Recls.canonicalise_path('../dir.1/dir.2/'))
|
192
|
+
assert_equal('../dir.4/', Recls.canonicalise_path('../dir.1/../dir.4/'))
|
193
193
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
194
|
+
assert_equal('/dir.1/dir.2/', Recls.canonicalise_path('/dir.1/dir.2/'))
|
195
|
+
assert_equal('/dir.1/dir.2/', Recls.canonicalise_path('/dir.1/dir.2/dir.3/../'))
|
196
|
+
assert_equal('/dir.1/dir.2/', Recls.canonicalise_path('/dir.1/dir.2/dir.3/../'))
|
197
|
+
assert_equal('/dir.1/dir.2/', Recls.canonicalise_path('/dir.1/dir.3/../dir.2/'))
|
198
|
+
assert_equal('/dir.1/dir.2/', Recls.canonicalise_path('/dir.3/../dir.1/dir.2/'))
|
199
199
|
|
200
|
-
|
201
|
-
|
200
|
+
assert_equal('/dir.1/dir.2/', Recls.canonicalise_path('/../dir.1/dir.2/'))
|
201
|
+
assert_equal('/dir.4/', Recls.canonicalise_path('/../dir.1/../dir.4/'))
|
202
202
|
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
203
|
+
assert_equal('/dir.14/', Recls.canonicalise_path('/dir.14/dir.2/..'))
|
204
|
+
assert_equal('/', Recls.canonicalise_path('/dir.14/dir.2/../..'))
|
205
|
+
assert_equal('/', Recls.canonicalise_path('/dir.14/dir.2/../../..'))
|
206
|
+
assert_equal('dir.14/', Recls.canonicalise_path('dir.14/dir.2/..'))
|
207
|
+
assert_equal('.', Recls.canonicalise_path('dir.14/dir.2/../..'))
|
208
|
+
assert_equal('..', Recls.canonicalise_path('dir.14/dir.2/../../..'))
|
209
209
|
|
210
|
-
|
210
|
+
if Recls::Ximpl::OS::OS_IS_WINDOWS
|
211
211
|
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
212
|
+
assert_equal('H:\\dir.1\\dir.2\\', Recls.canonicalise_path('H:\\dir.1\\dir.2\\'))
|
213
|
+
assert_equal('H:\\dir.1\\dir.2\\', Recls.canonicalise_path('H:\\dir.1\\dir.2\\dir.3\\..\\'))
|
214
|
+
assert_equal('H:\\dir.1\\dir.2\\', Recls.canonicalise_path('H:\\dir.1\\dir.2\\dir.3\\..\\'))
|
215
|
+
assert_equal('H:\\dir.1\\dir.2\\', Recls.canonicalise_path('H:\\dir.1\\dir.3\\..\\dir.2\\'))
|
216
|
+
assert_equal('H:\\dir.1\\dir.2\\', Recls.canonicalise_path('H:\\dir.3\\..\\dir.1\\dir.2\\'))
|
217
217
|
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
218
|
+
assert_equal('H:\\dir.43\\dir.5\\', Recls.canonicalise_path('H:\\..\\dir.43\\dir.5\\'))
|
219
|
+
assert_equal('H:\\dir.42\\', Recls.canonicalise_path('H:\\..\\dir.1\\..\\dir.42\\'))
|
220
|
+
end
|
221
|
+
end
|
222
222
|
|
223
|
-
|
223
|
+
def test_complex_examples
|
224
224
|
|
225
|
-
|
226
|
-
|
227
|
-
|
225
|
+
assert_equal('../dir.11/dir.22/dir.33/file3.', Recls.canonicalise_path('abc/.././././.././dir.1/../dir.11/dir.22/dir.33/file3.'))
|
226
|
+
assert_equal('/dir.11/dir.22/dir.33/file3.', Recls.canonicalise_path('/abc/.././././.././dir.1/../dir.11/dir.22/dir.33/file3.'))
|
227
|
+
assert_equal('../dir.11/dir.22/dir.33/file3.', Recls.canonicalise_path('./././abc/.././././.././dir.1/../dir.11/dir.22/././dir.33/././file3.'))
|
228
228
|
|
229
|
-
|
229
|
+
if Recls::Ximpl::OS::OS_IS_WINDOWS
|
230
230
|
|
231
|
-
|
232
|
-
|
231
|
+
end
|
232
|
+
end
|
233
233
|
end
|
234
234
|
|
235
|
-
|
236
235
|
# ############################## end of file ############################# #
|
237
236
|
|
237
|
+
|