grepper 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,3 +22,8 @@
22
22
  * Added some logic to the Match and Result classes
23
23
 
24
24
  * Refactoring
25
+
26
+ === 0.9.3 / 2009-01-13
27
+
28
+ * Added l/L, h/H, o options
29
+
@@ -2,6 +2,7 @@ History.txt
2
2
  Manifest.txt
3
3
  README.txt
4
4
  Rakefile
5
+ TODO
5
6
  bin/grep.rb
6
7
  lib/grepper.rb
7
8
  lib/grepper/formatter.rb
data/README.txt CHANGED
@@ -46,6 +46,8 @@ Available options are:
46
46
  * <tt>v</tt> -- negate the sense of the match
47
47
  * <tt>An</tt> -- provide n lines of after-context
48
48
  * <tt>Bn</tt> -- provide b lines of before-context
49
+ * <tt>o</tt> -- store only the part of the line that matched the pattern
50
+ * <tt>w</tt> -- count only complete-word matches
49
51
 
50
52
  == Generating the result set
51
53
 
@@ -84,7 +86,7 @@ and
84
86
 
85
87
  == Version
86
88
 
87
- 0.9.2, December 24, 2008
89
+ 0.9.3, January 13, 2009
88
90
 
89
91
  == Author
90
92
 
@@ -92,7 +94,7 @@ David A. Black (dblack@rubypal.com)
92
94
 
93
95
  == Copyright and license
94
96
 
95
- Copyright (c) 2008, Ruby Power and Light, LLC
97
+ Copyright (c) 2008-2009, Ruby Power and Light, LLC
96
98
 
97
99
  Released under the Ruby license. No warranty of any kind. Use
98
100
  entirely at your own risk.
data/TODO ADDED
@@ -0,0 +1,14 @@
1
+ Switches/options to add:
2
+
3
+ * = done
4
+
5
+ * -H -- show filenames for all matches
6
+ * -h -- show no filenames
7
+ * -w -- select only matches that are made up of whole words
8
+ * -L -- invert -l (filenames with no matches)
9
+ * -o -- show only part of line that matches pattern
10
+ -x -- select only matches that match the whole line
11
+
12
+ API considerations:
13
+
14
+ Should Grepper have an option for only finding n matches?
@@ -1,17 +1,31 @@
1
- $: << '../lib'
1
+ # grep.rb
2
+ #
3
+ # grep-like commandline script
4
+ #
5
+ # Part of the Grepper package
6
+ #
7
+ # David A. Black/Ruby Power and Light, LLC
8
+ #
9
+ # January 13, 2009
10
+
2
11
  require 'rubygems'
3
12
  require 'grepper'
4
13
  require 'grepper/formatter'
5
14
 
6
15
  require 'getoptlong'
7
16
 
8
-
9
17
  opts = GetoptLong.new(
10
- ['--help', '-h', GetoptLong::NO_ARGUMENT],
11
- ['--line-number', '-n', GetoptLong::NO_ARGUMENT],
12
- ['--before-context', '-B', GetoptLong::REQUIRED_ARGUMENT],
13
- ['--after-context', '-A', GetoptLong::REQUIRED_ARGUMENT],
14
- ['--invert-match', '-v', GetoptLong::NO_ARGUMENT]
18
+ ['--line-number', '-n', GetoptLong::NO_ARGUMENT],
19
+ ['--files-with-match', '-l', GetoptLong::NO_ARGUMENT],
20
+ ['--files-without-match', '-L', GetoptLong::NO_ARGUMENT],
21
+ ['--with-filename', '-H', GetoptLong::NO_ARGUMENT],
22
+ ['--no-filename', '-h', GetoptLong::NO_ARGUMENT],
23
+ ['--before-context', '-B', GetoptLong::REQUIRED_ARGUMENT],
24
+ ['--after-context', '-A', GetoptLong::REQUIRED_ARGUMENT],
25
+ ['--context', '-C', GetoptLong::REQUIRED_ARGUMENT],
26
+ ['--count', '-c', GetoptLong::NO_ARGUMENT],
27
+ ['--invert-match', '-v', GetoptLong::NO_ARGUMENT],
28
+ ['--help', GetoptLong::NO_ARGUMENT]
15
29
  )
