document: revert comparison of Documents to old style & add nil check

@envygeeks, this should address your comment: fcce0d5482 (commitcomment-15162261)
This commit is contained in:
Parker Moore 2015-12-25 22:54:12 -05:00
parent debdb15171
commit c63b51b661
1 changed files with 3 additions and 5 deletions

View File

@ -356,11 +356,9 @@ module Jekyll
# equal or greater than the other doc's path. See String#<=> for more details. # equal or greater than the other doc's path. See String#<=> for more details.
def <=>(other) def <=>(other)
return ArgumentError.new("document cannot be compared against #{other}") unless other.respond_to?(:data) return ArgumentError.new("document cannot be compared against #{other}") unless other.respond_to?(:data)
if data['date'] && other.data['date'] && (cmp = data['date'] <=> other.data['date']) != 0 cmp = data['date'] <=> other.data['date']
cmp cmp = path <=> other.path if cmp.nil? || cmp == 0
else cmp
path <=> other.path
end
end end
# Determine whether this document should be written. # Determine whether this document should be written.