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

(MODULES-2456) Modify union to accept more than two arrays #507

Merged
merged 1 commit into from
Aug 24, 2015
Merged

(MODULES-2456) Modify union to accept more than two arrays #507

merged 1 commit into from
Aug 24, 2015

Conversation

Jetroid
Copy link
Contributor

@Jetroid Jetroid commented Aug 24, 2015

Add spec tests to test the new functionality:
*Case for 3 arrays.
*Case for 4 arrays.
Modify README to note new functionality.

This is for issue MODULE-2456, follow the precedent of MODULE-444.

This change allows union to be much more useful, unioning many arrays
in one line rather than in n lines. Additionally, as this is only added
functionality, and does not affect the 2 array case that all modules
currently using array are using, it should not affect any existing
modules utilizing union.

This is now useful, for example, for merging many arrays of resources
(eg: packages.) to generate just one list with no duplicates, to avoid
duplicate resource declarations.

@Jetroid Jetroid changed the title (#2456) Modify union to accept more than two arrays (MODULES-2456) Modify union to accept more than two arrays Aug 24, 2015
raise(Puppet::ParseError, "union(): Wrong number of arguments " +
"given (#{arguments.size} for 2)") if arguments.size != 2
# Check that 2 or more arguments have been given ...
raise(Puppet::ParseError, "concat(): Wrong number of arguments " +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean 'union', not 'concat' here?

@DavidS
Copy link
Contributor

DavidS commented Aug 24, 2015

Hi, this seems to be a worthwhile addition. There seems to be one typo in the error message and the actual function body could be simplified significantly. I've pointed that out in code comments.

Cheers!

@Jetroid
Copy link
Contributor Author

Jetroid commented Aug 24, 2015

Thanks for the criticism, DavidS.

Your comments are all valid. Have made the necessary changes and pushed.

@DavidS
Copy link
Contributor

DavidS commented Aug 24, 2015

Sweet. Would you mind squashing it into a single commit, just so the history is nice and clean?

http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html

Add spec tests to test the new functionality:
 *Case for 3 arrays.
 *Case for 4 arrays.
Modify README to note new functionality.

This is for issue MODULE-2456, follow the precedent of MODULE-444.

This change allows union to be much more useful, unioning many arrays
in one line rather than in n lines. Additionally, as this is only added
functionality, and does not affect the 2 array case that all modules
currently using array are using, it should not affect any existing
modules utilizing union.

This is now useful, for example, for merging many arrays of resources
(eg: packages.) to generate just one list with no duplicates, to avoid
duplicate resource declarations.
@Jetroid
Copy link
Contributor Author

Jetroid commented Aug 24, 2015

No worries. Complete.

Thanks!

@DavidS
Copy link
Contributor

DavidS commented Aug 24, 2015

Thank you for your contribution!

DavidS added a commit that referenced this pull request Aug 24, 2015
(MODULES-2456) Modify union to accept more than two arrays
@DavidS DavidS merged commit 24e57b5 into puppetlabs:master Aug 24, 2015
@Jetroid Jetroid deleted the mod2456 branch August 24, 2015 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants