mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-10-04 00:00:47 -04:00
⚠️ Drop support for Ruby < 2.6 & clarify version policy (#1684)
* update version requirements * linting * Fix linting * add ci comment * remove unused block
This commit is contained in:
parent
3919242336
commit
fd4368dbb8
3
.github/workflows/ci.yml
vendored
3
.github/workflows/ci.yml
vendored
@ -46,7 +46,8 @@ jobs:
|
||||
runs-on: ubuntu-22.04
|
||||
strategy:
|
||||
matrix:
|
||||
ruby-version: [2.3, 2.4, 2.5, 2.6, 2.7, '3.0', 3.1, 3.2, 3.3, 3.4, jruby-9.4.0.0, truffleruby-head]
|
||||
# following https://docs.stripe.com/sdks/versioning?server=ruby#stripe-sdk-language-version-support-policy
|
||||
ruby-version: [2.6, 2.7, '3.0', 3.1, 3.2, 3.3, 3.4, jruby-9.4.0.0, truffleruby-head]
|
||||
steps:
|
||||
- uses: extractions/setup-just@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
17
.rubocop.yml
17
.rubocop.yml
@ -2,7 +2,8 @@ inherit_from: .rubocop_todo.yml
|
||||
|
||||
AllCops:
|
||||
DisplayCopNames: true
|
||||
TargetRubyVersion: 2.3
|
||||
TargetRubyVersion: 2.6
|
||||
SuggestExtensions: false
|
||||
|
||||
Layout/CaseIndentation:
|
||||
EnforcedStyle: end
|
||||
@ -72,14 +73,6 @@ Metrics/MethodLength:
|
||||
- initialize
|
||||
- inner_class_types
|
||||
|
||||
# TODO(xavdid): remove this once the first `basil` release is out
|
||||
Naming/MethodName:
|
||||
# these endpoints are removed soon so we pulled their overrides, meaning their names are wrong
|
||||
# that won't make it out to users, but it's breaking linting/formatting in the meantime
|
||||
Exclude:
|
||||
- "lib/stripe/services/invoice_service.rb"
|
||||
- "lib/stripe/resources/invoice.rb"
|
||||
|
||||
Metrics/ModuleLength:
|
||||
Enabled: false
|
||||
|
||||
@ -122,6 +115,9 @@ Style/HashTransformKeys:
|
||||
|
||||
Style/HashTransformValues:
|
||||
Enabled: true
|
||||
Exclude:
|
||||
# RUN_DEVSDK-1956
|
||||
- "lib/stripe/api_requestor.rb"
|
||||
|
||||
Style/NumericPredicate:
|
||||
Enabled: false
|
||||
@ -266,6 +262,9 @@ Style/MapCompactWithConditionalBlock: # new in 1.30
|
||||
Enabled: true
|
||||
Style/MapToHash: # new in 1.24
|
||||
Enabled: true
|
||||
Exclude:
|
||||
# RUN_DEVSDK-1956
|
||||
- "lib/stripe/api_requestor.rb"
|
||||
Style/MapToSet: # new in 1.42
|
||||
Enabled: true
|
||||
Style/MinMaxComparison: # new in 1.42
|
||||
|
@ -37,7 +37,9 @@ gem build stripe.gemspec
|
||||
|
||||
### Requirements
|
||||
|
||||
- Ruby 2.3+.
|
||||
Per our [Language Version Support Policy](https://docs.stripe.com/sdks/versioning?server=ruby#stripe-sdk-language-version-support-policy), we currently support **Ruby 2.6+**.
|
||||
|
||||
Support for Ruby 2.6 and 2.7 is deprecated and will be removed in upcoming major versions. Read more and see the full schedule in the docs: https://docs.stripe.com/sdks/versioning?server=ruby#stripe-sdk-language-version-support-policy
|
||||
|
||||
### Bundler
|
||||
|
||||
@ -55,8 +57,7 @@ gem 'stripe'
|
||||
## Usage
|
||||
|
||||
The library needs to be configured with your account's secret key which is
|
||||
available in your [Stripe Dashboard][api-keys]. Set `Stripe.api_key` to its
|
||||
value:
|
||||
available in your [Stripe Dashboard][api-keys]. Initialize a new client with your API key:
|
||||
|
||||
```ruby
|
||||
require 'stripe'
|
||||
|
@ -572,8 +572,10 @@ module Stripe
|
||||
headers["Content-Type"] = content_type
|
||||
|
||||
# `#to_s` any complex objects like files and the like to build output
|
||||
# that's more condusive to logging.
|
||||
# that's more conducive to logging.
|
||||
flattened_params =
|
||||
# https://go/j/RUN_DEVSDK-1956 - this is probably a bug
|
||||
# once fixed, you can remove the exclusions referencing this ticket in .rubocop.yml
|
||||
flattened_params.map { |k, v| [k, v.is_a?(String) ? v : v.to_s] }.to_h
|
||||
|
||||
elsif api_mode == :v2
|
||||
|
@ -132,9 +132,7 @@ module Stripe
|
||||
|
||||
# Get options that are copyable from StripeObject to StripeObject
|
||||
def self.copyable(req_opts)
|
||||
req_opts.select do |k, _v|
|
||||
RequestOptions::OPTS_COPYABLE.include?(k)
|
||||
end
|
||||
req_opts.slice(*RequestOptions::OPTS_COPYABLE)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -43,7 +43,7 @@ module Stripe
|
||||
connect_base: connect_base,
|
||||
meter_events_base: meter_events_base,
|
||||
client_id: client_id,
|
||||
}.reject { |_k, v| v.nil? }
|
||||
}.compact
|
||||
|
||||
config = StripeConfiguration.client_init(config_opts)
|
||||
@requestor = APIRequestor.new(config)
|
||||
|
@ -45,12 +45,7 @@ module Stripe
|
||||
imported_options = USER_CONFIGURABLE_GLOBAL_OPTIONS - StripeClient::CLIENT_OPTIONS
|
||||
client_config = StripeConfiguration.setup do |instance|
|
||||
imported_options.each do |key|
|
||||
begin
|
||||
instance.public_send("#{key}=", global_config.public_send(key)) if global_config.respond_to?(key)
|
||||
rescue NotImplementedError => e
|
||||
# In Ruby <= 2.5, we can't set write_timeout on Net::HTTP, log an error and continue
|
||||
Util.log_error("Failed to set #{key} on client configuration: #{e}")
|
||||
end
|
||||
end
|
||||
end
|
||||
client_config.reverse_duplicate_merge(config_opts)
|
||||
|
@ -202,8 +202,8 @@ module Stripe
|
||||
value.respond_to?(:to_hash) ? value.to_hash : value
|
||||
end
|
||||
|
||||
@values.each_with_object({}) do |(key, value), acc|
|
||||
acc[key] = case value
|
||||
@values.transform_values do |value|
|
||||
case value
|
||||
when Array
|
||||
value.map(&maybe_to_hash)
|
||||
else
|
||||
@ -273,7 +273,7 @@ module Stripe
|
||||
|
||||
# a `nil` that makes it out of `#serialize_params_value` signals an empty
|
||||
# value that we shouldn't appear in the serialized form of the object
|
||||
update_hash.reject! { |_, v| v.nil? }
|
||||
update_hash.compact!
|
||||
|
||||
update_hash
|
||||
end
|
||||
|
@ -328,7 +328,7 @@ module Stripe
|
||||
def self.valid_variable_name?(key)
|
||||
return false if key.empty? || key[0] !~ LEGAL_FIRST_CHARACTER
|
||||
|
||||
key[1..-1].chars.all? { |char| char =~ LEGAL_VARIABLE_CHARACTER }
|
||||
key[1..].chars.all? { |char| char =~ LEGAL_VARIABLE_CHARACTER }
|
||||
end
|
||||
|
||||
def self.check_string_argument!(key)
|
||||
@ -428,7 +428,7 @@ module Stripe
|
||||
private_class_method :level_name
|
||||
|
||||
def self.log_internal(message, data = {}, color:, level:, logger:, out:)
|
||||
data_str = data.reject { |_k, v| v.nil? }
|
||||
data_str = data.compact
|
||||
.map do |(k, v)|
|
||||
format("%<key>s=%<value>s",
|
||||
key: colorize(k, color, logger.nil? && !out.nil? && out.isatty),
|
||||
|
@ -7,7 +7,7 @@ require "stripe/version"
|
||||
Gem::Specification.new do |s|
|
||||
s.name = "stripe"
|
||||
s.version = Stripe::VERSION
|
||||
s.required_ruby_version = ">= 2.3.0"
|
||||
s.required_ruby_version = ">= 2.6.0"
|
||||
s.summary = "Ruby bindings for the Stripe API"
|
||||
s.description = "Stripe is the easiest way to accept payments online. " \
|
||||
"See https://stripe.com for details."
|
||||
|
@ -728,7 +728,6 @@ module Stripe
|
||||
|
||||
context "Stripe-Account header" do
|
||||
should "use a globally set header" do
|
||||
begin
|
||||
old = Stripe.stripe_account
|
||||
Stripe.stripe_account = "acct_1234"
|
||||
|
||||
@ -740,7 +739,6 @@ module Stripe
|
||||
ensure
|
||||
Stripe.stripe_account = old
|
||||
end
|
||||
end
|
||||
|
||||
should "use a local request set header" do
|
||||
stripe_account = "acct_0000"
|
||||
@ -798,7 +796,6 @@ module Stripe
|
||||
|
||||
context "app_info" do
|
||||
should "send app_info if set" do
|
||||
begin
|
||||
old = Stripe.app_info
|
||||
Stripe.set_app_info(
|
||||
"MyAwesomePlugin",
|
||||
@ -834,7 +831,6 @@ module Stripe
|
||||
Stripe.app_info = old
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "error handling" do
|
||||
should "handle error response with empty body" do
|
||||
@ -1361,7 +1357,6 @@ module Stripe
|
||||
end
|
||||
|
||||
should "reset local thread state after a call" do
|
||||
begin
|
||||
APIRequestor.current_thread_context.active_requestor = :api_requestor
|
||||
|
||||
client = APIRequestor.new("sk_test_123")
|
||||
@ -1372,7 +1367,6 @@ module Stripe
|
||||
ensure
|
||||
APIRequestor.current_thread_context.active_requestor = nil
|
||||
end
|
||||
end
|
||||
|
||||
should "correctly return last responses despite multiple clients" do
|
||||
charge_resp = { object: "charge" }
|
||||
@ -1468,7 +1462,6 @@ module Stripe
|
||||
|
||||
context "#proxy" do
|
||||
should "run the request through the proxy" do
|
||||
begin
|
||||
APIRequestor.clear_all_connection_managers
|
||||
|
||||
Stripe.proxy = "http://user:pass@localhost:8080"
|
||||
@ -1488,7 +1481,6 @@ module Stripe
|
||||
APIRequestor.clear_all_connection_managers
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "#telemetry" do
|
||||
teardown do
|
||||
|
@ -126,7 +126,7 @@ module Stripe
|
||||
@client_opts[:api_key] = "client_test_123"
|
||||
@client_opts[:stripe_account] = "client_acct_123"
|
||||
@client_opts[:uploads_base] = "client_uploads_base.stripe.com"
|
||||
@client_opts.reject! { |_k, v| v.nil? }
|
||||
@client_opts.compact!
|
||||
|
||||
client_config = Stripe::StripeConfiguration.client_init(@client_opts)
|
||||
|
||||
|
@ -159,7 +159,6 @@ module Stripe
|
||||
|
||||
context "#to_hash" do
|
||||
should "skip calling to_hash on nil" do
|
||||
begin
|
||||
module NilWithToHash
|
||||
def to_hash
|
||||
raise "Can't call to_hash on nil"
|
||||
@ -174,7 +173,6 @@ module Stripe
|
||||
ensure
|
||||
::NilClass.send(:undef_method, :to_hash)
|
||||
end
|
||||
end
|
||||
|
||||
should "recursively call to_hash on its values" do
|
||||
# deep nested hash (when contained in an array) or StripeObject
|
||||
|
@ -4,7 +4,6 @@ require File.expand_path("test_helper", __dir__)
|
||||
|
||||
class StripeTest < Test::Unit::TestCase
|
||||
should "allow app_info to be configured" do
|
||||
begin
|
||||
old = Stripe.app_info
|
||||
Stripe.set_app_info(
|
||||
"MyAwesomePlugin",
|
||||
@ -21,7 +20,6 @@ class StripeTest < Test::Unit::TestCase
|
||||
ensure
|
||||
Stripe.app_info = old
|
||||
end
|
||||
end
|
||||
|
||||
context "forwardable configurations" do
|
||||
context "internal configurations" do
|
||||
@ -78,7 +76,6 @@ class StripeTest < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
should "allow enable_telemetry to be configured" do
|
||||
begin
|
||||
old = Stripe.enable_telemetry?
|
||||
|
||||
Stripe.enable_telemetry = false
|
||||
@ -86,7 +83,6 @@ class StripeTest < Test::Unit::TestCase
|
||||
ensure
|
||||
Stripe.enable_telemetry = old
|
||||
end
|
||||
end
|
||||
|
||||
should "allow log_level to be configured" do
|
||||
Stripe.log_level = "debug"
|
||||
|
Loading…
x
Reference in New Issue
Block a user