From be40b6ff40009c52e1079fe55b99bbd180cc62d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonne=20Ha=C3=9F?= Date: Sat, 28 May 2016 11:30:19 +0200 Subject: [PATCH] Rename IniFile to INI, closes #2450, ref #279 --- spec/std/{inifile_spec.cr => ini_spec.cr} | 14 +++++++------- src/docs_main.cr | 2 +- src/{inifile.cr => ini.cr} | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) rename spec/std/{inifile_spec.cr => ini_spec.cr} (52%) rename src/{inifile.cr => ini.cr} (77%) diff --git a/spec/std/inifile_spec.cr b/spec/std/ini_spec.cr similarity index 52% rename from spec/std/inifile_spec.cr rename to spec/std/ini_spec.cr index 334b97c3bdbe..6334016741c1 100644 --- a/spec/std/inifile_spec.cr +++ b/spec/std/ini_spec.cr @@ -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", }, diff --git a/src/docs_main.cr b/src/docs_main.cr index 342b49600d82..280312fb6ad6 100644 --- a/src/docs_main.cr +++ b/src/docs_main.cr @@ -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" diff --git a/src/inifile.cr b/src/ini.cr similarity index 77% rename from src/inifile.cr rename to src/ini.cr index f08fc268baf6..e0cc6d7584d4 100644 --- a/src/inifile.cr +++ b/src/ini.cr @@ -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 = ""