Parent

Syckle::Plugins::RubyProf

RubyProf Profiling Plugin

This is a service plugin for ruby-prof command line tool.

Constants

DEFAULT_SCRIPTS

Default script files to run via ruby-prof.

Attributes

options[R]

Additional commandline options string passed to ruby-prof.

output[R]

Output directory. This defaults to an rubyprof/ folder in the the project’s log directory.

scripts[R]

Pattern of script files to run for coverage check. Usually these are your test files, but they can be any ruby scripts. By default this is includes .rb file in the test/ directory whose name begins with test_ or ends with _test.

Public Instance Methods

analyize() click to toggle source

Shell out to ruby-prof.

TODO: Need to create an index.html file to link to all the others.

# File lib/plugins/syckle/rubyprof.rb, line 39
def analyize
  files = scripts.map{ |s| Dir[s] }.flatten
  # create output directory if needed
  mkdir_p(output) unless File.exist?(output)
  # if nothing is out-of-date
  if outofdate?(output, *files) or force?
    # make a profile for each script
    files.each do |file|
      fname = output + "#{File.basename(file)}.html"
      if outofdate?(output, file) or force?
        sh "ruby-prof #{options} -m 1 -p graph_html -f #{fname} #{file}"
      end
    end
    report "ruby-prof updated (at #{output.sub(Dir.pwd,'')})"
  else
    report "ruby-prof is current (at #{output.sub(Dir.pwd,'')})"
  end
end
clean() click to toggle source

Remove output directory and it’s contents.

# File lib/plugins/syckle/rubyprof.rb, line 67
def clean
  if File.directory?(output)
    rm_r(output)
    status "removed #{output}" #unless trial?
  end
end
initialize_defaults() click to toggle source
# File lib/plugins/syckle/rubyprof.rb, line 30
def initialize_defaults
  @output  = project.log + 'rubyprof'
  @scripts = DEFAULT_SCRIPTS
end
reset() click to toggle source

Reset output directory, ie. set mtime to oldest date possible.

# File lib/plugins/syckle/rubyprof.rb, line 59
def reset
  if File.directory?(output)
    File.utime(0,0,output)
    report "reset #{output}" #unless trial?
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.