-
Notifications
You must be signed in to change notification settings - Fork 340
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
renamed :local to :path #16
Conversation
# @return [Bool] whether the dependency points to a local path. | ||
# | ||
def local? | ||
!!(external_source[:path] || external_source[:local]) rescue false |
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.
Why, the rescue? Wouldn't it just shadow a bug?
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 external_source is nil, it'd throw a NoMethodError. so it's basically checking
if external source && (!!external_source[:path] || !!external_source[:local])
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. So maybe we could do the following which I consider more readable (there is no need to coerce to a bool as the &&
operator already returns one).
def local?
external_source && (external_source[:path] || external_source[:local])
end
I generally tend to avoid rescue calls because I prefer to fail fast. For example the #external_source
implementation might change and this would shadow any bug happening inside.
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.
👍 ❤️
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.
wait.. or doesn't 😄
pry(main)> true && (false || 2)
=> 2
I can add the !! in front of ()
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, the !!
sounds good. I need some good coffee 😄
let's 🚢 it |
go for it! |
renamed :local to :path
Backwards compatibility should be kept.
Cocoapods specs are passing.