Module: RequestLogAnalyzer
- Defined in:
- lib/request_log_analyzer.rb,
lib/request_log_analyzer/mailer.rb,
lib/request_log_analyzer/request.rb,
lib/request_log_analyzer/controller.rb,
lib/request_log_analyzer/log_processor.rb,
lib/request_log_analyzer/line_definition.rb
Overview
RequestLogAnalyzer is the base namespace in which all functionality of RequestLogAnalyzer is implemented.
-
This module itselfs contains some functions to help with class and source file loading.
-
The actual application resides in the RequestLogAnalyzer::Controller class.
Defined Under Namespace
Modules: Aggregator, FileFormat, Filter, Output, Source, Tracker Classes: Controller, Database, LineDefinition, LogProcessor, Mailer, Request
Constant Summary collapse
- VERSION =
The current version of request-log-analyzer. Do not change the value by hand; it will be updated automatically by the gem release script.
"1.4.1"
Class Method Summary collapse
-
.const_missing(const) ⇒ Object
- Loads constants in the RequestLogAnalyzer namespace using self.load_default_class_file(base, const)
const
-
The constant that is not yet loaded in the RequestLogAnalyzer namespace.
- Loads constants in the RequestLogAnalyzer namespace using self.load_default_class_file(base, const)
-
.load_default_class_file(base, const) ⇒ Object
Loads constants that reside in the RequestLogAnalyzer tree using the constant name and its base constant to determine the filename.
-
.to_camelcase(str) ⇒ Object
Convert a string/symbol in underscores (
request_log_analyzer/controller
) to camelcase (RequestLogAnalyzer::Controller
). -
.to_underscore(str) ⇒ Object
Convert a string/symbol in camelcase (RequestLogAnalyzer::Controller) to underscores (request_log_analyzer/controller) This function can be used to load the file (using require) in which the given constant is defined.
Class Method Details
.const_missing(const) ⇒ Object
Loads constants in the RequestLogAnalyzer namespace using self.load_default_class_file(base, const)
const
-
The constant that is not yet loaded in the RequestLogAnalyzer namespace. This should be passed as a string or symbol.
18 19 20 |
# File 'lib/request_log_analyzer.rb', line 18 def self.const_missing(const) load_default_class_file(RequestLogAnalyzer, const) end |
.load_default_class_file(base, const) ⇒ Object
Loads constants that reside in the RequestLogAnalyzer tree using the constant name and its base constant to determine the filename.
base
-
The base constant to load the constant from. This should be Foo when the constant Foo::Bar is being loaded.
const
-
The constant to load from the base constant as a string or symbol. This should be ‘Bar’ or :Bar when the constant Foo::Bar is being loaded.
26 27 28 29 |
# File 'lib/request_log_analyzer.rb', line 26 def self.load_default_class_file(base, const) require "#{to_underscore("#{base.name}::#{const}")}" base.const_get(const) if base.const_defined?(const) end |
.to_camelcase(str) ⇒ Object
Convert a string/symbol in underscores (request_log_analyzer/controller
) to camelcase (RequestLogAnalyzer::Controller
). This can be used to find the class that is defined in a given filename.
str
-
The string to convert in the following format:
module_name/class_name
41 42 43 |
# File 'lib/request_log_analyzer.rb', line 41 def self.to_camelcase(str) str.to_s.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase } end |
.to_underscore(str) ⇒ Object
Convert a string/symbol in camelcase (RequestLogAnalyzer::Controller) to underscores (request_log_analyzer/controller) This function can be used to load the file (using require) in which the given constant is defined.
str
-
The string to convert in the following format:
ModuleName::ClassName
34 35 36 |
# File 'lib/request_log_analyzer.rb', line 34 def self.to_underscore(str) str.to_s.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').gsub(/([a-z\d])([A-Z])/,'\1_\2').tr("-", "_").downcase end |