Project

inidol

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Inidol is for Hash -> INI and back converting
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

Inidol

Pure Ruby atomic-small and super-simple library for transforming Hashes to INI code. Use gem install inidol for install.

API

Inidol has little method, that extends Hash class in Ruby.

Hash.to_ini

Convert Hash to INI string. Example:

require 'inidol'
settings = {
	global: {
		name: 'Bounce',
		author: 'homonoid',
		version: '~1.0.0'
	},
	
	settings: {
		graphics: 'low',
		shadows: false
	}
}
puts settings.to_ini

outputs following INI:

[global]
name=Bounce
author=homonoid
version=~1.0.0

[settings]
graphics=low
shadows=false

String.from_ini

Convert INI string to Hash. Example:

require 'inidol'
require 'pp'

settings = <<-END
	[numbers]
	digits = 12 # will be transformed into number
	version = 1.0.0 # will be transformed into string
	float = 3.14 # will be transformed into float

	[strings]
	simple = "Hello, World!" # followed with quotes
	also = Hello, World! # or without quotes

	[arrays]
	constants[] = 3.14
	constants[] = 2.71
	constants[] = 1.45
END

pp settings.from_ini

outputs following Hash:

{
	:numbers => {
		:digits => 12,
		:version => "1.0.0",
		:float => 3.14
	},
	:strings => {
		:simple => "Hello, World!",
		:also => "Hello, World!"
	},
	:arrays => {
		:constants => [3.14, 2.71, 1.45]
	}
}

Bugs

  • Inserts newline at start of INI. May be fixed using [1..-1].