request-log-analyzer 1.4.1 → 1.4.2

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.4.1"
14
+ VERSION = "1.4.2"
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.
@@ -1,14 +1,12 @@
1
1
  module RequestLogAnalyzer
2
2
 
3
3
  # The RequestLogAnalyzer::Controller class creates a LogParser instance for the
4
- # requested file format, and connect it with sources and aggregators.
4
+ # requested file format and connect it with sources and aggregators.
5
5
  #
6
6
  # Sources are streams or files from which the requests will be parsed.
7
7
  # Aggregators will handle every passed request to yield a meaningfull results.
8
8
  #
9
- # - Use the build-function to build a controller instance using command line arguments.
10
- # - Use add_aggregator to register a new aggregator
11
- # - Use add_source to register a new aggregator
9
+ # - Use the build -function to build a new controller instance.
12
10
  # - Use the run! method to start the parser and send the requests to the aggregators.
13
11
  #
14
12
  # Note that the order of sources can be imported if you have log files than succeed
@@ -21,7 +19,6 @@ module RequestLogAnalyzer
21
19
 
22
20
  # Builds a RequestLogAnalyzer::Controller given parsed command line arguments
23
21
  # <tt>arguments<tt> A CommandLine::Arguments hash containing parsed commandline parameters.
24
- # <rr>report_with</tt> Width of the report. Defaults to 80.
25
22
  def self.build_from_arguments(arguments)
26
23
 
27
24
  options = {}
@@ -32,7 +29,6 @@ module RequestLogAnalyzer
32
29
  options[:debug] = arguments[:debug]
33
30
  options[:yaml] = arguments[:dump]
34
31
  options[:mail] = arguments[:mail]
35
- options[:parse_strategy] = arguments[:parse_strategy]
36
32
  options[:no_progress] = arguments[:no_progress]
37
33
  options[:format] = arguments[:format]
38
34
  options[:output] = arguments[:output]
@@ -73,32 +69,39 @@ module RequestLogAnalyzer
73
69
  build(options)
74
70
  end
75
71
 
76
- # Build a new controller using parameters (Base for new API)
77
- # <tt>source</tt> The source file
78
- # Options are passd on to the LogParser.
72
+ # Build a new controller.
73
+ # Returns a new RequestLogAnalyzer::Controller object.
79
74
  #
80
75
  # Options
81
- # * <tt>:database</tt> Database file
82
- # * <tt>:reset_database</tt>
83
- # * <tt>:debug</tt> Enables echo aggregator.
84
- # * <tt>:yaml</tt> Output to YAML
85
- # * <tt>:parse_strategy</tt>
86
- # * <tt>:no_progress</tt> Do not display the progress bar
87
- # * <tt>:output</tt> :fixed_width, :html or Output class. Defaults to fixed width.
88
- # * <tt>:file</tt> Filestring or File or StringIO
89
- # * <tt>:format</tt> :rails, {:apache => 'FORMATSTRING'}, :merb, etcetera or Format Class. Defaults to :rails.
90
- # * <tt>:source_files</tt> File or STDIN
91
76
  # * <tt>:after</tt> Drop all requests after this date (Date, DateTime, Time, or a String in "YYYY-MM-DD hh:mm:ss" format)
