lib/local_pac/server.rb in local_pac-0.2.3 vs lib/local_pac/server.rb in local_pac-0.3.0

- old
+ new

@@ -1,28 +1,19 @@ # encoding:utf-8 module LocalPac class Server - attr_reader :port, :host, :path, :environment - def initialize(listen, environment = 'development') - uri = URI.parse(listen) + private - @port = uri.port - @host = uri.host - @environment = environment - rescue => e - fail Exceptions::ServerListenStatementInvalid, "I cannot parse the listen statement: #{listen}. It is invalid: #{e.message}" + attr_reader :command + + public + + def initialize(command = ServerCommands::Rackup.new) + @command = command end def start - cmd = [] - cmd << 'rackup' - cmd << "-E #{environment}" - cmd << "-P #{LocalPac.config.pid_file}" - cmd << "-o #{host}" - cmd << "-p #{port}" - cmd << ::File.expand_path('../../../config.ru', __FILE__) - - exec(cmd.join(" ")) + exec command.to_s end end end