From ff2a54af537bdc2551e698d2988e044a7ac98e4e Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Mon, 19 Jan 2009 07:52:39 -0800 Subject: [PATCH] Changes to make the command-line tool more testable. --- bin/compass | 2 +- lib/compass/exec.rb | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/bin/compass b/bin/compass index a98225e1..fb94e65f 100755 --- a/bin/compass +++ b/bin/compass @@ -5,4 +5,4 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'compass require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'compass', 'exec')) command = Compass::Exec::Compass.new(ARGV) -command.run! +exit command.run! diff --git a/lib/compass/exec.rb b/lib/compass/exec.rb index 054b40e3..51578300 100644 --- a/lib/compass/exec.rb +++ b/lib/compass/exec.rb @@ -37,11 +37,11 @@ module Compass def initialize(args) self.args = args self.options = {} + parse! end def run! begin - parse! perform! rescue Exception => e raise e if e.is_a? SystemExit @@ -50,9 +50,9 @@ module Compass else ::Compass::Exec.report_error(e, @options) end - exit 1 + return 1 end - exit 0 + return 0 end protected @@ -165,7 +165,6 @@ END end def do_command(command) - require File.join(File.dirname(__FILE__), 'commands', command.to_s) command_class_name = command.to_s.split(/_/).map{|p| p.capitalize}.join('') command_class = eval("::Compass::Commands::#{command_class_name}") command_class.new(Dir.getwd, options).perform @@ -174,3 +173,7 @@ END end end end + +Dir.glob(File.join(File.dirname(__FILE__), 'commands', "*.rb")).each do |file| + require file +end