Sha256: 5903afa05a30e54453a67fc0dda0c735ad9c57e8856ec5dd0a7d4070c1e97952
Contents?: true
Size: 1.57 KB
Versions: 2
Compression:
Stored size: 1.57 KB
Contents
module Gandalf class Seed include DataMapper::Resource property :id, Serial property :include_update, Boolean, :index => true property :interval_update, Integer property :url, String, :length => 255, :unique_index => true def to_json {:id => id, :include_update => include_update, :interval_update => interval_update, :url => url}.to_json end end class Post include DataMapper::Resource storage_names[:default] = 'posts' property :id, Serial, :field => 'psid' property :channel_id, Integer, :length => 11, :index => true property :link, Text, :length => 255 property :title, String, :length => 255 property :author, String, :lazy => true property :pub_date, DateTime, :field => 'pubDate' property :update_date, DateTime, :field => 'updateDate', :default => DateTime.now property :description, Text property :cache_link, String, :length => 32, :unique_index => true belongs_to :seed, :child_key => [:channel_id] def clean! self.title = self.title[0,255] if self.description self.description.gsub!(/\<[^\>]+\>|\n| /,' ') self.description.gsub!(/\s{2,}/,' ') end end def Post.parse(feed) feed.entries.map do |entry| post = self.new({ :title => entry.title, :link => entry.url, :author => entry.author, :description => entry.summary, :pub_date => entry.published.to_datetime, :cache_link => Digest::MD5.hexdigest(entry.url) }) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gandalf-0.0.2 | lib/gandalf/models.rb |
gandalf-0.0.1 | lib/gandalf/models.rb |