forked from id774/automaticruby
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfull_text.rb
More file actions
57 lines (49 loc) · 1.34 KB
/
full_text.rb
File metadata and controls
57 lines (49 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# -*- coding: utf-8 -*-
# Name:: Automatic::Plugin::Store::FullText
# Author:: 774 <http://id774.net>
# Created:: Feb 26, 2012
# Updated:: Oct 09, 2014
# Copyright:: Copyright (c) 2012-2014 Automatic Ruby Developers.
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
require 'plugins/store/database'
module Automatic::Plugin
class Blog < ActiveRecord::Base
end
class StoreFullText
include Automatic::Plugin::Database
def initialize(config, pipeline=[])
@config = config
@pipeline = pipeline
end
def column_definition
{
:title => :string,
:link => :string,
:description => :string,
:content => :string,
:created_at => :string,
}
end
def unique_keys
[:link, :title]
end
def model_class
Automatic::Plugin::Blog
end
def run
for_each_new_feed {|feed|
Automatic::Log.puts("info", "Saving FullText: #{feed.link}")
begin
Blog.create(
:title => feed.title,
:link => feed.link,
:description => feed.description,
:content => feed.content_encoded,
:created_at => Time.now.strftime("%Y/%m/%d %X"))
rescue
Automatic::Log.puts("warn", "Skip feed due to fault in save.")
end
}
end
end
end