lib/bullet.rb in bullet-5.9.0 vs lib/bullet.rb in bullet-6.0.0

- old
+ new

@@ -61,10 +61,14 @@ def enable? !!@enable end + def app_root + (defined?(::Rails.root) ? Rails.root.to_s : Dir.pwd).to_s + end + def n_plus_one_query_enable? enable? && !!@n_plus_one_query_enable end def unused_eager_loading_enable? @@ -109,13 +113,12 @@ end def bullet_logger=(active) if active require 'fileutils' - root_path = (rails? ? Rails.root.to_s : Dir.pwd).to_s - FileUtils.mkdir_p(root_path + '/log') - bullet_log_file = File.open("#{root_path}/log/bullet.log", 'a+') + FileUtils.mkdir_p(app_root + '/log') + bullet_log_file = File.open("#{app_root}/log/bullet.log", 'a+') bullet_log_file.sync = true UniformNotifier.customized_logger = bullet_log_file end end @@ -190,10 +193,18 @@ info << notification.short_notice end info end + def text_notifications + info = [] + notification_collector.collection.each do |notification| + info << notification.notification_data.values.compact.join("\n") + end + info + end + def warnings notification_collector.collection.each_with_object({}) do |notification, warnings| warning_type = notification.class.to_s.split(':').last.tableize warnings[warning_type] ||= [] warnings[warning_type] << notification @@ -215,9 +226,13 @@ else return_value = yield end return_value + end + + def console_enabled? + UniformNotifier.active_notifiers.include?(UniformNotifier::JavascriptConsole) end private def for_each_active_notifier_with_notification