require 'dtracer'
require 'dtracer_client'

module DtraceReport

  def self.included(base)
    base.extend DtraceMacro
  end

  module DtraceMacro
    def dtrace(enable=:on, options={})
      if enable == :on
        if options[:tracer] == :self
          DtraceReport.tracer = Dtracer.new
        elsif options[:tracer] == :helper
          DtracerReport.tracer = DtracerClient.new
        else
          raise "tracer option is self or helper"
        end
      end
    end
  end

  attr_reader :dtrace_report

  protected
  def self.tracer=(tracer)
    @@tracer = tracer
  end
  
  def enable_dtrace
    @@tracer.start_dtrace($$)
  end

  def append_dtrace_report
    @dtrace_report = @@tracer.end_dtrace
    # yuck!
    old_template_root = @template.base_path
    begin
      @template.view_paths = File.join(RAILS_ROOT, 'vendor/plugins/dtrace/views')
      response.body.gsub!(/<\/body/, @template.render(:partial => 'dtrace/report') + '</body')
    ensure
      @template.view_paths = old_template_root
    end
  end
  
end

require 'dtracer'
require 'dtracer_client'

module DtraceReport

  def self.included(base)
    base.extend DtraceMacro
  end

  module DtraceMacro
    def dtrace(enable=:on, options={})
      if enable == :on
        if options[:tracer] == :self
          DtraceReport.tracer = Dtracer.new
        elsif options[:tracer] == :helper
          DtraceReport.tracer = DtracerClient.new
        else
          raise "tracer option is self or helper"
        end
      end
    end
  end

  attr_reader :dtrace_report

  protected
  def self.tracer=(tracer)
    @@tracer = tracer
  end
  
  def enable_dtrace
    @@tracer.start_dtrace($$)
  end

  def append_dtrace_report
    @dtrace_report = @@tracer.end_dtrace
    # yuck!
    old_template_root = @template.base_path
    begin
      @template.view_paths = File.join(RAILS_ROOT, 'vendor/plugins/dtrace/views')
      response.body.gsub!(/<\/body/, @template.render(:partial => 'dtrace/report') + '</body')
    ensure
      @template.view_paths = old_template_root
    end
  end
  
end

Fix "helper" mode, typo corrected.
Fix "helper" mode, typo corrected.


git-svn-id: 40196796c19c0e7557af02d93710b150381d7241@72 f5dbc166-08e2-44d3-850c-36126807790f
