antw/iniparse — Issue #4: Comment lines with multiple comment_sep aren't handled correctly
Author: mlsquires
Created: 2011-12-21 23:30:41+00:00
State: open

Lines like:
# comment
a = 1 # comment
b = '#' # comment

are all handled correctly. However, lines like this are not:
# block comment style #

In parser.rb, in the strip_comment method, there is this statement:
if m = /^(.*?)(?:\s+(;|\#)\s*(.*))$/.match(line) ||
m = /(^)(?:(;|\#)\s*(.*))$/.match(line) # Comment lines.

The second of those matches the block comments better, so reversing the order of those seems to fix the issue. I ran it that way against my dataset and it doesn't look like I broke anything. I ran 'rake spec' and everything passed except this note:

Pending:
IniParse race07.ini fixture should be identical to the original when calling #to_ini
# awaiting presevation (or lack) of whitespace around =
# ./spec/fixture_spec.rb:114

+ if m = /(^)(?:(;|\#)\s*(.*))$/.match(line) ||
+ m = /^(.*?)(?:\s+(;|\#)\s*(.*))$/.match(line)