Skip to content

Commit

Permalink
represent the boolean values as per the YAML spec
Browse files Browse the repository at this point in the history
see http://yaml.org/type/bool.html for implementation detail
  • Loading branch information
jwaldrip committed Aug 17, 2017
1 parent 53cbc4e commit 14f3f32
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/yaml/from_yaml.cr
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ def Nil.new(pull : YAML::PullParser)
end

def Bool.new(pull : YAML::PullParser)
pull.read_scalar == "true"
case value
when "true", "True", "TRUE", "on", "On", "ON", "y", "Y", "yes", "Yes", "YES"
true
when "false", "False", "FALSE", "off", "Off", "OFF", "n", "N", "no", "No", "NO"
false
else
raise YAML::ParseException.new("Expected bool, not #{value}", 0, 0)
end
end

{% for type in %w(Int8 Int16 Int32 Int64 UInt8 UInt16 UInt32 UInt64) %}
Expand Down

0 comments on commit 14f3f32

Please sign in to comment.