Class: TestServer::ServerCommands::Puma

Inherits:
Object
  • Object
show all
Defined in:
lib/test_server/server_commands/puma.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Puma

Returns a new instance of Puma



12
13
14
15
16
17
18
19
20
21
# File 'lib/test_server/server_commands/puma.rb', line 12

def initialize(options = {})
  @environment  = options.fetch(:environment, :development)
  @pid_file     = options.fetch(:pid_file, TestServer.config.pid_file)
  @config_file  = options.fetch(:config_file, ::File.expand_path('../../../../config.ru', __FILE__))
  @listen       = options.fetch(:listen, 'tcp://127.0.0.1:8080')
  @worker_count = options.fetch(:worker_count, nil)

rescue KeyError => e
  raise ArgumentError, e.message
end

Instance Method Details

#to_sObject



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/test_server/server_commands/puma.rb', line 23

def to_s
  cmd = []

  cmd << 'puma'
  cmd << "-e #{environment}" if environment
  cmd << "--pidfile #{pid_file}" if pid_file
  cmd << "-b #{listen}" if listen
  cmd << "-w #{worker_count}" if worker_count
  cmd << config_file if config_file

  cmd.join(" ")
end