glark 1.9.0 → 1.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. data/bin/glark +2 -2
  2. data/lib/glark.rb +1 -1
  3. data/lib/glark/app/app.rb +48 -0
  4. data/lib/glark/app/help.rb +103 -0
  5. data/lib/glark/app/info/options.rb +84 -0
  6. data/lib/glark/app/options.rb +201 -0
  7. data/lib/glark/app/rcfile.rb +49 -0
  8. data/lib/glark/app/runner.rb +140 -0
  9. data/lib/glark/app/spec.rb +19 -0
  10. data/lib/glark/input/filter/criteria_opts.rb +41 -0
  11. data/lib/glark/input/filter/dir_criteria_opts.rb +37 -0
  12. data/lib/glark/input/filter/file_criteria_opts.rb +33 -0
  13. data/lib/glark/input/filter/filter.rb +59 -0
  14. data/lib/glark/input/filter/options.rb +171 -0
  15. data/lib/glark/input/options.rb +120 -0
  16. data/lib/glark/input/range.rb +104 -0
  17. data/lib/glark/input/spec.rb +39 -0
  18. data/lib/glark/io/file/archive_file.rb +64 -0
  19. data/lib/glark/io/file/binary_file.rb +19 -0
  20. data/lib/glark/io/file/file.rb +57 -0
  21. data/lib/glark/io/file/gz_file.rb +21 -0
  22. data/lib/glark/io/file/tar_file.rb +35 -0
  23. data/lib/glark/io/file/tar_gz_file.rb +52 -0
  24. data/lib/glark/io/file/zip_file.rb +39 -0
  25. data/lib/glark/match/and.rb +83 -0
  26. data/lib/glark/match/and_distance.rb +58 -0
  27. data/lib/glark/match/compound.rb +34 -0
  28. data/lib/glark/match/expression.rb +63 -0
  29. data/lib/glark/match/factory.rb +173 -0
  30. data/lib/glark/match/ior.rb +20 -0
  31. data/lib/glark/match/options.rb +74 -0
  32. data/lib/glark/match/or.rb +41 -0
  33. data/lib/glark/match/re.rb +81 -0
  34. data/lib/glark/match/re_factory.rb +44 -0
  35. data/lib/glark/match/spec.rb +59 -0
  36. data/lib/glark/match/xor.rb +20 -0
  37. data/lib/glark/output/binary_file_summary.rb +17 -0
  38. data/lib/glark/output/common.rb +43 -0
  39. data/lib/glark/output/context.rb +57 -0
  40. data/lib/glark/output/count.rb +26 -0
  41. data/lib/glark/output/file_header.rb +20 -0
  42. data/lib/glark/output/file_name_only.rb +35 -0
  43. data/lib/glark/output/formatted.rb +22 -0
  44. data/lib/glark/output/glark_count.rb +23 -0
  45. data/lib/glark/output/glark_format.rb +62 -0
  46. data/lib/glark/output/glark_lines.rb +36 -0
  47. data/lib/glark/output/grep_count.rb +18 -0
  48. data/lib/glark/output/grep_lines.rb +42 -0
  49. data/lib/glark/output/line_status.rb +46 -0
  50. data/lib/glark/output/lines.rb +100 -0
  51. data/lib/glark/output/match_list.rb +15 -0
  52. data/lib/glark/output/options.rb +103 -0
  53. data/lib/glark/output/results.rb +23 -0
  54. data/lib/glark/output/spec.rb +105 -0
  55. data/lib/glark/output/unfiltered_lines.rb +28 -0
  56. data/lib/glark/util/colors/options.rb +143 -0
  57. data/lib/glark/util/colors/spec.rb +21 -0
  58. data/lib/glark/util/highlight.rb +108 -0
  59. data/lib/glark/util/io/depth.rb +29 -0
  60. data/lib/glark/util/io/fileset.rb +162 -0
  61. data/lib/glark/util/io/filter/criteria.rb +49 -0
  62. data/lib/glark/util/io/filter/filter.rb +10 -0
  63. data/lib/glark/util/io/lines.rb +117 -0
  64. data/lib/glark/util/option.rb +34 -0
  65. data/lib/glark/util/options.rb +12 -0
  66. data/lib/glark/util/optutil.rb +69 -0
  67. data/lib/glark/util/timestamper.rb +18 -0
  68. data/man/glark.1 +1134 -0
  69. data/test/glark/app/and_test.rb +82 -0
  70. data/test/glark/app/compound_test.rb +33 -0
  71. data/test/glark/app/context_test.rb +43 -0
  72. data/test/glark/app/count_test.rb +89 -0
  73. data/test/glark/app/dump_test.rb +16 -0
  74. data/test/glark/app/expression_file_test.rb +22 -0
  75. data/test/glark/app/extended_regexp_test.rb +17 -0
  76. data/test/glark/app/extract_matches_test.rb +27 -0
  77. data/test/glark/app/files_with_match_test.rb +32 -0
  78. data/test/glark/app/files_without_match_test.rb +26 -0
  79. data/test/glark/app/filter_test.rb +118 -0
  80. data/test/glark/app/highlight_test.rb +78 -0
  81. data/test/glark/app/ignore_case_test.rb +22 -0
  82. data/test/glark/app/invert_test.rb +49 -0
  83. data/test/glark/app/ior_test.rb +21 -0
  84. data/test/glark/app/label_test.rb +28 -0
  85. data/test/glark/app/line_number_color_test.rb +42 -0
  86. data/test/glark/app/line_numbers_test.rb +42 -0
  87. data/test/glark/app/match_limit_test.rb +49 -0
  88. data/test/glark/app/options_test.rb +722 -0
  89. data/test/glark/app/range_test.rb +101 -0
  90. data/test/glark/app/rcfile_test.rb +113 -0
  91. data/test/glark/app/record_separator_test.rb +32 -0
  92. data/test/glark/app/regexp_test.rb +48 -0
  93. data/test/glark/app/tc.rb +92 -0
  94. data/test/glark/app/text_color_test.rb +31 -0
  95. data/test/glark/app/whole_lines_test.rb +17 -0
  96. data/test/glark/app/whole_words_test.rb +42 -0
  97. data/test/glark/app/xor_test.rb +19 -0
  98. data/test/glark/input/binary_file_test.rb +0 -0
  99. data/test/glark/input/directory_test.rb +202 -0
  100. data/test/glark/input/dirname_test.rb +69 -0
  101. data/test/glark/input/exclude_matching_test.rb +20 -0
  102. data/test/glark/input/ext_test.rb +65 -0
  103. data/test/glark/input/filter/criteria_test.rb +91 -0
  104. data/test/glark/input/filter/filter_spec_test.rb +27 -0
  105. data/test/glark/input/filter/filter_test.rb +21 -0
  106. data/test/glark/input/name_test.rb +75 -0
  107. data/test/glark/input/path_test.rb +72 -0
  108. data/test/glark/input/range_test.rb +82 -0
  109. data/test/glark/input/size_limit_test.rb +51 -0
  110. data/test/glark/input/split_as_path_test.rb +28 -0
  111. data/test/glark/match_test.rb +192 -0
  112. data/test/glark/resources.rb +21 -0
  113. data/test/glark/tc.rb +37 -0
  114. data/test/resources/add.rb +10 -0
  115. data/test/resources/echo.rb +2 -0
  116. data/test/resources/greet.rb +13 -0
  117. metadata +198 -28
  118. data/README +0 -0
  119. data/bin/jlark +0 -63
  120. data/lib/glark/expression.rb +0 -440
  121. data/lib/glark/exprfactory.rb +0 -248
  122. data/lib/glark/glark.rb +0 -297
  123. data/lib/glark/help.rb +0 -85
  124. data/lib/glark/input.rb +0 -183
  125. data/lib/glark/options.rb +0 -757
  126. data/lib/glark/output.rb +0 -266
  127. data/test/lib/glark/glark_test.rb +0 -317
  128. data/test/lib/glark/options_test.rb +0 -891
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'glark/app/tc'
5
+
6
+ module Glark
7
+ class AndTestCase < AppTestCase
8
+ def test_one_line
9
+ fname = '/proj/org/incava/glark/test/resources/textfile.txt'
10
+ expected = [
11
+ " 6 -rw-r--r-- 1 jpace jpace 63290 2010-12-04 15:24 05-TheManOfLawsTale.txt",
12
+ " 10 -rw-r--r-- 1 jpace jpace 64791 2010-12-04 15:24 09-TheClerksTale.txt",
13
+ " 11 -rw-r--r-- 1 jpace jpace 65852 2010-12-04 15:24 10-TheMerchantsTale.txt",
14
+ ]
15
+ run_app_test expected, [ '--and', '\b6\d{4}\b', 'The.*Tale' ], fname
16
+ end
17
+
18
+ def test_multi_line
19
+ fname = '/proj/org/incava/glark/test/resources/textfile.txt'
20
+ expected = [
21
+ " 12 -rw-r--r-- 1 jpace jpace 42282 2010-12-04 15:24 11-TheSquiresTale.txt",
22
+ " 13 -rw-r--r-- 1 jpace jpace 51996 2010-12-04 15:24 12-TheFranklinsTale.txt",
23
+ " 14 -rw-r--r-- 1 jpace jpace 15615 2010-12-04 15:24 13-TheDoctorsTale.txt",
24
+ " 15 -rw-r--r-- 1 jpace jpace 39546 2010-12-04 15:24 14-ThePardonersTale.txt",
25
+ " 16 -rw-r--r-- 1 jpace jpace 25163 2010-12-04 15:24 15-TheShipmansTale.txt",
26
+ " 22 -rw-r--r-- 1 jpace jpace 30734 2010-12-04 15:24 21-TheSecondNunsTale.txt",
27
+ " 23 -rw-r--r-- 1 jpace jpace 52953 2010-12-04 15:24 22-TheCanonsYeomansTale.txt",
28
+ " 24 -rw-r--r-- 1 jpace jpace 21141 2010-12-04 15:24 23-TheManciplesTale.txt",
29
+ " 25 -rw-r--r-- 1 jpace jpace 58300 2010-12-04 15:24 24-TheParsonsTale.txt",
30
+ ]
31
+ run_app_test expected, [ '--and=3', '\b5\d{4}\b', 'TheS.*Tale' ], fname
32
+ end
33
+
34
+ def test_infinite_distance
35
+ fname = '/proj/org/incava/glark/test/resources/textfile.txt'
36
+ expected = [
37
+ " 2 -rw-r--r-- 1 jpace jpace 126084 2010-12-04 15:24 01-TheKnightsTale.txt",
38
+ " 3 -rw-r--r-- 1 jpace jpace 45450 2010-12-04 15:24 02-TheMillersTale.txt",
39
+ " 4 -rw-r--r-- 1 jpace jpace 29296 2010-12-04 15:24 03-TheReevesTale.txt",
40
+ " 5 -rw-r--r-- 1 jpace jpace 6525 2010-12-04 15:24 04-TheCooksTale.txt",
41
+ " 6 -rw-r--r-- 1 jpace jpace 63290 2010-12-04 15:24 05-TheManOfLawsTale.txt",
42
+ " 7 -rw-r--r-- 1 jpace jpace 71054 2010-12-04 15:24 06-TheWifeOfBathsTale.txt",
43
+ " 8 -rw-r--r-- 1 jpace jpace 22754 2010-12-04 15:24 07-TheFriarsTale.txt",
44
+ " 9 -rw-r--r-- 1 jpace jpace 35994 2010-12-04 15:24 08-TheSompnoursTale.txt",
45
+ " 10 -rw-r--r-- 1 jpace jpace 64791 2010-12-04 15:24 09-TheClerksTale.txt",
46
+ " 11 -rw-r--r-- 1 jpace jpace 65852 2010-12-04 15:24 10-TheMerchantsTale.txt",
47
+ " 12 -rw-r--r-- 1 jpace jpace 42282 2010-12-04 15:24 11-TheSquiresTale.txt",
48
+ " 13 -rw-r--r-- 1 jpace jpace 51996 2010-12-04 15:24 12-TheFranklinsTale.txt",
49
+ " 14 -rw-r--r-- 1 jpace jpace 15615 2010-12-04 15:24 13-TheDoctorsTale.txt",
50
+ " 15 -rw-r--r-- 1 jpace jpace 39546 2010-12-04 15:24 14-ThePardonersTale.txt",
51
+ " 16 -rw-r--r-- 1 jpace jpace 25163 2010-12-04 15:24 15-TheShipmansTale.txt",
52
+ " 17 -rw-r--r-- 1 jpace jpace 14979 2010-12-04 15:24 16-ThePrioresssTale.txt",
53
+ " 18 -rw-r--r-- 1 jpace jpace 14834 2010-12-04 15:24 17-ChaucersTaleOfSirThopas.txt",
54
+ " 19 -rw-r--r-- 1 jpace jpace 43249 2010-12-04 15:24 18-ChaucersTaleOfMeliboeus.txt",
55
+ " 20 -rw-r--r-- 1 jpace jpace 49747 2010-12-04 15:24 19-TheMonksTale.txt",
56
+ " 21 -rw-r--r-- 1 jpace jpace 45326 2010-12-04 15:24 20-TheNunsPriestsTale.txt",
57
+ " 22 -rw-r--r-- 1 jpace jpace 30734 2010-12-04 15:24 21-TheSecondNunsTale.txt",
58
+ " 23 -rw-r--r-- 1 jpace jpace 52953 2010-12-04 15:24 22-TheCanonsYeomansTale.txt",
59
+ ]
60
+ run_app_test expected, [ '--and=-1', '\b529\d{2}\b', 'TheKni.*Tale' ], fname
61
+ end
62
+
63
+ def test_multi_line_grep_one_file
64
+ fname = '/proj/org/incava/glark/test/resources/textfile.txt'
65
+ expected = [
66
+ " -rw-r--r-- 1 jpace jpace 42282 2010-12-04 15:24 11-TheSquiresTale.txt",
67
+ " -rw-r--r-- 1 jpace jpace 30734 2010-12-04 15:24 21-TheSecondNunsTale.txt",
68
+ " -rw-r--r-- 1 jpace jpace 51996 2010-12-04 15:24 12-TheFranklinsTale.txt",
69
+ ]
70
+ run_app_test expected, [ '-g', '--and=3', '\b5\d{4}\b', 'TheS.*Tale' ], fname
71
+ end
72
+
73
+ def test_multi_line_grep_two_files
74
+ fnames = [ '/proj/org/incava/glark/test/resources/textfile.txt', '/proj/org/incava/glark/test/resources/filelist.txt' ]
75
+ expected = [
76
+ "/proj/org/incava/glark/test/resources/textfile.txt: -rw-r--r-- 1 jpace jpace 30734 2010-12-04 15:24 21-TheSecondNunsTale.txt",
77
+ "/proj/org/incava/glark/test/resources/filelist.txt:21-The_Second_Nuns_Tale.txt",
78
+ ]
79
+ run_app_test expected, [ '-g', '--and=3', '\b21\b', 'The.*Can.*Tale' ], *fnames
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'glark/app/tc'
5
+
6
+ module Glark
7
+ class CompoundTestCase < AppTestCase
8
+ def test_hardly_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-TheMillersTale.txt",
12
+ " 4 -rw-r--r-- 1 jpace jpace 29296 2010-12-04 15:24 03-TheReevesTale.txt",
13
+ " 5 -rw-r--r-- 1 jpace jpace 6525 2010-12-04 15:24 04-TheCooksTale.txt",
14
+ " 6 -rw-r--r-- 1 jpace jpace 63290 2010-12-04 15:24 05-TheManOfLawsTale.txt",
15
+ " 7 -rw-r--r-- 1 jpace jpace 71054 2010-12-04 15:24 06-TheWifeOfBathsTale.txt",
16
+ " 8 -rw-r--r-- 1 jpace jpace 22754 2010-12-04 15:24 07-TheFriarsTale.txt",
17
+ " 9 -rw-r--r-- 1 jpace jpace 35994 2010-12-04 15:24 08-TheSompnoursTale.txt",
18
+ " 10 -rw-r--r-- 1 jpace jpace 64791 2010-12-04 15:24 09-TheClerksTale.txt",
19
+ " 11 -rw-r--r-- 1 jpace jpace 65852 2010-12-04 15:24 10-TheMerchantsTale.txt",
20
+ " 12 -rw-r--r-- 1 jpace jpace 42282 2010-12-04 15:24 11-TheSquiresTale.txt",
21
+ " 13 -rw-r--r-- 1 jpace jpace 51996 2010-12-04 15:24 12-TheFranklinsTale.txt",
22
+ " 18 -rw-r--r-- 1 jpace jpace 14834 2010-12-04 15:24 17-ChaucersTaleOfSirThopas.txt",
23
+ " 19 -rw-r--r-- 1 jpace jpace 43249 2010-12-04 15:24 18-ChaucersTaleOfMeliboeus.txt",
24
+ " 20 -rw-r--r-- 1 jpace jpace 49747 2010-12-04 15:24 19-TheMonksTale.txt",
25
+ " 21 -rw-r--r-- 1 jpace jpace 45326 2010-12-04 15:24 20-TheNunsPriestsTale.txt",
26
+ " 22 -rw-r--r-- 1 jpace jpace 30734 2010-12-04 15:24 21-TheSecondNunsTale.txt",
27
+ " 23 -rw-r--r-- 1 jpace jpace 52953 2010-12-04 15:24 22-TheCanonsYeomansTale.txt",
28
+ " 24 -rw-r--r-- 1 jpace jpace 21141 2010-12-04 15:24 23-TheManciplesTale.txt",
29
+ ]
30
+ run_app_test expected, [ '--and=3', '--or', '\b6\d{4}\b', '\b\d{4}4\b', '--or', 'TheF.*', 'TheM.*Tale' ], fname
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'glark/app/tc'
5
+
6
+ module Glark
7
+ class ContextTestCase < AppTestCase
8
+ def test_context
9
+ fname = '/proj/org/incava/glark/test/resources/textfile.txt'
10
+ expected = [
11
+ " 11 - -rw-r--r-- 1 jpace jpace 65852 2010-12-04 15:24 10-TheMerchantsTale.txt",
12
+ " 12 - -rw-r--r-- 1 jpace jpace 42282 2010-12-04 15:24 11-TheSquiresTale.txt",
13
+ " 13 - -rw-r--r-- 1 jpace jpace 51996 2010-12-04 15:24 12-TheFranklinsTale.txt",
14
+ " 14 : -rw-r--r-- 1 jpace jpace 15615 2010-12-04 15:24 13-TheDoctorsTale.txt",
15
+ " 15 + -rw-r--r-- 1 jpace jpace 39546 2010-12-04 15:24 14-ThePardonersTale.txt",
16
+ " 16 + -rw-r--r-- 1 jpace jpace 25163 2010-12-04 15:24 15-TheShipmansTale.txt",
17
+ " 17 + -rw-r--r-- 1 jpace jpace 14979 2010-12-04 15:24 16-ThePrioresssTale.txt",
18
+ ]
19
+ run_app_test expected, %w{ -3 TheDoc }, fname
20
+ end
21
+
22
+ def test_after
23
+ fname = '/proj/org/incava/glark/test/resources/textfile.txt'
24
+ expected = [
25
+ " 14 : -rw-r--r-- 1 jpace jpace 15615 2010-12-04 15:24 13-TheDoctorsTale.txt",
26
+ " 15 + -rw-r--r-- 1 jpace jpace 39546 2010-12-04 15:24 14-ThePardonersTale.txt",
27
+ " 16 + -rw-r--r-- 1 jpace jpace 25163 2010-12-04 15:24 15-TheShipmansTale.txt",
28
+ ]
29
+ run_app_test expected, %w{ --after-context 2 TheDoc }, fname
30
+ end
31
+
32
+ def test_before
33
+ fname = '/proj/org/incava/glark/test/resources/textfile.txt'
34
+ expected = [
35
+ " 11 - -rw-r--r-- 1 jpace jpace 65852 2010-12-04 15:24 10-TheMerchantsTale.txt",
36
+ " 12 - -rw-r--r-- 1 jpace jpace 42282 2010-12-04 15:24 11-TheSquiresTale.txt",
37
+ " 13 - -rw-r--r-- 1 jpace jpace 51996 2010-12-04 15:24 12-TheFranklinsTale.txt",
38
+ " 14 : -rw-r--r-- 1 jpace jpace 15615 2010-12-04 15:24 13-TheDoctorsTale.txt",
39
+ ]
40
+ run_app_test expected, %w{ --before-context 3 TheDoc }, fname
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'glark/app/tc'
5
+
6
+ module Glark
7
+ class CountTestCase < AppTestCase
8
+ def test_one_file
9
+ fname = '/proj/org/incava/glark/test/resources/spaces.txt'
10
+ expected = [
11
+ " 13",
12
+ ]
13
+ run_app_test expected, [ '--count', '\wa\w+s' ], fname
14
+ end
15
+
16
+ def test_two_files_one_matches
17
+ fnames = [ '/proj/org/incava/glark/test/resources/textfile.txt', '/proj/org/incava/glark/test/resources/filelist.txt' ]
18
+ expected = [
19
+ "/proj/org/incava/glark/test/resources/textfile.txt",
20
+ " 2",
21
+ ]
22
+ run_app_test expected, [ '--count', '2 ' ], *fnames
23
+ end
24
+
25
+ def test_two_files_both_match
26
+ fnames = [ '/proj/org/incava/glark/test/resources/textfile.txt', '/proj/org/incava/glark/test/resources/filelist.txt' ]
27
+ expected = [
28
+ "/proj/org/incava/glark/test/resources/textfile.txt",
29
+ " 13",
30
+ "/proj/org/incava/glark/test/resources/filelist.txt",
31
+ " 2",
32
+ ]
33
+ run_app_test expected, [ '--count', '6.*The' ], *fnames
34
+ end
35
+
36
+ def test_grep_one_file
37
+ fnames = [ '/proj/org/incava/glark/test/resources/spaces.txt' ]
38
+ expected = [
39
+ "2",
40
+ ]
41
+ run_app_test expected, [ '-g', '--count', '6.*The' ], *fnames
42
+ end
43
+
44
+ def test_grep_two_files_one_matches
45
+ fnames = [ '/proj/org/incava/glark/test/resources/textfile.txt', '/proj/org/incava/glark/test/resources/filelist.txt' ]
46
+ expected = [
47
+ "/proj/org/incava/glark/test/resources/textfile.txt:2",
48
+ ]
49
+ run_app_test expected, [ '-g', '--count', '2 ' ], *fnames
50
+ end
51
+
52
+ def test_grep_two_files_both_match
53
+ fnames = [ '/proj/org/incava/glark/test/resources/textfile.txt', '/proj/org/incava/glark/test/resources/filelist.txt' ]
54
+ expected = [
55
+ "/proj/org/incava/glark/test/resources/textfile.txt:13",
56
+ "/proj/org/incava/glark/test/resources/filelist.txt:2"
57
+ ]
58
+ run_app_test expected, [ '-g', '--count', '6.*The' ], *fnames
59
+ end
60
+
61
+ def test_grep_one_file_invert
62
+ fnames = [ '/proj/org/incava/glark/test/resources/spaces.txt' ]
63
+ expected = [
64
+ "24",
65
+ ]
66
+ run_app_test expected, [ '--invert-match', '-g', '--count', '6.*The' ], *fnames
67
+ end
68
+
69
+ def test_grep_two_files_invert_one_matches
70
+ fnames = [ '/proj/org/incava/glark/test/resources/textfile.txt', '/proj/org/incava/glark/test/resources/filelist.txt' ]
71
+ expected = [
72
+ "/proj/org/incava/glark/test/resources/textfile.txt:24",
73
+ "/proj/org/incava/glark/test/resources/filelist.txt:26",
74
+ ]
75
+ run_app_test expected, [ '--invert-match', '-g', '--count', '2 ' ], *fnames
76
+ end
77
+
78
+ def test_glark_two_files_invert_both_match
79
+ fnames = [ '/proj/org/incava/glark/test/resources/textfile.txt', '/proj/org/incava/glark/test/resources/filelist.txt' ]
80
+ expected = [
81
+ "/proj/org/incava/glark/test/resources/textfile.txt",
82
+ " 13",
83
+ "/proj/org/incava/glark/test/resources/filelist.txt",
84
+ " 24",
85
+ ]
86
+ run_app_test expected, [ '--invert-match', '--count', '6.*The' ], *fnames
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'glark/app/tc'
5
+
6
+ module Glark
7
+ class DumpTestCase < AppTestCase
8
+ def test_dump
9
+ fname = ''
10
+ expected = [
11
+ " 13",
12
+ ]
13
+ # run_app_test expected, [ '--dump' ], fname
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'glark/app/tc'
5
+
6
+ module Glark
7
+ class ExpressionFileTestCase < AppTestCase
8
+ def test_simple
9
+ infile = '/proj/org/incava/glark/test/resources/expressions.txt'
10
+ file = '/proj/org/incava/glark/test/resources/textfile.txt'
11
+ expected = [
12
+ " 3 -rw-r--r-- 1 jpace jpace 45450 2010-12-04 15:24 02-TheMillersTale.txt",
13
+ " 6 -rw-r--r-- 1 jpace jpace 63290 2010-12-04 15:24 05-TheManOfLawsTale.txt",
14
+ " 10 -rw-r--r-- 1 jpace jpace 64791 2010-12-04 15:24 09-TheClerksTale.txt",
15
+ " 11 -rw-r--r-- 1 jpace jpace 65852 2010-12-04 15:24 10-TheMerchantsTale.txt",
16
+ " 20 -rw-r--r-- 1 jpace jpace 49747 2010-12-04 15:24 19-TheMonksTale.txt",
17
+ " 24 -rw-r--r-- 1 jpace jpace 21141 2010-12-04 15:24 23-TheManciplesTale.txt",
18
+ ]
19
+ run_app_test expected, [ '--file', infile ], file
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'glark/app/tc'
5
+
6
+ module Glark
7
+ class ExtendedRegexpTestCase < AppTestCase
8
+ def test_simple
9
+ fname = '/proj/org/incava/glark/test/resources/textfile.txt'
10
+ expected = [
11
+ " 15 -rw-r--r-- 1 jpace jpace 39546 2010-12-04 15:24 14-ThePardonersTale.txt",
12
+ " 25 -rw-r--r-- 1 jpace jpace 58300 2010-12-04 15:24 24-TheParsonsTale.txt",
13
+ ]
14
+ run_app_test expected, [ '--extended', 'The P a r' ], fname
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'glark/app/tc'
5
+
6
+ module Glark
7
+ class ExtractMatchesTestCase < AppTestCase
8
+ def test_simple
9
+ fname = '/proj/org/incava/glark/test/resources/textfile.txt'
10
+ expected = [
11
+ " 1 ThePrologue",
12
+ " 3 TheMillersTale",
13
+ " 5 TheCooksTale",
14
+ " 6 TheManOfLawsTale",
15
+ " 10 TheClerksTale",
16
+ " 11 TheMerchantsTale",
17
+ " 15 ThePardonersTale",
18
+ " 17 ThePrioresssTale",
19
+ " 20 TheMonksTale",
20
+ " 23 TheCanonsYeomansTale",
21
+ " 24 TheManciplesTale",
22
+ " 25 TheParsonsTale",
23
+ ]
24
+ run_app_test expected, %w{ --extract-matches The[MCP]\w+ }, fname
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'glark/app/tc'
5
+
6
+ module Glark
7
+ class FilesWithMatchTestCase < AppTestCase
8
+ def test_one_of_one
9
+ file = '/proj/org/incava/glark/test/resources/textfile.txt'
10
+ expected = [ file ]
11
+ run_app_test expected, [ '-l', 'TheM\w+Tale' ], file
12
+ end
13
+
14
+ def test_one_of_two
15
+ files = [ '/proj/org/incava/glark/test/resources/textfile.txt', '/proj/org/incava/glark/test/resources/filelist.txt' ]
16
+ expected = [ files[0] ]
17
+ run_app_test expected, [ '-l', 'TheM\w+Tale' ], *files
18
+ end
19
+
20
+ def test_two_of_two
21
+ files = [ '/proj/org/incava/glark/test/resources/textfile.txt', '/proj/org/incava/glark/test/resources/filelist.txt' ]
22
+ expected = files
23
+ run_app_test expected, [ '-l', 'The.*M\w+Tale' ], *files
24
+ end
25
+
26
+ def test_null_two
27
+ files = [ '/proj/org/incava/glark/test/resources/textfile.txt', '/proj/org/incava/glark/test/resources/filelist.txt' ]
28
+ expected = files.collect { |x| "#{x}\000" }.join('')
29
+ run_app_test_exact_output expected, [ '-l', '-Z', 'The.*M\w+Tale' ], *files
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'glark/app/tc'
5
+
6
+ module Glark
7
+ class FilesWithoutMatchTestCase < AppTestCase
8
+ def test_one_of_one
9
+ file = '/proj/org/incava/glark/test/resources/textfile.txt'
10
+ expected = [ file ]
11
+ run_app_test expected, [ '-L', 'TheX\w+Tale' ], file
12
+ end
13
+
14
+ def test_one_of_two
15
+ files = [ '/proj/org/incava/glark/test/resources/textfile.txt', '/proj/org/incava/glark/test/resources/filelist.txt' ]
16
+ expected = [ files[1] ]
17
+ run_app_test expected, [ '-L', 'TheM\w+Tale' ], *files
18
+ end
19
+
20
+ def test_none_of_two
21
+ files = [ '/proj/org/incava/glark/test/resources/textfile.txt', '/proj/org/incava/glark/test/resources/filelist.txt' ]
22
+ expected = [ ]
23
+ run_app_test expected, [ '-L', 'The.*P\w+Tale' ], *files
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,118 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'glark/app/tc'
5
+
6
+ module Glark
7
+ class FilterTestCase < AppTestCase
8
+ def test_one_file_with_matches
9
+ fname = '/proj/org/incava/glark/test/resources/textfile.txt'
10
+ expected = [
11
+ " 1 -rw-r--r-- 1 jpace jpace 52183 2010-12-04 15:24 00-ThePrologue.txt",
12
+ " 2 -rw-r--r-- 1 jpace jpace 126084 2010-12-04 15:24 01-TheKnightsTale.txt",
13
+ " 3 -rw-r--r-- 1 jpace jpace 45450 2010-12-04 15:24 02-TheMillersTale.txt",
14
+ " 4 -rw-r--r-- 1 jpace jpace 29296 2010-12-04 15:24 03-TheReevesTale.txt",
15
+ " 5 -rw-r--r-- 1 jpace jpace 6525 2010-12-04 15:24 04-TheCooksTale.txt",
16
+ " 6 -rw-r--r-- 1 jpace jpace 63290 2010-12-04 15:24 05-TheManOfLawsTale.txt",
17
+ " 7 -rw-r--r-- 1 jpace jpace 71054 2010-12-04 15:24 06-TheWifeOfBathsTale.txt",
18
+ " 8 -rw-r--r-- 1 jpace jpace 22754 2010-12-04 15:24 07-TheFriarsTale.txt",
19
+ " 9 -rw-r--r-- 1 jpace jpace 35994 2010-12-04 15:24 08-TheSompnoursTale.txt",
20
+ " 10 -rw-r--r-- 1 jpace jpace 64791 2010-12-04 15:24 09-TheClerksTale.txt",
21
+ " 11 -rw-r--r-- 1 jpace jpace 65852 2010-12-04 15:24 10-TheMerchantsTale.txt",
22
+ " 12 -rw-r--r-- 1 jpace jpace 42282 2010-12-04 15:24 11-TheSquiresTale.txt",
23
+ " 13 -rw-r--r-- 1 jpace jpace 51996 2010-12-04 15:24 12-TheFranklinsTale.txt",
24
+ " 14 -rw-r--r-- 1 jpace jpace 15615 2010-12-04 15:24 13-TheDoctorsTale.txt",
25
+ " 15 -rw-r--r-- 1 jpace jpace 39546 2010-12-04 15:24 14-ThePardonersTale.txt",
26
+ " 16 -rw-r--r-- 1 jpace jpace 25163 2010-12-04 15:24 15-TheShipmansTale.txt",
27
+ " 17 -rw-r--r-- 1 jpace jpace 14979 2010-12-04 15:24 16-ThePrioresssTale.txt",
28
+ " 18 -rw-r--r-- 1 jpace jpace 14834 2010-12-04 15:24 17-ChaucersTaleOfSirThopas.txt",
29
+ " 19 -rw-r--r-- 1 jpace jpace 43249 2010-12-04 15:24 18-ChaucersTaleOfMeliboeus.txt",
30
+ " 20 -rw-r--r-- 1 jpace jpace 49747 2010-12-04 15:24 19-TheMonksTale.txt",
31
+ " 21 -rw-r--r-- 1 jpace jpace 45326 2010-12-04 15:24 20-TheNunsPriestsTale.txt",
32
+ " 22 -rw-r--r-- 1 jpace jpace 30734 2010-12-04 15:24 21-TheSecondNunsTale.txt",
33
+ " 23 -rw-r--r-- 1 jpace jpace 52953 2010-12-04 15:24 22-TheCanonsYeomansTale.txt",
34
+ " 24 -rw-r--r-- 1 jpace jpace 21141 2010-12-04 15:24 23-TheManciplesTale.txt",
35
+ " 25 -rw-r--r-- 1 jpace jpace 58300 2010-12-04 15:24 24-TheParsonsTale.txt",
36
+ " 26 -rw-r--r-- 1 jpace jpace 3650 2010-12-04 15:24 25-PrecesDeChauceres.txt",
37
+ ]
38
+ run_app_test expected, [ '--no-filter', 'TheS\w+Tale' ], fname
39
+ end
40
+
41
+ def test_one_file_no_matches
42
+ fname = '/proj/org/incava/glark/test/resources/textfile.txt'
43
+ expected = [
44
+ " 1 -rw-r--r-- 1 jpace jpace 52183 2010-12-04 15:24 00-ThePrologue.txt",
45
+ " 2 -rw-r--r-- 1 jpace jpace 126084 2010-12-04 15:24 01-TheKnightsTale.txt",
46
+ " 3 -rw-r--r-- 1 jpace jpace 45450 2010-12-04 15:24 02-TheMillersTale.txt",
47
+ " 4 -rw-r--r-- 1 jpace jpace 29296 2010-12-04 15:24 03-TheReevesTale.txt",
48
+ " 5 -rw-r--r-- 1 jpace jpace 6525 2010-12-04 15:24 04-TheCooksTale.txt",
49
+ " 6 -rw-r--r-- 1 jpace jpace 63290 2010-12-04 15:24 05-TheManOfLawsTale.txt",
50
+ " 7 -rw-r--r-- 1 jpace jpace 71054 2010-12-04 15:24 06-TheWifeOfBathsTale.txt",
51
+ " 8 -rw-r--r-- 1 jpace jpace 22754 2010-12-04 15:24 07-TheFriarsTale.txt",
52
+ " 9 -rw-r--r-- 1 jpace jpace 35994 2010-12-04 15:24 08-TheSompnoursTale.txt",
53
+ " 10 -rw-r--r-- 1 jpace jpace 64791 2010-12-04 15:24 09-TheClerksTale.txt",
54
+ " 11 -rw-r--r-- 1 jpace jpace 65852 2010-12-04 15:24 10-TheMerchantsTale.txt",
55
+ " 12 -rw-r--r-- 1 jpace jpace 42282 2010-12-04 15:24 11-TheSquiresTale.txt",
56
+ " 13 -rw-r--r-- 1 jpace jpace 51996 2010-12-04 15:24 12-TheFranklinsTale.txt",
57
+ " 14 -rw-r--r-- 1 jpace jpace 15615 2010-12-04 15:24 13-TheDoctorsTale.txt",
58
+ " 15 -rw-r--r-- 1 jpace jpace 39546 2010-12-04 15:24 14-ThePardonersTale.txt",
59
+ " 16 -rw-r--r-- 1 jpace jpace 25163 2010-12-04 15:24 15-TheShipmansTale.txt",
60
+ " 17 -rw-r--r-- 1 jpace jpace 14979 2010-12-04 15:24 16-ThePrioresssTale.txt",
61
+ " 18 -rw-r--r-- 1 jpace jpace 14834 2010-12-04 15:24 17-ChaucersTaleOfSirThopas.txt",
62
+ " 19 -rw-r--r-- 1 jpace jpace 43249 2010-12-04 15:24 18-ChaucersTaleOfMeliboeus.txt",
63
+ " 20 -rw-r--r-- 1 jpace jpace 49747 2010-12-04 15:24 19-TheMonksTale.txt",
64
+ " 21 -rw-r--r-- 1 jpace jpace 45326 2010-12-04 15:24 20-TheNunsPriestsTale.txt",
65
+ " 22 -rw-r--r-- 1 jpace jpace 30734 2010-12-04 15:24 21-TheSecondNunsTale.txt",
66
+ " 23 -rw-r--r-- 1 jpace jpace 52953 2010-12-04 15:24 22-TheCanonsYeomansTale.txt",
67
+ " 24 -rw-r--r-- 1 jpace jpace 21141 2010-12-04 15:24 23-TheManciplesTale.txt",
68
+ " 25 -rw-r--r-- 1 jpace jpace 58300 2010-12-04 15:24 24-TheParsonsTale.txt",
69
+ " 26 -rw-r--r-- 1 jpace jpace 3650 2010-12-04 15:24 25-PrecesDeChauceres.txt",
70
+ ]
71
+ run_app_test expected, [ '--no-filter', 'TheX\w+Tale' ], fname
72
+ end
73
+
74
+ def test_two_files
75
+ fnames = [ '/proj/org/incava/glark/test/resources/textfile.txt', '/proj/org/incava/glark/test/resources/04-TheCooksTale.txt' ]
76
+ expected = [
77
+ "/proj/org/incava/glark/test/resources/textfile.txt",
78
+ " 1 -rw-r--r-- 1 jpace jpace 52183 2010-12-04 15:24 00-ThePrologue.txt",
79
+ " 2 -rw-r--r-- 1 jpace jpace 126084 2010-12-04 15:24 01-TheKnightsTale.txt",
80
+ " 3 -rw-r--r-- 1 jpace jpace 45450 2010-12-04 15:24 02-TheMillersTale.txt",
81
+ " 4 -rw-r--r-- 1 jpace jpace 29296 2010-12-04 15:24 03-TheReevesTale.txt",
82
+ " 5 -rw-r--r-- 1 jpace jpace 6525 2010-12-04 15:24 04-TheCooksTale.txt",
83
+ " 6 -rw-r--r-- 1 jpace jpace 63290 2010-12-04 15:24 05-TheManOfLawsTale.txt",
84
+ " 7 -rw-r--r-- 1 jpace jpace 71054 2010-12-04 15:24 06-TheWifeOfBathsTale.txt",
85
+ " 8 -rw-r--r-- 1 jpace jpace 22754 2010-12-04 15:24 07-TheFriarsTale.txt",
86
+ " 9 -rw-r--r-- 1 jpace jpace 35994 2010-12-04 15:24 08-TheSompnoursTale.txt",
87
+ " 10 -rw-r--r-- 1 jpace jpace 64791 2010-12-04 15:24 09-TheClerksTale.txt",
88
+ " 11 -rw-r--r-- 1 jpace jpace 65852 2010-12-04 15:24 10-TheMerchantsTale.txt",
89
+ " 12 -rw-r--r-- 1 jpace jpace 42282 2010-12-04 15:24 11-TheSquiresTale.txt",
90
+ " 13 -rw-r--r-- 1 jpace jpace 51996 2010-12-04 15:24 12-TheFranklinsTale.txt",
91
+ " 14 -rw-r--r-- 1 jpace jpace 15615 2010-12-04 15:24 13-TheDoctorsTale.txt",
92
+ " 15 -rw-r--r-- 1 jpace jpace 39546 2010-12-04 15:24 14-ThePardonersTale.txt",
93
+ " 16 -rw-r--r-- 1 jpace jpace 25163 2010-12-04 15:24 15-TheShipmansTale.txt",
94
+ " 17 -rw-r--r-- 1 jpace jpace 14979 2010-12-04 15:24 16-ThePrioresssTale.txt",
95
+ " 18 -rw-r--r-- 1 jpace jpace 14834 2010-12-04 15:24 17-ChaucersTaleOfSirThopas.txt",
96
+ " 19 -rw-r--r-- 1 jpace jpace 43249 2010-12-04 15:24 18-ChaucersTaleOfMeliboeus.txt",
97
+ " 20 -rw-r--r-- 1 jpace jpace 49747 2010-12-04 15:24 19-TheMonksTale.txt",
98
+ " 21 -rw-r--r-- 1 jpace jpace 45326 2010-12-04 15:24 20-TheNunsPriestsTale.txt",
99
+ " 22 -rw-r--r-- 1 jpace jpace 30734 2010-12-04 15:24 21-TheSecondNunsTale.txt",
100
+ " 23 -rw-r--r-- 1 jpace jpace 52953 2010-12-04 15:24 22-TheCanonsYeomansTale.txt",
101
+ " 24 -rw-r--r-- 1 jpace jpace 21141 2010-12-04 15:24 23-TheManciplesTale.txt",
102
+ " 25 -rw-r--r-- 1 jpace jpace 58300 2010-12-04 15:24 24-TheParsonsTale.txt",
103
+ " 26 -rw-r--r-- 1 jpace jpace 3650 2010-12-04 15:24 25-PrecesDeChauceres.txt",
104
+ "/proj/org/incava/glark/test/resources/04-TheCooksTale.txt",
105
+ " 1 Of many a pilgrim hast thou Christe's curse,",
106
+ " 2 For of thy parsley yet fare they the worse.",
107
+ " 3 ",
108
+ " 4 That they have eaten in thy stubble goose:",
109
+ " 5 For in thy shop doth many a fly go loose.",
110
+ " 6 ",
111
+ " 7 Now tell on, gentle Roger, by thy name,",
112
+ " 8 But yet I pray thee be not wroth for game;",
113
+ " 9 A man may say full sooth in game and play.",
114
+ ]
115
+ run_app_test expected, [ '--no-filter', 'or' ], *fnames
116
+ end
117
+ end
118
+ end