Patches: Browse | Submit New | Admin

[#10071] Multiple entries for the same key

Date:
2007-04-12 23:04
Priority:
3
Submitted By:
Jerrett Taylor (ennoia)
Assigned To:
Nobody (None)
Category:
None
State:
Open
Summary:
Multiple entries for the same key

Detailed description
I ran into a problem where i was parsing a file that had multiple entries using the same key (specifically,php.ini and:


extension = "something.so"
extension = "somethingelse.so"


ini.rb handled it by clobbering the first with the second, so i modified it to take this into account and create an
array of values when it encounters this scenario. When writing out it simple writes out a new key/value pair for each
element in the array.


A little odd perhaps that an ini file would have multiple entries with the same key, but the file i needed to parse
did :)

Add A Comment: Notepad

Please login


Followup

Message
Date: 2007-04-12 23:36
Sender: Jerrett Taylor

just a note, to use this to *create* multiple entries with
the same key, you would just do: 


ini = Ini.open("php.ini")
ini["Extensions"]["extension"]
= ["apc.so","something.so"]


which would write out as 

[Extensions]
extension = apc.so
extension = something.so




Attached Files:

Name Description Download
multiple-samekey-ini.rb.diff Download
multiple-samekey-ini.rb.diff update - fixed a stupid mistake Download

Changes:

Field Old Value Date By
File Added1821: multiple-samekey-ini.rb.diff2007-04-13 00:00ennoia
File Added1820: multiple-samekey-ini.rb.diff2007-04-12 23:04ennoia