Skip to content

Commit

Permalink
Rename IniFile to INI, closes crystal-lang#2450, ref crystal-lang#279
Browse files Browse the repository at this point in the history
  • Loading branch information
jhass committed May 28, 2016
1 parent d16a31d commit be40b6f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions spec/std/inifile_spec.cr → spec/std/ini_spec.cr
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
require "spec"
require "inifile"
require "ini"

describe "IniFile" do
describe "INI" do
describe "parse from string" do
it "parses key = value" do
IniFile.load("key = value").should eq({"" => {"key" => "value"}})
INI.parse("key = value").should eq({"" => {"key" => "value"}})
end

it "ignores whitespaces" do
IniFile.load(" key = value ").should eq({"" => {"key" => "value"}})
INI.parse(" key = value ").should eq({"" => {"key" => "value"}})
end

it "parses sections" do
IniFile.load("[section]\na = 1").should eq({"section" => {"a" => "1"}})
INI.parse("[section]\na = 1").should eq({"section" => {"a" => "1"}})
end

it "empty section" do
IniFile.load("[section]").should eq({"section" => {} of String => String})
INI.parse("[section]").should eq({"section" => {} of String => String})
end

it "parse file" do
IniFile.load(File.read "#{__DIR__}/data/test_file.ini").should eq({
INI.parse(File.read "#{__DIR__}/data/test_file.ini").should eq({
"general" => {
"log_level" => "DEBUG",
},
Expand Down
2 changes: 1 addition & 1 deletion src/docs_main.cr
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ require "./colorize"
require "./complex"
require "./deque"
require "./dl"
require "./inifile"
require "./ini_file"
require "./levenshtein"
require "./option_parser"
require "./partial_comparable"
Expand Down
6 changes: 3 additions & 3 deletions src/inifile.cr → src/ini.cr
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
class IniFile
class INI
# Parses INI-style configuration from the given string.
#
# ```
# IniFile.load("[foo]\na = 1") # => {"foo" => {"a" => "1"}}
# INI.parse("[foo]\na = 1") # => {"foo" => {"a" => "1"}}
# ```
def self.load(str) : Hash(String, Hash(String, String))
def self.parse(str) : Hash(String, Hash(String, String))
ini = {} of String => Hash(String, String)

section = ""
Expand Down

0 comments on commit be40b6f

Please sign in to comment.