request-log-analyzer 1.1.6 → 1.2.0
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.
- data/Rakefile +1 -2
- data/bin/request-log-analyzer +1 -0
- data/lib/request_log_analyzer/output/fixed_width.rb +1 -0
- data/lib/request_log_analyzer.rb +6 -1
- data/spec/unit/tracker/hourly_spread_spec.rb +75 -0
- data/spec/unit/tracker/timespan_tracker_spec.rb +1 -0
- data/tasks/rspec.rake +12 -0
- metadata +5 -2
data/Rakefile
CHANGED
data/bin/request-log-analyzer
CHANGED
@@ -43,6 +43,7 @@ begin
|
|
43
43
|
end
|
44
44
|
|
45
45
|
rescue CommandLine::Error => e
|
46
|
+
puts "Request-log-analyzer, by Willem van Bergen and Bart ten Brinke - version #{RequestLogAnalyzer::VERSION}"
|
46
47
|
puts "ARGUMENT ERROR: " + e.message if e.message
|
47
48
|
puts
|
48
49
|
puts "Usage: request-log-analyzer [LOGFILES*] <OPTIONS>"
|
data/lib/request_log_analyzer.rb
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
require 'date'
|
2
2
|
|
3
|
+
# Satisfy ruby 1.9 sensitivity about encoding.
|
4
|
+
if defined? Encoding and Encoding.respond_to? 'default_external='
|
5
|
+
Encoding.default_external = 'binary'
|
6
|
+
end
|
7
|
+
|
3
8
|
# RequestLogAnalyzer is the base namespace in which all functionality of RequestLogAnalyzer is implemented.
|
4
9
|
#
|
5
10
|
# - This module itselfs contains some functions to help with class and source file loading.
|
@@ -8,7 +13,7 @@ module RequestLogAnalyzer
|
|
8
13
|
|
9
14
|
# The current version of request-log-analyzer.
|
10
15
|
# This will be diplayed in output reports etc.
|
11
|
-
VERSION = '1.1'
|
16
|
+
VERSION = '1.1.7'
|
12
17
|
|
13
18
|
# Loads constants in the RequestLogAnalyzer namespace using self.load_default_class_file(base, const)
|
14
19
|
# <tt>const</tt>:: The constant that is not yet loaded in the RequestLogAnalyzer namespace. This should be passed as a string or symbol.
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe RequestLogAnalyzer::Tracker::HourlySpread do
|
4
|
+
|
5
|
+
include RequestLogAnalyzer::Spec::Helper
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
@tracker = RequestLogAnalyzer::Tracker::HourlySpread.new
|
9
|
+
@tracker.prepare
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should store timestamps correctly" do
|
13
|
+
@tracker.update(request(:timestamp => 20090102000000))
|
14
|
+
@tracker.update(request(:timestamp => 20090101000000))
|
15
|
+
@tracker.update(request(:timestamp => 20090103000000))
|
16
|
+
|
17
|
+
@tracker.request_time_graph[0].should eql(3)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should count the number of timestamps correctly" do
|
21
|
+
@tracker.update(request(:timestamp => 20090102000000))
|
22
|
+
@tracker.update(request(:timestamp => 20090101000000))
|
23
|
+
@tracker.update(request(:timestamp => 20090103000000))
|
24
|
+
@tracker.update(request(:timestamp => 20090103010000))
|
25
|
+
|
26
|
+
@tracker.total_requests.should eql(4)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should set the first request timestamp correctly" do
|
30
|
+
@tracker.update(request(:timestamp => 20090102000000))
|
31
|
+
@tracker.update(request(:timestamp => 20090101000000))
|
32
|
+
@tracker.update(request(:timestamp => 20090103000000))
|
33
|
+
|
34
|
+
@tracker.first_timestamp.should == DateTime.parse('Januari 1, 2009 00:00:00')
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should set the last request timestamp correctly" do
|
38
|
+
@tracker.update(request(:timestamp => 20090102000000))
|
39
|
+
@tracker.update(request(:timestamp => 20090101000000))
|
40
|
+
@tracker.update(request(:timestamp => 20090103000000))
|
41
|
+
|
42
|
+
@tracker.last_timestamp.should == DateTime.parse('Januari 3, 2009 00:00:00')
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should return the correct timespan in days when multiple requests are given" do
|
46
|
+
@tracker.update(request(:timestamp => 20090102000000))
|
47
|
+
@tracker.update(request(:timestamp => 20090101000000))
|
48
|
+
@tracker.update(request(:timestamp => 20090103000000))
|
49
|
+
|
50
|
+
@tracker.timespan.should == 2
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
describe RequestLogAnalyzer::Tracker::HourlySpread, 'reporting' do
|
56
|
+
|
57
|
+
include RequestLogAnalyzer::Spec::Helper
|
58
|
+
|
59
|
+
before(:each) do
|
60
|
+
@tracker = RequestLogAnalyzer::Tracker::HourlySpread.new
|
61
|
+
@tracker.prepare
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should generate a report without errors when no request was tracked" do
|
65
|
+
lambda { @tracker.report(mock_output) }.should_not raise_error
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should generate a report without errors when multiple requests were tracked" do
|
69
|
+
@tracker.update(request(:timestamp => 20090102000000))
|
70
|
+
@tracker.update(request(:timestamp => 20090101000000))
|
71
|
+
@tracker.update(request(:timestamp => 20090103000000))
|
72
|
+
@tracker.update(request(:timestamp => 20090103010000))
|
73
|
+
lambda { @tracker.report(mock_output) }.should_not raise_error
|
74
|
+
end
|
75
|
+
end
|
@@ -59,6 +59,7 @@ describe RequestLogAnalyzer::Tracker::Timespan, 'reporting' do
|
|
59
59
|
it "should generate a report without errors when multiple requests were tracked" do
|
60
60
|
@tracker.update(request(:category => 'a', :timestamp => 20090102000000))
|
61
61
|
@tracker.update(request(:category => 'a', :timestamp => 20090101000000))
|
62
|
+
@tracker.update(request(:category => 'a', :timestamp => 20090103000000))
|
62
63
|
lambda { @tracker.report(mock_output) }.should_not raise_error
|
63
64
|
end
|
64
65
|
end
|
data/tasks/rspec.rake
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'spec/rake/spectask'
|
3
|
+
|
4
|
+
namespace :spec do
|
5
|
+
desc "Run all rspec with RCov"
|
6
|
+
Spec::Rake::SpecTask.new(:rcov) do |t|
|
7
|
+
|
8
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
9
|
+
t.rcov = true
|
10
|
+
t.rcov_opts = ['--exclude', '"spec/*,gems/*"', '--rails']
|
11
|
+
end
|
12
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: request-log-analyzer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Willem van Bergen
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-
|
13
|
+
date: 2009-06-12 00:00:00 +02:00
|
14
14
|
default_executable: request-log-analyzer
|
15
15
|
dependencies: []
|
16
16
|
|
@@ -112,11 +112,13 @@ files:
|
|
112
112
|
- spec/unit/tracker
|
113
113
|
- spec/unit/tracker/duration_tracker_spec.rb
|
114
114
|
- spec/unit/tracker/frequency_tracker_spec.rb
|
115
|
+
- spec/unit/tracker/hourly_spread_spec.rb
|
115
116
|
- spec/unit/tracker/timespan_tracker_spec.rb
|
116
117
|
- spec/unit/tracker/tracker_api_test.rb
|
117
118
|
- tasks
|
118
119
|
- tasks/github-gem.rake
|
119
120
|
- tasks/request_log_analyzer.rake
|
121
|
+
- tasks/rspec.rake
|
120
122
|
has_rdoc: true
|
121
123
|
homepage: http://github.com/wvanbergen/request-log-analyzer/wikis
|
122
124
|
post_install_message:
|
@@ -165,4 +167,5 @@ test_files:
|
|
165
167
|
- spec/unit/source/request_spec.rb
|
166
168
|
- spec/unit/tracker/duration_tracker_spec.rb
|
167
169
|
- spec/unit/tracker/frequency_tracker_spec.rb
|
170
|
+
- spec/unit/tracker/hourly_spread_spec.rb
|
168
171
|
- spec/unit/tracker/timespan_tracker_spec.rb
|