1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00

require to require_relative (#2964)

This commit is contained in:
MSP-Greg 2022-09-21 01:00:30 -05:00 committed by GitHub
parent 3374827b47
commit e7ff17d98c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 74 additions and 70 deletions

View file

@ -10,14 +10,16 @@ require 'stringio'
require 'thread' require 'thread'
# use require, see https://github.com/puma/puma/pull/2381
require 'puma/puma_http11' require 'puma/puma_http11'
require 'puma/detect'
require 'puma/json_serialization' require_relative 'puma/detect'
require_relative 'puma/json_serialization'
module Puma module Puma
autoload :Const, 'puma/const' autoload :Const, "#{__dir__}/puma/const"
autoload :Server, 'puma/server' autoload :Server, "#{__dir__}/puma/server"
autoload :Launcher, 'puma/launcher' autoload :Launcher, "#{__dir__}/puma/launcher"
# at present, MiniSSL::Engine is only defined in extension code (puma_http11), # at present, MiniSSL::Engine is only defined in extension code (puma_http11),
# not in minissl.rb # not in minissl.rb
@ -26,7 +28,7 @@ module Puma
HAS_UNIX_SOCKET = Object.const_defined? :UNIXSocket HAS_UNIX_SOCKET = Object.const_defined? :UNIXSocket
if HAS_SSL if HAS_SSL
require 'puma/minissl' require_relative 'puma/minissl'
else else
module MiniSSL module MiniSSL
# this class is defined so that it exists when Puma is compiled # this class is defined so that it exists when Puma is compiled

View file

@ -1,5 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
require 'puma/json_serialization' require_relative '../json_serialization'
module Puma module Puma
module App module App

View file

@ -3,15 +3,15 @@
require 'uri' require 'uri'
require 'socket' require 'socket'
require 'puma/const' require_relative 'const'
require 'puma/util' require_relative 'util'
require 'puma/configuration' require_relative 'configuration'
module Puma module Puma
if HAS_SSL if HAS_SSL
require 'puma/minissl' require_relative 'minissl'
require 'puma/minissl/context_builder' require_relative 'minissl/context_builder'
end end
class Binder class Binder

View file

@ -3,11 +3,11 @@
require 'optparse' require 'optparse'
require 'uri' require 'uri'
require 'puma' require_relative '../puma'
require 'puma/configuration' require_relative 'configuration'
require 'puma/launcher' require_relative 'launcher'
require 'puma/const' require_relative 'const'
require 'puma/log_writer' require_relative 'log_writer'
module Puma module Puma
class << self class << self

View file

@ -8,7 +8,7 @@ class IO
end end
end end
require 'puma/detect' require_relative 'detect'
require 'tempfile' require 'tempfile'
require 'forwardable' require 'forwardable'

View file

@ -1,10 +1,10 @@
# frozen_string_literal: true # frozen_string_literal: true
require 'puma/runner' require_relative 'runner'
require 'puma/util' require_relative 'util'
require 'puma/plugin' require_relative 'plugin'
require 'puma/cluster/worker_handle' require_relative 'cluster/worker_handle'
require 'puma/cluster/worker' require_relative 'cluster/worker'
require 'time' require 'time'

View file

@ -1,8 +1,9 @@
# frozen_string_literal: true # frozen_string_literal: true
require 'puma/rack/builder' require_relative 'rack/builder'
require 'puma/plugin' require_relative 'plugin'
require 'puma/const' require_relative 'const'
# note that dsl is loaded at end of file, requires ConfigDefault constants
module Puma module Puma
# A class used for storing "leveled" configuration options. # A class used for storing "leveled" configuration options.
@ -285,7 +286,7 @@ module Puma
found = options[:app] || load_rackup found = options[:app] || load_rackup
if @options[:log_requests] if @options[:log_requests]
require 'puma/commonlogger' require_relative 'commonlogger'
logger = @options[:logger] logger = @options[:logger]
found = CommonLogger.new(found, logger) found = CommonLogger.new(found, logger)
end end
@ -383,4 +384,4 @@ module Puma
end end
end end
require 'puma/dsl' require_relative 'dsl'

View file

@ -284,7 +284,7 @@ module Puma
private private
def start def start
require 'puma/cli' require_relative 'cli'
run_args = [] run_args = []

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
require 'puma/const' require_relative 'const'
require 'puma/util' require_relative 'util'
module Puma module Puma
# The methods that are available for use inside the configuration file. # The methods that are available for use inside the configuration file.

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
require 'puma/const' require_relative 'const'
module Puma module Puma
# The implementation of a detailed error logging. # The implementation of a detailed error logging.

View file

@ -1,12 +1,12 @@
# frozen_string_literal: true # frozen_string_literal: true
require 'puma/log_writer' require_relative 'log_writer'
require 'puma/events' require_relative 'events'
require 'puma/detect' require_relative 'detect'
require 'puma/cluster' require_relative 'cluster'
require 'puma/single' require_relative 'single'
require 'puma/const' require_relative 'const'
require 'puma/binder' require_relative 'binder'
module Puma module Puma
# Puma::Launcher is the single entry point for starting a Puma server based on user # Puma::Launcher is the single entry point for starting a Puma server based on user
@ -115,7 +115,7 @@ module Puma
permission = @options[:state_permission] permission = @options[:state_permission]
return unless path return unless path
require 'puma/state_file' require_relative 'state_file'
sf = StateFile.new sf = StateFile.new
sf.pid = Process.pid sf.pid = Process.pid
@ -278,7 +278,7 @@ module Puma
if Puma.jruby? if Puma.jruby?
close_binder_listeners close_binder_listeners
require 'puma/jruby_restart' require_relative 'jruby_restart'
JRubyRestart.chdir_exec(@restart_dir, restart_args) JRubyRestart.chdir_exec(@restart_dir, restart_args)
elsif Puma.windows? elsif Puma.windows?
close_binder_listeners close_binder_listeners
@ -319,7 +319,7 @@ module Puma
return unless ENV["NOTIFY_SOCKET"] return unless ENV["NOTIFY_SOCKET"]
begin begin
require 'puma/systemd' require_relative 'systemd'
rescue LoadError rescue LoadError
log "Systemd integration failed. It looks like you're trying to use systemd notify but don't have sd_notify gem installed" log "Systemd integration failed. It looks like you're trying to use systemd notify but don't have sd_notify gem installed"
return return

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
require 'puma/null_io' require_relative 'null_io'
require 'puma/error_logger' require_relative 'error_logger'
require 'stringio' require 'stringio'
require 'io/wait' unless Puma::HAS_NATIVE_IO_WAIT require 'io/wait' unless Puma::HAS_NATIVE_IO_WAIT

View file

@ -6,6 +6,7 @@ rescue LoadError
end end
# need for Puma::MiniSSL::OPENSSL constants used in `HAS_TLS1_3` # need for Puma::MiniSSL::OPENSSL constants used in `HAS_TLS1_3`
# use require, see https://github.com/puma/puma/pull/2381
require 'puma/puma_http11' require 'puma/puma_http11'
module Puma module Puma

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
require 'puma/plugin' require_relative '../plugin'
Puma::Plugin.create do Puma::Plugin.create do
def start(launcher) def start(launcher)

View file

@ -287,7 +287,7 @@ module Puma::Rack
private private
def generate_map(default_app, mapping) def generate_map(default_app, mapping)
require 'puma/rack/urlmap' require_relative 'urlmap'
mapped = default_app ? {'/' => default_app} : {} mapped = default_app ? {'/' => default_app} : {}
mapping.each { |r,b| mapped[r] = self.class.new(default_app, &b).to_app } mapping.each { |r,b| mapped[r] = self.class.new(default_app, &b).to_app }

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
require 'rack/handler/puma' require_relative '../rack/handler/puma'
module Rack::Handler module Rack::Handler
def self.default(options = {}) def self.default(options = {})

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
require 'puma/queue_close' unless ::Queue.instance_methods.include? :close require_relative 'queue_close' unless ::Queue.instance_methods.include? :close
module Puma module Puma
class UnsupportedBackend < StandardError; end class UnsupportedBackend < StandardError; end

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
require 'puma/server' require_relative 'server'
require 'puma/const' require_relative 'const'
module Puma module Puma
# Generic class that is used by `Puma::Cluster` and `Puma::Single` to # Generic class that is used by `Puma::Cluster` and `Puma::Single` to
@ -61,7 +61,7 @@ module Puma
str = @options[:control_url] str = @options[:control_url]
return unless str return unless str
require 'puma/app/status' require_relative 'app/status'
if token = @options[:control_auth_token] if token = @options[:control_auth_token]
token = nil if token.empty? || token == 'none' token = nil if token.empty? || token == 'none'

View file

@ -2,17 +2,17 @@
require 'stringio' require 'stringio'
require 'puma/thread_pool' require_relative 'thread_pool'
require 'puma/const' require_relative 'const'
require 'puma/log_writer' require_relative 'log_writer'
require 'puma/events' require_relative 'events'
require 'puma/null_io' require_relative 'null_io'
require 'puma/reactor' require_relative 'reactor'
require 'puma/client' require_relative 'client'
require 'puma/binder' require_relative 'binder'
require 'puma/util' require_relative 'util'
require 'puma/io_buffer' require_relative 'io_buffer'
require 'puma/request' require_relative 'request'
require 'socket' require 'socket'
require 'io/wait' unless Puma::HAS_NATIVE_IO_WAIT require 'io/wait' unless Puma::HAS_NATIVE_IO_WAIT

View file

@ -1,8 +1,8 @@
# frozen_string_literal: true # frozen_string_literal: true
require 'puma/runner' require_relative 'runner'
require 'puma/detect' require_relative 'detect'
require 'puma/plugin' require_relative 'plugin'
module Puma module Puma
# This class is instantiated by the `Puma::Launcher` and used # This class is instantiated by the `Puma::Launcher` and used

View file

@ -2,7 +2,7 @@
require 'thread' require 'thread'
require 'puma/io_buffer' require_relative 'io_buffer'
module Puma module Puma
# Internal Docs for A simple thread pool management object. # Internal Docs for A simple thread pool management object.

View file

@ -11,10 +11,10 @@ module Rack
} }
def self.config(app, options = {}) def self.config(app, options = {})
require 'puma' require_relative '../../puma'
require 'puma/configuration' require_relative '../../puma/configuration'
require 'puma/log_writer' require_relative '../../puma/log_writer'
require 'puma/launcher' require_relative '../../puma/launcher'
default_options = DEFAULT_OPTIONS.dup default_options = DEFAULT_OPTIONS.dup