request-log-analyzer 1.6.0 → 1.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,7 +11,7 @@ module RequestLogAnalyzer
11
11
 
12
12
  # The current version of request-log-analyzer.
13
13
  # Do not change the value by hand; it will be updated automatically by the gem release script.
14
- VERSION = "1.6.0"
14
+ VERSION = "1.6.1"
15
15
 
16
16
  # Loads constants in the RequestLogAnalyzer namespace using self.load_default_class_file(base, const)
17
17
  # <tt>const</tt>:: The constant that is not yet loaded in the RequestLogAnalyzer namespace. This should be passed as a string or symbol.
@@ -82,14 +82,13 @@ class RequestLogAnalyzer::Database::Base < ActiveRecord::Base
82
82
  capture[:provides].each { |field, field_type| t.column(field, column_type(field_type)) } if capture[:provides].kind_of?(Hash)
83
83
  end
84
84
  end
85
+
86
+ # Add indices to table for more speedy querying
87
+ database.connection.add_index(self.table_name.to_sym, [:request_id]) # rescue
88
+ database.connection.add_index(self.table_name.to_sym, [:source_id]) # rescue
85
89
  end
86
-
87
- # Add indices to table for more speedy querying
88
- database.connection.add_index(self.table_name.to_sym, [:request_id]) # rescue
89
- database.connection.add_index(self.table_name.to_sym, [:source_id]) # rescue
90
90
  end
91
91
 
92
-
93
92
  # Function to determine the column type for a field
94
93
  # TODO: make more robust / include in file-format definition
95
94
  def self.column_type(type_indicator)
@@ -71,7 +71,7 @@ module RequestLogAnalyzer::Tracker
71
71
  return "- " if value.nil?
72
72
  return "0 " if value.zero?
73
73
 
74
- case Math.log10(value).floor
74
+ case [Math.log10(value.abs).floor, 0].max
75
75
  when 0...4 then '%d ' % value
76
76
  when 4...7 then '%dk' % (value / 1000)
77
77
  when 7...10 then '%dM' % (value / 1000_000)
@@ -23,7 +23,7 @@ module RequestLogAnalyzer::Tracker
23
23
  return "-" if bytes.nil?
24
24
  return "0 B" if bytes.zero?
25
25
 
26
- case Math.log10(bytes).floor
26
+ case [Math.log10(bytes.abs).floor, 0].max
27
27
  when 0...4 then '%d B' % bytes
28
28
  when 4...7 then '%d kB' % (bytes / 1000)
29
29
  when 7...10 then '%d MB' % (bytes / 1000_000)
@@ -2,8 +2,8 @@ Gem::Specification.new do |s|
2
2
  s.name = "request-log-analyzer"
3
3
 
4
4
  # Do not set the version and date field manually, this is done by the release script
5
- s.version = "1.6.0"
6
- s.date = "2010-01-08"
5
+ s.version = "1.6.1"
6
+ s.date = "2010-01-16"
7
7
 
8
8
  s.rubyforge_project = 'r-l-a'
9
9
 
@@ -85,22 +85,22 @@ describe RequestLogAnalyzer::Tracker::Base do
85
85
  end
86
86
 
87
87
  it "should return the value of the block if one is given to the :if option" do
88
- tracker = @tracker_class.new(:if => lambda { false } )
88
+ tracker = @tracker_class.new(:if => lambda { |r| false } )
89
89
  tracker.should_update?(request(:field => 'anything')).should be_false
90
90
  end
91
91
 
92
92
  it "should return the inverse value of the block if one is given to the :if option" do
93
- tracker = @tracker_class.new(:unless => lambda { false } )
93
+ tracker = @tracker_class.new(:unless => lambda { |r| false } )
94
94
  tracker.should_update?(request(:field => 'anything')).should be_true
95
95
  end
96
96
 
97
97
  it "should return false if any of the checks fail" do
98
- tracker = @tracker_class.new(:if => :field, :unless => lambda { false }, :line_type => :not_present )
98
+ tracker = @tracker_class.new(:if => :field, :unless => lambda { |r| false }, :line_type => :not_present )
99
99
  tracker.should_update?(request(:line_type => :present, :field => 'anything')).should be_false
100
100
  end
101
101
 
102
102
  it "should return true if all of the checks succeed" do
103
- tracker = @tracker_class.new(:if => :field, :unless => lambda { false }, :line_type => :present )
103
+ tracker = @tracker_class.new(:if => :field, :unless => lambda { |r| false }, :line_type => :present )
104
104
  tracker.should_update?(request(:line_type => :present, :field => 'anything')).should be_true
105
105
  end
106
106
 
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.6.0
4
+ version: 1.6.1
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: 2010-01-08 00:00:00 +01:00
13
+ date: 2010-01-16 00:00:00 +01:00
14
14
  default_executable: request-log-analyzer
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency