Sha256: 408c5f12fd7eeaad403dbffc4a84df7336d40b17ed4ff2218ef2be76da549383
Contents?: true
Size: 1.27 KB
Versions: 2
Compression:
Stored size: 1.27 KB
Contents
module HoptoadNotifier module Rails module JavascriptNotifier def self.included(base) #:nodoc: base.send(:after_filter, :insert_hoptoad_javascript_notifier) end private def insert_hoptoad_javascript_notifier return unless HoptoadNotifier.configuration.public? return unless HoptoadNotifier.configuration.js_notifier path = File.join(File.dirname(__FILE__), '..', '..', 'templates', 'javascript_notifier.erb') host = HoptoadNotifier.configuration.host.dup port = HoptoadNotifier.configuration.port host << ":#{port}" unless [80, 443].include?(port) options = { :file => path, :layout => false, :use_full_path => false, :locals => { :host => host, :api_key => HoptoadNotifier.configuration.api_key, :environment => HoptoadNotifier.configuration.environment_name } } if @template javascript = @template.render(options) else javascript = render_to_string(options) end if response.body.respond_to?(:gsub) response.body = response.body.gsub(/<(head.*?)>/i, "<\1>\n" + javascript) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hoptoad_notifier-2.4.1 | lib/hoptoad_notifier/rails/javascript_notifier.rb |
hoptoad_notifier-2.4.0 | lib/hoptoad_notifier/rails/javascript_notifier.rb |