Browse files

add enclosures to json

  • Loading branch information...
1 parent 5ff194f commit 039d7876d72167ab9374aaf7a3ba5999fb821ae4 @mmb committed Sep 6, 2011
Showing with 10 additions and 0 deletions.
  1. +4 −0 lib/murlsh/enclosure.rb
  2. +6 −0 lib/murlsh/json_body.rb
View
4 lib/murlsh/enclosure.rb
@@ -5,6 +5,10 @@ module Murlsh
# Enclosure ActiveRecord.
class Enclosure < ActiveRecord::Base
belongs_to :url
+
+ # Title with whitespace compressed and leading and trailing whitespace
+ # stripped.
+ def title_stripped; title.strip.gsub(/\s+/, ' '); end
end
end
View
6 lib/murlsh/json_body.rb
@@ -33,6 +33,12 @@ def build
h['thumbnail_url']).to_s
end
+ h['enclosures'] = mu.enclosures.map do |e|
+ new_e = e.attributes.reject { |k,v| k == 'url_id' }
+ new_e['title'] = e.title_stripped
+ new_e
+ end
+
h
end
@body = urls.to_json

0 comments on commit 039d787

Please sign in to comment.