<commit_before>= IniParse

IniParse is a pure Ruby library for parsing
INI[http://en.wikipedia.org/wiki/INI_file] configuration and data
files.

This rubygem is in ongoing development and - specs aside - hasn't yet been
properly tested in a production environment. If you think you've found a bug,
or you feed it an INI file which doesn't work as you'd expected, please mail
me at +anthony at ninecraft dot com+, ideally with a copy of the INI file in
question.

IniParse tests pass on Ruby 1.8.6p383, 1.8.7p174, and 1.9.1p243.

=== Main features

* <b>Support for duplicate options.</b> While not common, some INI files
  contain an option more than once. IniParse does not overwrite previous
  options, but allows you to access all of the duplicate values.

* <b>Preservation of white space and blank lines.</b> When writing back to
  your INI file, line indents, white space and comments (and their indents)
  are preserved. Only trailing white space (which has no significance in INI
  files) will be removed.

* <b>Preservation of section and option ordering.</b> Sections and options
  are kept in the same order they are in the original document ensuring that
  nothing gets mangled when writing back to the file.

If you don't need the above mentioned features, you may find the simpler
IniFile gem does all you need.

=== Opening an INI file

Parsing an INI file is fairly simple:

    IniParse.parse( File.open('path/to/my/file.ini') ) # => IniParse::Document

IniParse.parse returns an IniParse::Document instance which represents the
passed "INI string". Assuming you know the structure of the document, you can
access the sections in the INI document with IniParse::Document#[]. For
example:

    document = IniParse.parse( File.read('path/to/my/file.ini') )<commit_msg>Update the list of Ruby versions specs are run against.<commit_after>= IniParse

IniParse is a pure Ruby library for parsing
INI[http://en.wikipedia.org/wiki/INI_file] configuration and data
files.

This rubygem is in ongoing development and - specs aside - hasn't yet been
properly tested in a production environment. If you think you've found a bug,
or you feed it an INI file which doesn't work as you'd expected, please mail
me at +anthony at ninecraft dot com+, ideally with a copy of the INI file in
question.

IniParse tests pass on Ruby 1.8.6p399, 1.8.7p249, and 1.9.1p378, JRuby 1.4.0 and Rubinius 1.0.0 RC2.

=== Main features

* <b>Support for duplicate options.</b> While not common, some INI files
  contain an option more than once. IniParse does not overwrite previous
  options, but allows you to access all of the duplicate values.

* <b>Preservation of white space and blank lines.</b> When writing back to
  your INI file, line indents, white space and comments (and their indents)
  are preserved. Only trailing white space (which has no significance in INI
  files) will be removed.

* <b>Preservation of section and option ordering.</b> Sections and options
  are kept in the same order they are in the original document ensuring that
  nothing gets mangled when writing back to the file.

If you don't need the above mentioned features, you may find the simpler
IniFile gem does all you need.

=== Opening an INI file

Parsing an INI file is fairly simple:

    IniParse.parse( File.open('path/to/my/file.ini') ) # => IniParse::Document

IniParse.parse returns an IniParse::Document instance which represents the
passed "INI string". Assuming you know the structure of the document, you can
access the sections in the INI document with IniParse::Document#[]. For
example:

    document = IniParse.parse( File.read('path/to/my/file.ini') )
{'fraction_non_alphanumeric': 0.06970362239297476, 'fraction_numerical': 0.011800219538968168, 'mean_word_length': 4.1265822784810124, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '702705', 'n_tokens_mistral': 1076, 'n_tokens_neox': 1022, 'n_words': 523}