Skip to content

Commit 3e62202

Browse files
committed
221 Create module Automatic::RSSMaker
1 parent 303b81e commit 3e62202

File tree

3 files changed

+38
-27
lines changed

3 files changed

+38
-27
lines changed

lib/automatic.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Name:: Automatic::Ruby
33
# Author:: 774 <http://id774.net>
44
# Created:: Feb 18, 2012
5-
# Updated:: Oct 16, 2012
5+
# Updated:: Dec 20, 2012
66
# Copyright:: 774 Copyright (c) 2012
77
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
88

@@ -12,6 +12,7 @@ module Automatic
1212
require 'automatic/pipeline'
1313
require 'automatic/log'
1414
require 'automatic/feed_parser'
15+
require 'automatic/rss_maker'
1516

1617
VERSION = "12.10.0-dev"
1718
USER_DIR = "/.automatic"

lib/automatic/rss_maker.rb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# -*- coding: utf-8 -*-
2+
# Name:: Automatic::RSSMaker
3+
# Author:: 774 <http://id774.net>
4+
# Created:: Dec 20, 2012
5+
# Updated:: Dec 20, 2012
6+
# Copyright:: 774 Copyright (c) 2012
7+
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
8+
9+
module Automatic
10+
module RSSMaker
11+
def self.create(feeds)
12+
RSS::Maker.make("2.0") {|maker|
13+
xss = maker.xml_stylesheets.new_xml_stylesheet
14+
maker.channel.title = "Automatic Ruby"
15+
maker.channel.description = "Automatic Ruby"
16+
maker.channel.link = "https://github.com/id774/automaticruby"
17+
maker.items.do_sort = true
18+
unless feeds.nil?
19+
feeds.each {|feed|
20+
unless feed.link.nil?
21+
item = maker.items.new_item
22+
item.title = feed.title
23+
item.link = feed.link
24+
item.description = feed.description
25+
item.author = feed.author
26+
item.comments = feed.comments
27+
item.date = feed.pubDate || Time.now
28+
end
29+
}
30+
end
31+
}
32+
end
33+
end
34+
end

plugins/store/database.rb

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
# 774 <http://id774.net>
55
# soramugi <http://soramugi.net>
66
# Created:: Feb 27, 2012
7-
# Updated:: Dec 13, 2012
7+
# Updated:: Dec 20, 2012
88
# Copyright:: kzgs Copyright (c) 2012
99
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
1010

1111
require 'active_record'
12-
require 'rss'
1312

1413
module Automatic::Plugin
1514
module Database
@@ -28,37 +27,14 @@ def for_each_new_feed
2827
end
2928
end
3029
}
31-
@return_feeds << create_rss(new_feeds) if new_feeds.length > 0
30+
@return_feeds << Automatic::RSSMaker.create(new_feeds) if new_feeds.length > 0
3231
end
3332
}
3433
@return_feeds
3534
end
3635

3736
private
3837

39-
def create_rss(feeds)
40-
RSS::Maker.make("2.0") {|maker|
41-
xss = maker.xml_stylesheets.new_xml_stylesheet
42-
xss.href = "http://www.rssboard.org/rss-specification"
43-
maker.channel.about = "http://feeds.rssboard.org/rssboard"
44-
maker.channel.title = "Automatic Ruby"
45-
maker.channel.description = "Automatic Ruby"
46-
maker.channel.link = "http://www.rssboard.org/rss-specification"
47-
maker.items.do_sort = true
48-
unless feeds.nil?
49-
feeds.each {|feed|
50-
unless feed.link.nil?
51-
item = maker.items.new_item
52-
item.title = feed.title
53-
item.link = feed.link
54-
item.date = Time.now
55-
item.description = "Automatic::Plugin::Store::Database"
56-
end
57-
}
58-
end
59-
}
60-
end
61-
6238
def create_table
6339
ActiveRecord::Migration.create_table(model_class.table_name) {|t|
6440
column_definition.each_pair {|column_name, column_type|

0 commit comments

Comments
 (0)