92
- # * <tt>:before</tt> Drop all requests before this date (Date, DateTime, Time, or a String in "YYYY-MM-DD hh:mm:ss" format)
93
- # * <tt>:reject</tt> Reject specific {:field => :value} combination. Expects single hash.
94
- # * <tt>:select</tt> Select specific {:field => :value} combination. Expects single hash.
95
- # * <tt>:aggregator</tt> Array of aggregators (ATM: STRINGS OR SYMBOLS ONLY!). Defaults to [:summarizer
96
- # * <tt>:boring</tt> Do not show color on STDOUT. Defaults to False.
97
- # * <tt>:report_width</tt> Width or reports in characters. Defaults to 80.
77
+ # * <tt>:aggregator</tt> Array of aggregators (ATM: STRINGS OR SYMBOLS ONLY! - Defaults to [:summarizer]).
78
+ # * <tt>:boring</tt> Do not show color on STDOUT (Defaults to false).
79
+ # * <tt>:before</tt> Drop all requests before this date (Date, DateTime, Time or a String in "YYYY-MM-DD hh:mm:ss" format)
80
+ # * <tt>:database</tt> Database file to insert encountered requests to.
81
+ # * <tt>:debug</tt> Enables echo aggregator which will echo each request analyzed.
82
+ # * <tt>:file</tt> Filestring, File or StringIO.
83
+ # * <tt>:format</tt> :rails, {:apache => 'FORMATSTRING'}, :merb, etcetera or Format Class. (Defaults to :rails).
84
+ # * <tt>:mail</tt> Email the results to this email address.
85
+ # * <tt>:no_progress</tt> Do not display the progress bar (increases speed).
86
+ # * <tt>:output</tt> :fixed_width, :html or Output class. Defaults to fixed width.
87
+ # * <tt>:reject</tt> Reject specific {:field => :value} combination (expects a single hash).
88
+ # * <tt>:report_width</tt> Width or reports in characters. (Defaults to 80)
89
+ # * <tt>:reset_database</tt> Reset the database before starting.
90
+ # * <tt>:select</tt> Select specific {:field => :value} combination (expects a single hash).
91
+ # * <tt>:source_files</tt> Source files to analyze. Provide either File, array of files or STDIN.
92
+ # * <tt>:yaml</tt> Output to YAML file.
93
+ #
94
+ # === Example
95
+ # RequestLogAnalyzer::Controller.build(
96
+ # :output => :HTML,
97
+ # :mail => 'root@localhost',
98
+ # :after => Time.now - 24*60*60,
99
+ # :source_files => '/var/log/passenger.log'
100
+ # ).run!
98
101
  #
99
- # TODO:
100
- # Check if defaults work (Aggregator defaults seem wrong).
101
- # Refactor :database => options[:database], :dump => options[:dump] away from contoller intialization.
102
+ # === Todo
103
+ # * Check if defaults work (Aggregator defaults seem wrong).
104
+ # * Refactor :database => options[:database], :dump => options[:dump] away from contoller intialization.
102
105
  def self.build(options)
103
106
  # Defaults
104
107
  options[:output] ||= 'fixed_width'
@@ -109,7 +112,7 @@ module RequestLogAnalyzer
109
112
  options[:report_sort] ||= 'sum,mean'
110
113
  options[:boring] ||= false
111
114
 
112
- # Backwards compatibility
115
+ # Deprecation warnings
113
116
  if options[:dump] && options[:yaml].blank?
114
117
  warn "[DEPRECATION] `:dump` is deprecated. Please use `:yaml` instead."
115
118
  options[:yaml] = options[:dump]
@@ -1,15 +1,20 @@
1
1
  module RequestLogAnalyzer
2
2
 
3
+ # Mail report to a specified emailaddress
3
4
  class Mailer
4
5
 
5
6
  attr_accessor :data, :to, :host
6
7
 
7
8
  # Initialize a mailer
8
- # <tt>to</tt> to address
9
- # <tt>host</tt> the mailer host
9
+ # <tt>to</tt> to email address to mail to
10
+ # <tt>host</tt> the mailer host (defaults to localhost)
10
11
  # <tt>options</tt> Specific style options
12
+ #
11
13
  # Options
12
- # <tt>:debug</tt> Do not actually mail
14
+ # * <tt>:debug</tt> Do not actually mail
15
+ # * <tt>:from_alias</tt> The from alias
16
+ # * <tt>:to_alias</tt> The to alias
17
+ # * <tt>:subject</tt> The message subject
13
18
  def initialize(to, host = 'localhost', options = {})
14
19
  require 'net/smtp'
15
20
  @to = to
@@ -18,19 +23,24 @@ module RequestLogAnalyzer
18
23
  @data = []
19
24
  end
20
25
 
26
+ # Send all data in @data to the email address used during initialization.
27
+ # Returns array containg [message_data, from_email_address, to_email_address] of sent email.
21
28
  def mail
