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

Fix bugs related to Array vs Enumerator vs Port for options[:port/host]. #212

Merged
merged 2 commits into from
Apr 14, 2016

Conversation

tylercloke
Copy link
Contributor

[options[:port]].flatten does not do the right thing in the case that options[:port] is an Enumerator.

options[:host] is not always an Array (can be a String).

@@ -164,10 +165,11 @@ def port
#
def url
sch = @options[:ssl] ? 'https' : 'http'
@url ||= if @options[:host].first.include?(':')
URI("#{sch}://[#{@options[:host].first}]:#{port}").to_s
flattened_hosts = [@options[:host]].flatten
Copy link
Contributor

Choose a reason for hiding this comment

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

Would Array(@options[:host]) be more idiomatic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I can switch to that! I used the flatten method, because that was what was already in the code, but then I deleted it, so no reason to match it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@@ -291,9 +293,17 @@ def start_background(wait = 5)
ENV['HTTPS'] = 'on' if options[:ssl]
@server.mount('/', Rack::Handler::WEBrick, app)

# If options[:port] can be an Enumerator, an Array, or an Integer,
# we need something that can respond to .each (Enum and Array can already).
enumerable = if options[:port].respond_to?(:each)
Copy link
Contributor

Choose a reason for hiding this comment

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

If you just say Array(options[:port], that will do what you need without anif` statement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right! This was before I learned more about enumerable. Thanks :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@danielsdeleo
Copy link
Contributor

Do we know what's up with the chef gem install? Would be preferable to have green travis.

Code changes look fine, though. 👍

[options[:port]].flatten does not do the right thing in the case that options[:port] is an Enumerator.

options[:host] is not always an Array (can be a String).
@stevendanna
Copy link
Contributor

👍 looks ok

@jkeiser
Copy link
Contributor

jkeiser commented Apr 14, 2016

👍

@tylercloke tylercloke added the bug label Apr 14, 2016
@jkeiser jkeiser merged commit 812ddb2 into master Apr 14, 2016
@thommay thommay added Type: Bug Does not work as expected. and removed bug labels Jan 24, 2017
@chef chef locked and limited conversation to collaborators Nov 16, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: Bug Does not work as expected.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants