indy 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.1.4 / 2011-01-19
2
+
3
+ * Add support for Ruby 1.8.5
4
+
1
5
  === 0.1.3 / 2011-01-18
2
6
 
3
7
  * Faster (than a turtle)
data/indy.gemspec CHANGED
@@ -30,14 +30,14 @@ Gem::Specification.new do |s|
30
30
  s.name = 'indy'
31
31
  s.version = ::Indy::VERSION
32
32
  s.authors = ["Franklin Webber","Brandon Faloona"]
33
- s.description = %{ Indy is a log archelogy tool explore logs like objects and search by field and/or time.}
34
- s.summary = "Log Search Tool"
33
+ s.description = %{ Indy is a log archelogy library that treats logs like data structures. Search fixed format or custom logs by field and/or time. }
34
+ s.summary = "Log Search Library"
35
35
  s.email = 'franklin.webber@gmail.com'
36
36
  s.homepage = "http://github.com/burtlo/Indy"
37
37
  s.license = 'MIT'
38
38
 
39
39
  s.platform = Gem::Platform::RUBY
40
- s.required_ruby_version = '>= 1.8.7'
40
+ s.required_ruby_version = '>= 1.8.5'
41
41
  s.add_dependency('activesupport', '>= 2.3.5')
42
42
 
43
43
  s.add_development_dependency('cucumber', '>= 0.9.2')
data/lib/indy/indy.rb CHANGED
@@ -3,7 +3,7 @@ require 'active_support/core_ext'
3
3
 
4
4
  class Indy
5
5
 
6
- VERSION = "0.1.3"
6
+ VERSION = "0.1.4"
7
7
 
8
8
  #
9
9
  # hash with one key (:string, :file, or :cmd) set to the string that defines the log
@@ -296,7 +296,7 @@ class Indy
296
296
  time_search = use_time_criteria?
297
297
 
298
298
  source_io = open_source
299
- results = source_io.each.collect do |line|
299
+ results = source_io.collect do |line|
300
300
 
301
301
  hash = parse_line(line)
302
302
 
@@ -356,8 +356,10 @@ class Indy
356
356
  #
357
357
  def parse_line( line )
358
358
 
359
- if /#{@log_regexp}/.match(line)
360
- values = /#{@log_regexp}/.match(line).captures
359
+ match_data = /#{@log_regexp}/.match(line)
360
+
361
+ if match_data
362
+ values = match_data.captures
361
363
  raise "Field mismatch between log pattern and log data. The data is: '#{values.join(':::')}'" unless values.length == @log_fields.length
362
364
 
363
365
  hash = Hash[ *@log_fields.zip( values ).flatten ]
data/spec/indy_spec.rb CHANGED
@@ -30,7 +30,7 @@ describe Indy do
30
30
  :source => "1-13-2000 yes",
31
31
  :pattern => ['^([^\s]+) (\w+)$', :time, :message]}
32
32
  lambda{ @indy = Indy.search( hash ) }.should_not raise_error
33
- @indy.for(:all).count.should == 1
33
+ @indy.for(:all).length.should == 1
34
34
  end
35
35
 
36
36
 
@@ -156,7 +156,7 @@ describe Indy do
156
156
  end
157
157
 
158
158
  it "should find all 3 rows" do
159
- @indy.for(:all).count.should == 3
159
+ @indy.for(:all).length.should == 3
160
160
  end
161
161
 
162
162
  end
@@ -181,7 +181,7 @@ describe Indy do
181
181
  end
182
182
 
183
183
  it "with() should use default log pattern when passed :default" do
184
- @indy.with(:default).for(:all).count.should == 3
184
+ @indy.with(:default).for(:all).length.should == 3
185
185
  end
186
186
 
187
187
  it "with() should accept no params without error" do
@@ -43,13 +43,13 @@ describe Indy do
43
43
  it "#{format[:name]} should work" do
44
44
  indy = Indy.new(:source => format[:source], :pattern => [format[:regexp],format[:fields]].flatten)
45
45
  result = indy.for(format[:test_field] => 'louie')
46
- result.count.should == 1
46
+ result.length.should == 1
47
47
  end
48
48
 
49
49
  it "#{format[:name]} @pattern can be set to the Indy::LogFormat const" do
50
50
  indy = Indy.new(:source => format[:source], :pattern => eval('Indy::' + format[:name].upcase))
51
51
  result = indy.for(format[:test_field] => 'louie')
52
- result.count.should == 1
52
+ result.length.should == 1
53
53
 
54
54
  end
55
55
  end
data/spec/time_spec.rb CHANGED
@@ -15,19 +15,135 @@ describe Indy do
15
15
 
