22 Commits

Author SHA1 Message Date
Brandur
85013c9770 Use Faraday's Net::HTTP::Persistent adapter
This changes the library's default connection over to use the adapter
for `Net::HTTP::Persistent`, which is a connection pooling library for
Ruby.

In the long run, I think we should probably just drop Faraday ... the
amount of value it's getting us is extremely tenuous and its API is
difficult to work with. I hate to do it at this point though because
technically people could be writing custom middleware for it.
2018-11-15 08:55:28 -08:00
Brandur
863da48398 Add frozen_string_literal to every file and enforce Rubocop rule
Adds the magic `frozen_string_literal: true` comment to every file and
enables a Rubocop rule to make sure that it's always going to be there
going forward as well.

See here for more background [1], but the basic idea is that unlike many
other languages, static strings in code are mutable by default. This has
since been acknowledged as not a particularly good idea, and the
intention is to rectify the mistake when Ruby 3 comes out, where all
string literals will be frozen. The `frozen_string_literal` magic
comment was introduced in Ruby 2.3 as a way of easing the transition,
and allows libraries and projects to freeze their literals in advance.

I don't think this is breaking in any way: it's possible that users
might've been pulling out one of are literals somehow and mutating it,
but that would probably not have been useful for anything and would
certainly not be recommended, so I'm quite comfortable pushing this
change through as a minor version.

As discussed in #641.

[1] https://stackoverflow.com/a/37799399
2018-05-10 14:56:14 -07:00
Olivier Bellone
56430ad405
Add support for coveralls.io 2017-12-08 17:48:40 -08:00
Brandur
7f85eea3ee Fix low hanging Rubocop TODOs
I wanted to see what fixing Rubocop TODOs was like, so I tried to
eliminate all the easy ones. Most of these were pretty easy, and the
changes required are relatively minimal.

Some of the stuff left is harder. Pretty much everything under
`Metrics/*` is going to be a pretty big yak shave. A few of the others
are just going to need a little more work (e.g. `Style/ClassVars` and
`Style/GuardClause`). Going to stop here for now.
2017-09-27 15:07:18 -07:00
Brandur
867bf9c4e0 Pin Rubocop dependency in Gemfile
Because we're a library, our `Gemfile.lock` is in `.gitinore` (see [1]).
This means that you'd be otherwise be vulnerable to the whims of
whatever version of Rubocop is installed on the local system.

Because Rubocop changes fairly quickly and those changes tend to lead to
either errors or warnings on its runs, lock the gem to a particular
version in our `Gemfile`. We should try to keep the locked version
relatively current.

[1] http://yehudakatz.com/2010/12/16/clarifying-the-roles-of-the-gemspec-and-gemfile/
2017-09-27 13:07:50 -07:00
Olivier Bellone
e02ff7f849
Start using RuboCop for linting 2017-09-27 21:28:25 +02:00
Brandur
ce69d749e1 Implement STRIPE_LOG for stripe-ruby
Adds logging support for stripe-ruby in a similar way that we did it for
stripe-python [1], with the idea that users you can optionally get some
additional low-cost-to-configure logging for operational visibility or
debugging.

I made a few tweaks from the Python implementation (which I'll try to
contribute back to there):

* Added an elapsed parameter to responses so you can tell how long they
  lasted.
* Mixed in idempotency_key to all lines that users have a way to
  aggregate logs related to a request from start to finish.
* Standardized naming between different log lines as much as possible.
* Detect a TTY and produce output that's colorized and formatted.

[1] https://github.com/stripe/stripe-python/pull/269
2017-08-03 13:39:15 -07:00
Brandur
00180c5f35 Power test suite with stripe-mock
Moves away from Committee and towards stripe-mock, an external
self-contained executable API stub server based on OpenAPI [1]. The
motivation here is that instead of making stripe-ruby a special
snowflake, we can use a single well-tested and feature-rich mock
implementation to drive every API's test suite.

[1] https://github.com/stripe/stripe-mock
2017-07-31 13:25:48 -07:00
Brandur
357a99236a Add Committee/Sinatra + add Rack hack
We want to support older versions of Ruby so introduce a Rack hack to
get an older version of it that can run against them.
2017-02-14 12:17:37 -08:00
Brandur
db72af0fdc Push Pry into MRI
The JRuby build seems to be having trouble.
2017-02-14 12:17:37 -08:00
Brandur
ddaf36e00c Remove support for Ruby 1.9
This has been discussed, but we'll finally be doing it for the next
major version so that we can introduce a few features that depend on
gems that don't support 1.9.
2017-02-14 12:06:10 -08:00
Brandur
aa12f7e621 Relax rest-client requirements
Our fairly old requirements for rest-client (and therefore mime-types)
are starting to cause some dependency hell problems for some customers.
Try relaxing these constraints and locking 1.9 specifically into
compatible versions.
2016-08-31 06:56:17 -07:00
Brandur
d250120102 Workaround for mime-types related failures on 1.9 2016-07-11 15:06:56 -07:00
Brandur
1e166d9be7 Fix Gem builds in CI
CI is failing for a number of Ruby versions because shoulda is pulling
in should-matchers, which then pulls in activesupport. activesupport's
new 5.0.0 version is being picked up, and that requires at least Ruby
2.2.2.

Luckily the solution is easy, we're not using shoulda-matchers, only
shoulda-context, so just tighten up our dependencies a little and the
problem goes away.
2016-07-01 15:44:32 -07:00
Brandur
dd2bae2057 Lock Byebug to just the MRI
Here we predicate the installation of Byebug on being on the MRI. This
allows us to `bundle install` on alternate platforms like JRuby.

Also performs some Gemfile management: add latest MRI and JRuby versions
and remove special case Gemfiles.
2016-03-14 08:59:13 -07:00
Kyle Conroy
7bf660d124 Only support Ruby >= 1.9.3
Update the README, Gemfiles, and gemspec to remove all references to
Rubies < 1.9.3.
2015-11-04 14:52:56 -08:00
Russell Davis
317634ede7 Force an older version of the i18n gem for Ruby < 1.9.3
This should fix the travis build for 1.8.7 and 1.9.2.
2014-12-26 14:45:25 -08:00
Russell Davis
5ec4c3f68f Fix error in new versions of bundler from using frozen version string 2014-08-18 14:56:38 -07:00
Andy Brody
9cf5089dc1 Revert "Change rest-client pin to ruby < 1.9.2."
This reverts commit 39a196541f857ac6266b7a06f589ead21c87a8aa.

Just kidding. Activesupport itself depends on ruby >= 1.9.3.
2014-07-15 13:42:48 -07:00
Andy Brody
39a196541f Change rest-client pin to ruby < 1.9.2.
The latest rest-client supports rubies >= 1.9.2
2014-07-15 13:06:04 -07:00
Russell Davis
3c76c9f150 Fix gemfiles for use with Ruby < 1.9.3
Any project using this gem (with Ruby < 1.9.3) will need to do the same
in its own gemfile.
2014-07-13 13:44:36 -07:00
Evan Broder
eba6826b05 Add a (simple) Gemfile 2012-05-03 23:38:05 -07:00