indy 0.1.4 → 0.1.5

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.
@@ -23,8 +23,28 @@ describe "Search Performance" do
23
23
  @indy.like(:message => 'filesystem')
24
24
  end
25
25
 
26
- it "should profile code using #time()" do
27
- @indy.after(:time => "12-29-2010 12:11:33").for(:all)
26
+ it "should profile code using #after()" do
27
+ @indy.after(:time => "29-12-2010 12:11:32").for(:all)
28
+ end
29
+
30
+ end
31
+
32
+ end
33
+
34
+ context "with a 10000 line log file" do
35
+
36
+ large_file = "#{File.dirname(__FILE__)}/large.log"
37
+ before(:all) do
38
+ @indy = Indy.new(
39
+ :source => large_file,
40
+ :pattern => [/^\[([^\|]+)\|([^\]]+)\] (.*)$/,:severity, :time, :message],
41
+ :time_format => '%d-%m-%Y %H:%M:%S')
42
+ end
43
+
44
+ profile :file => STDOUT, :printer => :flat, :min_percent => 1 do
45
+
46
+ it "should profile code using #after() and an explicit @time_format" do
47
+ @indy.after(:time => "29-12-2010 12:11:32").for(:all)
28
48
  end
29
49
 
30
50
  end
data/spec/indy_spec.rb CHANGED
@@ -82,6 +82,18 @@ describe Indy do
82
82
  Indy.search(:cmd => "ls").source.should_not be_nil
83
83
  end
84
84
 
85
+ it "the instance should raise an exception when passed an invalid source: Fixnum" do
86
+ lambda{ Indy.search(9) }.should raise_error Indy::InvalidSource
87
+ end
88
+
89
+ it "the instance should raise an exception when passed an invalid source: nil" do
90
+ lambda{ Indy.search(nil) }.should raise_error Indy::InvalidSource
91
+ end
92
+
93
+ it "the instance should raise an exception when the arity is incorrect" do
94
+ lambda{ Indy.search( ) }.should raise_error Indy::InvalidSource
95
+ end
96
+
85
97
  context "for a String" do
86
98
 
87
99
  let(:log_file) { "#{File.dirname(__FILE__)}/data.log" }
@@ -151,7 +163,7 @@ describe Indy do
151
163
  context "bad data" do
152
164
 
153
165
  before(:each) do
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"
166
+ log = "2000-09-07 14:07:41 INFO MyApp - Entering APPLICATION.\n \n2000-09-07 14:07:41 INFO MyApp - Entering APPLICATION.\n bad \n2000-09-07 14:07:41 INFO MyApp - Entering APPLICATION.\n\n"
155
167
  @indy = Indy.search(log)
156
168
  end
157
169
 
@@ -164,7 +176,7 @@ describe Indy do
164
176
  context "instance" do
165
177
 
166
178
  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."
179
+ 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
180
  @indy = Indy.search(log)
169
181
  end
170
182
 
data/spec/time_spec.rb CHANGED
@@ -10,7 +10,7 @@ describe Indy do
10
10
 
11
11
  it "should parse a standard date" do
12
12
  line_hash = {:time => "2000-09-07 14:07:41", :message => "Entering APPLICATION"}
13
- @indy.send(:parse_date, line_hash).class.should == DateTime
13
+ @indy.send(:parse_date, line_hash).class.should == Time
14
14
  end
15
15
 
16
16
  it "should parse dates when log includes non-conforming data" do
@@ -118,8 +118,7 @@ describe Indy do
118
118
  end
119
119
 
120
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
121
+ @indy.around(:time => '2000-09-07 14:11:00', :span => 2).for(:all).count.should == 2
123
122
  end
124
123
 
125
124
  it "using after and inclusive should find the correct entries" do
@@ -140,7 +139,7 @@ describe Indy do
140
139
  ].join("\n") )
141
140
  end
142
141
 
143
- it "should find the correct entries" do
142
+ it "should find the correct entries (Bug: https://github.com/burtlo/Indy/issues#issue/3)" do
144
143
  @indy.after(:time => '2000-09-07 14:07:42').for(:all).length.should == 3
145
144
  @indy.before(:time => '2000-09-07 14:07:43').for(:all).length.should == 2
