indy 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,30 +2,29 @@ require "#{File.dirname(__FILE__)}/helper"
2
2
 
3
3
  describe "Search Performance" do
4
4
 
5
+ context "with a 10000 line log file" do
5
6
 
6
- context "with a 420 line log file" do
7
-
8
- log_content = [
9
- "2000-09-07 14:07:41 INFO MyApp - Entering application.\n",
10
- "2000-09-07 14:07:42 DEBUG MyApp - Focusing application.\n",
11
- "2000-09-07 14:07:43 DEBUG MyApp - Blurring application.\n",
12
- "2000-09-07 14:07:44 WARN MyApp - Low on Memory.\n",
13
- "2000-09-07 14:07:45 ERROR MyApp - Out of Memory.\n",
14
- "2000-09-07 14:07:46 INFO MyApp - Exiting application.\n"
15
- ].collect {|line| line * 70 }.join
7
+ large_file = "#{File.dirname(__FILE__)}/large.log"
8
+ before(:all) do
9
+ @indy = Indy.search(large_file).with([/^\[([^\|]+)\|([^\]]+)\] (.*)$/,:severity, :time, :message])
10
+ end
16
11
 
17
12
  profile :file => STDOUT, :printer => :flat, :min_percent => 1 do
18
13
 
19
14
  it "should profile code using #for(:all)" do
20
- Indy.search(log_content.dup).for(:all)
15
+ @indy.for(:all)
21
16
  end
22
17
 
23
18
  it "should profile code using #for(:field => 'value')" do
24
- Indy.search(log_content.dup).for(:severity => 'INFO')
19
+ @indy.for(:severity => 'DEBUG')
20
+ end
21
+
22
+ it "should profile code using #like(:field => 'value')" do
23
+ @indy.like(:message => 'filesystem')
25
24
  end
26
25
 
27
26
  it "should profile code using #time()" do
28
- Indy.search(log_content.dup).after(:time => "2000-09-07 14:07:45").for(:all)
27
+ @indy.after(:time => "12-29-2010 12:11:33").for(:all)
29
28
  end
30
29
 
31
30
  end
data/spec/indy_spec.rb CHANGED
@@ -2,7 +2,7 @@ require "#{File.dirname(__FILE__)}/helper"
2
2
 
3
3
  describe Indy do
4
4
 
5
- context :initialize do
5
+ context ':initialize' do
6
6
 
7
7
  # http://log4r.rubyforge.org/rdoc/Log4r/rdoc/patternformatter.html
8
8
  it "should accept a log4r pattern string without error" do
@@ -58,7 +58,7 @@ describe Indy do
58
58
 
59
59
  end
60
60
 
61
- context :search do
61
+ context ':search' do
62
62
 
63
63
  it "should be a class method" do
64
64
  Indy.should respond_to(:search)
@@ -148,13 +148,26 @@ describe Indy do
148
148
 
149
149
  end
150
150
 
151
- context "instance" do
151
+ context "bad data" do
152
152
 
153
153
  before(:each) do
154
154
  log = "2000-09-07 14:07:41 INFO MyApp - Entering APPLICATION.\n \n2000-09-07 14:07:41 INFO MyApp Entering APPLICATION.\n2000-09-07 14:07:41 INFO MyApp - Entering APPLICATION.\n\n"
155
155
  @indy = Indy.search(log)
156
156
  end
157
157
 
158
+ it "should find all 3 rows" do
159
+ @indy.for(:all).count.should == 3
160
+ end
161
+
162
+ end
163
+
164
+ context "instance" do
165
+
166
+ before(:each) do
167
+ log = "2000-09-07 14:07:41 INFO MyApp - Entering APPLICATION.\n2000-09-07 14:07:41 INFO MyApp Entering APPLICATION.\n2000-09-07 14:07:41 INFO MyApp - Entering APPLICATION."
168
+ @indy = Indy.search(log)
169
+ end
170
+
158
171
  it "with() should be a method" do
159
172
  @indy.should respond_to(:with)
160
173
  end
@@ -167,6 +180,10 @@ describe Indy do
167
180
  lambda { @indy.with(:default) }.should_not raise_error
168
181
  end
169
182
 
183
+ it "with() should use default log pattern when passed :default" do
184
+ @indy.with(:default).for(:all).count.should == 3
185
+ end
186
+
170
187
  it "with() should accept no params without error" do
171
188
  lambda { @indy.with() }.should_not raise_error
172
189
  end
@@ -1,9 +1,36 @@
1
1
  require "#{File.dirname(__FILE__)}/helper"
2
2
 
3
- describe ResultSet do
3
+ describe 'ResultSet' do
4
4
 
5
5
  it "should be Enumerable" do
6
6
  ResultSet.new.should be_kind_of(Enumerable)
7
7
  end
8
8
 
9
+ context 'search results' do
10
+
11
+ before(:all) do
12
+ logcontent = "2000-09-07 14:07:42 INFO MyApp - Entering APPLICATION.\n2000-09-07 14:07:43 DEBUG MyOtherApp - Entering APPLICATION.\n2000-09-07 14:07:45 WARN MyThirdApp - Entering APPLICATION."
13
+ @indy = Indy.search(logcontent)
14
+ end
15
+
16
+ context 'per line results' do
17
+
18
+ it "should contain an array of Enumerables" do
19
+ @indy.for(:all).first.should be_kind_of(Enumerable)
20
+ end
21
+
22
+ it "should provide attribute readers for each field" do
23
+ line1, line2, line3 = @indy.for(:all)
24
+ line1.time.should == '2000-09-07 14:07:42'
25
+ line1.severity.should == 'INFO'
26
+ line1.application.should == 'MyApp'
27
+ line1.message.should == 'Entering APPLICATION.'
28
+ line2.application.should == 'MyOtherApp'
29
+ line3.application.should == 'MyThirdApp'
30
+ end
31
+
32
+ end
33
+ end
34
+
35
+
9
36
  end
