Skip to content

Commit

Permalink
Fix rdebug recursion issue (#1205)
Browse files Browse the repository at this point in the history
Co-authored-by: @native-api
  • Loading branch information
iMacTia authored Nov 13, 2020
1 parent 8c746f6 commit 1595e6f
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 47 deletions.
9 changes: 3 additions & 6 deletions faraday.gemspec
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
# frozen_string_literal: true

lib = 'faraday'
lib_file = File.expand_path("../lib/#{lib}.rb", __FILE__)
File.read(lib_file) =~ /\bVERSION\s*=\s*["'](.+?)["']/
version = Regexp.last_match(1)
require_relative 'lib/faraday/version'

Gem::Specification.new do |spec|
spec.name = lib
spec.version = version
spec.name = 'faraday'
spec.version = Faraday::VERSION

spec.summary = 'HTTP/REST API client library.'

Expand Down
89 changes: 48 additions & 41 deletions lib/faraday.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@
require 'faraday/middleware_registry'
require 'faraday/dependency_loader'

unless defined?(::Faraday::Timer)
require 'timeout'
Timer = Timeout
end

require 'faraday/version'
require 'faraday/methods'
require 'faraday/utils'
require 'faraday/options'
require 'faraday/connection'
require 'faraday/rack_builder'
require 'faraday/parameters'
require 'faraday/middleware'
require 'faraday/adapter'
require 'faraday/request'
require 'faraday/response'
require 'faraday/error'
require 'faraday/file_part'
require 'faraday/param_part'

# This is the main namespace for Faraday.
#
# It provides methods to create {Connection} objects, and HTTP-related
Expand All @@ -20,10 +40,6 @@
# conn.get '/'
#
module Faraday
VERSION = '1.1.0'
METHODS_WITH_QUERY = %w[get head delete trace].freeze
METHODS_WITH_BODY = %w[post put patch].freeze

class << self
# The root path that Faraday is being loaded from.
#
Expand Down Expand Up @@ -108,6 +124,34 @@ def respond_to_missing?(symbol, include_private = false)
default_connection.respond_to?(symbol, include_private) || super
end

# @overload default_connection
# Gets the default connection used for simple scripts.
# @return [Faraday::Connection] a connection configured with
# the default_adapter.
# @overload default_connection=(connection)
# @param connection [Faraday::Connection]
# Sets the default {Faraday::Connection} for simple scripts that
# access the Faraday constant directly, such as
# <code>Faraday.get "https://faraday.com"</code>.
def default_connection
@default_connection ||= Connection.new(default_connection_options)
end

# Gets the default connection options used when calling {Faraday#new}.
#
# @return [Faraday::ConnectionOptions]
def default_connection_options
@default_connection_options ||= ConnectionOptions.new
end

# Sets the default options used when calling {Faraday#new}.
#
# @param options [Hash, Faraday::ConnectionOptions]
def default_connection_options=(options)
@default_connection = nil
@default_connection_options = ConnectionOptions.from(options)
end

private

# Internal: Proxies method calls on the Faraday constant to
Expand All @@ -126,42 +170,5 @@ def method_missing(name, *args, &block)
self.lib_path = File.expand_path 'faraday', __dir__
self.default_adapter = :net_http

# @overload default_connection
# Gets the default connection used for simple scripts.
# @return [Faraday::Connection] a connection configured with
# the default_adapter.
# @overload default_connection=(connection)
# @param connection [Faraday::Connection]
# Sets the default {Faraday::Connection} for simple scripts that
# access the Faraday constant directly, such as
# <code>Faraday.get "https://faraday.com"</code>.
def self.default_connection
@default_connection ||= Connection.new(default_connection_options)
end

# Gets the default connection options used when calling {Faraday#new}.
#
# @return [Faraday::ConnectionOptions]
def self.default_connection_options
@default_connection_options ||= ConnectionOptions.new
end

# Sets the default options used when calling {Faraday#new}.
#
# @param options [Hash, Faraday::ConnectionOptions]
def self.default_connection_options=(options)
@default_connection = nil
@default_connection_options = ConnectionOptions.from(options)
end

unless defined?(::Faraday::Timer)
require 'timeout'
Timer = Timeout
end

require_libs 'utils', 'options', 'connection', 'rack_builder', 'parameters',
'middleware', 'adapter', 'request', 'response', 'error',
'file_part', 'param_part'

require_lib 'autoload' unless ENV['FARADAY_NO_AUTOLOAD']
end
6 changes: 6 additions & 0 deletions lib/faraday/methods.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

module Faraday
METHODS_WITH_QUERY = %w[get head delete trace].freeze
METHODS_WITH_BODY = %w[post put patch].freeze
end
5 changes: 5 additions & 0 deletions lib/faraday/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

module Faraday
VERSION = '1.1.0'
end

0 comments on commit 1595e6f

Please sign in to comment.