Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implements a parser that concatenates duplicated keys in a section #79

Merged
merged 5 commits into from
May 31, 2015

Conversation

rickyah
Copy link
Owner

@rickyah rickyah commented May 30, 2015

Instead of just ignoring or throwing errors when the parser founds a duplicated
key, this parser merges the key values using an specified string
This is a new implementation requested by user @xtu and references PR #70

e.g. this ini file

[section]
key1 = hello
key1 = world

is equivalent to this one:

[section]
key1 = hello;world

@rickyah
Copy link
Owner Author

rickyah commented May 30, 2015

@xtu could you please check that this implementation works for you. I still need to change the interface so the parser accepts a configuration object, but it is functional

@beatcracker
Copy link

Wow, that's great news! For example, Subgit uses duplicate keys to store SVN→Git branch mappings and I recently had to parse its ini file. Example:

#  Wildcard mappings:
#    Use wildcard branches and tags mappings to define correspondence between set of Subversion
#    directories that represent branches or tags and corresponding Git references:
#
#    branches = branches/*:refs/heads/*
#    branches = branches/*/*:refs/heads/*/*
#    branches = branches/*/project:refs/heads/*
#    branches = branches/feature_*_2015:refs/heads/features/*

I look forward for this feature to be finished, so I can update my PowerShell module.

@rickyah rickyah force-pushed the concatenate-duplicate-keys branch from 1f06bb7 to 75a67d9 Compare May 30, 2015 23:00
@rickyah
Copy link
Owner Author

rickyah commented May 30, 2015

Just updated the PR, now the new parser accepts a configuration object that allows setting the string used to concatenate the duplicated keys instead of passing that data in the constructor. That's similar as the way the normal parser works. This led to a simplification of the API, the IniParserConfiguration class now has the same functionality as DefaultIniParserDataConfiguration (this last one class is just an "alias") and I got rid of the IIniParserConfiguration interface, as extending a configuration object it just complicated things for no reason: you needed to create both a new interface and a new class.

I've also used the tests provided by @xtu in his original PR, there are implemented in the class ConcatenateDuplicatedKeysIniDataParserTests.

@beatcracker glad this feature is also useful to you! :)

Take a look to the commit message for detailed info: (75a67d9804a7132876d5725433b92be48d11282a]

BTW if anyone has a better and shorter name for the new parser class (ConcatenateDuplicatedKeysIniParser) I'm open to suggestions, looks too long for me

@rickyah
Copy link
Owner Author

rickyah commented May 30, 2015

Tomorrow I'l create a new package for NuGet, it is 1am here and I need to 😴

xtu and others added 5 commits May 31, 2015 19:04
Now when creating an instance of a ConcatenateDuplicatedKeysIniDataParser
you can pass a configuration file that allows changing the string used to
concatenate the duplicated keys.

Configuration.ConcatenateString = ";" // Default value

The configuration AllowDuplicatedKeys is considered as always true, and
changing its value has no effect for the ConcatenateDuplicatedKeysIniDataParser
@rickyah rickyah force-pushed the concatenate-duplicate-keys branch from fc73b75 to 9f16cff Compare May 31, 2015 17:11
@rickyah rickyah added this to the 2.2.0 milestone May 31, 2015
rickyah added a commit that referenced this pull request May 31, 2015
Implements a parser that concatenates duplicated keys in a section
@rickyah rickyah merged commit f9c1861 into development May 31, 2015
@rickyah rickyah deleted the concatenate-duplicate-keys branch May 31, 2015 17:16
@rickyah
Copy link
Owner Author

rickyah commented May 31, 2015

@xtu @beatcracker I've merged this PR released version 2.2.0. You can grab the source code or update your packages if you are using NuGet.
Enjoy! ;)

@xtu
Copy link
Contributor

xtu commented Jun 6, 2015

Great job! Thanks @rickyah

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants