-
-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate constructor as a block #110
Deprecate constructor as a block #110
Conversation
c8d12c2
to
ac62082
Compare
Wow, that turned out to be easy! And I much prefer the name "constructor" to "processor" as the way to describe this. I was just thinking this was all a little familiar, and I realised I had an open PR for this already too, from a while ago: #86. That one looks like it handles the migration away from the default value being a positional arg too. Would you mind taking a look at that one and seeing if there's anything that's been missed, now that your head is in this space? Maybe we could bring the two together. |
Hey @timriley, thanks for your review. It seems your PR does more than this one:
Would it be ok if we split the whole work into two different PR? I'd merge this one, and then I can prepare another one taking what you did to support the new |
@waiting-for-dev Happy for it to be done in two PRs, yep :) Let us know when you're ready for the first one to be reviewed. @solnic @flash-gordon - what do we feel about releasing these API changes? If they can be handled via deprecations and are therefore not a breaking change, I presume we might be more willing for them to go into a new ordinary 0.x.0 release? With the 1.0 release being the one that removes the deprecation shims? |
So far, we have been accepting both a block and the `constructor:` keyword argument for providing a constructor. The former will not be available in 1.0, so we're deprecating it now. We also prepare the test suite for the change and make naming consistent using "constructor" where we were using "pre-processor."
ac62082
to
c81ea71
Compare
@timriley, it's ready now 🚀 |
end | ||
|
||
it 'supports but deprecates giving a constructor as a block' do | ||
expect(Dry::Core::Deprecations).to receive(:announce) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just set a logger that would write to log/deprecations.log
and this way you could verify if the messages look good. It's an approach we've been using so far.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
it 'supports but deprecates giving a constructor as a block' do | ||
logger = StringIO.new | ||
Dry::Core::Deprecations.logger(logger) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@waiting-for-dev you can move this to spec_helper
and use Logger.new("log/deprecations.log")
there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless I'm missing something, this will make the logger persistent across tests, so we'll be sharing a state between them. I think it's not ideal unless we can't avoid it. What do you think creating about creating a helper method so that we can reuse it easily? For instance:
with_logger do |log|
# expectation
expect(log).to include('....')
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@waiting-for-dev OK let's leave it here since it's the only place where we need it for now. Eventually we should have something reusable though, that can be provided by dry-core.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, it's going to be very soon, as I'm going to use it again in the PR that will deprecate providing the default as positional argument 😄
I change the code to deprecate in the same way that #83 is doing. This way we can already remove |
Nice one, I was actually going to ask about this :) Have you pushed this change up, though? I can't see it in the diff yet. |
I just left my terminal while it was prompting for the ssh password 😅 Please, check it out now. |
Continues at #111 (created branch in |
So far, we have been accepting both a block and the
constructor:
keyword argument for providing a constructor. The former will not be
available in 1.0, so we're deprecating it now.
We also prepare the test suite for the change and make naming consistent
using "constructor" where we were using "pre-processor."