class Sqreen::Frameworks::RailsFramework
Rails related framework code
Constants
- DB_MAPPING
- P_OTHER
Public Class Methods
new()
click to toggle source
Calls superclass method
Sqreen::Frameworks::GenericFramework::new
# File lib/sqreen/frameworks/rails.rb, line 22 def initialize super end
parameters_from_request(request)
click to toggle source
Calls superclass method
Sqreen::Frameworks::GenericFramework::parameters_from_request
# File lib/sqreen/frameworks/rails.rb, line 135 def self.parameters_from_request(request) return {} unless request ret = super(request) ret[P_OTHER] = rails_params(request) ret end
rails_params(request)
click to toggle source
# File lib/sqreen/frameworks/rails.rb, line 122 def self.rails_params(request) return nil unless request other = request.env['action_dispatch.request.parameters'] return nil unless other # Remove Rails created parameters: other = other.dup other.delete :action other.delete :controller other end
Public Instance Methods
application_name()
click to toggle source
# File lib/sqreen/frameworks/rails.rb, line 84 def application_name Rails.application.class.name.deconstantize.underscore end
db_settings(options = {})
click to toggle source
# File lib/sqreen/frameworks/rails.rb, line 38 def db_settings(options = {}) adapter = options[:connection_adapter] return nil unless adapter begin adapter_name = adapter.adapter_name rescue # FIXME: we may want to log that Sqreen.log.warn 'cannot find ADAPTER_NAME' return nil end db_type = DB_MAPPING[adapter_name] db_infos = { :name => adapter_name } [db_type, db_infos] end
development?()
click to toggle source
# File lib/sqreen/frameworks/rails.rb, line 34 def development? Rails.env.development? end
framework_infos()
click to toggle source
# File lib/sqreen/frameworks/rails.rb, line 26 def framework_infos { :framework_type => 'Rails', :framework_version => Rails::VERSION::STRING, :environment => Rails.env.to_s, } end
instrument_when_ready!(instrumentor, rules)
click to toggle source
# File lib/sqreen/frameworks/rails.rb, line 114 def instrument_when_ready!(instrumentor, rules) instrumentor.instrument!(rules, self) end
ip_headers()
click to toggle source
Calls superclass method
Sqreen::Frameworks::GenericFramework#ip_headers
# File lib/sqreen/frameworks/rails.rb, line 54 def ip_headers ret = super remote_ip = rails_client_ip ret << ['action_dispatch.remote_ip', remote_ip] unless remote_ip.nil? ret end
prevent_startup()
click to toggle source
Calls superclass method
Sqreen::Frameworks::GenericFramework#prevent_startup
# File lib/sqreen/frameworks/rails.rb, line 100 def prevent_startup res = super return res if res run_in_test = sqreen_configuration.get(:run_in_test) return :rails_test if !run_in_test && (Rails.env.test? || Rails.env.cucumber?) return nil unless defined?(Rails::CommandsTasks) return nil if defined?(Rails::Server) return :rails_console if defined?(Rails::Console) return :rails_dbconsole if defined?(Rails::DBConsole) return :rails_generators if defined?(Rails::Generators) nil end
rails_client_ip()
click to toggle source
What is the current client IP as seen by rails
# File lib/sqreen/frameworks/rails.rb, line 62 def rails_client_ip req = request return unless req && req.env remote_ip = req.env['action_dispatch.remote_ip'] return unless remote_ip # FIXME: - this exist only since Rails 3.2.1 # http://apidock.com/rails/v3.2.1/ActionDispatch/RemoteIp/GetIp/calculate_ip return remote_ip.calculate_ip if remote_ip.respond_to?(:calculate_ip) # This might not return the same value as calculate IP remote_ip.to_s end
rails_params()
click to toggle source
# File lib/sqreen/frameworks/rails.rb, line 118 def rails_params self.class.rails_params(request) end
request_id()
click to toggle source
Calls superclass method
Sqreen::Frameworks::GenericFramework#request_id
# File lib/sqreen/frameworks/rails.rb, line 74 def request_id req = request return super unless req req.env['action_dispatch.request_id'] || super end
root()
click to toggle source
# File lib/sqreen/frameworks/rails.rb, line 80 def root Rails.application.root end