data/spec/search_spec.rb CHANGED
@@ -98,6 +98,13 @@ describe Indy do
98
98
 
99
99
  it "should return 2 records" do
100
100
  @indy.for(:application => 'MyApp').length.should == 2
101
+ results = @indy.for(:application => 'MyApp')
102
+ results.last.time.should == '2000-09-07 14:10:55'
103
+ results.last.severity.should == 'INFO'
104
+ results.last.application.should == 'MyApp'
105
+ results.last.message.should == 'Exiting APPLICATION.'
106
+ results.last._time.class.should_not be_nil
107
+
101
108
  end
102
109
 
103
110
  it "should execute cmd on each successive search" do
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: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
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-17 00:00:00 -08:00
19
+ date: 2011-01-18 00:00:00 -08:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -52,9 +52,41 @@ dependencies:
52
52
  type: :development
53
53
  version_requirements: *id002
54
54
  - !ruby/object:Gem::Dependency
55
- name: rspec
55
+ name: yard
56
56
  prerelease: false
57
57
  requirement: &id003 !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ hash: 15
63
+ segments:
64
+ - 0
65
+ - 6
66
+ - 4
67
+ version: 0.6.4
68
+ type: :development
69
+ version_requirements: *id003
70
+ - !ruby/object:Gem::Dependency
71
+ name: cucumber-in-the-yard
72
+ prerelease: false
73
+ requirement: &id004 !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ hash: 5
79
+ segments:
80
+ - 1
81
+ - 7
82
+ - 7
83
+ version: 1.7.7
84
+ type: :development
85
+ version_requirements: *id004
86
+ - !ruby/object:Gem::Dependency
87
+ name: rspec
88
+ prerelease: false
89
+ requirement: &id005 !ruby/object:Gem::Requirement
58
90
  none: false
59
91
  requirements:
60
92
  - - ">="
@@ -66,11 +98,11 @@ dependencies:
66
98
  - 0
67
99
  version: 2.4.0
68
100
  type: :development
69
- version_requirements: *id003
101
+ version_requirements: *id005
70
102
  - !ruby/object:Gem::Dependency
71
103
  name: rspec-mocks
72
104
  prerelease: false
73
- requirement: &id004 !ruby/object:Gem::Requirement
105
+ requirement: &id006 !ruby/object:Gem::Requirement
74
106
  none: false
75
107
  requirements:
76
108
  - - ">="
@@ -82,11 +114,11 @@ dependencies:
82
114
  - 0
83
115
  version: 2.4.0
84
116
  type: :development
85
- version_requirements: *id004
117
+ version_requirements: *id006
86
118
  - !ruby/object:Gem::Dependency
87
119
  name: rspec-prof
88
120
  prerelease: false
89
- requirement: &id005 !ruby/object:Gem::Requirement
121
+ requirement: &id007 !ruby/object:Gem::Requirement
90
122
  none: false
91
123
  requirements:
92
124
  - - ">="
@@ -98,11 +130,11 @@ dependencies:
98
130
  - 3
99
131
  version: 0.0.3
100
132
  type: :development
101
- version_requirements: *id005
133
+ version_requirements: *id007
102
134
  - !ruby/object:Gem::Dependency
103
135
  name: rcov
104
136
  prerelease: false
105
- requirement: &id006 !ruby/object:Gem::Requirement
137
+ requirement: &id008 !ruby/object:Gem::Requirement
106
138
  none: false
107
139
  requirements:
108
140
  - - ">="
@@ -114,11 +146,11 @@ dependencies:
114
146
  - 9
115
147
  version: 0.9.9
116
148
  type: :development
117
- version_requirements: *id006
149
+ version_requirements: *id008
118
150
  - !ruby/object:Gem::Dependency
119
151
  name: flog
120
152
  prerelease: false
121
- requirement: &id007 !ruby/object:Gem::Requirement
153
+ requirement: &id009 !ruby/object:Gem::Requirement
122
154
  none: false
123
155
  requirements:
124
156
  - - ">="
@@ -130,8 +162,8 @@ dependencies:
130
162
  - 0
131
163
  version: 2.5.0
132
164
  type: :development
133
- version_requirements: *id007
134
- description: " Indy is a log archelogy tool that allows you to interact with log data like an object while you search by fields and/or time."
165
+ version_requirements: *id009
166
+ description: " Indy is a log archelogy tool explore logs like objects and search by field and/or time."
135
167
  email: franklin.webber@gmail.com
136
168
  executables: []
137
169
 
@@ -176,6 +208,7 @@ files:
176
208
  - lib/indy/patterns.rb
177
209
  - lib/indy/result_set.rb
178
210
  - performance/helper.rb
211
+ - performance/large.log
179
212
  - performance/profile_spec.rb
180
213
  - spec/data.log
181
214
  - spec/helper.rb
@@ -188,7 +221,7 @@ has_rdoc: true
188
221
  homepage: http://github.com/burtlo/Indy
189
222
  licenses:
190
223
  - MIT
191
- post_install_message: "\n [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>]\n\n Thank you for installing Indy 0.1.2 / 2011-01-18.\n\n Changes:\n \n * Predefined log formats for NCSA Common, NCSA Combined, and Log4r (default)\n * Source IO is explicitly closed after each #_search\n * Removed instance method #search; use #for.\n * Removed instance method #severity\n \n\n [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>]\n\n "
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 "
192
225
  rdoc_options:
193
226
  - --charset=UTF-8
194
227
  require_paths: