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

renamed :local to :path #16

Merged
merged 4 commits into from
Apr 16, 2013
Merged

renamed :local to :path #16

merged 4 commits into from
Apr 16, 2013

Conversation

supermarin
Copy link

Backwards compatibility should be kept.
Cocoapods specs are passing.

# @return [Bool] whether the dependency points to a local path.
#
def local?
!!(external_source[:path] || external_source[:local]) rescue false
Copy link
Member

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?

Copy link
Author

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])

Copy link
Member

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.

Copy link
Author

Choose a reason for hiding this comment

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

👍 ❤️

Copy link
Author

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 ()

Copy link
Member

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 😄

@supermarin
Copy link
Author

:shipit: let's 🚢 it :shipit:

@fabiopelosin
Copy link
Member

go for it!

supermarin pushed a commit that referenced this pull request Apr 16, 2013
@supermarin supermarin merged commit 05bc268 into master Apr 16, 2013
@supermarin supermarin deleted the rename_local_to_path branch April 16, 2013 16:14
@coveralls
Copy link

Coverage decreased (-0.5%) when pulling ac71dda on rename_local_to_path into 4360966 on master.

View Details

@coveralls
Copy link

Coverage increased (+0.0%) when pulling ac71dda on rename_local_to_path into 4360966 on master.

View Details

@coveralls
Copy link

Coverage increased (+0.0%) when pulling ac71dda on rename_local_to_path into 4360966 on master.

View Details

Ashton-W pushed a commit to Ashton-W/Core that referenced this pull request Nov 2, 2015
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.

None yet

3 participants