lib/bergamasco/summarize.rb in bergamasco-0.2.7 vs lib/bergamasco/summarize.rb in bergamasco-0.2.8

- old
+ new

@@ -1,10 +1,12 @@ module Bergamasco module Summarize # based on from https://github.com/middleman/middleman-blog/blob/master/lib/middleman-blog/blog_article.rb def self.summary(text, options={}) - if options[:separator] - truncate_at_separator(text, options[:separator]) + separator = options[:separator] || "READMORE" + + if !options[:length] && text.include?(separator) + truncate_at_separator(text, separator) else max_length = options[:length] || 250 ellipsis = options[:ellipsis] || "..." truncate_at_length(text, max_length, ellipsis) end