Changes to make the command-line tool more testable.
This commit is contained in:
parent
5fce487ba8
commit
ff2a54af53
@ -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'))
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'compass', 'exec'))
|
||||||
|
|
||||||
command = Compass::Exec::Compass.new(ARGV)
|
command = Compass::Exec::Compass.new(ARGV)
|
||||||
command.run!
|
exit command.run!
|
||||||
|
@ -37,11 +37,11 @@ module Compass
|
|||||||
def initialize(args)
|
def initialize(args)
|
||||||
self.args = args
|
self.args = args
|
||||||
self.options = {}
|
self.options = {}
|
||||||
|
parse!
|
||||||
end
|
end
|
||||||
|
|
||||||
def run!
|
def run!
|
||||||
begin
|
begin
|
||||||
parse!
|
|
||||||
perform!
|
perform!
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
raise e if e.is_a? SystemExit
|
raise e if e.is_a? SystemExit
|
||||||
@ -50,9 +50,9 @@ module Compass
|
|||||||
else
|
else
|
||||||
::Compass::Exec.report_error(e, @options)
|
::Compass::Exec.report_error(e, @options)
|
||||||
end
|
end
|
||||||
exit 1
|
return 1
|
||||||
end
|
end
|
||||||
exit 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
@ -165,7 +165,6 @@ END
|
|||||||
end
|
end
|
||||||
|
|
||||||
def do_command(command)
|
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_name = command.to_s.split(/_/).map{|p| p.capitalize}.join('')
|
||||||
command_class = eval("::Compass::Commands::#{command_class_name}")
|
command_class = eval("::Compass::Commands::#{command_class_name}")
|
||||||
command_class.new(Dir.getwd, options).perform
|
command_class.new(Dir.getwd, options).perform
|
||||||
@ -174,3 +173,7 @@ END
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Dir.glob(File.join(File.dirname(__FILE__), 'commands', "*.rb")).each do |file|
|
||||||
|
require file
|
||||||
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user