Skip to content

Commit

Permalink
Drop support for old versions of Ruby
Browse files Browse the repository at this point in the history
Drops support for Ruby 2.1 (EOL March 31, 2017) and 2.2 (EOL March 31,
2018). They're removed from `.travis.yml` and the gemspec and RuboCop
configuration have also been updated to the new lower bound.

Most of the diff here are minor updates to styling as required by
RuboCop:

* String literals are frozen by default, so the `.freeze` we had
  everywhere is now considered redundant.

* We can now use Ruby 1.9 style hash syntax with string keys like `{
  "foo": "bar" }.

* Converted a few heredocs over to use squiggly (leading whitespace
  removed) syntax.

As discussed in Slack, I didn't drop support for Ruby 2.2 (EOL March 31,
2019) as we still have quite a few users on it. As far as I know
dropping it doesn't get us access to any major syntax improvements or
anything, so it's probably not a big deal.
  • Loading branch information
brandur committed Jul 29, 2019
1 parent 2c80bc8 commit 7da7070
Show file tree
Hide file tree
Showing 97 changed files with 133 additions and 141 deletions.
5 changes: 4 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ inherit_from: .rubocop_todo.yml

AllCops:
DisplayCopNames: true
TargetRubyVersion: 2.1
TargetRubyVersion: 2.3

Layout/CaseIndentation:
EnforcedStyle: end
Expand Down Expand Up @@ -39,6 +39,9 @@ Style/AccessModifierDeclarations:
Style/FrozenStringLiteralComment:
EnforcedStyle: always

Style/NumericPredicate:
Enabled: false

Style/StringLiterals:
EnforcedStyle: double_quotes

Expand Down
6 changes: 0 additions & 6 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

Layout/ClosingHeredocIndentation:
# As far as I can tell, this lint rule just doesn't work when it comes to
# heredoc in `it` blocks.
Exclude:
- 'test/**/*'

# Offense count: 20
Metrics/AbcSize:
Max: 53
Expand Down
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
language: ruby

rvm:
- 2.1
- 2.2
- 2.3
- 2.4
- 2.5
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/list_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class ListObject < StripeObject
include Stripe::APIOperations::Request
include Stripe::APIOperations::Create

OBJECT_NAME = "list".freeze
OBJECT_NAME = "list"

# This accessor allows a `ListObject` to inherit various filters that were
# given to a predecessor. This allows for things like consistent limits,
Expand Down
9 changes: 4 additions & 5 deletions lib/stripe/multipart_encoder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module Stripe
# placed in the `Content-Type` header of a subsequent request (which includes
# a boundary value).
class MultipartEncoder
MULTIPART_FORM_DATA = "multipart/form-data".freeze
MULTIPART_FORM_DATA = "multipart/form-data"

# A shortcut for encoding a single set of parameters and finalizing a
# result.
Expand All @@ -35,10 +35,9 @@ def self.encode(params)

# Initializes a new multipart encoder.
def initialize
# We seed this with an empty string so that it encoding defaults to UTF-8
# instead of ASCII. The empty string is UTF-8 and new string inherits the
# encoding of the string it's seeded with.
@body = String.new("")
# Kind of weird, but required by Rubocop because the unary plus operator
# is considered faster than `Stripe.new`.
@body = +""

# Chose the same number of random bytes that Go uses in its standard
# library implementation. Easily enough entropy to ensure that it won't
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/resources/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Account < APIResource
include Stripe::APIOperations::Save
extend Stripe::APIOperations::NestedResource

OBJECT_NAME = "account".freeze
OBJECT_NAME = "account"

custom_method :reject, http_verb: :post

Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/resources/account_link.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ module Stripe
class AccountLink < APIResource
extend Stripe::APIOperations::Create

OBJECT_NAME = "account_link".freeze
OBJECT_NAME = "account_link"
end
end
2 changes: 1 addition & 1 deletion lib/stripe/resources/alipay_account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class AlipayAccount < APIResource
include Stripe::APIOperations::Save
include Stripe::APIOperations::Delete

OBJECT_NAME = "alipay_account".freeze
OBJECT_NAME = "alipay_account"

def resource_url
if !respond_to?(:customer) || customer.nil?
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/resources/apple_pay_domain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class ApplePayDomain < APIResource
include Stripe::APIOperations::Delete
extend Stripe::APIOperations::List

OBJECT_NAME = "apple_pay_domain".freeze
OBJECT_NAME = "apple_pay_domain"

def self.resource_url
"/v1/apple_pay/domains"
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/resources/application_fee.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class ApplicationFee < APIResource
extend Stripe::APIOperations::List
extend Stripe::APIOperations::NestedResource

OBJECT_NAME = "application_fee".freeze
OBJECT_NAME = "application_fee"

nested_resource_class_methods :refund,
operations: %i[create retrieve update list]
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/resources/application_fee_refund.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class ApplicationFeeRefund < APIResource
include Stripe::APIOperations::Save
extend Stripe::APIOperations::List

OBJECT_NAME = "fee_refund".freeze
OBJECT_NAME = "fee_refund"

def resource_url
"#{ApplicationFee.resource_url}/#{CGI.escape(fee)}/refunds" \
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/resources/balance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module Stripe
class Balance < SingletonAPIResource
OBJECT_NAME = "balance".freeze
OBJECT_NAME = "balance"
end
end
2 changes: 1 addition & 1 deletion lib/stripe/resources/balance_transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Stripe
class BalanceTransaction < APIResource
extend Stripe::APIOperations::List

OBJECT_NAME = "balance_transaction".freeze
OBJECT_NAME = "balance_transaction"

def self.resource_url
"/v1/balance/history"
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/resources/bank_account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class BankAccount < APIResource
extend Stripe::APIOperations::List
include Stripe::APIOperations::Save

OBJECT_NAME = "bank_account".freeze
OBJECT_NAME = "bank_account"

def verify(params = {}, opts = {})
resp, opts = request(:post, resource_url + "/verify", params, opts)
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/resources/bitcoin_receiver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Stripe
class BitcoinReceiver < APIResource
extend Stripe::APIOperations::List

OBJECT_NAME = "bitcoin_receiver".freeze
OBJECT_NAME = "bitcoin_receiver"

def self.resource_url
"/v1/bitcoin/receivers"
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/resources/bitcoin_transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class BitcoinTransaction < APIResource
# Sources API instead: https://stripe.com/docs/sources/bitcoin
extend Stripe::APIOperations::List

OBJECT_NAME = "bitcoin_transaction".freeze
OBJECT_NAME = "bitcoin_transaction"

def self.resource_url
"/v1/bitcoin/transactions"
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/resources/capability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Capability < APIResource
extend Stripe::APIOperations::List
include Stripe::APIOperations::Save

OBJECT_NAME = "capability".freeze
OBJECT_NAME = "capability"

def resource_url
if !respond_to?(:account) || account.nil?
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/resources/card.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Card < APIResource
extend Stripe::APIOperations::List
include Stripe::APIOperations::Save

OBJECT_NAME = "card".freeze
OBJECT_NAME = "card"

def resource_url
if respond_to?(:recipient) && !recipient.nil? && !recipient.empty?
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/resources/charge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Charge < APIResource
extend Stripe::APIOperations::List
include Stripe::APIOperations::Save

OBJECT_NAME = "charge".freeze
OBJECT_NAME = "charge"

custom_method :capture, http_verb: :post

Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/resources/checkout/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Checkout
class Session < APIResource
extend Stripe::APIOperations::Create

OBJECT_NAME = "checkout.session".freeze
OBJECT_NAME = "checkout.session"
end
end
end
2 changes: 1 addition & 1 deletion lib/stripe/resources/country_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ module Stripe
class CountrySpec < APIResource
extend Stripe::APIOperations::List

OBJECT_NAME = "country_spec".freeze
OBJECT_NAME = "country_spec"
end
end
2 changes: 1 addition & 1 deletion lib/stripe/resources/coupon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ class Coupon < APIResource
extend Stripe::APIOperations::List
include Stripe::APIOperations::Save

OBJECT_NAME = "coupon".freeze
OBJECT_NAME = "coupon"
end
end
2 changes: 1 addition & 1 deletion lib/stripe/resources/credit_note.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class CreditNote < APIResource
extend Stripe::APIOperations::List
include Stripe::APIOperations::Save

OBJECT_NAME = "credit_note".freeze
OBJECT_NAME = "credit_note"

custom_method :void_credit_note, http_verb: :post, http_path: "void"

Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/resources/customer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Customer < APIResource
include Stripe::APIOperations::Save
extend Stripe::APIOperations::NestedResource

OBJECT_NAME = "customer".freeze
OBJECT_NAME = "customer"

nested_resource_class_methods :balance_transaction,
operations: %i[create retrieve update list]
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/resources/customer_balance_transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class CustomerBalanceTransaction < APIResource
extend Stripe::APIOperations::List
include Stripe::APIOperations::Save

OBJECT_NAME = "customer_balance_transaction".freeze
OBJECT_NAME = "customer_balance_transaction"

def resource_url
if !respond_to?(:customer) || customer.nil?
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/resources/discount.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module Stripe
class Discount < StripeObject
OBJECT_NAME = "discount".freeze
OBJECT_NAME = "discount"
end
end
2 changes: 1 addition & 1 deletion lib/stripe/resources/dispute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Dispute < APIResource
extend Stripe::APIOperations::List
include Stripe::APIOperations::Save

OBJECT_NAME = "dispute".freeze
OBJECT_NAME = "dispute"

custom_method :close, http_verb: :post

Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/resources/ephemeral_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class EphemeralKey < APIResource
extend Stripe::APIOperations::Create
include Stripe::APIOperations::Delete

OBJECT_NAME = "ephemeral_key".freeze
OBJECT_NAME = "ephemeral_key"

def self.create(params = {}, opts = {})
opts = Util.normalize_opts(opts)
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/resources/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ module Stripe
class Event < APIResource
extend Stripe::APIOperations::List

OBJECT_NAME = "event".freeze
OBJECT_NAME = "event"
end
end
2 changes: 1 addition & 1 deletion lib/stripe/resources/exchange_rate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ module Stripe
class ExchangeRate < APIResource
extend Stripe::APIOperations::List

OBJECT_NAME = "exchange_rate".freeze
OBJECT_NAME = "exchange_rate"
end
end
4 changes: 2 additions & 2 deletions lib/stripe/resources/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ class File < APIResource
extend Stripe::APIOperations::Create
extend Stripe::APIOperations::List

OBJECT_NAME = "file".freeze
OBJECT_NAME = "file"

# This resource can have two different object names. In latter API
# versions, only `file` is used, but since stripe-ruby may be used with
# any API version, we need to support deserializing the older
# `file_upload` object into the same class.
OBJECT_NAME_ALT = "file_upload".freeze
OBJECT_NAME_ALT = "file_upload"

def self.resource_url
"/v1/files"
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/resources/file_link.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ class FileLink < APIResource
extend Stripe::APIOperations::List
include Stripe::APIOperations::Save

OBJECT_NAME = "file_link".freeze
OBJECT_NAME = "file_link"
end
end
2 changes: 1 addition & 1 deletion lib/stripe/resources/invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Invoice < APIResource
extend Stripe::APIOperations::List
include Stripe::APIOperations::Save

OBJECT_NAME = "invoice".freeze
OBJECT_NAME = "invoice"

custom_method :finalize_invoice, http_verb: :post, http_path: "finalize"
custom_method :mark_uncollectible, http_verb: :post
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/resources/invoice_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ class InvoiceItem < APIResource
extend Stripe::APIOperations::List
include Stripe::APIOperations::Save

OBJECT_NAME = "invoiceitem".freeze
OBJECT_NAME = "invoiceitem"
end
end
2 changes: 1 addition & 1 deletion lib/stripe/resources/invoice_line_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module Stripe
class InvoiceLineItem < StripeObject
OBJECT_NAME = "line_item".freeze
OBJECT_NAME = "line_item"
end
end
2 changes: 1 addition & 1 deletion lib/stripe/resources/issuer_fraud_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ module Stripe
class IssuerFraudRecord < APIResource
extend Stripe::APIOperations::List

OBJECT_NAME = "issuer_fraud_record".freeze
OBJECT_NAME = "issuer_fraud_record"
end
end
2 changes: 1 addition & 1 deletion lib/stripe/resources/issuing/authorization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Authorization < APIResource
extend Stripe::APIOperations::List
include Stripe::APIOperations::Save

OBJECT_NAME = "issuing.authorization".freeze
OBJECT_NAME = "issuing.authorization"

custom_method :approve, http_verb: :post
custom_method :decline, http_verb: :post
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/resources/issuing/card.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Card < APIResource
extend Stripe::APIOperations::List
include Stripe::APIOperations::Save

OBJECT_NAME = "issuing.card".freeze
OBJECT_NAME = "issuing.card"

custom_method :details, http_verb: :get

Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/resources/issuing/card_details.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Stripe
module Issuing
class CardDetails < Stripe::StripeObject
OBJECT_NAME = "issuing.card_details".freeze
OBJECT_NAME = "issuing.card_details"
end
end
end
2 changes: 1 addition & 1 deletion lib/stripe/resources/issuing/cardholder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Cardholder < APIResource
extend Stripe::APIOperations::List
include Stripe::APIOperations::Save

OBJECT_NAME = "issuing.cardholder".freeze
OBJECT_NAME = "issuing.cardholder"
end
end
end
2 changes: 1 addition & 1 deletion lib/stripe/resources/issuing/dispute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Dispute < APIResource
extend Stripe::APIOperations::List
include Stripe::APIOperations::Save

OBJECT_NAME = "issuing.dispute".freeze
OBJECT_NAME = "issuing.dispute"
end
end
end
Loading

0 comments on commit 7da7070

Please sign in to comment.