Class: TestServer::ServerCommands::Rackup
- Inherits:
-
Object
- Object
- TestServer::ServerCommands::Rackup
- Defined in:
- lib/test_server/server_commands/rackup.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Rackup
constructor
A new instance of Rackup.
- #to_s ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Rackup
Returns a new instance of Rackup.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/test_server/server_commands/rackup.rb', line 12 def initialize( = {}) @environment = .fetch(:environment, :development) @pid_file = .fetch(:pid_file, TestServer.config.pid_file) @config_file = .fetch(:config_file, ::File.('../../../../config.ru', __FILE__)) listen = .fetch(:listen, '127.0.0.1:8080') begin uri = Addressable::URI.heuristic_parse(listen) rescue StandardError => e fail Exceptions::ServerListenStatementInvalid, "I cannot parse the listen statement: #{listen}. It is invalid: #{e.}" end @port = uri.port @host = uri.host rescue KeyError => e raise ArgumentError, e. end |
Instance Method Details
#to_s ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/test_server/server_commands/rackup.rb', line 30 def to_s cmd = [] cmd << 'rackup' cmd << "-E #{environment}" if environment cmd << "-P #{pid_file}" if pid_file cmd << "-o #{host}" if host cmd << "-p #{port}" if port cmd << config_file if config_file cmd.join(" ") end |