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.
@@ -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"] = true
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
@@ -19,5 +19,5 @@ Gem::Specification.new do |s|
19
19
 
20
20
  # specify any dependencies here; for example:
21
21
  s.add_development_dependency "rspec", "~> 2.11.0"
22
- s.add_development_dependency "ruby-debug19"
22
+ #s.add_development_dependency "ruby-debug19"
23
23
  end
@@ -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 = DEBUG || !!options[ "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" if verbose?
90
+ puts "matched #{counter} line(s)\ndone.\n"
83
91
  counter
84
92
  else
85
93
  puts "done.\n" if verbose?
@@ -1,3 +1,3 @@
1
1
  module InteractiveGrep
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
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.4
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: 2012-07-21 00:00:00.000000000Z
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: &70136989126620 !ruby/object:Gem::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: *70136989126620
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: '0'
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: 1.8.17
69
+ rubygems_version: 2.0.6
80
70
  signing_key:
81
- specification_version: 3
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: