Conversation
spec/retriable_spec.rb
Outdated
| end | ||
|
|
||
| it '#retriable does not retry with a hash exception where the value is a proc that returns false' do | ||
| matcher = ->(e, *args) { e.message == 'something went wrong' } |
There was a problem hiding this comment.
Unused block argument - args. If it's necessary, use _ or _args as an argument name to indicate that it won't be used.
spec/retriable_spec.rb
Outdated
| expect(tries).must_equal 2 | ||
| end | ||
|
|
||
| it '#retriable does not retry with a hash exception where the value is a proc that returns false' do |
spec/retriable_spec.rb
Outdated
| end | ||
|
|
||
| it '#retriable retries with a hash exception where the value is a proc that returns true' do | ||
| matcher = ->(e, _try, _elapsed_time, _next_interval) { |
There was a problem hiding this comment.
Use the lambda method for multiline lambdas.
spec/retriable_spec.rb
Outdated
| expect(exceptions[3].class).must_equal StandardError | ||
| end | ||
|
|
||
| it '#retriable retries with a hash exception where the value is a proc that returns true' do |
lib/retriable.rb
Outdated
| end | ||
| end | ||
|
|
||
| def matched_exception?(on, exception, *additional_args) |
There was a problem hiding this comment.
Method has too many lines. [14/10]
There was a problem hiding this comment.
trivial but maybe rename additional_args to proc_args? so it's explicit in the naming where these args are going.
i don't love the name proc_args so maybe you can think of something better (matcher_proc_args?), but additional_args kind of makes it seem like the args will be used in the matched_exception? method, which they will not.
| end | ||
|
|
||
| interval = intervals[index] | ||
| raise unless matched_exception?(on, exception, try, elapsed_time.call, interval) |
772867a to
26ab1bf
Compare
|
@kamui ready! |
|
Ping! |
|
|
||
| A `Regexp` (or array of `Regexp`s). If any of the `Regexp`s match the exception's message, the block will be retried. | ||
| A `Proc` (or array of `Proc`s) that evaluates the exception being handled and returns `true` if the block should be retried. If any of the procs in the list return `true`, the block will be retried. | ||
| You can also mix and match `Proc`s and `Regexp`s in an `Array` |
There was a problem hiding this comment.
this is all sort of duplicative of the docs above... it's probably better to just link back there than to duplicate the explanation.
There was a problem hiding this comment.
I'm just staying consistent with the style of this documentation. Above there are other expanded versions of what's on those bullet points as well.
apurvis
left a comment
There was a problem hiding this comment.
not sure how much water my opinion carries but in general i think this is a good change.
|
(you could propose the version bump to 3.2.0 on this PR though maybe @kamui just prefers to handle the version bumping himself) |
README.md
Outdated
| - A single `Proc` (retries exceptions ONLY if it returns truthy) | ||
| - A single `Regexp` pattern (retries exceptions ONLY if their `message` matches the pattern) | ||
| - An array of patterns (retries exceptions ONLY if their `message` matches at least one of the patterns) | ||
| - An array of `Proc` and/or `Regexp` (retries exceptions ONLY if at least one exception matches `Regexp` or the `Proc` evaluates to `true`) |
There was a problem hiding this comment.
grammar: "retries exceptions ONLY if at least one exception message matches a Regexp or at least one Proc evaluates to true" (or "returns truthy"... not sure which it is but you should be correct and consistent in the documentation).
|
@kamui @rafaelsales what do we need to do here to get this merged? How can I help? |
|
Ping ^ |
lib/retriable.rb
Outdated
| end | ||
| end | ||
|
|
||
| def matched_exception?(on, exception, *additional_args) |
There was a problem hiding this comment.
Naming/UncommunicativeMethodParamName: Method parameter must be at least 3 characters long.
|
@kamui could you take a look at this one? |
| it "#retriable does not retry with a hash exception where the value is a proc that returns false" do | ||
| matcher = ->(e, *_args) { e.message == "something went wrong" } | ||
| tries = 0 | ||
| expect { |
There was a problem hiding this comment.
Style/BlockDelimiters: Avoid using {...} for multi-line blocks.
| e.message == "something went wrong" | ||
| end | ||
| tries = 0 | ||
| expect { |
There was a problem hiding this comment.
Style/BlockDelimiters: Avoid using {...} for multi-line blocks.
|
Thank you so much @rafaelsales! Um abraço amigo de Portugal 🙌 . |
|
I hope this feature will be merged. |
6196a1e to
c448885
Compare
#18