truncate gist titles at 120

This commit is contained in:
Sam 2013-04-25 18:00:02 +10:00
parent 134af233ad
commit 7abdd61354

View file

@ -13,7 +13,12 @@ module Oneboxer
def parse(data) def parse(data)
parsed = JSON.parse(data) parsed = JSON.parse(data)
result = {files: [], title: parsed['description']} desc = parsed['description']
if desc.length > 120
desc = desc[0..120]
desc << "..."
end
result = {files: [], title: desc}
parsed['files'].each do |filename, attrs| parsed['files'].each do |filename, attrs|
result[:files] << {filename: filename}.merge!(attrs) result[:files] << {filename: filename}.merge!(attrs)
end end