interactive_grep 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/igrep +6 -2
- data/interactive_grep.gemspec +1 -1
- data/lib/interactive_grep/grepper.rb +11 -3
- data/lib/interactive_grep/version.rb +1 -1
- metadata +11 -21
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4b61eca4378106cabe2d98c6d3d1f7b8891c7a1c
|
4
|
+
data.tar.gz: 739724e795b8df36eaead75c36f9eb1fcc7bc9af
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a41bff01405bec8cbaad0c4b63ca1007ec228d447f8be0a3f9e3f599ec6ba3eb30fd93e5976416f5668780e028511e192eec443e171c7d093d022b8300e2a100
|
7
|
+
data.tar.gz: 2ba9d6b091ac16305b86fd49f1f445fa234a3802cdd02139678e7c8e358a7bed8e373a025b3419675e8188b8faf65c25b7f879116e0c635583268e06f3c65d57
|
data/bin/igrep
CHANGED
@@ -11,7 +11,7 @@ end
|
|
11
11
|
require 'optparse'
|
12
12
|
|
13
13
|
options = {}
|
14
|
-
options["verbose"] =
|
14
|
+
options["verbose"] = false
|
15
15
|
|
16
16
|
opt_parser = OptionParser.new do |opts|
|
17
17
|
opts.banner = "Usage: #{$0} [OPTIONS] A_FILEGLOB or FILE(S)"
|
@@ -26,6 +26,10 @@ opt_parser = OptionParser.new do |opts|
|
|
26
26
|
options["mode"] = m
|
27
27
|
end
|
28
28
|
|
29
|
+
opts.on( "-v", '--verbose', "turn on verbosity") do
|
30
|
+
options["verbose"] = true
|
31
|
+
end
|
32
|
+
|
29
33
|
opts.on_tail( '-h', '--help', 'This help screen' ) do
|
30
34
|
puts opts
|
31
35
|
exit
|
@@ -42,6 +46,6 @@ end
|
|
42
46
|
|
43
47
|
igrep = InteractiveGrep::Grepper.new( options )
|
44
48
|
puts "Welcome..." if :interactive == options["mode"]
|
45
|
-
igrep.run()
|
49
|
+
puts igrep.run()
|
46
50
|
|
47
51
|
exit
|
data/interactive_grep.gemspec
CHANGED
@@ -13,7 +13,8 @@ module InteractiveGrep
|
|
13
13
|
options ||= {}
|
14
14
|
|
15
15
|
@progress_indicator_count = options[:progress_indicator_count] || DEFAULT_PROGRESS_INDICATOR_COUNT
|
16
|
-
@verbose =
|
16
|
+
@verbose = options.has_key?("verbose") ? options[ "verbose" ] : DEBUG
|
17
|
+
# puts "verbose: #{@verbose.inspect}"
|
17
18
|
@mode = options[ "mode" ] || "normal"
|
18
19
|
@gz = options[ "gz" ]
|
19
20
|
@initial_pattern = !!options[ "pattern" ] ? %r{#{options[ "pattern" ]}} : DEFAULT_PATTERN
|
@@ -61,12 +62,19 @@ module InteractiveGrep
|
|
61
62
|
@file_index += 1
|
62
63
|
end
|
63
64
|
|
65
|
+
def matches?(_line, _pattern)
|
66
|
+
return _line =~ _pattern
|
67
|
+
rescue ArgumentError
|
68
|
+
return false
|
69
|
+
end
|
70
|
+
|
64
71
|
def run
|
65
72
|
counter = 0
|
66
73
|
results = []
|
67
74
|
@current_pattern = initial_pattern
|
68
75
|
while line = next_line
|
69
|
-
if line[@current_pattern]
|
76
|
+
# if line[@current_pattern]
|
77
|
+
if matches?(line, @current_pattern)
|
70
78
|
line.strip!
|
71
79
|
counter += 1
|
72
80
|
unless just_count? || ( verbose? && interactive? )
|
@@ -79,7 +87,7 @@ module InteractiveGrep
|
|
79
87
|
reset_file_index
|
80
88
|
puts "no more files.\n" if verbose?
|
81
89
|
if just_count?
|
82
|
-
puts "matched #{counter} line(s)\ndone.\n"
|
90
|
+
puts "matched #{counter} line(s)\ndone.\n"
|
83
91
|
counter
|
84
92
|
else
|
85
93
|
puts "done.\n" if verbose?
|
metadata
CHANGED
@@ -1,38 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: interactive_grep
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.5
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- JayTeeSr
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-11-07 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rspec
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 2.11.0
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: ruby-debug19
|
27
|
-
requirement: &70136989126200 !ruby/object:Gem::Requirement
|
28
|
-
none: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
29
23
|
requirements:
|
30
|
-
- -
|
24
|
+
- - ~>
|
31
25
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
33
|
-
type: :development
|
34
|
-
prerelease: false
|
35
|
-
version_requirements: *70136989126200
|
26
|
+
version: 2.11.0
|
36
27
|
description: grep for stuff in (optionally gzipped) files ...even before you fully
|
37
28
|
know what that 'stuff' looks like
|
38
29
|
email:
|
@@ -58,27 +49,26 @@ files:
|
|
58
49
|
- spec/tmp/ungzipped_files/file.txt
|
59
50
|
homepage: https://github.com/JayTeeSF/interactive_grep
|
60
51
|
licenses: []
|
52
|
+
metadata: {}
|
61
53
|
post_install_message:
|
62
54
|
rdoc_options: []
|
63
55
|
require_paths:
|
64
56
|
- lib
|
65
57
|
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
-
none: false
|
67
58
|
requirements:
|
68
|
-
- -
|
59
|
+
- - '>='
|
69
60
|
- !ruby/object:Gem::Version
|
70
61
|
version: '0'
|
71
62
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
-
none: false
|
73
63
|
requirements:
|
74
|
-
- -
|
64
|
+
- - '>='
|
75
65
|
- !ruby/object:Gem::Version
|
76
66
|
version: '0'
|
77
67
|
requirements: []
|
78
68
|
rubyforge_project: interactive_grep
|
79
|
-
rubygems_version:
|
69
|
+
rubygems_version: 2.0.6
|
80
70
|
signing_key:
|
81
|
-
specification_version:
|
71
|
+
specification_version: 4
|
82
72
|
summary: My very first Ruby program, for interactively grepping through gzipped weblogs
|
83
73
|
for unexpected patterns
|
84
74
|
test_files:
|