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

Validate and raise error for unsupported colors #64

Merged
merged 6 commits into from
Jun 6, 2014

Conversation

erran
Copy link
Contributor

@erran erran commented Jun 2, 2014

Update Nexpose::Tag to respect Nexpose's allowed tag color values.

@mdaines-r7
Copy link
Contributor

I'm going to hold off on merging until I can confirm that this doesn't conflict with internal testing.

# Set the color but validate it
def color=(hex)
unless Type::Color::VALID_COLORS.include?(hex.to_s.downcase)
raise ArgumentError, "Unable to set color to an invalid color.\nUse one of #{Type::Color::VALID_COLORS}"
Copy link
Contributor

Choose a reason for hiding this comment

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

We've been using a style like Type::Color.constants internally to do similar things. Allows you to avoid storing it as a separate value, and if a new constant is added, it gets picked up automatically.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good. 👍 I'm used to doing the same, but wasn't sure how it's handled in here.

@erran
Copy link
Contributor Author

erran commented Jun 2, 2014

I'm going to hold off on merging until I can confirm that this doesn't conflict with internal testing.

@mdaines-r7 Understood. Fine by me.

@erran
Copy link
Contributor Author

erran commented Jun 3, 2014

This argument validation breaks the parsing method where color is set to nil.

@zachrab fixed in 2a753c3

mdaines-r7 added a commit that referenced this pull request Jun 6, 2014
Validate and raise error for unsupported colors
@mdaines-r7 mdaines-r7 merged commit 19421ac into rapid7:master Jun 6, 2014
@erran-r7 erran-r7 deleted the raise-error-for-unsupported-colors branch February 13, 2015 03:03
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