22
- from = @options[:from] || 'contact@railsdoctors.com'
23
- from_alias = @options[:from_alias] || 'Request-log-analyzer reporter'
24
- to_alias = @options[:to_alias] || to
25
- subject = @options[:subjeect] || "Request log analyzer report - generated on #{Time.now.to_s}"
29
+ from = @options[:from] || 'contact@railsdoctors.com'
30
+ from_alias = @options[:from_alias] || 'Request-log-analyzer reporter'
31
+ to_alias = @options[:to_alias] || to
32
+ subject = @options[:subject] || "Request log analyzer report - generated on #{Time.now.to_s}"
33
+ content_type = ""
34
+ content_type = 'Content-Type: text/html; charset="ISO-8859-1";' if @data.map{|l| l.include?('html')}.include?(true)
26
35
  msg = <<END_OF_MESSAGE
27
36
  From: #{from_alias} <#{from}>
28
37
  To: #{to_alias} <#{@to}>
29
38
  Subject: #{subject}
39
+ #{content_type}
30
40
 
31
41
  #{@data.to_s}
32
42
  END_OF_MESSAGE
33
-
43
+
34
44
  unless @options[:debug]
35
45
  Net::SMTP.start(@host) do |smtp|
36
46
  smtp.send_message msg, from, to
@@ -69,6 +69,8 @@ module RequestLogAnalyzer::Output
69
69
 
70
70
  # Genrate HTML header and associated stylesheet
71
71
  def header
72
+ @io.content_type = content_type if @io.respond_to?(:content_type)
73
+
72
74
  @io << "<html>"
73
75
  @io << tag(:head) do |headers|
74
76
  headers << tag(:title, 'Request-log-analyzer report')
@@ -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.4.1"
6
- s.date = "2009-10-07"
5
+ s.version = "1.4.2"
6
+ s.date = "2009-10-09"
7
7
 
8
8
  s.rubyforge_project = 'r-l-a'
9
9
 
@@ -35,6 +35,6 @@ Gem::Specification.new do |s|
35
35
 
36
36
  # The files and test_files directives are set automatically by the release script.
37
37
  # Do not change them by hand, but make sure to add the files to the git repository.