146
145
  end
@@ -156,7 +155,7 @@ describe Indy do
156
155
 
157
156
  it "should parse a non-standard date" do
158
157
  line_hash = {:time => "2000/09/07", :message => "Entering APPLICATION"}
159
- @indy.send(:parse_date, line_hash).class.should == DateTime
158
+ @indy.send(:parse_date, line_hash).class.should == Time
160
159
  end
161
160
 
162
161
  end
@@ -168,9 +167,11 @@ describe Indy do
168
167
  @indy = Indy.new(:time_format => '%m-%d-%Y', :source => "1-13-2002 message\n1-14-2002 another message\n1-15-2002 another message", :pattern => [pattern, :time, :message])
169
168
  end
170
169
 
171
- it "should parse a US style date when given a time format" do
170
+ it "should parse a US style date when given a time format by using DateTime" do
172
171
  line_hash = {:time => '1-13-2002', :message => 'message'}
173
- @indy.send(:parse_date, line_hash).class.should == DateTime
172
+ time = @indy.send(:parse_date, line_hash)
173
+ time.class.should == DateTime
174
+ time.day.should == 13
174
175
  end
175
176
 
176
177
  it "should accept standard time format searches even while using an explicit log time format" do
@@ -187,24 +188,21 @@ describe Indy do
187
188
  "2000-09-07 14:08:41 INFO MyApp - Exiting APPLICATION.",
188
189
  "2000-09-07 14:10:55 INFO MyApp - Exiting APPLICATION."].join("\n")
189
190
  @search_result = Indy.search(log_string).for(:application => 'MyApp')
190
- @time_search_result = Indy.search(log_string).before(:time => "2100-09-07").for(:application => 'MyApp')
191
+ @time_search_result = Indy.search(log_string).before(:time => "2020-09-07").for(:application => 'MyApp')
191
192
  end
192
193
 
193
194
  it "should not exist as an attribute when unless performing a time search" do
194
195
  @search_result.first._time.class.should == NilClass
195
- @time_search_result.first._time.class.should == DateTime
196
+ @time_search_result.first._time.class.should == Time
196
197
  end
197
198
 
198
199
  it "should be accurate" do
199
- @time_search_result.first._time.to_s.should == "2000-09-07T14:07:41+00:00"
200
+ @time_search_result.first._time.to_s.should == "Thu Sep 07 14:07:41 -0700 2000"
200
201
  end
201
202
 
202
203
  it "should allow for time range calculations" do
203
- time_span = @time_search_result.last._time - @time_search_result.first._time
204
- hours,minutes,seconds,frac = Date.day_fraction_to_time( time_span )
205
- hours.should == 0
206
- minutes.should == 3
207
- seconds.should == 14
204
+ seconds = @time_search_result.last._time - @time_search_result.first._time
205
+ seconds.should == 194
208
206
  end
209
207
 
210
208
  end
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: 19
5
- prerelease: false
4
+ hash: 17
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 4
10
- version: 0.1.4
9
+ - 5
10
+ version: 0.1.5
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-19 00:00:00 -08:00
19
+ date: 2011-01-21 00:00:00 -08:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -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.4 / 2011-01-19.\n\n Changes:\n \n * Add support for Ruby 1.8.5\n \n\n [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>]\n\n "
224
+ post_install_message: "\n [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>]\n\n Thank you for installing Indy 0.1.5 / 2011-01-21.\n\n Changes:\n \n * Searching with time scopes (#after, #within, #before) are much faster\n * Dates used in time scopes are limited to 1901 - 2038\n * The Windows platform limits dates further to 1969 - 2038\n * Explicit format string for time forces the old (slower) time scoping code\n * However, this removes the harsh limits on date values\n \n\n [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>] [<>]\n\n "
225
225
  rdoc_options:
226
226
  - --charset=UTF-8
227
227
  require_paths:
@@ -249,7 +249,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
249
249
  requirements: []
250
250
 
251
251
  rubyforge_project:
252
- rubygems_version: 1.3.7
252
+ rubygems_version: 1.4.2
253
253
  signing_key:
254
254
  specification_version: 3
255
255
  summary: Log Search Library