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 7, 2018
1 parent 91a025f commit 23fc875
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions spec/std/ini_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ describe "INI" do
INI.parse("key = ").should eq({"" => {"key" => ""}})
end

it "ignores whitespaces" do
it "parses 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? }
return ini.reject("") if ini[""].empty?
ini
end

Expand Down

0 comments on commit 23fc875

Please sign in to comment.