16
16
  it "should parse dates when log includes non-conforming data" do
17
17
  logdata = [ "12-03-2000 message1",
18
- "13-03-2000 message2",
19
- "14-03-2000 ",
20
- " message4",
21
- "a14-03-2000 message5",
22
- "14-03-2000 message6\n\n\n\n",
23
- "15-03-2000 message7",
24
- "16-03-2000 message8\r\n",
25
- "17-03-2000 message9"].join("\n")
18
+ "13-03-2000 message2",
19
+ "14-03-2000 ",
20
+ " message4",
21
+ "a14-03-2000 message5",
22
+ "14-03-2000 message6\n\n\n\n",
23
+ "15-03-2000 message7",
24
+ "16-03-2000 message8\r\n",
25
+ "17-03-2000 message9"].join("\n")
26
26
  @indy = Indy.new(:source => logdata, :pattern => ['^(\d[^\s]+\d) (.+)$', :time, :message])
27
27
  @indy.after(:time => '13-03-2000')
28
- @indy.for(:all).count.should == 4
28
+ @indy.for(:all).length.should == 4
29
29
  end
30
30
 
31
+ end
32
+
33
+ context "search time scope" do
34
+
35
+ before(:each) do
36
+ @indy = Indy.search(
37
+ [ "2000-09-07 14:07:41 INFO MyApp - Entering APPLICATION.",
38
+ "2000-09-07 14:07:42 INFO MyApp - Initializing APPLICATION.",
39
+ "2000-09-07 14:07:43 INFO MyApp - Configuring APPLICATION.",
40
+ "2000-09-07 14:07:44 INFO MyApp - Running APPLICATION.",
41
+ "2000-09-07 14:07:45 INFO MyApp - Exiting APPLICATION."
42
+ ].join("\n") )
43
+ end
44
+
45
+ context "after method" do
46
+
47
+ it "should find the correct entries" do
48
+ @indy.after(:time => '2000-09-07 14:07:42').for(:all).count.should == 3
49
+ end
50
+
51
+ it "should find 0 entries with a time that is past the log" do
52
+ @indy.after(:time => '2000-09-07 14:07:46').for(:all).length.should == 0
53
+ end
54
+
55
+ it "should find all entries with a time that is before the log" do
56
+ @indy.after(:time => '2000-09-07 14:07:40').for(:all).length.should == 5
57
+ end
58
+
59
+ it "should find entries using inclusive" do
60
+ @indy.after(:time => '2000-09-07 14:07:42', :inclusive => true).for(:all).length.should == 4
61
+ end
62
+
63
+ end
64
+
65
+ context "before method" do
66
+
67
+ it "should find the correct entries" do
68
+ @indy.before(:time => '2000-09-07 14:07:44').for(:all).count.should == 3
69
+ end
70
+
71
+ it "should find 0 entries with a time that is before the log" do
72
+ @indy.before(:time => '2000-09-07 14:07:40').for(:all).length.should == 0
73
+ end
74
+
75
+ it "should find all entries with a time that is after the log" do
76
+ @indy.before(:time => '2000-09-07 14:07:47').for(:all).length.should == 5
77
+ end
78
+
79
+ it "should find entries using inclusive" do
80
+ @indy.before(:time => '2000-09-07 14:07:44', :inclusive => true).for(:all).length.should == 4
81
+ end
82
+
83
+ end
84
+
85
+ context "within method" do
86
+
87
+ it "should find the correct entries" do
88
+ @indy.within(:time => ['2000-09-07 14:07:41', '2000-09-07 14:07:43']).for(:all).count.should == 1
89
+ end
90
+
91
+ it "should find the correct entries using inclusive" do
92
+ @indy.within(:time => ['2000-09-07 14:07:41', '2000-09-07 14:07:43'], :inclusive => true).for(:all).count.should == 3
93
+ end
94
+
95
+ end
96
+
97
+ end
98
+
99
+ context "search time scopes with span" do
100
+
101
+ before(:each) do
102
+ @indy = Indy.search(
103
+ [ "2000-09-07 14:07:41 INFO MyApp - Entering APPLICATION.",
104
+ "2000-09-07 14:08:41 INFO MyApp - Initializing APPLICATION.",
105
+ "2000-09-07 14:09:41 INFO MyApp - Configuring APPLICATION.",
106
+ "2000-09-07 14:10:50 INFO MyApp - Running APPLICATION.",
107
+ "2000-09-07 14:11:42 INFO MyApp - Exiting APPLICATION.",
108
+ "2000-09-07 14:12:15 INFO MyApp - Exiting APPLICATION."
109
+ ].join("\n") )
110
+ end
111
+
112
+ it "using after should find the correct entries" do
113
+ @indy.after(:time => '2000-09-07 14:07:42', :span => 1).for(:all).count.should == 1
114
+ end
115
+
116
+ it "using before should find the correct entries" do
117
+ @indy.before(:time => '2000-09-07 14:12:00', :span => 4).for(:all).count.should == 4
118
+ end
119
+
120
+ it "using around should find the correct entries" do
121
+ puts @indy.around(:time => '2000-09-07 14:11:00', :span => 2).inspect
122
+ @indy.for(:all).count.should == 3
123
+ end
124
+
125
+ it "using after and inclusive should find the correct entries" do
126
+ @indy.after(:time => '2000-09-07 14:07:41', :span => 1, :inclusive => true).for(:all).count.should == 1
127
+ end
128
+
129
+ end
130
+
131
+ context "multiple time scope methods on the same instance" do
132
+
133
+ before(:all) do
134
+ @indy = Indy.search(
135
+ [ "2000-09-07 14:07:41 INFO MyApp - Entering APPLICATION.",
136
+ "2000-09-07 14:07:42 INFO MyApp - Initializing APPLICATION.",
137
+ "2000-09-07 14:07:43 INFO MyApp - Configuring APPLICATION.",
138
+ "2000-09-07 14:07:44 INFO MyApp - Running APPLICATION.",
139
+ "2000-09-07 14:07:45 INFO MyApp - Exiting APPLICATION."
140
+ ].join("\n") )
141
+ end
142
+
143
+ it "should find the correct entries" do
144
+ @indy.after(:time => '2000-09-07 14:07:42').for(:all).length.should == 3
145
+ @indy.before(:time => '2000-09-07 14:07:43').for(:all).length.should == 2
146
+ end
31
147
 
