Skip to content

Commit

Permalink
Keep empty sections when parsing INI
Browse files Browse the repository at this point in the history
  • Loading branch information
j8r committed Apr 8, 2018
1 parent 91a025f commit bd4d261
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions spec/std/ini_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe "INI" do

it "ignores whitespaces" do
INI.parse(" key = value ").should eq({"" => {"key" => "value"}})
INI.parse(" [foo]").should eq({} of String => Hash(String, String))
INI.parse(" [foo]").should eq({"foo" => Hash(String, String).new})
end

it "ignores comments" do
Expand All @@ -50,8 +50,8 @@ describe "INI" do
INI.parse("[foo]\na=1\n[foo]\nb=2").should eq({"foo" => {"a" => "1", "b" => "2"}})
end

it "ignores an empty section" do
INI.parse("[section]").should eq({} of String => Hash(String, String))
it "parses empty section" do
INI.parse("[section]").should eq({"section" => Hash(String, String).new})
end

it "parses a file" do
Expand Down
2 changes: 1 addition & 1 deletion src/ini.cr
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class INI
end
end

ini.delete_if { |_, v| v.empty? }
ini.delete("") if ini[""].empty?
ini
end

Expand Down

0 comments on commit bd4d261

Please sign in to comment.