16
30
 
17
31
  grepper = Grepper.new
@@ -19,26 +33,32 @@ formatter = Grepper::Formatter.new(grepper)
19
33
 
20
34
  opts.each do |opt,arg|
21
35
  case opt
22
- when '--line-number'
23
- formatter.options << "n"
24
36
  when '--before-context'
25
37
  grepper.options << "B#{arg}"
26
38
  when '--after-context'
27
39
  grepper.options << "A#{arg}"
40
+ when 'context'
41
+ grepper.options << "C#{arg}"
42
+ when '--count'
43
+ formatter.options << "c"
28
44
  when '--invert-match'
29
45
  grepper.options << "v"
46
+ when '--line-number'
47
+ formatter.options << "n"
48
+ when '--with-filename'
49
+ formatter.options << "H"
50
+ when '--no-filename'
51
+ formatter.options << "h"
52
+ when '--files-with-match'
53
+ formatter.options << "l"
54
+ when '--files-without-match'
55
+ formatter.options << "L"
30
56
  when '--help'
31
- puts "Help"
57
+ usage
32
58
  exit 0
33
- else
34
- puts "Unknown option #{opt}"
35
59
  end
36
60
  end
37
61
 
38
- if ARGV.size < 2
39
- puts "Sorry"
40
- exit 0
41
- end
42
62
 
43
63
  grepper.pattern = Regexp.new(ARGV.shift)
44
64
  grepper.files = ARGV.dup
@@ -46,3 +66,71 @@ grepper.files = ARGV.dup
46
66
  grepper.run
47
67
  formatter.format
48
68
  puts formatter.output
69
+
70
+ BEGIN {
71
+
72
+ def usage
73
+ puts <<EOM
74
+
75
+ (This documentation comes from the GNU man page for grep(1). Please
76
+ let me know if the Ruby version doesn't conform to what's advertised
77
+ here.)
78
+
79
+ -A NUM, --after-context=NUM
80
+
81
+ Print NUM lines of trailing context after matching lines. Places
82
+ a line containing -- between contiguous groups of matches.
83
+
84
+ -B NUM, --before-context=NUM
85
+
86
+ Print NUM lines of leading context before matching lines. Places
87
+ a line containing -- between contiguous groups of matches.
88
+
89
+ -C NUM, --context=NUM
90
+
91
+ Print NUM lines of output context. Places a line containing --
92
+ between contiguous groups of matches.
93
+
94
+ -H, --with-filename
95
+
96
+ Print the filename for each match.
97
+
98
+ -h, --no-filename
99
+
100
+ Suppress the prefixing of filenames on output when multiple files
101
+ are searched.
102
+
103
+ -c, --count
104
+
105
+ Suppress normal output; instead print a count of matching
106
+ lines for each input file. With the -v, --invert-match option
107
+ (see below), count non-matching lines.
108
+
109
+ -L, --files-without-match
110
+
111
+ Suppress normal output; instead print the name of each input file
112
+ from which no output would normally have been printed.
113
+ The scanning will stop on the first match.
114
+
115
+ -l, --files-with-matches
116
+
117
+ Suppress normal output; instead print the name of each input file from which
118
+ output would normally have been printed. The scanning will stop on the first
119
+ match.
120
+
121
+ -n, --line-number
122
+
123
+ Prefix each line of output with the line number within its input
124
+ file.
125
+
126
+ -o, --only-matching
127
+
128
+ Show only the part of a matching line that matches PATTERN.
129
+
130
+ -v, --invert-match
131
+
132
+ Invert the sense of matching, to select non-matching lines.
133
+
134
+ EOM
135
+ end
136
+ }
@@ -43,7 +43,9 @@
43
43
  #
