-
Notifications
You must be signed in to change notification settings - Fork 0
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
Overwrites duplicate values with the values in the latest file #1
Conversation
It will probably be a good idea to bump the major version (to 1.0.0?) as the behavior is changed (breaking changes). |
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.
Changes look good, let's document the fixes in the PR's description, we can later copy these to other PR's / wikis, etc.
I think it is OK to commit an image file for the docs to the repo, as long as it is not included in the gem bundle file that is going to be published.
@nangelovaTeladoc Seems with the change to |
2b3e46f
to
7f81547
Compare
Seems many people have been working on similar things in paralle. |
Hi guys, thank you for your great work. I've figured out by playing around with your PR, that your solution also already addresses magynhard#6 I like your work and I would be happy to have your changes integrated into the original project. I would like to add some more tests for some cases related to the merging order after adding your changes and make a new 1.x release then. |
Hi @magynhard, |
@nangelovaTeladoc so can you merge this PR into the master and create a PR on the original github repo please? |
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.
@nangelovaTeladoc
The changes look good, there are passing specs that cover the functionality concerning bools (helper was removed).
@magynhard
You are right, this indeed fixes magynhard#6, we failed to correctly understand the expected behavior there initially. Thanks for the heads up!
The PR's description was updated to reflect that.
Also mentioned explicitly how the extend functionality is supposed to work when having nil
values (specs added).
Will now merge this and open a PR to the upstream repo.
The main changes intend to fix the multi-file inheritance precedence order.
This PR is regarding magynhard#7 and magynhard#6, but does NOT address magynhard#5
The desired behavior is described in the README (emphasis mine):
Before the current changes, the reality was that the precedence order was exactly the opposite - the topmost file would "win".
This was caused because the
deeper_merge
method from the deep_merge gem was used.According to this issue, the
deeper_merge!
version should be used instead for the cases where we want hash values to actually be overwritten (instead of just augmented with new keys). The documentation ofdeep_merge
is not very clear on that.Other changes in this PR:
config
param from the publicYAML.ext_load_file
method.
instead of#
(which is normally used for instance methods).Let's have the following file structure as an example for the inheritance problem (test case added to
specs
)with file contents of:
The expected result of
YAML.ext_load_file 'child.yml'
should then be:but instead of that, we were getting:
Nil values
Let's have the following file structure as an example for the inheritance problem with nil values (test case added to specs)
with file contents of:
The expected result of
YAML.ext_load_file extended.yml
should then be:but instead of that, we were getting:
For reference, here's how the underlying
deep_merge
gem handles cases withnil
values: