lib/stripe/util.rb in stripe-3.25.0 vs lib/stripe/util.rb in stripe-3.26.0
- old
+ new
@@ -84,10 +84,12 @@
Plan::OBJECT_NAME => Plan,
Product::OBJECT_NAME => Product,
Recipient::OBJECT_NAME => Recipient,
RecipientTransfer::OBJECT_NAME => RecipientTransfer,
Refund::OBJECT_NAME => Refund,
+ Reporting::ReportRun::OBJECT_NAME => Reporting::ReportRun,
+ Reporting::ReportType::OBJECT_NAME => Reporting::ReportType,
Reversal::OBJECT_NAME => Reversal,
SKU::OBJECT_NAME => SKU,
Sigma::ScheduledQueryRun::OBJECT_NAME => Sigma::ScheduledQueryRun,
Source::OBJECT_NAME => Source,
SourceTransaction::OBJECT_NAME => SourceTransaction,
@@ -148,22 +150,10 @@
log_internal(message, data, color: :blue,
level: Stripe::LEVEL_DEBUG, logger: Stripe.logger, out: $stdout)
end
end
- def self.file_readable(file)
- # This is nominally equivalent to File.readable?, but that can
- # report incorrect results on some more oddball filesystems
- # (such as AFS)
-
- ::File.open(file) { |f| }
- rescue StandardError
- false
- else
- true
- end
-
def self.symbolize_names(object)
case object
when Hash
new_hash = {}
object.each do |key, value|
@@ -274,15 +264,12 @@
# example, `request-id` becomes `Request-Id`. This is useful for extracting
# certain key values when the user could have set them with a variety of
# diffent naming schemes.
def self.normalize_headers(headers)
headers.each_with_object({}) do |(k, v), new_headers|
- if k.is_a?(Symbol)
- k = titlecase_parts(k.to_s.tr("_", "-"))
- elsif k.is_a?(String)
- k = titlecase_parts(k)
- end
+ k = k.to_s.tr("_", "-") if k.is_a?(Symbol)
+ k = k.split("-").reject(&:empty?).map(&:capitalize).join("-")
new_headers[k] = v
end
end
@@ -365,17 +352,9 @@
else
out.puts format("message=%s level=%s %s", wrap_logfmt_value(message), level_name(level), data_str)
end
end
private_class_method :log_internal
-
- def self.titlecase_parts(s)
- s.split("-")
- .reject { |p| p == "" }
- .map { |p| p[0].upcase + p[1..-1].downcase }
- .join("-")
- end
- private_class_method :titlecase_parts
# Wraps a value in double quotes if it looks sufficiently complex so that
# it can be read by logfmt parsers.
def self.wrap_logfmt_value(val)
# If value is any kind of number, just allow it to be formatted directly