interactive_grep 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/README.txt +38 -22
- data/bin/igrep +42 -40
- data/interactive_grep.gemspec +2 -2
- data/lib/interactive_grep/grepper.rb +155 -92
- data/lib/interactive_grep/version.rb +1 -1
- data/spec/lib/interactive_grep/grepper_spec.rb +85 -4
- data/spec/spec_helper.rb +32 -0
- data/spec/tmp/gzipped_files/file.txt.gz +0 -0
- data/spec/tmp/ungzipped_files/file.txt +5 -0
- metadata +12 -9
- data/lib/.DS_Store +0 -0
- data/lib/interactive_grep/.DS_Store +0 -0
data/.gitignore
CHANGED
data/README.txt
CHANGED
@@ -3,39 +3,55 @@ Interactively Grep for patterns.
|
|
3
3
|
This works particularly well for files with muli-line patterns (like
|
4
4
|
weblogs) and it handles zipped files.
|
5
5
|
|
6
|
-
The code:
|
7
|
-
|
8
|
-
|
6
|
+
The code: pretty-yucky. This is based on my very first Ruby program (and
|
7
|
+
the code was a total hack)!
|
8
|
+
|
9
|
+
But I've kept it because it's actually useful.
|
10
|
+
And hopefully by the time you see this the code will serve as an example
|
11
|
+
of the power of refactoring ;)
|
9
12
|
|
10
13
|
Basic use-case(s):
|
11
14
|
gem install interactive_grep
|
12
|
-
# from the commandline:
|
15
|
+
# Then, from the commandline:
|
13
16
|
igrep -h
|
14
17
|
|
15
|
-
# in your code:
|
18
|
+
# OR in your code:
|
16
19
|
irb
|
17
|
-
#
|
18
|
-
ig = InteractiveGrep::Grepper.new("/path/to/
|
19
|
-
|
20
|
-
|
20
|
+
# normal ('grep') mode - support(s) regular or gzipped files
|
21
|
+
ig = InteractiveGrep::Grepper.new("files" => "/path/to/weblog.gz",
|
22
|
+
"pattern" => search_string
|
23
|
+
)
|
24
|
+
puts ig.run
|
21
25
|
# => [matching_line1, matching_line2, matching_line3, etc...]
|
22
26
|
|
23
|
-
#
|
24
|
-
ig = InteractiveGrep::Grepper.new("/path/to/
|
27
|
+
# count ('grep -c') mode - support(s) regular or gzipped files
|
28
|
+
ig = InteractiveGrep::Grepper.new("files" => "/path/to/weblog.gz",
|
29
|
+
"pattern" => search_string,
|
30
|
+
"mode" => "count"
|
31
|
+
)
|
25
32
|
ig.run
|
26
|
-
# => 20
|
27
|
-
the grepper to merely "count" the number of matches
|
33
|
+
# => 20
|
28
34
|
|
29
|
-
#
|
30
|
-
ig = InteractiveGrep::Grepper.new("/path/to/
|
35
|
+
# interactive mode - oh yeah!!!
|
36
|
+
ig = InteractiveGrep::Grepper.new(files => "/path/to/weblog.gz",
|
37
|
+
"pattern" => search_string
|
38
|
+
)
|
31
39
|
ig.interactive = true
|
32
40
|
ig.run
|
33
|
-
# every time your *current* pattern is matched,
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
|
38
|
-
|
41
|
+
# every time your *current* pattern is matched,
|
42
|
+
# the match is displayed
|
43
|
+
# and you are prompted to:
|
44
|
+
# repeat the same search pattern (press enter)
|
45
|
+
# 'S'ee what's on the next line of the file (enter S)
|
46
|
+
# adjust the search pattern (whatever you enter)
|
47
|
+
# turn 'O'ff interactive-mode (enter O)
|
48
|
+
# ...at which point the rest of the results will be
|
49
|
+
# automatically matched using the current pattern
|
50
|
+
|
51
|
+
(See specs for more detailed use-cases ...and short-comings)
|
39
52
|
rake rspec
|
40
53
|
|
41
|
-
# TODO:
|
54
|
+
# TODO:
|
55
|
+
# add specs for the behavior I described above
|
56
|
+
# test-drive an API I can be proud of ;-)
|
57
|
+
# ability to record & replay grep-sessions
|
data/bin/igrep
CHANGED
@@ -1,44 +1,46 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
# the "i" is for interactive
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
puts "usage $0 -h"
|
9
|
-
puts "\tproduces this help-message"
|
10
|
-
puts ""
|
11
|
-
|
12
|
-
puts "usage $0 <input_file> [<pattern>] [<display count-only>] [<interactive-mode=on>]"
|
13
|
-
puts ""
|
14
|
-
puts "e.g."
|
15
|
-
puts "./igrep.rb big_test.txt.gz"
|
16
|
-
puts './igrep.rb "/reporting/access*.gz" cvsfa=63'
|
17
|
-
puts ""
|
18
|
-
exit
|
19
|
-
end
|
20
|
-
|
21
|
-
in_file = ARGV[0]
|
22
|
-
pattern = nil
|
23
|
-
interactive = nil
|
24
|
-
just_count = false
|
25
|
-
prompt = nil
|
26
|
-
if 2 <= ARGV.size
|
27
|
-
pattern = ARGV[1]
|
28
|
-
end
|
29
|
-
if 3 <= ARGV.size
|
30
|
-
# ARGV[2]
|
31
|
-
just_count = true
|
32
|
-
puts "true count: #{ARGV[2]}"
|
33
|
-
end
|
34
|
-
if 4 <= ARGV.size
|
35
|
-
interactive = ARGV[3]
|
36
|
-
puts "interactive mode: #{interactive}"
|
37
|
-
end
|
38
|
-
|
39
|
-
prompt = 'ready to continue' if interactive
|
40
|
-
igrep = InteractiveGrep::Grepper.new(in_file,pattern,just_count,interactive)
|
41
|
-
puts "#{prompt}\n\n" if interactive
|
42
|
-
igrep.run()
|
43
|
-
exit
|
4
|
+
begin
|
5
|
+
require 'rubygems'
|
6
|
+
gem 'interactive_grep'
|
7
|
+
rescue LoadError
|
44
8
|
end
|
9
|
+
file_or_gem = File.expand_path( '../../lib/interactive_grep/grepper.rb', __FILE__ )
|
10
|
+
file_or_gem = 'interactive_grep' unless File.exists?( file_or_gem )
|
11
|
+
require file_or_gem
|
12
|
+
|
13
|
+
# TODO: replace this w/ a real cmd-line options parser!
|
14
|
+
if 0 == ARGV.size || InteractiveGrep::Grepper.contains_option?(ARGV,'h')
|
15
|
+
puts InteractiveGrep::Grepper.usage
|
16
|
+
end
|
17
|
+
|
18
|
+
pattern = nil; interactive = true
|
19
|
+
|
20
|
+
in_file = ARGV[0]
|
21
|
+
|
22
|
+
if 2 <= ARGV.size
|
23
|
+
pattern = ARGV[1]
|
24
|
+
end
|
25
|
+
|
26
|
+
if 3 <= ARGV.size
|
27
|
+
mode = case ARGV[2]
|
28
|
+
when /^i/i
|
29
|
+
interactive = true
|
30
|
+
"interactive"
|
31
|
+
when /^c/i
|
32
|
+
interactive = false
|
33
|
+
"count"
|
34
|
+
else
|
35
|
+
interactive = false
|
36
|
+
"normal"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
mode ||= interactive ? "interactive" : "normal"
|
41
|
+
igrep = InteractiveGrep::Grepper.new( { "files" => in_file, "pattern" => pattern, "mode" => mode, "verbose" => "true" } )
|
42
|
+
|
43
|
+
puts "Welcome..." if interactive
|
44
|
+
igrep.run()
|
45
|
+
|
46
|
+
exit
|
data/interactive_grep.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.authors = ["JayTeeSr"]
|
9
9
|
s.email = ["jaytee_sr_at_his-service_dot_net"]
|
10
10
|
s.homepage = "https://github.com/JayTeeSF/interactive_grep"
|
11
|
-
s.summary = %q{My very first Ruby program,
|
12
|
-
s.description = %q{
|
11
|
+
s.summary = %q{My very first Ruby program, for interactively grepping through gzipped weblogs for unexpected patterns}
|
12
|
+
s.description = %q{grep for stuff in (optionally gzipped) files ...even before you fully know what that 'stuff' looks like}
|
13
13
|
s.rubyforge_project = "interactive_grep"
|
14
14
|
s.files = `git ls-files`.split("\n")
|
15
15
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
@@ -1,133 +1,196 @@
|
|
1
|
+
require 'zlib'
|
2
|
+
|
1
3
|
module InteractiveGrep
|
2
4
|
class Grepper
|
3
|
-
|
5
|
+
DEFAULT_PATTERN = %r{.}.freeze
|
6
|
+
DEFAULT_NUMBER_OF_LINES_TO_INDICATE = 100.freeze
|
7
|
+
DEBUG = false.freeze
|
4
8
|
|
5
|
-
|
6
|
-
attr_accessor :in_file, :ending, :def_pattern, :interactive, :counter, :just_count, :gz
|
9
|
+
attr_accessor :file_names, :current_pattern, :initial_pattern, :gz, :file_index, :enough_lines_to_indicate
|
7
10
|
|
8
|
-
def initialize(
|
9
|
-
|
10
|
-
@
|
11
|
-
@
|
12
|
-
|
11
|
+
def initialize( options = nil )
|
12
|
+
options ||= {}
|
13
|
+
@enough_lines_to_indicate = options[:line_indicator_count] || DEFAULT_NUMBER_OF_LINES_TO_INDICATE
|
14
|
+
@verbose = DEBUG || !!options[ "verbose" ]
|
15
|
+
reset_file_index
|
16
|
+
@file_names = options[ "files" ]
|
17
|
+
if ( !@file_names.is_a?( Array ) ) && @file_names[/\*/]
|
18
|
+
@file_names = Dir.glob( @file_names ).map{|fname| fname}
|
19
|
+
end
|
20
|
+
@file_names = [ @file_names ] unless @file_names.is_a? Array
|
21
|
+
unless current_file && File.exists?( current_file )
|
22
|
+
raise "must specify at least one valid file (and/or file_glob)"
|
23
|
+
end
|
13
24
|
|
14
|
-
@
|
25
|
+
@initial_pattern = !!options[ "pattern" ] ? %r{#{options[ "pattern" ]}} : DEFAULT_PATTERN
|
26
|
+
@current_pattern = @initial_pattern
|
15
27
|
|
16
|
-
|
17
|
-
if /\*/.match(@in_file[0])
|
18
|
-
@in_file = Dir.glob(@in_file[0]).map{|fname| fname}
|
19
|
-
end
|
28
|
+
@mode = options[ "mode" ] || "normal"
|
20
29
|
|
21
|
-
@
|
22
|
-
if interactive && just_count
|
23
|
-
just_count = false
|
24
|
-
end
|
30
|
+
@gz = options[ "gz" ]
|
25
31
|
|
26
|
-
|
27
|
-
|
28
|
-
@gz = false
|
29
|
-
if '.gz' == @ending
|
30
|
-
@gz = true
|
32
|
+
if verbose?
|
33
|
+
puts "using:\n\tfiles: #{file_names}\n\tending in: #{ending}\n\tinitial_pattern: #{current_pattern_string}\n"
|
31
34
|
end
|
35
|
+
end
|
32
36
|
|
33
|
-
|
34
|
-
|
35
|
-
print "#{@ending}\n\tdef_pattern: #{@def_pattern}\n"
|
36
|
-
end
|
37
|
+
def self.contains_option?(input_options, option_string)
|
38
|
+
input_options.any?{|o| o[/^\s*\-+#{option_string}/] }
|
37
39
|
end
|
38
40
|
|
39
|
-
def
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
41
|
+
def self.usage
|
42
|
+
puts "usage $0 [-h]"
|
43
|
+
puts "\tproduces this help-message"
|
44
|
+
puts ""
|
45
|
+
|
46
|
+
puts "usage $0 <input_file> [<pattern>] [<mode>]"
|
47
|
+
puts ""
|
48
|
+
puts "modes: 'interactive' (default), 'count', or 'normal'"
|
49
|
+
puts "e.g."
|
50
|
+
puts "./igrep.rb big_test.txt.gz"
|
51
|
+
puts './igrep.rb "/reporting/access*.gz" cvsfa=63 interactive'
|
52
|
+
puts './igrep.rb "/reporting/access*.gz" cvsfa=63 count'
|
53
|
+
puts './igrep.rb "/reporting/access*.gz" cvsfa=63 # normal-grep mode'
|
54
|
+
puts ""
|
55
|
+
exit
|
56
|
+
end
|
57
|
+
|
58
|
+
def default_pattern?
|
59
|
+
DEFAULT_PATTERN == current_pattern
|
60
|
+
end
|
61
|
+
|
62
|
+
def current_pattern_string
|
63
|
+
default_pattern? ? "<match every line>" : current_pattern
|
64
|
+
end
|
65
|
+
|
66
|
+
def ending
|
67
|
+
File.extname( current_file )
|
68
|
+
end
|
69
|
+
|
70
|
+
def gz?
|
71
|
+
@gz || ending[/.?gz$/]
|
72
|
+
end
|
73
|
+
|
74
|
+
def current_file
|
75
|
+
file_names[ file_index ]
|
76
|
+
end
|
77
|
+
|
78
|
+
def reset_file_index
|
79
|
+
@file_index = 0
|
80
|
+
end
|
81
|
+
|
82
|
+
def increment_file_index
|
83
|
+
@file_index += 1
|
84
|
+
end
|
85
|
+
|
86
|
+
def run
|
87
|
+
counter = 0
|
88
|
+
results = []
|
89
|
+
@current_pattern = initial_pattern
|
90
|
+
while line = next_line
|
91
|
+
if line[@current_pattern]
|
92
|
+
line.strip!
|
93
|
+
counter += 1
|
94
|
+
unless just_count? || ( verbose? && interactive? )
|
95
|
+
results << line
|
50
96
|
end
|
51
|
-
|
97
|
+
@current_pattern = prompt( line )
|
98
|
+
end
|
99
|
+
if verbose?
|
100
|
+
puts "." if 0 == (counter % enough_lines_to_indicate)
|
52
101
|
end
|
53
102
|
end
|
54
|
-
|
55
|
-
if
|
56
|
-
|
57
|
-
|
103
|
+
reset_file_index
|
104
|
+
puts "no more files.\n" if verbose?
|
105
|
+
if just_count?
|
106
|
+
if verbose?
|
107
|
+
puts "matched #{counter} line(s)"
|
108
|
+
puts "done.\n"
|
58
109
|
end
|
59
|
-
|
110
|
+
counter
|
60
111
|
else
|
61
|
-
puts "
|
62
|
-
|
112
|
+
puts "done.\n" if verbose?
|
113
|
+
results
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
private
|
118
|
+
|
119
|
+
def verbose?
|
120
|
+
!!@verbose
|
121
|
+
end
|
122
|
+
|
123
|
+
def just_count?
|
124
|
+
@mode == "count"
|
125
|
+
end
|
126
|
+
|
127
|
+
def interactive?
|
128
|
+
@mode == "interactive"
|
129
|
+
end
|
130
|
+
|
131
|
+
def prompt( msg )
|
132
|
+
if verbose? && msg && !just_count?
|
133
|
+
puts "\n>>\n#{msg}\n<<"
|
134
|
+
end
|
135
|
+
|
136
|
+
if interactive?
|
137
|
+
puts "S | O | <pattern: [#{current_pattern_string}]> ? "
|
138
|
+
user_input = STDIN.gets.strip
|
63
139
|
puts ""
|
64
|
-
if
|
65
|
-
puts "user_input: >>#{user_input}<<"
|
140
|
+
if DEBUG
|
141
|
+
puts "user_input: >>#{user_input.inspect}<<"
|
66
142
|
end
|
67
143
|
|
68
144
|
case
|
69
|
-
when /^\s*$/.match(user_input) #corresponds w/ <enter> (or <return>)
|
70
|
-
if
|
71
|
-
puts "
|
145
|
+
when /^\s*$/.match( user_input ) #corresponds w/ <enter> (or <return>)
|
146
|
+
if verbose?
|
147
|
+
puts " => continuing w/ the previous pattern"
|
72
148
|
end
|
73
|
-
|
74
|
-
when
|
75
|
-
@
|
76
|
-
if
|
77
|
-
puts "
|
149
|
+
@current_pattern
|
150
|
+
when [ "O", "o" ].include?( user_input ) #interactive mode Off
|
151
|
+
@mode = "normal"
|
152
|
+
if verbose?
|
153
|
+
puts " => interactive switched mode off"
|
78
154
|
end
|
79
|
-
|
80
|
-
when
|
81
|
-
if
|
82
|
-
puts "
|
155
|
+
@current_pattern
|
156
|
+
when [ "S", "s" ].include?( user_input ) #Show every line
|
157
|
+
if verbose?
|
158
|
+
puts " => showing the next line"
|
83
159
|
end
|
84
160
|
/./
|
85
161
|
else #use whatever was entered
|
86
|
-
if
|
87
|
-
puts "
|
162
|
+
if verbose?
|
163
|
+
puts " => using your input as the new search pattern"
|
88
164
|
end
|
89
165
|
%r{#{user_input}}
|
90
166
|
end
|
167
|
+
else
|
168
|
+
@current_pattern
|
91
169
|
end
|
92
170
|
end
|
93
171
|
|
94
|
-
def
|
95
|
-
|
96
|
-
while
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
puts ""
|
103
|
-
end
|
104
|
-
if line
|
105
|
-
line.strip!
|
106
|
-
results << line
|
107
|
-
end
|
108
|
-
pattern = prompt( pattern, line, display_results )
|
109
|
-
if @@DEBUG
|
110
|
-
puts ""
|
111
|
-
end
|
112
|
-
end
|
113
|
-
if @@DEBUG
|
114
|
-
puts "."
|
115
|
-
end
|
116
|
-
end
|
172
|
+
def next_line
|
173
|
+
@handle ||= get_file_handle
|
174
|
+
while @handle.eof?
|
175
|
+
@handle.close
|
176
|
+
puts "trying next file..." if verbose?
|
177
|
+
return if not_another_file?
|
178
|
+
increment_file_index
|
179
|
+
return unless @handle = get_file_handle
|
117
180
|
end
|
118
|
-
|
119
|
-
|
181
|
+
return @handle.gets
|
182
|
+
end
|
183
|
+
|
184
|
+
def not_another_file?
|
185
|
+
! (file_names.count > file_index + 1)
|
120
186
|
end
|
121
187
|
|
122
188
|
def get_file_handle
|
123
|
-
|
124
|
-
|
125
|
-
handle = Zlib::GzipReader.open(@in_file[@file_index]);
|
189
|
+
if gz?
|
190
|
+
Zlib::GzipReader.open( current_file );
|
126
191
|
else
|
127
|
-
|
192
|
+
File.open( current_file, 'r' )
|
128
193
|
end
|
129
|
-
@file_index += 1
|
130
|
-
handle
|
131
194
|
end
|
132
195
|
end
|
133
196
|
end
|
@@ -1,17 +1,98 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
describe InteractiveGrep::Grepper do
|
3
|
-
|
3
|
+
describe "instantiation" do
|
4
|
+
let(:params) { {} }
|
5
|
+
let(:grepper) { InteractiveGrep::Grepper.new( params ) }
|
4
6
|
context "with invalid params" do
|
5
7
|
it "should raise an error" do
|
6
|
-
expect { InteractiveGrep::Grepper.new }.to raise_error(ArgumentError)
|
7
8
|
expect { InteractiveGrep::Grepper.new(:one) }.to raise_error
|
9
|
+
expect { InteractiveGrep::Grepper.new("./*.gz") }.to raise_error
|
10
|
+
expect { InteractiveGrep::Grepper.new( { "files" => "" } ) }.to raise_error
|
11
|
+
expect { InteractiveGrep::Grepper.new }.to raise_error
|
8
12
|
end
|
9
13
|
end
|
10
14
|
context "with valid params" do
|
11
15
|
it "should not raise an error" do
|
12
|
-
expect { InteractiveGrep::Grepper.new( "
|
16
|
+
expect { InteractiveGrep::Grepper.new( { "files" => "#{file_dir}/**/*", "verbose" => nil, "pattern" => "", "mode" => "", "gz" => "" } ) }.not_to raise_error
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "detecting files" do
|
21
|
+
context "when specifying an ungzipped file" do
|
22
|
+
let(:params) { { "files" => "#{ungzipped_file}" } }
|
23
|
+
|
24
|
+
it "should have an array consisting of the ungzipped file" do
|
25
|
+
grepper.file_names.should == [ ungzipped_file ]
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should have gz set to false" do
|
29
|
+
grepper.gz.should be_false
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "when specifying a gzipped file" do
|
34
|
+
let(:params) { { "files" => "#{gzipped_file}" } }
|
35
|
+
|
36
|
+
it "should have an array consisting of the gzipped file" do
|
37
|
+
grepper.file_names.should == [ gzipped_file ]
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should have gz set to true" do
|
41
|
+
grepper.gz.should be_true
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context "when specifying a gzip glob " do
|
46
|
+
let(:params) { { "files" => "#{gzip_glob}" } }
|
47
|
+
|
48
|
+
it "should have an array consisting of the gzipped file" do
|
49
|
+
grepper.file_names.should == [ gzipped_file ]
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should have gz set to true" do
|
53
|
+
grepper.gz.should be_true
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context "when specifying a ungzipped glob " do
|
58
|
+
let(:params) { { "files" => "#{ungzip_glob}" } }
|
59
|
+
|
60
|
+
it "should have an array consisting of the ungzipped file" do
|
61
|
+
grepper.file_names.should == [ ungzipped_file ]
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should have gz set to false" do
|
65
|
+
grepper.gz.should be_false
|
66
|
+
end
|
13
67
|
end
|
14
68
|
end
|
15
|
-
end
|
16
69
|
|
70
|
+
describe "detecting file-patterns" do
|
71
|
+
context "in gzipped files" do
|
72
|
+
context "counting matches" do
|
73
|
+
let(:params) { { "files" => "#{gzipped_file}", "pattern" => "pattern", "mode" => "count" } }
|
74
|
+
it "should be in 'count' mode" do
|
75
|
+
grepper.should be_just_count
|
76
|
+
end
|
77
|
+
it "should match two lines" do
|
78
|
+
grepper.run.should == 2
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
# test w/ default pattern
|
84
|
+
context "in ungzipped files" do
|
85
|
+
context "counting matches" do
|
86
|
+
let(:params) { { "files" => "#{ungzipped_file}", "pattern" => "pattern", "mode" => "count" } }
|
87
|
+
it "should be in 'count' mode" do
|
88
|
+
grepper.should be_just_count
|
89
|
+
end
|
90
|
+
it "should match two lines" do
|
91
|
+
grepper.run.should == 2
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
17
98
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -3,3 +3,35 @@ Bundler.setup
|
|
3
3
|
|
4
4
|
require "rspec"
|
5
5
|
require "interactive_grep"
|
6
|
+
|
7
|
+
def file_dir
|
8
|
+
File.expand_path( '../tmp', __FILE__ )
|
9
|
+
end
|
10
|
+
|
11
|
+
def ungzipped_file_dir
|
12
|
+
"#{file_dir}/ungzipped_files"
|
13
|
+
end
|
14
|
+
|
15
|
+
def all_file_glob
|
16
|
+
"#{file_dir}/*/*"
|
17
|
+
end
|
18
|
+
|
19
|
+
def ungzip_glob
|
20
|
+
"#{ungzipped_file_dir}/*"
|
21
|
+
end
|
22
|
+
|
23
|
+
def gzip_glob
|
24
|
+
"#{gzipped_file_dir}/*"
|
25
|
+
end
|
26
|
+
|
27
|
+
def gzipped_file
|
28
|
+
"#{gzipped_file_dir}/file.txt.gz"
|
29
|
+
end
|
30
|
+
|
31
|
+
def ungzipped_file
|
32
|
+
"#{ungzipped_file_dir}/file.txt"
|
33
|
+
end
|
34
|
+
|
35
|
+
def gzipped_file_dir
|
36
|
+
"#{file_dir}/gzipped_files"
|
37
|
+
end
|
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: interactive_grep
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-21 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70175694399860 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,8 +21,9 @@ dependencies:
|
|
21
21
|
version: 2.11.0
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
25
|
-
description:
|
24
|
+
version_requirements: *70175694399860
|
25
|
+
description: grep for stuff in (optionally gzipped) files ...even before you fully
|
26
|
+
know what that 'stuff' looks like
|
26
27
|
email:
|
27
28
|
- jaytee_sr_at_his-service_dot_net
|
28
29
|
executables:
|
@@ -37,13 +38,13 @@ files:
|
|
37
38
|
- Rakefile
|
38
39
|
- bin/igrep
|
39
40
|
- interactive_grep.gemspec
|
40
|
-
- lib/.DS_Store
|
41
41
|
- lib/interactive_grep.rb
|
42
|
-
- lib/interactive_grep/.DS_Store
|
43
42
|
- lib/interactive_grep/grepper.rb
|
44
43
|
- lib/interactive_grep/version.rb
|
45
44
|
- spec/lib/interactive_grep/grepper_spec.rb
|
46
45
|
- spec/spec_helper.rb
|
46
|
+
- spec/tmp/gzipped_files/file.txt.gz
|
47
|
+
- spec/tmp/ungzipped_files/file.txt
|
47
48
|
homepage: https://github.com/JayTeeSF/interactive_grep
|
48
49
|
licenses: []
|
49
50
|
post_install_message:
|
@@ -67,8 +68,10 @@ rubyforge_project: interactive_grep
|
|
67
68
|
rubygems_version: 1.8.17
|
68
69
|
signing_key:
|
69
70
|
specification_version: 3
|
70
|
-
summary: My very first Ruby program,
|
71
|
-
|
71
|
+
summary: My very first Ruby program, for interactively grepping through gzipped weblogs
|
72
|
+
for unexpected patterns
|
72
73
|
test_files:
|
73
74
|
- spec/lib/interactive_grep/grepper_spec.rb
|
74
75
|
- spec/spec_helper.rb
|
76
|
+
- spec/tmp/gzipped_files/file.txt.gz
|
77
|
+
- spec/tmp/ungzipped_files/file.txt
|
data/lib/.DS_Store
DELETED
Binary file
|
Binary file
|