Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add enclosures to json

  • Loading branch information...
commit 039d7876d72167ab9374aaf7a3ba5999fb821ae4 1 parent 5ff194f
@mmb authored
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
Please sign in to comment.
Something went wrong with that request. Please try again.