44
44
  # Available options are:
45
45
  #
46
+ # * <tt>o</tt> -- store only the part of the line that matched the pattern
46
47
  # * <tt>v</tt> -- negate the sense of the match
48
+ # * <tt>w</tt> -- count only complete-word matches
47
49
  # * <tt>An</tt> -- provide n lines of after-context
48
50
  # * <tt>Bn</tt> -- provide b lines of before-context
49
51
  #
@@ -84,7 +86,7 @@
84
86
  #
85
87
  # == Version
86
88
  #
87
- # 0.9.2, December 24, 2008
89
+ # 0.9.3, January 13, 2009
88
90
  #
89
91
  # == Author
90
92
  #
@@ -92,16 +94,16 @@
92
94
  #
93
95
  # == Copyright and license
94
96
  #
95
- # Copyright (c) 2008, Ruby Power and Light, LLC
97
+ # Copyright (c) 2008-2009, Ruby Power and Light, LLC
96
98
  #
97
99
  # Released under the Ruby license. No warranty of any kind. Use
98
100
  # entirely at your own risk.
99
101
  #
100
102
 
101
103
  class Grepper
102
- VERSION = '0.9.2'
104
+ VERSION = '0.9.3'
103
105
 
104
- attr_accessor :files, :pattern, :options
106
+ attr_accessor :files, :options, :pattern
105
107
  attr_reader :results
106
108
 
107
109
  def initialize
@@ -113,14 +115,21 @@ class Grepper
113
115
 
114
116
  private
115
117
 