38
- s.files = %w(spec/unit/filter/anonymize_filter_spec.rb spec/fixtures/rails_22_cached.log lib/request_log_analyzer/line_definition.rb lib/request_log_analyzer/output/html.rb lib/request_log_analyzer/controller.rb spec/lib/macros.rb lib/request_log_analyzer/file_format/rails_development.rb spec/fixtures/apache_combined.log spec/fixtures/apache_common.log spec/fixtures/merb_prefixed.log lib/request_log_analyzer/file_format/amazon_s3.rb tasks/request_log_analyzer.rake spec/unit/file_format/file_format_api_spec.rb spec/unit/file_format/apache_format_spec.rb spec/integration/command_line_usage_spec.rb lib/request_log_analyzer/database.rb spec/fixtures/decompression.log.bz2 spec/fixtures/rails_unordered.log lib/request_log_analyzer/log_processor.rb lib/request_log_analyzer/tracker.rb lib/request_log_analyzer/filter.rb bin/request-log-analyzer request-log-analyzer.gemspec DESIGN.rdoc spec/unit/filter/timespan_filter_spec.rb spec/unit/aggregator/database_inserter_spec.rb spec/lib/matchers.rb lib/request_log_analyzer/filter/field.rb lib/request_log_analyzer/tracker/frequency.rb spec/fixtures/decompression.log.gz spec/fixtures/decompression.log spec/lib/testing_format.rb spec/fixtures/test_order.log spec/fixtures/rails.db lib/request_log_analyzer/output/fixed_width.rb lib/request_log_analyzer/filter/anonymize.rb lib/request_log_analyzer/tracker/timespan.rb lib/request_log_analyzer/database/base.rb lib/request_log_analyzer/aggregator.rb spec/unit/request_spec.rb lib/cli/progressbar.rb lib/request_log_analyzer/mailer.rb README.rdoc lib/request_log_analyzer/database/warning.rb spec/fixtures/merb.log lib/request_log_analyzer/tracker/hourly_spread.rb .gitignore spec/unit/tracker/tracker_api_spec.rb spec/unit/tracker/duration_tracker_spec.rb spec/unit/file_format/amazon_s3_format_spec.rb spec/integration/scout_spec.rb lib/request_log_analyzer/aggregator/echo.rb spec/unit/mailer_spec.rb spec/unit/controller/log_processor_spec.rb spec/spec_helper.rb lib/request_log_analyzer.rb spec/database.yml Rakefile lib/request_log_analyzer/database/connection.rb spec/unit/filter/filter_spec.rb spec/fixtures/test_language_combined.log lib/request_log_analyzer/aggregator/database_inserter.rb lib/request_log_analyzer/aggregator/summarizer.rb lib/request_log_analyzer/file_format/rack.rb lib/request_log_analyzer/database/source.rb lib/request_log_analyzer/file_format/rails.rb spec/fixtures/decompression.tar.gz spec/unit/tracker/traffic_tracker_spec.rb spec/unit/filter/field_filter_spec.rb spec/unit/database/base_class_spec.rb lib/request_log_analyzer/filter/timespan.rb lib/request_log_analyzer/source/log_parser.rb spec/fixtures/decompression.tgz spec/unit/tracker/timespan_tracker_spec.rb spec/unit/tracker/hourly_spread_spec.rb spec/fixtures/header_and_footer.log lib/cli/tools.rb lib/request_log_analyzer/file_format/merb.rb spec/fixtures/multiple_files_1.log spec/unit/file_format/merb_format_spec.rb spec/unit/file_format/line_definition_spec.rb lib/request_log_analyzer/source.rb lib/request_log_analyzer/request.rb lib/cli/database_console.rb spec/unit/database/connection_spec.rb spec/unit/controller/controller_spec.rb spec/lib/mocks.rb spec/lib/helpers.rb spec/fixtures/rails_1x.log lib/cli/database_console_init.rb lib/request_log_analyzer/output.rb lib/request_log_analyzer/file_format/apache.rb spec/fixtures/decompression.log.zip spec/unit/source/log_parser_spec.rb spec/integration/scouts_custom_output.rb spec/fixtures/test_file_format.log tasks/github-gem.rake spec/unit/database/database_spec.rb spec/integration/munin_plugins_rails_spec.rb lib/request_log_analyzer/tracker/duration.rb lib/request_log_analyzer/tracker/traffic.rb lib/request_log_analyzer/file_format.rb spec/unit/aggregator/summarizer_spec.rb spec/fixtures/syslog_1x.log spec/fixtures/rails_22.log lib/request_log_analyzer/database/request.rb spec/fixtures/multiple_files_2.log LICENSE lib/request_log_analyzer/source/database_loader.rb spec/unit/tracker/frequency_tracker_spec.rb spec/unit/file_format/rails_format_spec.rb lib/cli/command_line_arguments.rb)
38
+ s.files = %w(spec/unit/filter/anonymize_filter_spec.rb spec/fixtures/rails_22_cached.log lib/request_log_analyzer/line_definition.rb lib/request_log_analyzer/output/html.rb lib/request_log_analyzer/controller.rb spec/lib/macros.rb lib/request_log_analyzer/file_format/rails_development.rb spec/fixtures/apache_combined.log spec/fixtures/apache_common.log spec/fixtures/merb_prefixed.log lib/request_log_analyzer/file_format/amazon_s3.rb tasks/request_log_analyzer.rake spec/unit/file_format/file_format_api_spec.rb spec/unit/file_format/apache_format_spec.rb spec/integration/command_line_usage_spec.rb lib/request_log_analyzer/database.rb spec/fixtures/decompression.log.bz2 spec/fixtures/rails_unordered.log lib/request_log_analyzer/log_processor.rb lib/request_log_analyzer/tracker.rb lib/request_log_analyzer/filter.rb bin/request-log-analyzer request-log-analyzer.gemspec DESIGN.rdoc spec/unit/filter/timespan_filter_spec.rb spec/unit/aggregator/database_inserter_spec.rb spec/lib/matchers.rb lib/request_log_analyzer/filter/field.rb lib/request_log_analyzer/tracker/frequency.rb spec/fixtures/decompression.log.gz spec/fixtures/decompression.log spec/lib/testing_format.rb spec/fixtures/test_order.log spec/fixtures/rails.db lib/request_log_analyzer/output/fixed_width.rb lib/request_log_analyzer/filter/anonymize.rb lib/request_log_analyzer/tracker/timespan.rb lib/request_log_analyzer/database/base.rb lib/request_log_analyzer/aggregator.rb spec/unit/request_spec.rb lib/cli/progressbar.rb lib/request_log_analyzer/mailer.rb README.rdoc lib/request_log_analyzer/database/warning.rb spec/fixtures/merb.log lib/request_log_analyzer/tracker/hourly_spread.rb .gitignore spec/unit/tracker/tracker_api_spec.rb spec/unit/tracker/duration_tracker_spec.rb spec/unit/file_format/amazon_s3_format_spec.rb spec/integration/scout_spec.rb lib/request_log_analyzer/aggregator/echo.rb spec/unit/mailer_spec.rb spec/unit/controller/log_processor_spec.rb spec/spec_helper.rb lib/request_log_analyzer.rb spec/database.yml Rakefile lib/request_log_analyzer/database/connection.rb spec/unit/filter/filter_spec.rb spec/fixtures/test_language_combined.log lib/request_log_analyzer/aggregator/database_inserter.rb lib/request_log_analyzer/aggregator/summarizer.rb lib/request_log_analyzer/file_format/rack.rb lib/request_log_analyzer/database/source.rb lib/request_log_analyzer/file_format/rails.rb spec/fixtures/decompression.tar.gz spec/unit/tracker/traffic_tracker_spec.rb spec/unit/filter/field_filter_spec.rb spec/unit/database/base_class_spec.rb lib/request_log_analyzer/filter/timespan.rb lib/request_log_analyzer/source/log_parser.rb spec/fixtures/decompression.tgz spec/unit/tracker/timespan_tracker_spec.rb spec/unit/tracker/hourly_spread_spec.rb spec/fixtures/header_and_footer.log lib/cli/tools.rb lib/request_log_analyzer/file_format/merb.rb spec/fixtures/multiple_files_1.log spec/unit/file_format/merb_format_spec.rb spec/unit/file_format/line_definition_spec.rb lib/request_log_analyzer/source.rb lib/request_log_analyzer/request.rb lib/cli/database_console.rb spec/unit/database/connection_spec.rb spec/unit/controller/controller_spec.rb spec/lib/mocks.rb spec/lib/helpers.rb spec/fixtures/rails_1x.log lib/cli/database_console_init.rb lib/request_log_analyzer/output.rb lib/request_log_analyzer/file_format/apache.rb spec/fixtures/decompression.log.zip spec/unit/source/log_parser_spec.rb spec/fixtures/test_file_format.log tasks/github-gem.rake spec/unit/database/database_spec.rb spec/integration/munin_plugins_rails_spec.rb lib/request_log_analyzer/tracker/duration.rb lib/request_log_analyzer/tracker/traffic.rb lib/request_log_analyzer/file_format.rb spec/unit/aggregator/summarizer_spec.rb spec/fixtures/syslog_1x.log spec/fixtures/rails_22.log lib/request_log_analyzer/database/request.rb spec/fixtures/multiple_files_2.log LICENSE lib/request_log_analyzer/source/database_loader.rb spec/unit/tracker/frequency_tracker_spec.rb spec/unit/file_format/rails_format_spec.rb lib/cli/command_line_arguments.rb)
39
39
  s.test_files = %w(spec/unit/filter/anonymize_filter_spec.rb spec/unit/file_format/file_format_api_spec.rb spec/unit/file_format/apache_format_spec.rb spec/integration/command_line_usage_spec.rb spec/unit/filter/timespan_filter_spec.rb spec/unit/aggregator/database_inserter_spec.rb spec/unit/request_spec.rb spec/unit/tracker/tracker_api_spec.rb spec/unit/tracker/duration_tracker_spec.rb spec/unit/file_format/amazon_s3_format_spec.rb spec/integration/scout_spec.rb spec/unit/mailer_spec.rb spec/unit/controller/log_processor_spec.rb spec/unit/filter/filter_spec.rb spec/unit/tracker/traffic_tracker_spec.rb spec/unit/filter/field_filter_spec.rb spec/unit/database/base_class_spec.rb spec/unit/tracker/timespan_tracker_spec.rb spec/unit/tracker/hourly_spread_spec.rb spec/unit/file_format/merb_format_spec.rb spec/unit/file_format/line_definition_spec.rb spec/unit/database/connection_spec.rb spec/unit/controller/controller_spec.rb spec/unit/source/log_parser_spec.rb spec/unit/database/database_spec.rb spec/integration/munin_plugins_rails_spec.rb spec/unit/aggregator/summarizer_spec.rb spec/unit/tracker/frequency_tracker_spec.rb spec/unit/file_format/rails_format_spec.rb)
