Add a --profile option to the compass CLI

This commit is contained in:
Chris Eppstein 2010-09-12 14:11:05 -07:00
parent b313ac794e
commit dd2c9eb72d
2 changed files with 18 additions and 2 deletions

View File

@ -11,3 +11,4 @@ gem "rcov"
gem "rubyzip"
gem "livereload"
gem "chunky_png"
gem "ruby-prof"

View File

@ -21,6 +21,21 @@ fallback_load_path(File.join(File.dirname(__FILE__), '..', 'lib')) do
require 'compass/exec'
end
runner = Proc.new do
command_line_class = Compass::Exec::Helpers.select_appropriate_command_line_ui(ARGV)
command_line_class.new(ARGV).run!
end
command_line_class = Compass::Exec::Helpers.select_appropriate_command_line_ui(ARGV)
exit command_line_class.new(ARGV).run!
if ARGV.delete("--profile")
require 'ruby-prof'
RubyProf.start
exit_code = runner.call
result = RubyProf.stop
# Print a flat profile to text
printer = RubyProf::FlatPrinter.new(result)
printer.print(STDERR, 0)
exit exit_code
else
exit runner.call
end