118
+ def massage_pattern
119
+ if @options.include?('w')
120
+ @pattern = Regexp.new(/\b#{@pattern}\b/)
121
+ else
122
+ @pattern = /#{@pattern}/
123
+ end
124
+ end
125
+
116
126
  def get_after_context(fh, after_count)
117
127
 
118
128
  res = []
119
129
  after_count.times do |i|
120
130
  line = fh.gets
121
131
  break unless line
122
-
123
- if match?(line)
132
+ if match_for(line)
124
133
  fh.pos -= line.size
125
134
  break
126
135
  else
@@ -130,19 +139,36 @@ class Grepper
130
139
  res.empty? ? nil : res
131
140
  end
132
141
 
133
- def match?(line)
134
- m = line =~ @pattern
135
- @negate ? !m : m
142
+ def match_for(line)
143
+ m = @pattern.match(line)
144
+ if m && @negate
145
+ return false
146
+ elsif @negate
147
+ return line
148
+ elsif m
149
+ if options.include?('o')
150
+ return m[0]
151
+ else
152
+ return line
153
+ end
154
+ else
155
+ return false
156
+ end
136
157
  end
137
158
 
138
159
  public
139
160
 
140
161
  # Generate the result set.
141
162
  def run
163
+ massage_pattern
142
164
  @negate = true if options.include?('v')
143
165
 
144
166
  after_count = $1.to_i if options.find {|o| /A(\d+)/.match(o) }
145
167
  before_count = $1.to_i if options.find {|o| /B(\d+)/.match(o) }
168
+ if options.find {|o| /C(\d+)/.match(o) }
169
+ after_count ||= $1.to_i
170
+ before_count ||= $1.to_i
171
+ end
146
172
 
147
173
  files.each do |file|
148
174
  result = Result.new(file)
@@ -153,13 +179,13 @@ class Grepper
153
179
  while line = fh.gets
154
180
  i += 1
155
181
 
156
- if match?(line)
157
- match = Match.new(line)
182
+ if matched = match_for(line)
183
+ match = Match.new(matched)
158
184
  match.lineno = i
159
185
 
160
186
  if after_count
161
187
  match.after = get_after_context(fh, after_count)
162
- i += match.after.to_s.scan(/\n/).size
188
+ i += (match.after || []).size
163
189
  end
164
190
 
165
191
  if before_count
@@ -199,11 +225,11 @@ class Grepper
199
225
  end
200
226
 
201
227
  def absolute_start
202
- lineno - before.to_s.scan(/\n/).size
228
+ lineno - (before || []).size
203
229
  end
204
230
 
205
231
  def absolute_end
206
- lineno + after.to_s.scan(/\n/).size
232
+ lineno + (after || []).size
207
233
  end
208
234
  end
209
235
 
@@ -236,7 +262,7 @@ class Grepper
236
262
  end
237
263
 
238
264
  def context?
239
- any? {|f,matches| matches.any? {|n,b,l,a| b || a } }
265
+ @context = any? {|f,matches| matches.any? {|n,b,l,a| b || a } }
240
266
  end
241
267
  end
242
268
 
@@ -32,6 +32,8 @@ class Grepper
32
32
  # * <tt>l</tt> -- show matching filenames only
33
33
  # * <tt>c</tt> -- show match count only
34
34
  # * <tt>n</tt> -- show the line number of the match
35
+ # * <tt>H</tt> -- show the name of the file of each match
36
+ # * <tt>h</tt> -- don't show the names of any files
35
37
  #
36
38
  # Note that Grepper objects also have options ('v', 'A1', etc.).
37
39
  # Both the Formatter options and the Grepper options are pulled
@@ -75,7 +77,7 @@ class Grepper
75
77
  end
76
78
 
77
79
  def one_or_many(string, many_string)
78
- multi? ? many_string + string : string
80
+ (multi? &&! options.include?("h")) || options.include?("H") ? many_string + string : string
79
81
  end
80
82
 
81
83
  def context_lines(lines,file,n,position)
@@ -126,7 +128,11 @@ class Grepper
126
128
 
127
129
  # 'l' -- filenames only
128
130
  if options.include?('l')
129
- str << "#{file}\n"
131
+ str << "#{file}\n" unless matches.empty?
132
+
133
+ # 'L' -- filenames only, for non-matching files
134
+ elsif options.include?('L')
135
+ str << "#{file}\n" if matches.empty?
130
136
 
131
137
  # 'c' -- match count only
132
138
  elsif options.include?('c')
@@ -11,7 +11,7 @@ class FormatterTest < Test::Unit::TestCase
11
11
  end
12
12
 
13
13
  def run_with_files(grepper,*files)
14
- grepper.files = *files
14
+ grepper.files = Array(*files)
15
15
  grepper.run
16
16
  end
17
17
 
@@ -164,11 +164,11 @@ EOM
164
164
  EOM
165
165
  end
166
166
 
167
- def test_after_context_with_line_numbers
168
- @g.options = ["A2"]
169
- run_with_files(@g, %w{ test/input.6 })
170
- f = formatter_for(@g,["n"])
171
- assert_equal(<<EOM, f.output)
167
+ def test_after_context_with_line_numbers
168
+ @g.options = ["A2"]
169
+ run_with_files(@g, %w{ test/input.6 })
170
+ f = formatter_for(@g,["n"])
171
+ assert_equal(<<EOM, f.output)
172
172
  3:abc
173
173
  4-three
174
174
  5-four
@@ -205,6 +205,235 @@ test/input.2:3:So does this abc.
205
205
  test/input.2-4-does.
206
206
  EOM
207
207
  end
208
- end
209
208
 
209
+ def test_add_filenames_to_output_from_single_file
210
+ run_with_files(@g, %w{ test/input.1 })
211
+ f = formatter_for(@g, ["H"])
212
+ assert_equal(<<EOM, f.output)
213
+ test/input.1:This matches abc.
214
+ EOM
215
+ end
216
+
217
+ def test_add_filenames_to_c_switch_single_file
218
+ run_with_files(@g, %w{ test/input.1 })
219
+ f = formatter_for(@g, ["H","c"])
220
+ assert_equal(<<EOM, f.output)
221
+ test/input.1:1
222
+ EOM
223
+ end
224
+
225
+ def test_add_filenames_to_output_from_multi_files
226
+ run_with_files(@g, %w{ test/input.1 test/input.2 test/input.4 })
227
+ f = formatter_for(@g, ["H"])
228
+ assert_equal(<<EOM, f.output)
229
+ test/input.1:This matches abc.
230
+ test/input.2:So does this abc.
231
+ test/input.4:this abc
232
+ test/input.4:that abc
233
+ EOM
234
+ end
235
+
236
+ def test_add_filenames_to_c_switch_multi_files
237
+ run_with_files(@g, %w{ test/input.1 test/input.2 test/input.4 })
238
+ f = formatter_for(@g, ["H","c"])
239
+ assert_equal(<<EOM, f.output)
240
+ test/input.1:1
241
+ test/input.2:1
242
+ test/input.4:2
243
+ EOM
244
+ end
245
+
246
+ def test_combine_filenames_with_context_multi_files
247
+ @g.options = ["A2"]
248
+ run_with_files(@g, %w{ test/input.1 test/input.2 test/input.4 })
249
+ f = formatter_for(@g, ["H"])
250
+ assert_equal(<<EOM, f.output)
251
+ test/input.1:This matches abc.
252
+ test/input.1-This doesn't.
253
+ --
254
+ test/input.2:So does this abc.
255
+ test/input.2-does.
256
+ --
257
+ test/input.4:this abc
258
+ test/input.4-blah one
259
+ test/input.4-blah two
260
+ --
261
+ test/input.4:that abc
262
+ test/input.4-one
263
+ test/input.4-two
264
+ EOM
265
+ end
266
+
267
+ def test_combine_filenames_with_line_numbers_single_file
268
+ run_with_files(@g, %w{ test/input.1 })
269
+ f = formatter_for(@g, ["H", "n"])
270
+ assert_equal(<<EOM, f.output)
271
+ test/input.1:2:This matches abc.
272
+ EOM
273
+ end
274
+
275
+ def test_combine_filenames_with_line_numbers_multi_file
276
+ run_with_files(@g, %w{ test/input.1 test/input.2 test/input.4 })
277
+ f = formatter_for(@g, ["H", "n"])
278
+ assert_equal(<<EOM, f.output)
279
+ test/input.1:2:This matches abc.
280
+ test/input.2:3:So does this abc.
281
+ test/input.4:1:this abc
282
+ test/input.4:5:that abc
283
+ EOM
284
+ end
285
+
286
+ def test_combine_filenames_with_line_numbers_and_context_multi_file
287
+ @g.options = ["A2"]
288
+ run_with_files(@g, %w{ test/input.1 test/input.2 test/input.4 })
289
+ f = formatter_for(@g, ["H", "n"])
290
+ assert_equal(<<EOM, f.output)
291
+ test/input.1:2:This matches abc.
292
+ test/input.1-3-This doesn't.
293
+ --
294
+ test/input.2:3:So does this abc.
295
+ test/input.2-4-does.
296
+ --
297
+ test/input.4:1:this abc
298
+ test/input.4-2-blah one
299
+ test/input.4-3-blah two
300
+ --
301
+ test/input.4:5:that abc
302
+ test/input.4-6-one
303
+ test/input.4-7-two
304
+ EOM
305
+ end
306
+
307
+ def test_suppress_filenames_multi_files
308
+ run_with_files(@g, %w{ test/input.1 test/input.2 test/input.4 })
309
+ f = formatter_for(@g, ["h"])
310
+ assert_equal(<<EOM, f.output)
311
+ This matches abc.
312
+ So does this abc.
313
+ this abc
314
+ that abc
315
+ EOM
316
+ end
317
+
318
+ def test_suppress_filenames_with_line_numbers_multi_files
319
+ run_with_files(@g, %w{ test/input.1 test/input.2 test/input.4 })
320
+ f = formatter_for(@g, ["h", "n"])
321
+ assert_equal(<<EOM, f.output)
322
+ 2:This matches abc.
323
+ 3:So does this abc.
324
+ 1:this abc
325
+ 5:that abc
326
+ EOM
327
+ end
328
+
329
+ def test_suppress_filenames_with_context_multi_files
330
+ @g.options = ["A2"]
331
+ run_with_files(@g, %w{ test/input.1 test/input.2 test/input.4 })
332
+ f = formatter_for(@g, ["h"])
333
+ assert_equal(<<EOM, f.output)
334
+ This matches abc.
335
+ This doesn't.
336
+ --
337
+ So does this abc.
338
+ does.
339
+ --
340
+ this abc
341
+ blah one
342
+ blah two
343
+ --
344
+ that abc
345
+ one
346
+ two
347
+ EOM
348
+ end
349
+
350
+ def test_double_context_C_switch_single_file
351
+ @g.options = ["C2"]
352
+ run_with_files(@g, %w{ test/input.4 })
353
+ f = formatter_for(@g)
354
+ assert_equal(<<EOM, f.output)
355
+ this abc
356
+ blah one
357
+ blah two
358
+ blah three
359
+ that abc
360
+ one
361
+ two
362
+ EOM
363
+ end
364
+
365
+ def test_double_context_C_switch_multi_files
366
+ @g.options = ["C2"]
367
+ run_with_files(@g, %w{ test/input.1 test/input.4 })
368
+ f = formatter_for(@g)
369
+ assert_equal(<<EOM, f.output)
370
+ test/input.1-This is a file
371
+ test/input.1:This matches abc.
372
+ test/input.1-This doesn't.
373
+ --
374
+ test/input.4:this abc
375
+ test/input.4-blah one
376
+ test/input.4-blah two
377
+ test/input.4-blah three
378
+ test/input.4:that abc
379
+ test/input.4-one
380
+ test/input.4-two
381
+ EOM
382
+ end
383
+
384
+ def test_double_context_loses_to_specific_A_or_b
385
+ @g.options = ["A1", "C2"]
386
+ run_with_files(@g, %w{ test/input.1 test/input.4 })
387
+ f = formatter_for(@g)
388
+ assert_equal(<<EOM, f.output)
389
+ test/input.1-This is a file
390
+ test/input.1:This matches abc.
391
+ test/input.1-This doesn't.
392
+ --
393
+ test/input.4:this abc
394
+ test/input.4-blah one
395
+ test/input.4-blah two
396
+ test/input.4-blah three
397
+ test/input.4:that abc
398
+ test/input.4-one
399
+ EOM
400
+ end
401
+
402
+ def test_lots_of_switches_together
403
+ @g.options = ["A1", "B2"]
404
+ run_with_files(@g, %w{ test/input.1 test/input.4 })
405
+ f = formatter_for(@g, ["h", "n"])
406
+ assert_equal(<<EOM, f.output)
407
+ 1-This is a file
408
+ 2:This matches abc.
409
+ 3-This doesn't.
410
+ --
411
+ 1:this abc
412
+ 2-blah one
413
+ 3-blah two
414
+ 4-blah three
415
+ 5:that abc
416
+ 6-one
417
+ EOM
418
+ end
210
419
 
420
+ def test_listing_matching_files_where_some_dont_match
421
+ @g.pattern = "This"
422
+ run_with_files(@g, %w{ test/input.1 test/input.2 test/input.4 test/input.6 })
423
+ f = formatter_for(@g, ["l"])
424
+ assert_equal(<<EOM, f.output)
425
+ test/input.1
426
+ test/input.2
427
+ EOM
428
+ end
429
+
430
+ def test_listing_non_matching_files
431
+ @g.pattern = "This"
432
+ run_with_files(@g, %w{ test/input.1 test/input.2 test/input.4 test/input.6 })
433
+ f = formatter_for(@g, ["L"])
434
+ assert_equal(<<EOM, f.output)
435
+ test/input.4
436
+ test/input.6
437
+ EOM
438
+ end
439
+ end
@@ -84,7 +84,7 @@ EOM
84
84
  end
85
85
 
86
86
  def test_overlapping_context_from_one_file
87
- @g.options = "A4"
87
+ @g.options = ["A4"]
88
88
  @g.files = ["test/input.4"]
89
89
  @g.run
90
90
  assert_equal(1, @g.results.size)
@@ -104,7 +104,7 @@ EOM
104
104
 
105
105
  def test_before_buffer
106
106
  @g.files = ["test/input.4"]
107
- @g.options = "B2"
107
+ @g.options = ["B2"]
108
108
  @g.run
109
109
  r = @g.results[0]
110
110
  assert_equal(1, @g.results.size)
@@ -145,4 +145,28 @@ EOM
145
145
  test_basic_lines_from_multiple_files
146
146
  assert_equal(3, @g.results[1].matches[0].lineno)
147
147
  end
148
+
149
+ def test_match_only_on_word_boundaries_fail
150
+ @g.pattern = "bc"
151
+ @g.files = ["test/input.4"]
152
+ @g.options = ["w"]
153
+ @g.run
154
+ assert_equal(0, @g.results[0].matches.size)
155
+ end
156
+
157
+ def test_match_only_on_word_boundaries_succeed
158
+ @g.options = ["w"]
159
+ @g.pattern = "abc"
160
+ @g.files = ["test/input.4"]
161
+ @g.run
162
+ assert_equal(2, @g.results[0].matches.size)
163
+ end
164
+
165
+ def test_return_only_the_part_matched
166
+ @g.options = ["o"]
167
+ @g.pattern = "abc"
168
+ @g.files = ["test/input.4"]
169
+ @g.run
170
+ assert_equal("abc", @g.results[0].matches[0].line)
171
+ end
148
172
  end
@@ -23,7 +23,7 @@ class Grepper::MatchTest < Test::Unit::TestCase
23
23
  end
24
24
 
25
25
  def test_before_context
26
- @g.options = "B2"
26
+ @g.options = ["B2"]
27
27
  @g.run
28
28
  matches = @g.results[0].matches
29
29
  assert_match_stats(matches[0], 3,1,3)
@@ -32,7 +32,7 @@ class Grepper::MatchTest < Test::Unit::TestCase
32
32
  end
33
33
 
34
34
  def test_after_context
35
- @g.options = "A2"
35
+ @g.options = ["A2"]
36
36
  @g.run
37
37
  matches = @g.results[0].matches
38
38
  assert_match_stats(matches[0], 3,3,5)
@@ -41,7 +41,7 @@ class Grepper::MatchTest < Test::Unit::TestCase
41
41
  end
42
42
 
43
43
  def test_both_contexts
44
- @g.options = "A1B1"
44
+ @g.options = ["A1", "B1"]
45
45
  @g.run
46
46
  matches = @g.results[0].matches
47
47
  assert_match_stats(matches[0], 3,2,4)
@@ -51,4 +51,4 @@ class Grepper::MatchTest < Test::Unit::TestCase
51
51
 
52
52
  end
53
53
 
54
-
54
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grepper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - David A. Black
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-24 00:00:00 -05:00
12
+ date: 2009-01-13 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -38,6 +38,7 @@ files:
38
38
  - Manifest.txt
39
39
  - README.txt
40
40
  - Rakefile
41
+ - TODO
41
42
  - bin/grep.rb
42
43
  - lib/grepper.rb
43
44
  - lib/grepper/formatter.rb