40
40
  end
@@ -1,5 +1,4 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper.rb'
2
- require File.dirname(__FILE__) + '/scouts_custom_output'
3
2
 
4
3
  def capture_stdout_and_stderr_with_warnings_on
5
4
  $stdout, $stderr, warnings, $VERBOSE =
@@ -69,3 +68,84 @@ describe RequestLogAnalyzer, 'when using the rla API like the scout plugin' do
69
68
  end
70
69
 
71
70
  end
71
+
72
+ # Helpers
73
+ class EmbeddedHTML < RequestLogAnalyzer::Output::Base
74
+ def print(str)
75
+ @io << str
76
+ end
77
+ alias_method :<<, :print
78
+
79
+ def puts(str = "")
80
+ @io << "#{str}<br/>\n"
81
+ end
82
+
83
+ def title(title)
84
+ @io.puts(tag(:h2, title))
85
+ end
86
+
87
+ def line(*font)
88
+ @io.puts(tag(:hr))
89
+ end
90
+
91
+ def link(text, url = nil)
92
+ url = text if url.nil?
93
+ tag(:a, text, :href => url)
94
+ end
95
+
96
+ def table(*columns, &block)
97
+ rows = Array.new
98
+ yield(rows)
99
+
100
+ @io << tag(:table, :cellspacing => 0) do |content|
101
+ if table_has_header?(columns)
102
+ content << tag(:tr) do
103
+ columns.map { |col| tag(:th, col[:title]) }.join("\n")
104
+ end
105
+ end
106
+
107
+ odd = false
108
+ rows.each do |row|
109
+ odd = !odd
110
+ content << tag(:tr) do
111
+ if odd
112
+ row.map { |cell| tag(:td, cell, :class => "alt") }.join("\n")
113
+ else
114
+ row.map { |cell| tag(:td, cell) }.join("\n")
115
+ end
116
+ end
117
+ end
118
+ end
119
+ end
120
+
121
+ def header
122
+ end
123
+
124
+ def footer
125
+ @io << tag(:hr) << tag(:p, "Powered by request-log-analyzer v#{RequestLogAnalyzer::VERSION}")
126
+ end
127
+
128
+ private
129
+
130
+ def tag(tag, content = nil, attributes = nil)
131
+ if block_given?
132
+ attributes = content.nil? ? "" : " " + content.map { |(key, value)| "#{key}=\"#{value}\"" }.join(" ")
133
+ content_string = ""
134
+ content = yield(content_string)
135
+ content = content_string unless content_string.empty?
136
+ "<#{tag}#{attributes}>#{content}</#{tag}>"
137
+ else
138
+ attributes = attributes.nil? ? "" : " " + attributes.map { |(key, value)| "#{key}=\"#{value}\"" }.join(" ")
139
+ if content.nil?
140
+ "<#{tag}#{attributes} />"
141
+ else
142
+ if content.class == Float
143
+ "<#{tag}#{attributes}><div class='color_bar' style=\"width:#{(content*200).floor}px;\"/></#{tag}>"
144
+ else
145
+ "<#{tag}#{attributes}>#{content}</#{tag}>"
146
+ end
147
+ end
148
+ end
149
+ end
150
+ end
151
+
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.1
4
+ version: 1.4.2
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-10-07 00:00:00 +02:00
13
+ date: 2009-10-09 00:00:00 +02:00
14
14
  default_executable: request-log-analyzer
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -138,7 +138,6 @@ files:
138
138
  - lib/request_log_analyzer/file_format/apache.rb
