Comments (5)
Hi @patrickberkeley,
thank you for your contribution.
At first I thought, that there may be a bug, but the YAML library itself has the same behaviour, so it happend not by my extending gem.
After some research I found out, that your described behaviour is indeed a part of the official YAML specification:
https://yaml.org/type/bool.html
All of the following key words are transformed into booleans:
YAML 1.1 specification
y|Y|yes|Yes|YES|n|N|no|No|NO
|true|True|TRUE|false|False|FALSE
|on|On|ON|off|Off|OFF
YAML 1.2 specification:
true | True | TRUE | false | False | FALSE
Ruby YAML apparently implements the 1.1 specification.
If you want to use keys or values with these key words not to be transformed into their boolean values, you have to quote them.
from yaml_extend.
from yaml_extend.
I just tried an simple example in IRB:
require 'yaml'
require 'yaml_extend'
YAML.load 'no: so'
# => {false=>"so"}
File.write "t.yml","no: so"
# => 6
YAML.load_file "t.yml"
# => {false=>"so"}
YAML.ext_load_file "t.yml"
# => {false=>"so"}
I did not recognize your description, but maybe you have another constellation where a error may happen. Even a simple sample with inheritance worked fine.
You are invited to give an example that does not work in your case, then i will see what I can do for you. ππ»
from yaml_extend.
@magynhard you are correct. The issue I'm seeing is if I have multiple keys that are evaluated as false, the last one wins and the previous ones don't appear in the output e.g.,
require 'yaml'
YAML.load '{ no: "no", false: "false" }'
# => {false=>"false"}
YAML.load '{ false: "false", no: "no" }'
# => {false=>"no"}
This is normal behavior, but the whole yaml-changing-keys thing is new to me.
from yaml_extend.
@patrickberkeley this behaviour of YAML was also new to me, to thanks for inspiring me. ππ»
from yaml_extend.
Related Issues (10)
- Override only works for string values HOT 2
- Extend existing array option overwriting values in array HOT 1
- undefined method `start_with?' for #<Pathname:0x00000006327430> HOT 2
- Emulating nested settings HOT 15
- Boolean keys with value "true" in base YAML are not overwritten by "false" in extended YAMLs HOT 4
- cannot find yaml files that are extended HOT 3
- Issues with the order extends work HOT 3
- merged order wrong? HOT 10
- Inheriting from several files does not merge them top to bottom HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yaml_extend.