glark 1.9.0 → 1.10.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/glark +2 -2
- data/lib/glark.rb +1 -1
- data/lib/glark/app/app.rb +48 -0
- data/lib/glark/app/help.rb +103 -0
- data/lib/glark/app/info/options.rb +84 -0
- data/lib/glark/app/options.rb +201 -0
- data/lib/glark/app/rcfile.rb +49 -0
- data/lib/glark/app/runner.rb +140 -0
- data/lib/glark/app/spec.rb +19 -0
- data/lib/glark/input/filter/criteria_opts.rb +41 -0
- data/lib/glark/input/filter/dir_criteria_opts.rb +37 -0
- data/lib/glark/input/filter/file_criteria_opts.rb +33 -0
- data/lib/glark/input/filter/filter.rb +59 -0
- data/lib/glark/input/filter/options.rb +171 -0
- data/lib/glark/input/options.rb +120 -0
- data/lib/glark/input/range.rb +104 -0
- data/lib/glark/input/spec.rb +39 -0
- data/lib/glark/io/file/archive_file.rb +64 -0
- data/lib/glark/io/file/binary_file.rb +19 -0
- data/lib/glark/io/file/file.rb +57 -0
- data/lib/glark/io/file/gz_file.rb +21 -0
- data/lib/glark/io/file/tar_file.rb +35 -0
- data/lib/glark/io/file/tar_gz_file.rb +52 -0
- data/lib/glark/io/file/zip_file.rb +39 -0
- data/lib/glark/match/and.rb +83 -0
- data/lib/glark/match/and_distance.rb +58 -0
- data/lib/glark/match/compound.rb +34 -0
- data/lib/glark/match/expression.rb +63 -0
- data/lib/glark/match/factory.rb +173 -0
- data/lib/glark/match/ior.rb +20 -0
- data/lib/glark/match/options.rb +74 -0
- data/lib/glark/match/or.rb +41 -0
- data/lib/glark/match/re.rb +81 -0
- data/lib/glark/match/re_factory.rb +44 -0
- data/lib/glark/match/spec.rb +59 -0
- data/lib/glark/match/xor.rb +20 -0
- data/lib/glark/output/binary_file_summary.rb +17 -0
- data/lib/glark/output/common.rb +43 -0
- data/lib/glark/output/context.rb +57 -0
- data/lib/glark/output/count.rb +26 -0
- data/lib/glark/output/file_header.rb +20 -0
- data/lib/glark/output/file_name_only.rb +35 -0
- data/lib/glark/output/formatted.rb +22 -0
- data/lib/glark/output/glark_count.rb +23 -0
- data/lib/glark/output/glark_format.rb +62 -0
- data/lib/glark/output/glark_lines.rb +36 -0
- data/lib/glark/output/grep_count.rb +18 -0
- data/lib/glark/output/grep_lines.rb +42 -0
- data/lib/glark/output/line_status.rb +46 -0
- data/lib/glark/output/lines.rb +100 -0
- data/lib/glark/output/match_list.rb +15 -0
- data/lib/glark/output/options.rb +103 -0
- data/lib/glark/output/results.rb +23 -0
- data/lib/glark/output/spec.rb +105 -0
- data/lib/glark/output/unfiltered_lines.rb +28 -0
- data/lib/glark/util/colors/options.rb +143 -0
- data/lib/glark/util/colors/spec.rb +21 -0
- data/lib/glark/util/highlight.rb +108 -0
- data/lib/glark/util/io/depth.rb +29 -0
- data/lib/glark/util/io/fileset.rb +162 -0
- data/lib/glark/util/io/filter/criteria.rb +49 -0
- data/lib/glark/util/io/filter/filter.rb +10 -0
- data/lib/glark/util/io/lines.rb +117 -0
- data/lib/glark/util/option.rb +34 -0
- data/lib/glark/util/options.rb +12 -0
- data/lib/glark/util/optutil.rb +69 -0
- data/lib/glark/util/timestamper.rb +18 -0
- data/man/glark.1 +1134 -0
- data/test/glark/app/and_test.rb +82 -0
- data/test/glark/app/compound_test.rb +33 -0
- data/test/glark/app/context_test.rb +43 -0
- data/test/glark/app/count_test.rb +89 -0
- data/test/glark/app/dump_test.rb +16 -0
- data/test/glark/app/expression_file_test.rb +22 -0
- data/test/glark/app/extended_regexp_test.rb +17 -0
- data/test/glark/app/extract_matches_test.rb +27 -0
- data/test/glark/app/files_with_match_test.rb +32 -0
- data/test/glark/app/files_without_match_test.rb +26 -0
- data/test/glark/app/filter_test.rb +118 -0
- data/test/glark/app/highlight_test.rb +78 -0
- data/test/glark/app/ignore_case_test.rb +22 -0
- data/test/glark/app/invert_test.rb +49 -0
- data/test/glark/app/ior_test.rb +21 -0
- data/test/glark/app/label_test.rb +28 -0
- data/test/glark/app/line_number_color_test.rb +42 -0
- data/test/glark/app/line_numbers_test.rb +42 -0
- data/test/glark/app/match_limit_test.rb +49 -0
- data/test/glark/app/options_test.rb +722 -0
- data/test/glark/app/range_test.rb +101 -0
- data/test/glark/app/rcfile_test.rb +113 -0
- data/test/glark/app/record_separator_test.rb +32 -0
- data/test/glark/app/regexp_test.rb +48 -0
- data/test/glark/app/tc.rb +92 -0
- data/test/glark/app/text_color_test.rb +31 -0
- data/test/glark/app/whole_lines_test.rb +17 -0
- data/test/glark/app/whole_words_test.rb +42 -0
- data/test/glark/app/xor_test.rb +19 -0
- data/test/glark/input/binary_file_test.rb +0 -0
- data/test/glark/input/directory_test.rb +202 -0
- data/test/glark/input/dirname_test.rb +69 -0
- data/test/glark/input/exclude_matching_test.rb +20 -0
- data/test/glark/input/ext_test.rb +65 -0
- data/test/glark/input/filter/criteria_test.rb +91 -0
- data/test/glark/input/filter/filter_spec_test.rb +27 -0
- data/test/glark/input/filter/filter_test.rb +21 -0
- data/test/glark/input/name_test.rb +75 -0
- data/test/glark/input/path_test.rb +72 -0
- data/test/glark/input/range_test.rb +82 -0
- data/test/glark/input/size_limit_test.rb +51 -0
- data/test/glark/input/split_as_path_test.rb +28 -0
- data/test/glark/match_test.rb +192 -0
- data/test/glark/resources.rb +21 -0
- data/test/glark/tc.rb +37 -0
- data/test/resources/add.rb +10 -0
- data/test/resources/echo.rb +2 -0
- data/test/resources/greet.rb +13 -0
- metadata +198 -28
- data/README +0 -0
- data/bin/jlark +0 -63
- data/lib/glark/expression.rb +0 -440
- data/lib/glark/exprfactory.rb +0 -248
- data/lib/glark/glark.rb +0 -297
- data/lib/glark/help.rb +0 -85
- data/lib/glark/input.rb +0 -183
- data/lib/glark/options.rb +0 -757
- data/lib/glark/output.rb +0 -266
- data/test/lib/glark/glark_test.rb +0 -317
- data/test/lib/glark/options_test.rb +0 -891
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'glark/app/tc'
|
5
|
+
|
6
|
+
module Glark
|
7
|
+
class ExclusiveOrTestCase < AppTestCase
|
8
|
+
def test_simple
|
9
|
+
fname = '/proj/org/incava/glark/test/resources/textfile.txt'
|
10
|
+
expected = [
|
11
|
+
" 3 -rw-r--r-- 1 jpace jpace 45450 2010-12-04 15:24 02-[30m[42mTheMillersTale[0m.txt",
|
12
|
+
" 10 -rw-r--r-- 1 jpace jpace [30m[43m64791[0m 2010-12-04 15:24 09-TheClerksTale.txt",
|
13
|
+
" 20 -rw-r--r-- 1 jpace jpace 49747 2010-12-04 15:24 19-[30m[42mTheMonksTale[0m.txt",
|
14
|
+
" 24 -rw-r--r-- 1 jpace jpace 21141 2010-12-04 15:24 23-[30m[42mTheManciplesTale[0m.txt",
|
15
|
+
]
|
16
|
+
run_app_test expected, [ '--xor', '\b6\d{4}\b', 'TheM.*Tale' ], fname
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
Binary file
|
@@ -0,0 +1,202 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'glark/app/tc'
|
5
|
+
|
6
|
+
module Glark
|
7
|
+
class DirectoryTestCase < AppTestCase
|
8
|
+
def run_directory_list_test args
|
9
|
+
dirname = '/proj/org/incava/glark/test/resources'
|
10
|
+
expected = [
|
11
|
+
'[1m/proj/org/incava/glark/test/resources/filelist.txt[0m',
|
12
|
+
' 9 08-[30m[43mThe_Sompnours_Tale[0m.txt',
|
13
|
+
' 12 11-[30m[43mThe_Squires_Tale[0m.txt',
|
14
|
+
' 16 15-[30m[43mThe_Shipmans_Tale[0m.txt',
|
15
|
+
' 22 21-[30m[43mThe_Second_Nuns_Tale[0m.txt',
|
16
|
+
'[1m/proj/org/incava/glark/test/resources/spaces.txt[0m',
|
17
|
+
' 9 08 [30m[43mThe Sompnours Tale[0m.txt',
|
18
|
+
' 12 11 [30m[43mThe Squires Tale[0m.txt',
|
19
|
+
' 16 15 [30m[43mThe Shipmans Tale[0m.txt',
|
20
|
+
' 22 21 [30m[43mThe Second Nuns Tale[0m.txt',
|
21
|
+
'[1m/proj/org/incava/glark/test/resources/textfile.txt[0m',
|
22
|
+
' 9 -rw-r--r-- 1 jpace jpace 35994 2010-12-04 15:24 08-[30m[43mTheSompnoursTale[0m.txt',
|
23
|
+
' 12 -rw-r--r-- 1 jpace jpace 42282 2010-12-04 15:24 11-[30m[43mTheSquiresTale[0m.txt',
|
24
|
+
' 16 -rw-r--r-- 1 jpace jpace 25163 2010-12-04 15:24 15-[30m[43mTheShipmansTale[0m.txt',
|
25
|
+
' 22 -rw-r--r-- 1 jpace jpace 30734 2010-12-04 15:24 21-[30m[43mTheSecondNunsTale[0m.txt',
|
26
|
+
]
|
27
|
+
run_app_test expected, args + [ 'The.*S.*Tale' ], dirname
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_default
|
31
|
+
run_directory_list_test Array.new
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_list
|
35
|
+
run_directory_list_test %w{ --directories=list }
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_recurse_as_option
|
39
|
+
dirname = '/proj/org/incava/glark/test/resources'
|
40
|
+
expected = [
|
41
|
+
"[1m/proj/org/incava/glark/test/resources/add.rb[0m",
|
42
|
+
" 5 def initiali[30m[43mze[0m x, y",
|
43
|
+
"[1m/proj/org/incava/glark/test/resources/canterbury/franklin/tale.txt[0m",
|
44
|
+
" 298 For th' hori[30m[43mzon had reft the[0m sun his light",
|
45
|
+
"[1m/proj/org/incava/glark/test/resources/canterbury/prologue.txt[0m",
|
46
|
+
" 248 Of yeddings he bare utterly the pri[30m[43mze[0m.",
|
47
|
+
" 253 Better than a la[30m[43mzar or a beggere[0m,",
|
48
|
+
" 256 To have with such la[30m[43mzars acquaintance[0m.",
|
49
|
+
" 330 Justice he was full often in assi[30m[43mze[0m,",
|
50
|
+
" 605 Of which there was a do[30m[43mzen in that house[0m,",
|
51
|
+
"[1m/proj/org/incava/glark/test/resources/greet.rb[0m",
|
52
|
+
" 8 def initiali[30m[43mze name[0m",
|
53
|
+
"[1m/proj/org/incava/glark/test/resources/rcfile.txt[0m",
|
54
|
+
" 8 si[30m[43mze[0m-limit: 1000",
|
55
|
+
"[1m/proj/org/incava/glark/test/resources/zfile.txt[0m",
|
56
|
+
" 1 [30m[43mzaffre[0ms",
|
57
|
+
" 2 [30m[43mzoae[0ma",
|
58
|
+
" 3 [30m[43mzoae[0ma's",
|
59
|
+
" 4 [30m[43mzoe[0ma",
|
60
|
+
" 5 [30m[43mzoe[0mas",
|
61
|
+
" 6 [30m[43mzonulae[0m",
|
62
|
+
" 7 [30m[43mzooe[0ma",
|
63
|
+
" 8 [30m[43mzooeae[0m",
|
64
|
+
" 9 [30m[43mzooe[0mal",
|
65
|
+
" 10 [30m[43mzooe[0mas",
|
66
|
+
" 11 [30m[43mzooe[0mcia",
|
67
|
+
" 12 [30m[43mzooe[0mcium",
|
68
|
+
" 13 [30m[43mzoogloeae[0m",
|
69
|
+
" 14 [30m[43mzoogloe[0mal",
|
70
|
+
" 15 [30m[43mzoogloe[0mas",
|
71
|
+
" 16 [30m[43mzygae[0mnid",
|
72
|
+
]
|
73
|
+
run_app_test expected, [ '--directories=recurse', 'z.*e' ], dirname
|
74
|
+
end
|
75
|
+
|
76
|
+
def run_recurse_ellipses_all_expected dirname
|
77
|
+
expected = [
|
78
|
+
"[1m/proj/org/incava/glark/test/resources/canterbury/franklin/prologue.txt[0m",
|
79
|
+
" 60 Have me e[30m[43mxcused of my rude speec[0mh.",
|
80
|
+
"[1m/proj/org/incava/glark/test/resources/canterbury/franklin/tale.txt[0m",
|
81
|
+
" 530 Phoebus wa[30m[43mx'd old, and hued[0m like latoun,",
|
82
|
+
" 560 Neither his collect, nor his e[30m[43mxpanse yea[0mrs,",
|
83
|
+
" 567 From the head of that fi[30m[43mx'd Aries[0m above,",
|
84
|
+
" 706 Why should I more e[30m[43mxamples hereo[0mf sayn?",
|
85
|
+
"[1m/proj/org/incava/glark/test/resources/canterbury/prologue.txt[0m",
|
86
|
+
" 187 He gave not of the te[30m[43mxt a pulled hen[0m,",
|
87
|
+
" 192 This ilke te[30m[43mxt held he not worth an oyster[0m;",
|
88
|
+
" 291 Betwi[30m[43mxte Middleburg and Orewel[0ml",
|
89
|
+
" 292 Well could he in e[30m[43mxchange shieldes sel[0ml",
|
90
|
+
" 300 A CLERK there was of O[30m[43mxen[0mford also,",
|
91
|
+
" 327 There was also, full rich of e[30m[43mxcellen[0mce.",
|
92
|
+
" 417 From Bourdeau[30m[43mx-ward, while that the chapmen sleep[0m;",
|
93
|
+
" 578 His beard as any sow or fo[30m[43mx was red[0m,",
|
94
|
+
" 604 That were of law e[30m[43mxper[0mt and curious:",
|
95
|
+
"[1m/proj/org/incava/glark/test/resources/rcfile.txt[0m",
|
96
|
+
" 10 te[30m[43mxt-color-3: underline magen[0mta",
|
97
|
+
]
|
98
|
+
run_app_test expected, [ 'x.*e\w' ], dirname
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_recurse_ellipses_no_limit
|
102
|
+
dirname = '/proj/org/incava/glark/test/resources/...'
|
103
|
+
run_recurse_ellipses_all_expected dirname
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_recurse_ellipses_limit_zero
|
107
|
+
dirname = '/proj/org/incava/glark/test/resources/...0'
|
108
|
+
expected = [
|
109
|
+
"[1m/proj/org/incava/glark/test/resources/rcfile.txt[0m",
|
110
|
+
" 10 te[30m[43mxt-color-3: underline magen[0mta",
|
111
|
+
]
|
112
|
+
run_app_test expected, [ 'x.*e\w' ], dirname
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_recurse_ellipses_limit_one
|
116
|
+
dirname = '/proj/org/incava/glark/test/resources/...1'
|
117
|
+
expected = [
|
118
|
+
"[1m/proj/org/incava/glark/test/resources/canterbury/prologue.txt[0m",
|
119
|
+
" 187 He gave not of the te[30m[43mxt a pulled hen[0m,",
|
120
|
+
" 192 This ilke te[30m[43mxt held he not worth an oyster[0m;",
|
121
|
+
" 291 Betwi[30m[43mxte Middleburg and Orewel[0ml",
|
122
|
+
" 292 Well could he in e[30m[43mxchange shieldes sel[0ml",
|
123
|
+
" 300 A CLERK there was of O[30m[43mxen[0mford also,",
|
124
|
+
" 327 There was also, full rich of e[30m[43mxcellen[0mce.",
|
125
|
+
" 417 From Bourdeau[30m[43mx-ward, while that the chapmen sleep[0m;",
|
126
|
+
" 578 His beard as any sow or fo[30m[43mx was red[0m,",
|
127
|
+
" 604 That were of law e[30m[43mxper[0mt and curious:",
|
128
|
+
"[1m/proj/org/incava/glark/test/resources/rcfile.txt[0m",
|
129
|
+
" 10 te[30m[43mxt-color-3: underline magen[0mta",
|
130
|
+
]
|
131
|
+
run_app_test expected, [ 'x.*e\w' ], dirname
|
132
|
+
end
|
133
|
+
|
134
|
+
def test_recurse_ellipses_limit_two
|
135
|
+
dirname = '/proj/org/incava/glark/test/resources/...2'
|
136
|
+
run_recurse_ellipses_all_expected dirname
|
137
|
+
end
|
138
|
+
|
139
|
+
def test_skip
|
140
|
+
dirname = '/proj/org/incava/glark/test/resources'
|
141
|
+
expected = [ ]
|
142
|
+
run_app_test expected, [ '--directories=skip', 'The.*Tale' ], dirname
|
143
|
+
end
|
144
|
+
|
145
|
+
def test_list_no_files_in_directory
|
146
|
+
dirname = '/proj/org/incava/glark/test'
|
147
|
+
expected = [ ]
|
148
|
+
run_app_test expected, [ '--directories=list', 'The.*Tale' ], dirname
|
149
|
+
end
|
150
|
+
|
151
|
+
def test_recurse_from_current_dir
|
152
|
+
origdir = Dir.pwd
|
153
|
+
Dir.chdir '/proj/org/incava/glark/test/resources'
|
154
|
+
dirname = '.'
|
155
|
+
expected = [
|
156
|
+
"[1mfilelist.txt[0m",
|
157
|
+
" 23 22-[30m[43mThe_Canons_Yeomans_Tale[0m.txt",
|
158
|
+
"[1mspaces.txt[0m",
|
159
|
+
" 23 22 [30m[43mThe Canons Yeomans Tale[0m.txt",
|
160
|
+
"[1mtextfile.txt[0m",
|
161
|
+
" 23 -rw-r--r-- 1 jpace jpace 52953 2010-12-04 15:24 22-[30m[43mTheCanonsYeomansTale[0m.txt",
|
162
|
+
]
|
163
|
+
run_app_test expected, [ '-r', 'The.*Y.*Tale' ], dirname
|
164
|
+
Dir.chdir origdir
|
165
|
+
end
|
166
|
+
|
167
|
+
def test_list_with_binaries_read_skip_unreadable
|
168
|
+
dirname = '/proj/org/incava/glark/test/resources/...'
|
169
|
+
expected = [
|
170
|
+
'[1m/proj/org/incava/glark/test/resources/filelist.txt[0m',
|
171
|
+
' 23 22-[30m[43mThe_Canons_Yeomans_Tale[0m.txt',
|
172
|
+
'[1m/proj/org/incava/glark/test/resources/spaces.txt[0m',
|
173
|
+
' 23 22 [30m[43mThe Canons Yeomans Tale[0m.txt',
|
174
|
+
'[1m/proj/org/incava/glark/test/resources/textfile.txt[0m',
|
175
|
+
' 23 -rw-r--r-- 1 jpace jpace 52953 2010-12-04 15:24 22-[30m[43mTheCanonsYeomansTale[0m.txt',
|
176
|
+
'[1m/proj/org/incava/glark/test/resources/textfile.txt.gz[0m',
|
177
|
+
' 23 -rw-r--r-- 1 jpace jpace 52953 2010-12-04 15:24 22-[30m[43mTheCanonsYeomansTale[0m.txt',
|
178
|
+
'[1mfilelist.txt (in /proj/org/incava/glark/test/resources/txt.tgz)[0m',
|
179
|
+
' 23 22-[30m[43mThe_Canons_Yeomans_Tale[0m.txt',
|
180
|
+
]
|
181
|
+
run_app_test expected, [ '-r', '--binary-files=read', 'The.*Y.*Tale' ], dirname
|
182
|
+
end
|
183
|
+
|
184
|
+
def test_list_with_binaries_list_skip_unreadable
|
185
|
+
dirname = '/proj/org/incava/glark/test/resources/...'
|
186
|
+
expected = [
|
187
|
+
'[1m/proj/org/incava/glark/test/resources/aaa.zip[0m',
|
188
|
+
' 1 [30m[43mabcfile.txt[0m',
|
189
|
+
'[1m/proj/org/incava/glark/test/resources/rc.tar[0m',
|
190
|
+
' 1 [30m[43mrcext.txt[0m',
|
191
|
+
' 2 [30m[43mrcfile.txt[0m',
|
192
|
+
' 3 [30m[43mrcgrep.txt[0m',
|
193
|
+
' 4 [30m[43mrcmatch.txt[0m',
|
194
|
+
' 5 [30m[43mrcpath.txt[0m',
|
195
|
+
'[1m/proj/org/incava/glark/test/resources/txt.tgz[0m',
|
196
|
+
' 1 [30m[43mfilelist.txt[0m',
|
197
|
+
' 2 [30m[43mrcext.txt[0m',
|
198
|
+
]
|
199
|
+
run_app_test expected, [ '-r', '--binary-files=list', '^\w+\.txt$' ], dirname
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'glark/app/tc'
|
5
|
+
|
6
|
+
module Glark
|
7
|
+
class DirNameTestCase < AppTestCase
|
8
|
+
def test_skip_svn
|
9
|
+
dirname = '/proj/org/incava/glark/test/resources'
|
10
|
+
expected = [
|
11
|
+
"[1m/proj/org/incava/glark/test/resources/canterbury/franklin/tale.txt[0m",
|
12
|
+
" 10 That well unnethes durst [30m[43mthis knight for drea[0md,",
|
13
|
+
" 149 Why have ye wrought [30m[43mthis work unrea[0msonable?",
|
14
|
+
" 366 Let I [30m[43mthis woeful crea[0mture lie;",
|
15
|
+
]
|
16
|
+
run_app_test expected, [ '--directories=recurse', 'this.*rea' ], dirname
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_match_basename
|
20
|
+
dirnames = [ '/proj/org/incava/glark/test/resources/canterbury', '/proj/org/incava/glark/test/glark' ]
|
21
|
+
expected = [
|
22
|
+
"[1m/proj/org/incava/glark/test/resources/canterbury/prologue.txt[0m",
|
23
|
+
" 187 He gave not of the te[30m[43mxt a pulled he[0mn,",
|
24
|
+
" 192 This ilke te[30m[43mxt held he not worth an oyste[0mr;",
|
25
|
+
" 291 Betwi[30m[43mxte Middleburg and Orewe[0mll",
|
26
|
+
]
|
27
|
+
run_app_test expected, [ '-r', '--match-dirname=canterbury', 'xt.*e' ], *dirnames
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_not_basename
|
31
|
+
dirnames = [ '/proj/org/incava/glark/test' ]
|
32
|
+
expected = [
|
33
|
+
"[1m/proj/org/incava/glark/test/resources/canterbury/franklin/tale.txt[0m",
|
34
|
+
" 80 That is betwi[30m[43mxt a husband and his wife[0m?",
|
35
|
+
"[1m/proj/org/incava/glark/test/resources/canterbury/prologue.txt[0m",
|
36
|
+
" 187 He gave not of the te[30m[43mxt a pulled he[0mn,",
|
37
|
+
" 192 This ilke te[30m[43mxt held he not worth an oyste[0mr;",
|
38
|
+
" 291 Betwi[30m[43mxte Middleburg and Orewe[0mll",
|
39
|
+
"[1m/proj/org/incava/glark/test/resources/rcfile.txt[0m",
|
40
|
+
" 10 te[30m[43mxt-color-3: underline mage[0mnta",
|
41
|
+
]
|
42
|
+
run_app_test expected, [ '-r', '--skip-dirname=glark', 'xt.*e' ], *dirnames
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_match_pathname
|
46
|
+
dirnames = [ '/proj/org/incava/glark/test/glark', '/proj/org/incava/glark/test/resources' ]
|
47
|
+
expected = [
|
48
|
+
"[1m/proj/org/incava/glark/test/resources/rcfile.txt[0m",
|
49
|
+
" 10 te[30m[43mxt-color-3: underline mage[0mnta",
|
50
|
+
]
|
51
|
+
run_app_test expected, [ '-r', '--match-dirpath', '^.*es$', 'xt.*e' ], *dirnames
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_not_pathname
|
55
|
+
dirnames = [ '/proj/org/incava/glark/test/glark', '/proj/org/incava/glark/test/resources' ]
|
56
|
+
expected = [
|
57
|
+
"[1m/proj/org/incava/glark/test/resources/canterbury/franklin/tale.txt[0m",
|
58
|
+
" 80 That is betwi[30m[43mxt a husband and his wife[0m?",
|
59
|
+
"[1m/proj/org/incava/glark/test/resources/canterbury/prologue.txt[0m",
|
60
|
+
" 187 He gave not of the te[30m[43mxt a pulled he[0mn,",
|
61
|
+
" 192 This ilke te[30m[43mxt held he not worth an oyste[0mr;",
|
62
|
+
" 291 Betwi[30m[43mxte Middleburg and Orewe[0mll",
|
63
|
+
"[1m/proj/org/incava/glark/test/resources/rcfile.txt[0m",
|
64
|
+
" 10 te[30m[43mxt-color-3: underline mage[0mnta",
|
65
|
+
]
|
66
|
+
run_app_test expected, [ '-r', '--skip-dirpath', 'test/glark', 'xt.*e' ], *dirnames
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'glark/app/tc'
|
5
|
+
|
6
|
+
module Glark
|
7
|
+
class ExcludeMatchingTestCase < AppTestCase
|
8
|
+
def test_simple
|
9
|
+
dirname = '/proj/org/incava/glark/test/resources'
|
10
|
+
expected = [
|
11
|
+
"[1m/proj/org/incava/glark/test/resources/canterbury/prologue.txt[0m",
|
12
|
+
" 187 He gave not of the [30m[43mtext[0m a pulled hen,",
|
13
|
+
" 192 This ilke [30m[43mtext[0m held he not worth an oyster;",
|
14
|
+
"[1m/proj/org/incava/glark/test/resources/rcfile.txt[0m",
|
15
|
+
" 10 [30m[43mtext[0m-color-3: underline magenta",
|
16
|
+
]
|
17
|
+
run_app_test expected, [ '-r', '--exclude-matching', 'text' ], dirname
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'glark/app/tc'
|
5
|
+
|
6
|
+
module Glark
|
7
|
+
class ExtTestCase < AppTestCase
|
8
|
+
def test_match_single
|
9
|
+
dirname = '/proj/org/incava/glark/test/resources'
|
10
|
+
expected = [
|
11
|
+
"[1m/proj/org/incava/glark/test/resources/add.rb[0m",
|
12
|
+
" 5 def ini[30m[43mtialize[0m x, y",
|
13
|
+
"[1m/proj/org/incava/glark/test/resources/greet.rb[0m",
|
14
|
+
" 8 def ini[30m[43mtialize name[0m",
|
15
|
+
" 9 pu[30m[43mts \"hello, \" + name[0m",
|
16
|
+
" 13 Gree[30m[43mt.ne[0mw ARGV.shift || \"world\"",
|
17
|
+
]
|
18
|
+
run_app_test expected, [ '-r', '--match-ext', 'rb', 't.*e' ], dirname
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_not_single
|
22
|
+
dirname = '/proj/org/incava/glark/test/resources'
|
23
|
+
expected = [
|
24
|
+
"[1m/proj/org/incava/glark/test/resources/canterbury/franklin/prologue.txt[0m",
|
25
|
+
" 60 Have me e[30m[43mxcused of my[0m rude speech.",
|
26
|
+
"[1m/proj/org/incava/glark/test/resources/canterbury/franklin/tale.txt[0m",
|
27
|
+
" 184 And this was on the si[30m[43mxth morrow of May[0m,",
|
28
|
+
" 560 Neither his collect, nor his e[30m[43mxpanse y[0mears,",
|
29
|
+
" 706 Why should I more e[30m[43mxamples hereof say[0mn?",
|
30
|
+
" 813 Than to depart the love betwi[30m[43mxt y[0mou two.",
|
31
|
+
"[1m/proj/org/incava/glark/test/resources/canterbury/prologue.txt[0m",
|
32
|
+
" 192 This ilke te[30m[43mxt held he not worth an oy[0mster;",
|
33
|
+
]
|
34
|
+
run_app_test expected, [ '-r', '--skip-ext', 'rb', 'x.*y' ], dirname
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_match_multiple
|
38
|
+
dirname = '/proj/org/incava/glark/test/resources'
|
39
|
+
expected = [
|
40
|
+
"[1m/proj/org/incava/glark/test/resources/add.rb[0m",
|
41
|
+
" 5 def initialize [30m[43mx, y[0m",
|
42
|
+
" 6 puts [30m[43mx.to_s + \" + \" + y.to_s + \" = \" + (x.to_i + y[0m.to_i).to_s",
|
43
|
+
"[1m/proj/org/incava/glark/test/resources/canterbury/franklin/prologue.txt[0m",
|
44
|
+
" 60 Have me e[30m[43mxcused of my[0m rude speech.",
|
45
|
+
"[1m/proj/org/incava/glark/test/resources/canterbury/franklin/tale.txt[0m",
|
46
|
+
" 184 And this was on the si[30m[43mxth morrow of May[0m,",
|
47
|
+
" 560 Neither his collect, nor his e[30m[43mxpanse y[0mears,",
|
48
|
+
" 706 Why should I more e[30m[43mxamples hereof say[0mn?",
|
49
|
+
" 813 Than to depart the love betwi[30m[43mxt y[0mou two.",
|
50
|
+
"[1m/proj/org/incava/glark/test/resources/canterbury/prologue.txt[0m",
|
51
|
+
" 192 This ilke te[30m[43mxt held he not worth an oy[0mster;",
|
52
|
+
]
|
53
|
+
run_app_test expected, [ '-r', '--match-ext', 'rb', '--match-ext', 'txt', 'x.*y' ], dirname
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_not_multiple
|
57
|
+
dirname = '/proj/org/incava/glark/test/resources'
|
58
|
+
expected = [
|
59
|
+
"[1m/proj/org/incava/glark/test/resources/cat.pl[0m",
|
60
|
+
" 6 [30m[43mprint[0m <>;",
|
61
|
+
]
|
62
|
+
run_app_test expected, [ '-r', '--skip-ext', 'rb', '--not-ext', 'txt', 'p.*t' ], dirname
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'glark/app/tc'
|
5
|
+
require 'glark/util/io/filter/criteria'
|
6
|
+
require 'glark/input/filter/filter'
|
7
|
+
|
8
|
+
module Glark
|
9
|
+
class CriteriaTestCase < AppTestCase
|
10
|
+
def test_positive_one_match
|
11
|
+
crit = Criteria.new
|
12
|
+
crit.add :name, :positive, BaseNameFilter.new('foo.txt')
|
13
|
+
|
14
|
+
assert crit.match?(Pathname.new '/path/to/foo.txt')
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_positive_one_nomatch
|
18
|
+
crit = Criteria.new
|
19
|
+
crit.add :name, :positive, BaseNameFilter.new('foo.txt')
|
20
|
+
|
21
|
+
assert !crit.match?(Pathname.new '/path/to/bar.txt')
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_negative_one_match
|
25
|
+
crit = Criteria.new
|
26
|
+
crit.add :name, :negative, BaseNameFilter.new('foo.txt')
|
27
|
+
|
28
|
+
assert !crit.match?(Pathname.new '/path/to/foo.txt')
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_negative_one_nomatch
|
32
|
+
crit = Criteria.new
|
33
|
+
crit.add :name, :negative, BaseNameFilter.new('foo.txt')
|
34
|
+
|
35
|
+
assert crit.match?(Pathname.new '/path/to/bar.txt')
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_positive_two_match
|
39
|
+
crit = Criteria.new
|
40
|
+
crit.add :name, :positive, BaseNameFilter.new(%r{foo.*})
|
41
|
+
crit.add :ext, :positive, ExtFilter.new('txt')
|
42
|
+
|
43
|
+
assert crit.match?(Pathname.new '/path/to/foo.txt')
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_positive_two_nomatch
|
47
|
+
crit = Criteria.new
|
48
|
+
crit.add :name, :positive, BaseNameFilter.new(%r{foo.*})
|
49
|
+
crit.add :ext, :positive, ExtFilter.new('rb')
|
50
|
+
|
51
|
+
assert crit.match?(Pathname.new '/path/to/foo.rb')
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_positive_negative_match
|
55
|
+
crit = Criteria.new
|
56
|
+
crit.add :name, :positive, BaseNameFilter.new(%r{foo.*})
|
57
|
+
crit.add :ext, :negative, ExtFilter.new('txt')
|
58
|
+
|
59
|
+
assert crit.match?(Pathname.new '/path/to/foo.rb')
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_positive_negative_nomatch
|
63
|
+
crit = Criteria.new
|
64
|
+
crit.add :name, :positive, BaseNameFilter.new(%r{foo.*})
|
65
|
+
crit.add :ext, :negative, ExtFilter.new('rb')
|
66
|
+
|
67
|
+
assert !crit.match?(Pathname.new '/path/to/foo.rb')
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_find_by_class
|
71
|
+
fl = Criteria.new
|
72
|
+
bnf = BaseNameFilter.new '.svn'
|
73
|
+
fl.add :name, :negative, bnf
|
74
|
+
assert_equal bnf.object_id, fl.find_by_class(:name, :negative, BaseNameFilter).object_id
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_add
|
78
|
+
fl = Criteria.new
|
79
|
+
svnbnf = BaseNameFilter.new '.svn'
|
80
|
+
fl.add :name, :negative, svnbnf
|
81
|
+
bldbnf = BaseNameFilter.new 'build'
|
82
|
+
fl.add :name, :negative, bldbnf
|
83
|
+
|
84
|
+
slf = SizeLimitFilter.new 1000
|
85
|
+
fl.add :size, :negative, slf
|
86
|
+
|
87
|
+
extf = ExtFilter.new 'rb'
|
88
|
+
fl.add :ext, :positive, extf
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|