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

Make HostOrIP#convert more flexible on IP address range input #214

Merged
merged 2 commits into from
Apr 29, 2016

Conversation

gschneider-r7
Copy link
Contributor

Had discussions with 2 different people today where this change would be very useful to them, so figured I'd throw it in here so they don't have to do it in their own scripts.

As you can see in the new tests, IP ranges are now converted with or without whitespace. As long as there is a hyphen (-) it should correctly make a range regardless of whitespace.

context 'with an IP address range with whitespace' do
let(:asset) { asset = '192.168.1.0 - 192.168.1.255' }


Choose a reason for hiding this comment

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

Extra blank line detected.

@gschneider-r7
Copy link
Contributor Author

Oh I just realized this won't work with hyphenated hostnames... now I remember why it had whitespace.

@gschneider-r7
Copy link
Contributor Author

Actually nevermind, there is a test that proves my last comment wrong. 😵

@@ -50,7 +50,7 @@ module HostOrIP
# @return [IPRange|HostName] Valid class, if it can be converted.
#
def convert(asset)
ips = asset.split(' - ')
ips = asset.split('-').map(&:strip)
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need to add a nil check here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess we could just to throw a different error. I think this can only fail if the asset input is nil, which is true today anyway.

@sgreen-r7 sgreen-r7 merged commit f03cf20 into master Apr 29, 2016
@sgreen-r7 sgreen-r7 deleted the enhance_host_or_ip branch May 5, 2016 20:00
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