TwP / inifile

Native Ruby package for reading and writing INI files
http://codeforpeople.rubyforge.org/inifile
95 stars 47 forks source link

Adding multiline-support #2

Closed melkon closed 13 years ago

melkon commented 13 years ago

Hello guys,

I stumbled upon inifile during my quest for a good ruby-implementation of

http://www.php.net/manual/en/function.parse-ini-file.php

Since it doesn't support multine-line values (what I do need), I forked the project and added this feature myself. It's now working (though not fully functional, I'm missing the possibility to devaluate " with \ inside a multiline-value). I also added / changed new or existing testcases to test the new feature.

Note: I had to exchange the case-statement in the parse-function with ifs to be able to combine multiple conditions for a single if with AND.

I'd like to know if there's any interest in merging my changes back to the main repository.

Kind Regards, André Gawron

TwP commented 13 years ago

Thanks for the pull request. I'll work on it this weekend.

I'm positive there is some regular expression magic that will allow the code to skip over escaped quotation marks. Something like zero-width negative lookbehind to assert that the ending quote is not escaped ☞ http://www.regular-expressions.info/lookaround.html

TwP

melkon commented 13 years ago

Yeah, I was thinking of that as well but I haven't had any time to look into it yet (and I'm not a regular expression-champion). Thanks for your time!

TwP commented 13 years ago

http://rubular.com/ ☜ that site saves my bacon on a daily basis

melkon commented 13 years ago

Thanks for that site, unfortunately it is not capable of expressions like <?param> which comes in handy sometimes.

I also tried to cover the devaluation of " with \ using a regular expression and magic tricks (lookbehinds) but I wasn't able to get it working. Did you have any time to find a proper solution?

Anyways, even without the option of devaluation I'm successfully using the patched IniFile in one of my projects ( https://github.com/melkon/dddbl ). Would be nice if it will be merged into the master-branch :)

TwP commented 13 years ago

The changes have been merged into master. I modified the regular expressions so they are compatible with ruby 1.8.7 Alas, I could not find any regular expression magic that would handle escaped quotes inside a multiline value. Methinks a full fledged parser might be needed.

TwP