forked from id774/automaticruby
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpermalink.rb
More file actions
50 lines (42 loc) · 1.08 KB
/
permalink.rb
File metadata and controls
50 lines (42 loc) · 1.08 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
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
# Name:: Automatic::Plugin::Store::Permalink
# Author:: 774 <http://id774.net>
# Created:: Feb 22, 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 Permalink < ActiveRecord::Base
end
class StorePermalink
include Automatic::Plugin::Database
def initialize(config, pipeline=[])
@config = config
@pipeline = pipeline
end
def column_definition
{
:url => :string,
:created_at => :string
}
end
def unique_keys
[:url]
end
def model_class
Automatic::Plugin::Permalink
end
def run
for_each_new_feed {|feed|
unless feed.link.nil?
Permalink.create(
:url => feed.link,
:created_at => Time.now.strftime("%Y/%m/%d %X"))
Automatic::Log.puts("info", "Saving Permalink: #{feed.link}")
end
}
end
end
end