-
Notifications
You must be signed in to change notification settings - Fork 98
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
Conversation
@@ -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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
ebe1150
to
072ec60
Compare
@@ -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) |
There was a problem hiding this comment.
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 an
if` statement.
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
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).
25320df
to
838bdab
Compare
838bdab
to
5e6847a
Compare
5e6847a
to
40a969a
Compare
👍 looks ok |
40a969a
to
9c3a06b
Compare
👍 |
[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).