# encoding:utf-8 module LocalPac class Server attr_reader :port, :host, :path, :environment def initialize(listen, environment = 'development') uri = URI.parse(listen) @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}" 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(" ")) end end end