32
148
  end
33
149
 
@@ -58,7 +174,7 @@ describe Indy do
58
174
  end
59
175
 
60
176
  it "should accept standard time format searches even while using an explicit log time format" do
61
- @indy.after(:time => 'Jan 13 2002').for(:all).count.should == 2
177
+ @indy.after(:time => 'Jan 13 2002').for(:all).length.should == 2
62
178
  @indy.after(:time => 'Jan 14 2002').for(:all).last._time.mday.should == 15
63
179
  end
64
180
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: indy
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
5
- prerelease:
4
+ hash: 19
5
+ prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 3
10
- version: 0.1.3
9
+ - 4
10
+ version: 0.1.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Franklin Webber
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-01-18 00:00:00 -08:00
19
+ date: 2011-01-19 00:00:00 -08:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -163,7 +163,7 @@ dependencies:
163
163
  version: 2.5.0
164
164
  type: :development
165
165
  version_requirements: *id009
166
- description: " Indy is a log archelogy tool explore logs like objects and search by field and/or time."
166
+ description: " Indy is a log archelogy library that treats logs like data structures. Search fixed format or custom logs by field and/or time. "
167
167
  email: franklin.webber@gmail.com
168
168
  executables: []
169
169
 
@@ -221,7 +221,7 @@ has_rdoc: true
221
221
  homepage: http://github.com/burtlo/Indy
222
222
  licenses:
223
223
  - MIT
224
- post_install_message: "\n [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>]\n\n Thank you for installing Indy 0.1.3 / 2011-01-18.\n\n Changes:\n \n * Faster (than a turtle)\n * Lighter (than a tank)\n \n\n [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>]\n\n "
224
+ post_install_message: "\n [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>]\n\n Thank you for installing Indy 0.1.4 / 2011-01-19.\n\n Changes:\n \n * Add support for Ruby 1.8.5\n \n\n [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>]\n\n "
225
225
  rdoc_options:
226
226
  - --charset=UTF-8
227
227
  require_paths:
@@ -231,12 +231,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
231
231
  requirements:
232
232
  - - ">="
233
233
  - !ruby/object:Gem::Version
234
- hash: 57
234
+ hash: 61
235
235
  segments:
236
236
  - 1
237
237
  - 8
238
- - 7
239
- version: 1.8.7
238
+ - 5
239
+ version: 1.8.5
240
240
  required_rubygems_version: !ruby/object:Gem::Requirement
241
241
  none: false
242
242
  requirements:
@@ -249,9 +249,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
249
249
  requirements: []
250
250
 
251
251
  rubyforge_project:
252
- rubygems_version: 1.4.2
252
+ rubygems_version: 1.3.7
253
253
  signing_key:
254
254
  specification_version: 3
255
- summary: Log Search Tool
255
+ summary: Log Search Library
256
256
  test_files: []
257
257