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

include: fix 'no implicit conversion of nil to String' #5750

Merged
merged 2 commits into from Jan 14, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/jekyll/tags/include.rb
Expand Up @@ -112,8 +112,8 @@ def tag_includes_dirs(context)
def locate_include_file(context, file, safe)
includes_dirs = tag_includes_dirs(context)
includes_dirs.each do |dir|
path = File.join(dir, file)
return path if valid_include_file?(path, dir, safe)
path = File.join(dir.to_s, file.to_s)
return path if valid_include_file?(path, dir.to_s, safe)
end
raise IOError, "Could not locate the included file '#{file}' in any of "\
"#{includes_dirs}. Ensure it exists in one of those directories and, "\
Expand Down Expand Up @@ -163,7 +163,7 @@ def load_cached_partial(path, context)
end

def valid_include_file?(path, dir, safe)
!(outside_site_source?(path, dir, safe) || !File.exist?(path))
!(outside_site_source?(path, dir, safe) || !File.file?(path))
Copy link
Member Author

Choose a reason for hiding this comment

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

We don't want this to be a directory.

Copy link
Member

Choose a reason for hiding this comment

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

why not !File.directory?(path) ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe checking to see if it's a file is easier to read - affirmations are easier for us to grok than negations.

Copy link
Member

@ashmaroli ashmaroli Jan 10, 2017

Choose a reason for hiding this comment

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

checking to see if it's a file

but its !File.file?(path) instead of File.file?(path)...

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, If anything I'd write this as:

!outside_site_source?(path, dir, safe) && File.file?(path)

Copy link
Member Author

Choose a reason for hiding this comment

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

Works for me! Updated to Ben's suggestion.

end

def outside_site_source?(path, dir, safe)
Expand Down