Sha256: e713ae5b0f53a290c4fcd7817bb824c42a52b5f7e40c4e859e0eacdd611d83a8

Contents?: true

Size: 1019 Bytes

Versions: 20

Compression:

Stored size: 1019 Bytes

Contents

# encoding: utf-8
module TestServer
  module ServerCommands
    class Puma

      private

      attr_reader :environment, :pid_file, :config_file, :listen, :worker_count

      public

      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

      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
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
test_server-0.5.2 lib/test_server/server_commands/puma.rb
test_server-0.5.1 lib/test_server/server_commands/puma.rb
test_server-0.5.0 lib/test_server/server_commands/puma.rb
test_server-0.4.1 lib/test_server/server_commands/puma.rb
test_server-0.4.0 lib/test_server/server_commands/puma.rb
test_server-0.3.7 lib/test_server/server_commands/puma.rb
test_server-0.3.6 lib/test_server/server_commands/puma.rb
test_server-0.3.5 lib/test_server/server_commands/puma.rb
test_server-0.3.4 lib/test_server/server_commands/puma.rb
test_server-0.3.2 lib/test_server/server_commands/puma.rb
test_server-0.3.1 lib/test_server/server_commands/puma.rb
test_server-0.2.4 lib/test_server/server_commands/puma.rb
test_server-0.2.3 lib/test_server/server_commands/puma.rb
test_server-0.2.2 lib/test_server/server_commands/puma.rb
test_server-0.2.1 lib/test_server/server_commands/puma.rb
test_server-0.2.0 lib/test_server/server_commands/puma.rb
test_server-0.1.2 lib/test_server/server_commands/puma.rb
test_server-0.1.1 lib/test_server/server_commands/puma.rb
test_server-0.1.0 lib/test_server/server_commands/puma.rb
test_server-0.0.11 lib/test_server/server_commands/puma.rb