139
139
  - spec/fixtures/decompression.log.zip
140
140
  - spec/unit/source/log_parser_spec.rb
141
- - spec/integration/scouts_custom_output.rb
142
141
  - spec/fixtures/test_file_format.log
143
142
  - tasks/github-gem.rake
144
143
  - spec/unit/database/database_spec.rb
@@ -185,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
184
  requirements:
186
185
  - To use the database inserter, ActiveRecord and an appropriate database adapter are required.
187
186
  rubyforge_project: r-l-a
188
- rubygems_version: 1.3.5
187
+ rubygems_version: 1.3.4
189
188
  signing_key:
190
189
  specification_version: 3
191
190
  summary: A command line tool to analyze request logs for Apache, Rails, Merb and other web application servers
@@ -1,78 +0,0 @@
1
- class EmbeddedHTML < RequestLogAnalyzer::Output::Base
2
- def print(str)
3
- @io << str
4
- end
5
- alias_method :<<, :print
6
-
7
- def puts(str = "")
8
- @io << "#{str}<br/>\n"
9
- end
10
-
11
- def title(title)
12
- @io.puts(tag(:h2, title))
13
- end
14
-
15
- def line(*font)
16
- @io.puts(tag(:hr))
17
- end
18
-
19
- def link(text, url = nil)
20
- url = text if url.nil?
21
- tag(:a, text, :href => url)
22
- end
23
-
24
- def table(*columns, &block)
25
- rows = Array.new
26
- yield(rows)
27
-
28
- @io << tag(:table, :cellspacing => 0) do |content|
29
- if table_has_header?(columns)
30
- content << tag(:tr) do
31
- columns.map { |col| tag(:th, col[:title]) }.join("\n")
32
- end
33
- end
34
-
35
- odd = false
36
- rows.each do |row|
37
- odd = !odd
38
- content << tag(:tr) do
39
- if odd
40
- row.map { |cell| tag(:td, cell, :class => "alt") }.join("\n")
41
- else
42
- row.map { |cell| tag(:td, cell) }.join("\n")
43
- end
44
- end
45
- end
46
- end
47
- end
48
-
49
- def header
50
- end
51
-
52
- def footer
53
- @io << tag(:hr) << tag(:p, "Powered by request-log-analyzer v#{RequestLogAnalyzer::VERSION}")
54
- end
55
-
56
- private
57
-
58
- def tag(tag, content = nil, attributes = nil)
59
- if block_given?
60
- attributes = content.nil? ? "" : " " + content.map { |(key, value)| "#{key}=\"#{value}\"" }.join(" ")
61
- content_string = ""
62
- content = yield(content_string)
63
- content = content_string unless content_string.empty?
64
- "<#{tag}#{attributes}>#{content}</#{tag}>"
65
- else
66
- attributes = attributes.nil? ? "" : " " + attributes.map { |(key, value)| "#{key}=\"#{value}\"" }.join(" ")
67
- if content.nil?
68
- "<#{tag}#{attributes} />"
69
- else
70
- if content.class == Float
71
- "<#{tag}#{attributes}><div class='color_bar' style=\"width:#{(content*200).floor}px;\"/></#{tag}>"
72
- else
73
- "<#{tag}#{attributes}>#{content}</#{tag}>"
74
- end
75
- end
76
- end
77
- end
78
- end