Repository: puma/puma
File: lib/puma/dsl.rb (Ruby)

Code before:
    # Instead of `bind 'ssl://127.0.0.1:9292?key=key_path&cert=cert_path'` you
    # can also use the this method.
    #
    # @example
    #   ssl_bind '127.0.0.1', '9292', {
    #     cert: path_to_cert,
    #     key: path_to_key,
    #     ssl_cipher_filter: cipher_filter, # optional
    #     verify_mode: verify_mode,         # default 'none'
    #   }
    # @example For JRuby additional keys are required: keystore & keystore_pass.
    #   ssl_bind '127.0.0.1', '9292', {
    #     cert: path_to_cert,
    #     key: path_to_key,
    #     ssl_cipher_filter: cipher_filter, # optional
    #     verify_mode: verify_mode,         # default 'none'
    #     verification_flags: flags,        # optional, not supported by JRuby
    #     keystore: path_to_keystore,
    #     keystore_pass: password
    #   }
    def ssl_bind(host, port, opts)
      verify = opts.fetch(:verify_mode, 'none').to_s
      no_tlsv1 = opts.fetch(:no_tlsv1, 'false')
      no_tlsv1_1 = opts.fetch(:no_tlsv1_1, 'false')

      additions = +''
      additions << "&ca=#{opts[:ca]}" if ['peer', 'force_peer'].include?(verify)

      if defined?(JRUBY_VERSION)
        additions << "&keystore=#{opts[:keystore]}&keystore-pass=#{opts[:keystore_pass]}"
      else
        additions << "&ssl_cipher_filter=#{opts[:ssl_cipher_filter]}" if opts[:ssl_cipher_filter]
        Array(opts[:verification_flags]).each { |flag| additions << "&verification_flags=#{flag}" }
      end

      bind "ssl://#{host}:#{port}?cert=#{opts[:cert]}&key=#{opts[:key]}&verify_mode=#{verify}&no_tlsv1=#{no_tlsv1}&no_tlsv1_1=#{no_tlsv1_1}#{additions}"
    end

    # Use +path+ as the file to store the server info state. This is
    # used by +pumactl+ to query and control the server.
    #
    # @example
    #   state_path '/u/apps/lolcat/tmp/pids/puma.state'
    def state_path(path)
      @options[:state] = path.to_s
    end

    # Use +permission+ to restrict permissions for the state file.
    #
    # @example
    #   state_permission 0600

Review comment (suggestion):
Given that Puma is currently supporting Ruby 2.2:

```suggestion
      additions = ''.dup
```

Code after:
    def stdout_redirect(stdout=nil, stderr=nil, append=false)
      @options[:redirect_stdout] = stdout
      @options[:redirect_stderr] = stderr
      @options[:redirect_append] = append
    end

    def log_formatter(&block)
      @options[:log_formatter] = block
    end

    # Configure +min+ to be the minimum number of threads to use to answer
    # requests and +max+ the maximum.
    #
    # The default is "0, 16".
    #
    # @example
    #   threads 0, 16
    # @example
    #   threads 5, 5
    def threads(min, max)
      min = Integer(min)
      max = Integer(max)
      if min > max
        raise "The minimum (#{min}) number of threads must be less than or equal to the max (#{max})"
      end

      if max < 1
        raise "The maximum number of threads (#{max}) must be greater than 0"
      end

      @options[:min_threads] = min
      @options[:max_threads] = max
    end

    # Instead of `bind 'ssl://127.0.0.1:9292?key=key_path&cert=cert_path'` you
    # can also use the this method.
    #
    # @example
    #   ssl_bind '127.0.0.1', '9292', {
    #     cert: path_to_cert,
    #     key: path_to_key,
    #     ssl_cipher_filter: cipher_filter, # optional
    #     verify_mode: verify_mode,         # default 'none'
    #     verification_flags: flags,        # optional, not supported by JRuby
    #   }
    # @example For JRuby, two keys are required: keystore & keystore_pass.
    #   ssl_bind '127.0.0.1', '9292', {
    #     keystore: path_to_keystore,
    #     keystore_pass: password,
    #     ssl_cipher_list: cipher_list,     # optional
    #     verify_mode: verify_mode          # default 'none'