automatic 12.9.1 → 12.10.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/automatic.gemspec +4 -3
- data/doc/AUTHORS +0 -1
- data/doc/ChangeLog +7 -0
- data/doc/PLUGINS +38 -7
- data/doc/PLUGINS.ja +31 -0
- data/doc/README +7 -7
- data/doc/README.ja +7 -7
- data/lib/automatic.rb +2 -2
- data/lib/automatic/feed_parser.rb +1 -1
- data/lib/automatic/pipeline.rb +2 -3
- data/lib/automatic/recipe.rb +1 -1
- data/plugins/filter/image_source.rb +4 -4
- data/plugins/subscription/link.rb +31 -27
- data/plugins/subscription/tumblr.rb +67 -0
- data/plugins/subscription/twitter.rb +33 -29
- data/spec/lib/automatic_spec.rb +3 -3
- data/spec/plugins/subscription/link_spec.rb +2 -0
- data/spec/plugins/subscription/tumblr_spec.rb +57 -0
- data/spec/plugins/subscription/twitter_spec.rb +2 -0
- data/test/integration/test_image2local.yml +4 -2
- data/test/integration/test_tumblr2local.yml +6 -7
- metadata +4 -3
- data/test/integration/test_get_image.yml +0 -24
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
12.
|
1
|
+
12.10.0
|
data/automatic.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "automatic"
|
8
|
-
s.version = "12.
|
8
|
+
s.version = "12.10.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["id774"]
|
12
|
-
s.date = "2012-
|
12
|
+
s.date = "2012-10-16"
|
13
13
|
s.description = "Ruby General Automation Framework"
|
14
14
|
s.email = "idnanashi@gmail.com"
|
15
15
|
s.executables = ["automatic", "automatic-config"]
|
@@ -59,6 +59,7 @@ Gem::Specification.new do |s|
|
|
59
59
|
"plugins/store/target_link.rb",
|
60
60
|
"plugins/subscription/feed.rb",
|
61
61
|
"plugins/subscription/link.rb",
|
62
|
+
"plugins/subscription/tumblr.rb",
|
62
63
|
"plugins/subscription/twitter.rb",
|
63
64
|
"script/bootstrap",
|
64
65
|
"script/build",
|
@@ -84,13 +85,13 @@ Gem::Specification.new do |s|
|
|
84
85
|
"spec/plugins/store/target_link_spec.rb",
|
85
86
|
"spec/plugins/subscription/feed_spec.rb",
|
86
87
|
"spec/plugins/subscription/link_spec.rb",
|
88
|
+
"spec/plugins/subscription/tumblr_spec.rb",
|
87
89
|
"spec/plugins/subscription/twitter_spec.rb",
|
88
90
|
"spec/spec_helper.rb",
|
89
91
|
"spec/user_dir/plugins/store/mock.rb",
|
90
92
|
"test/fixtures/sampleOPML.xml",
|
91
93
|
"test/integration/test_activerecord.yml",
|
92
94
|
"test/integration/test_fulltext.yml",
|
93
|
-
"test/integration/test_get_image.yml",
|
94
95
|
"test/integration/test_googlealert.yml",
|
95
96
|
"test/integration/test_hatenabookmark.yml",
|
96
97
|
"test/integration/test_ignore.yml",
|
data/doc/AUTHORS
CHANGED
data/doc/ChangeLog
CHANGED
data/doc/PLUGINS
CHANGED
@@ -50,6 +50,24 @@ SubscriptionTwitter
|
|
50
50
|
- URL ...
|
51
51
|
|
52
52
|
|
53
|
+
SubscriptionTumblr
|
54
|
+
------------------
|
55
|
+
[Path]
|
56
|
+
/plugins/subscription/tumblr.rb
|
57
|
+
|
58
|
+
[Abstract]
|
59
|
+
Subscribe tumblr and extract the links.
|
60
|
+
If pages specified, including past pages.
|
61
|
+
|
62
|
+
[Syntax]
|
63
|
+
- module: SubscriptionTumblr
|
64
|
+
config:
|
65
|
+
urls:
|
66
|
+
- URL
|
67
|
+
- URL ...
|
68
|
+
pages: PAGES
|
69
|
+
|
70
|
+
|
53
71
|
FilterReverse
|
54
72
|
-------------
|
55
73
|
[Path]
|
@@ -68,7 +86,7 @@ FilterIgnore
|
|
68
86
|
/plugins/filter/ignore.rb
|
69
87
|
|
70
88
|
[Abstract]
|
71
|
-
|
89
|
+
Exclude the NG word.
|
72
90
|
|
73
91
|
[Syntax]
|
74
92
|
- module: FilterIgnore
|
@@ -78,6 +96,19 @@ FilterIgnore
|
|
78
96
|
- KEYWORD ...
|
79
97
|
|
80
98
|
|
99
|
+
FilterImage
|
100
|
+
-----------
|
101
|
+
[Path]
|
102
|
+
/plugins/filter/image.rb
|
103
|
+
|
104
|
+
[Abstract]
|
105
|
+
Extract images from the link.
|
106
|
+
If not image, the permalink will be nil.
|
107
|
+
|
108
|
+
[Syntax]
|
109
|
+
- module: FilterImage
|
110
|
+
|
111
|
+
|
81
112
|
FilterImageSource
|
82
113
|
-----------------
|
83
114
|
[Path]
|
@@ -111,7 +142,7 @@ FilterTumblrResize
|
|
111
142
|
/plugins/filter/tumblr_resize.rb
|
112
143
|
|
113
144
|
[Abstract]
|
114
|
-
|
145
|
+
Rewrite the permalink to the maximum size of
|
115
146
|
the Tumblr (High Res).
|
116
147
|
|
117
148
|
[Assumption]
|
@@ -187,10 +218,10 @@ PublishHatenaBookmark
|
|
187
218
|
/plugins/publish/hatenabookmark.rb
|
188
219
|
|
189
220
|
[Abstract]
|
190
|
-
|
221
|
+
Bookmarking to Hatena Bookmark (Social Bookmark).
|
191
222
|
|
192
223
|
[Description]
|
193
|
-
|
224
|
+
Generate the XML for submission to
|
194
225
|
Hatena Bookmark API.
|
195
226
|
|
196
227
|
[Syntax]
|
@@ -207,7 +238,7 @@ PublishGoogleCalendar
|
|
207
238
|
/plugins/publish/google_calendar.rb
|
208
239
|
|
209
240
|
[Abstract]
|
210
|
-
|
241
|
+
Register an appointment to Google Calendar.
|
211
242
|
|
212
243
|
[Description]
|
213
244
|
Register item.title to Google Calendar.
|
@@ -226,7 +257,7 @@ NotifyIkachan
|
|
226
257
|
/plugins/notify/ikachan.rb
|
227
258
|
|
228
259
|
[Abstract]
|
229
|
-
|
260
|
+
Send a message to ikachan.
|
230
261
|
|
231
262
|
[Description]
|
232
263
|
POST to ikachan via HTTP.
|
@@ -251,7 +282,7 @@ CustomFeedSVNLog
|
|
251
282
|
Get new revision info from SVN.
|
252
283
|
|
253
284
|
[Description]
|
254
|
-
|
285
|
+
Get the number that is specified by fetch_items.
|
255
286
|
|
256
287
|
[Syntax]
|
257
288
|
- module: CustomFeedSVNLog
|
data/doc/PLUGINS.ja
CHANGED
@@ -50,6 +50,24 @@ SubscriptionTwitter
|
|
50
50
|
- URL ...
|
51
51
|
|
52
52
|
|
53
|
+
SubscriptionTumblr
|
54
|
+
------------------
|
55
|
+
[パス]
|
56
|
+
/plugins/subscription/tumblr.rb
|
57
|
+
|
58
|
+
[概要]
|
59
|
+
Tumblr を購読し、リンクを抽出する
|
60
|
+
pages が指定された場合、過去のページも遡って購読する
|
61
|
+
|
62
|
+
[レシピ記法]
|
63
|
+
- module: SubscriptionTumblr
|
64
|
+
config:
|
65
|
+
urls:
|
66
|
+
- URL
|
67
|
+
- URL ...
|
68
|
+
pages: PAGES
|
69
|
+
|
70
|
+
|
53
71
|
FilterReverse
|
54
72
|
-------------
|
55
73
|
[パス]
|
@@ -78,6 +96,19 @@ FilterIgnore
|
|
78
96
|
- 無視キーワード ...
|
79
97
|
|
80
98
|
|
99
|
+
FilterImage
|
100
|
+
-----------
|
101
|
+
[パス]
|
102
|
+
/plugins/filter/image.rb
|
103
|
+
|
104
|
+
[概要]
|
105
|
+
パーマリンクから画像のみを抽出する
|
106
|
+
画像ではないパーマリンクは nil にする
|
107
|
+
|
108
|
+
[レシピ記法]
|
109
|
+
- module: FilterImage
|
110
|
+
|
111
|
+
|
81
112
|
FilterImageSource
|
82
113
|
-----------------
|
83
114
|
[パス]
|
data/doc/README
CHANGED
@@ -351,13 +351,13 @@ pipeline backs again as the return value.
|
|
351
351
|
|
352
352
|
Code is as follows.
|
353
353
|
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
354
|
+
pipeline = []
|
355
|
+
recipe.each_plugin {|plugin|
|
356
|
+
mod = plugin.module
|
357
|
+
load_plugin(mod)
|
358
|
+
klass = Automatic::Plugin.const_get(mod)
|
359
|
+
pipeline = klass.new(plugin.config, pipeline).run
|
360
|
+
}
|
361
361
|
|
362
362
|
In this iteration, sequential processing can be realized.
|
363
363
|
|
data/doc/README.ja
CHANGED
@@ -355,13 +355,13 @@ Automatic::Pipeline とは
|
|
355
355
|
|
356
356
|
コードは以下の通りである。
|
357
357
|
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
358
|
+
pipeline = []
|
359
|
+
recipe.each_plugin {|plugin|
|
360
|
+
mod = plugin.module
|
361
|
+
load_plugin(mod)
|
362
|
+
klass = Automatic::Plugin.const_get(mod)
|
363
|
+
pipeline = klass.new(plugin.config, pipeline).run
|
364
|
+
}
|
365
365
|
|
366
366
|
プラグイン間での連続した pipeline の受け渡しにより
|
367
367
|
処理要素を直列に連結し、あるプラグインの出力が次の
|
data/lib/automatic.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# Name:: Automatic::Ruby
|
3
3
|
# Author:: 774 <http://id774.net>
|
4
4
|
# Created:: Feb 18, 2012
|
5
|
-
# Updated::
|
5
|
+
# Updated:: Oct 16, 2012
|
6
6
|
# Copyright:: 774 Copyright (c) 2012
|
7
7
|
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|
8
8
|
|
@@ -13,7 +13,7 @@ module Automatic
|
|
13
13
|
require 'automatic/log'
|
14
14
|
require 'automatic/feed_parser'
|
15
15
|
|
16
|
-
VERSION = "12.
|
16
|
+
VERSION = "12.10.0"
|
17
17
|
USER_DIR = "/.automatic"
|
18
18
|
|
19
19
|
class << self
|
data/lib/automatic/pipeline.rb
CHANGED
@@ -16,7 +16,7 @@ module Automatic
|
|
16
16
|
module Pipeline
|
17
17
|
def self.load_plugin(module_name)
|
18
18
|
Dir[Automatic.user_plugins_dir + "/*",
|
19
|
-
Automatic.plugins_dir + "/*"].each{
|
19
|
+
Automatic.plugins_dir + "/*"].each {|dir|
|
20
20
|
subdir = File.basename dir
|
21
21
|
if /#{subdir}_(.*)$/ =~ module_name.underscore
|
22
22
|
path = dir + "/#{$1}.rb"
|
@@ -30,7 +30,7 @@ module Automatic
|
|
30
30
|
def self.run(recipe)
|
31
31
|
raise NoRecipeError if recipe.nil?
|
32
32
|
pipeline = []
|
33
|
-
recipe.each_plugin {
|
33
|
+
recipe.each_plugin {|plugin|
|
34
34
|
mod = plugin.module
|
35
35
|
load_plugin(mod)
|
36
36
|
klass = Automatic::Plugin.const_get(mod)
|
@@ -39,4 +39,3 @@ module Automatic
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
42
|
-
|
data/lib/automatic/recipe.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# Name:: Automatic::Plugin::Filter::ImageSource
|
3
3
|
# Author:: 774 <http://id774.net>
|
4
4
|
# Created:: Feb 28, 2012
|
5
|
-
# Updated::
|
5
|
+
# Updated:: Oct 16, 2012
|
6
6
|
# Copyright:: 774 Copyright (c) 2012
|
7
7
|
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|
8
8
|
|
@@ -16,12 +16,12 @@ module Automatic::Plugin
|
|
16
16
|
@pipeline = pipeline
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
19
|
+
def rewrite_link(string)
|
20
20
|
array = Array.new
|
21
21
|
string.scan(/<img src="(.*?)"/) { |matched|
|
22
22
|
array = array | matched
|
23
23
|
}
|
24
|
-
|
24
|
+
array
|
25
25
|
end
|
26
26
|
|
27
27
|
def run
|
@@ -30,7 +30,7 @@ module Automatic::Plugin
|
|
30
30
|
img_url = ""
|
31
31
|
unless feeds.nil?
|
32
32
|
feeds.items.each {|feed|
|
33
|
-
arr =
|
33
|
+
arr = rewrite_link(feed.description)
|
34
34
|
if arr.length > 0
|
35
35
|
feed.link = arr[0]
|
36
36
|
else
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# Name:: Automatic::Plugin::Subscription::Link
|
3
3
|
# Author:: 774 <http://id774.net>
|
4
4
|
# Created:: Sep 18, 2012
|
5
|
-
# Updated::
|
5
|
+
# Updated:: Oct 16, 2012
|
6
6
|
# Copyright:: 774 Copyright (c) 2012
|
7
7
|
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|
8
8
|
|
@@ -17,39 +17,43 @@ module Automatic::Plugin
|
|
17
17
|
@pipeline = pipeline
|
18
18
|
end
|
19
19
|
|
20
|
+
def create_rss(url)
|
21
|
+
Automatic::Log.puts("info", "Parsing: #{url}")
|
22
|
+
html = open(url).read
|
23
|
+
unless html.nil?
|
24
|
+
rss = RSS::Maker.make("2.0") {|maker|
|
25
|
+
xss = maker.xml_stylesheets.new_xml_stylesheet
|
26
|
+
xss.href = "http://www.rssboard.org/rss-specification"
|
27
|
+
maker.channel.about = "http://feeds.rssboard.org/rssboard"
|
28
|
+
maker.channel.title = "Automatic Ruby"
|
29
|
+
maker.channel.description = "Automatic Ruby"
|
30
|
+
maker.channel.link = "http://www.rssboard.org/rss-specification"
|
31
|
+
maker.items.do_sort = true
|
32
|
+
doc = Nokogiri::HTML(html)
|
33
|
+
(doc/:a).each {|link|
|
34
|
+
unless link[:href].nil?
|
35
|
+
item = maker.items.new_item
|
36
|
+
item.title = "Automatic Ruby"
|
37
|
+
item.link = link[:href]
|
38
|
+
item.date = Time.now
|
39
|
+
item.description = "Automatic::Plugin::Subscription::Link"
|
40
|
+
end
|
41
|
+
}
|
42
|
+
}
|
43
|
+
@return_feeds << rss
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
20
47
|
def run
|
21
|
-
@
|
48
|
+
@return_feeds = []
|
22
49
|
@config['urls'].each {|url|
|
23
50
|
begin
|
24
|
-
|
25
|
-
html = open(url).read
|
26
|
-
unless html.nil?
|
27
|
-
rss = RSS::Maker.make("2.0") {|maker|
|
28
|
-
xss = maker.xml_stylesheets.new_xml_stylesheet
|
29
|
-
xss.href = "http://www.rssboard.org/rss-specification"
|
30
|
-
maker.channel.about = "http://feeds.rssboard.org/rssboard"
|
31
|
-
maker.channel.title = "Automatic Ruby"
|
32
|
-
maker.channel.description = "Automatic Ruby"
|
33
|
-
maker.channel.link = "http://www.rssboard.org/rss-specification"
|
34
|
-
maker.items.do_sort = true
|
35
|
-
doc = Nokogiri::HTML(html)
|
36
|
-
(doc/:a).each {|link|
|
37
|
-
unless link[:href].nil?
|
38
|
-
item = maker.items.new_item
|
39
|
-
item.title = "Automatic Ruby"
|
40
|
-
item.link = link[:href]
|
41
|
-
item.date = Time.now
|
42
|
-
item.description = "Automatic::Plugin::Subscription::Link"
|
43
|
-
end
|
44
|
-
}
|
45
|
-
}
|
46
|
-
@return_feed << rss
|
47
|
-
end
|
51
|
+
create_rss(url)
|
48
52
|
rescue
|
49
53
|
Automatic::Log.puts("error", "Fault in parsing: #{url}")
|
50
54
|
end
|
51
55
|
}
|
52
|
-
@
|
56
|
+
@return_feeds
|
53
57
|
end
|
54
58
|
end
|
55
59
|
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Name:: Automatic::Plugin::Subscription::Tumblr
|
3
|
+
# Author:: 774 <http://id774.net>
|
4
|
+
# Created:: Oct 16, 2012
|
5
|
+
# Updated:: Oct 16, 2012
|
6
|
+
# Copyright:: 774 Copyright (c) 2012
|
7
|
+
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|
8
|
+
|
9
|
+
module Automatic::Plugin
|
10
|
+
class SubscriptionTumblr
|
11
|
+
require 'open-uri'
|
12
|
+
require 'nokogiri'
|
13
|
+
require 'rss'
|
14
|
+
|
15
|
+
def initialize(config, pipeline=[])
|
16
|
+
@config = config
|
17
|
+
@pipeline = pipeline
|
18
|
+
end
|
19
|
+
|
20
|
+
def create_rss(url)
|
21
|
+
Automatic::Log.puts("info", "Parsing: #{url}")
|
22
|
+
html = open(url).read
|
23
|
+
unless html.nil?
|
24
|
+
rss = RSS::Maker.make("2.0") {|maker|
|
25
|
+
xss = maker.xml_stylesheets.new_xml_stylesheet
|
26
|
+
xss.href = "http://www.rssboard.org/rss-specification"
|
27
|
+
maker.channel.about = "http://feeds.rssboard.org/rssboard"
|
28
|
+
maker.channel.title = "Automatic Ruby"
|
29
|
+
maker.channel.description = "Automatic Ruby"
|
30
|
+
maker.channel.link = "http://www.rssboard.org/rss-specification"
|
31
|
+
maker.items.do_sort = true
|
32
|
+
doc = Nokogiri::HTML(html)
|
33
|
+
(doc/:a).each {|link|
|
34
|
+
unless link[:href].nil?
|
35
|
+
item = maker.items.new_item
|
36
|
+
item.title = "Automatic Ruby"
|
37
|
+
item.link = link[:href]
|
38
|
+
item.date = Time.now
|
39
|
+
item.description = "Automatic::Plugin::Subscription::Link"
|
40
|
+
end
|
41
|
+
}
|
42
|
+
}
|
43
|
+
@return_feeds << rss
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def run
|
48
|
+
@return_feeds = []
|
49
|
+
@config['urls'].each {|url|
|
50
|
+
begin
|
51
|
+
create_rss(url)
|
52
|
+
unless @config['pages'].nil?
|
53
|
+
@config['pages'].times {|i|
|
54
|
+
if i > 0
|
55
|
+
old_url = url + "/page/" + (i+1).to_s
|
56
|
+
create_rss(old_url)
|
57
|
+
end
|
58
|
+
}
|
59
|
+
end
|
60
|
+
rescue
|
61
|
+
Automatic::Log.puts("error", "Fault in parsing: #{url}")
|
62
|
+
end
|
63
|
+
}
|
64
|
+
@return_feeds
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# Name:: Automatic::Plugin::Subscription::Twitter
|
3
3
|
# Author:: 774 <http://id774.net>
|
4
4
|
# Created:: Sep 9, 2012
|
5
|
-
# Updated::
|
5
|
+
# Updated:: Oct 16, 2012
|
6
6
|
# Copyright:: 774 Copyright (c) 2012
|
7
7
|
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|
8
8
|
|
@@ -17,41 +17,45 @@ module Automatic::Plugin
|
|
17
17
|
@pipeline = pipeline
|
18
18
|
end
|
19
19
|
|
20
|
+
def create_rss(url)
|
21
|
+
Automatic::Log.puts("info", "Parsing: #{url}")
|
22
|
+
html = open(url).read
|
23
|
+
unless html.nil?
|
24
|
+
rss = RSS::Maker.make("2.0") {|maker|
|
25
|
+
xss = maker.xml_stylesheets.new_xml_stylesheet
|
26
|
+
xss.href = "http://twitter.com"
|
27
|
+
maker.channel.about = "http://twitter.com/index.rdf"
|
28
|
+
maker.channel.title = "Twitter"
|
29
|
+
maker.channel.description = "Twitter"
|
30
|
+
maker.channel.link = "http://twitter.com/"
|
31
|
+
maker.items.do_sort = true
|
32
|
+
doc = Nokogiri::HTML(html)
|
33
|
+
doc.xpath("/html/body/div").search('[@class="content"]').each {|content|
|
34
|
+
item = maker.items.new_item
|
35
|
+
item.title = content.search('[@class="username js-action-profile-name"]').text.to_s
|
36
|
+
content.search('[@class="tweet-timestamp js-permalink js-nav"]').each {|node|
|
37
|
+
item.link = "http://twitter.com" + node['href'].to_s
|
38
|
+
}
|
39
|
+
content.search('[@class="_timestamp js-short-timestamp js-relative-timestamp"]').each {|node|
|
40
|
+
item.date = Time.at(node['data-time'].to_i)
|
41
|
+
}
|
42
|
+
item.description = content.search('[@class="js-tweet-text"]').text.to_s
|
43
|
+
}
|
44
|
+
}
|
45
|
+
@return_feeds << rss
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
20
49
|
def run
|
21
|
-
@
|
50
|
+
@return_feeds = []
|
22
51
|
@config['urls'].each {|url|
|
23
52
|
begin
|
24
|
-
|
25
|
-
html = open(url).read
|
26
|
-
unless html.nil?
|
27
|
-
rss = RSS::Maker.make("2.0") {|maker|
|
28
|
-
xss = maker.xml_stylesheets.new_xml_stylesheet
|
29
|
-
xss.href = "http://twitter.com"
|
30
|
-
maker.channel.about = "http://twitter.com/index.rdf"
|
31
|
-
maker.channel.title = "Twitter"
|
32
|
-
maker.channel.description = "Twitter"
|
33
|
-
maker.channel.link = "http://twitter.com/"
|
34
|
-
maker.items.do_sort = true
|
35
|
-
doc = Nokogiri::HTML(html)
|
36
|
-
doc.xpath("/html/body/div").search('[@class="content"]').each {|content|
|
37
|
-
item = maker.items.new_item
|
38
|
-
item.title = content.search('[@class="username js-action-profile-name"]').text.to_s
|
39
|
-
content.search('[@class="tweet-timestamp js-permalink js-nav"]').each {|node|
|
40
|
-
item.link = "http://twitter.com" + node['href'].to_s
|
41
|
-
}
|
42
|
-
content.search('[@class="_timestamp js-short-timestamp js-relative-timestamp"]').each {|node|
|
43
|
-
item.date = Time.at(node['data-time'].to_i)
|
44
|
-
}
|
45
|
-
item.description = content.search('[@class="js-tweet-text"]').text.to_s
|
46
|
-
}
|
47
|
-
}
|
48
|
-
@return_feed << rss
|
49
|
-
end
|
53
|
+
create_rss(url)
|
50
54
|
rescue
|
51
55
|
Automatic::Log.puts("error", "Fault in parsing: #{url}")
|
52
56
|
end
|
53
57
|
}
|
54
|
-
@
|
58
|
+
@return_feeds
|
55
59
|
end
|
56
60
|
end
|
57
61
|
end
|
data/spec/lib/automatic_spec.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# Author:: kzgs
|
4
4
|
# 774 <http://id774.net>
|
5
5
|
# Created:: Mar 9, 2012
|
6
|
-
# Updated::
|
6
|
+
# Updated:: Oct 16, 2012
|
7
7
|
# Copyright:: kzgs Copyright (c) 2012
|
8
8
|
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|
9
9
|
|
@@ -26,7 +26,7 @@ describe Automatic do
|
|
26
26
|
|
27
27
|
describe "#version" do
|
28
28
|
specify {
|
29
|
-
Automatic.const_get(:VERSION).should == "12.
|
29
|
+
Automatic.const_get(:VERSION).should == "12.10.0"
|
30
30
|
}
|
31
31
|
end
|
32
32
|
|
@@ -37,7 +37,7 @@ describe Automatic do
|
|
37
37
|
}
|
38
38
|
end
|
39
39
|
|
40
|
-
describe "#user_dir= in test env" do
|
40
|
+
describe "#user_dir= in test env" do
|
41
41
|
before(:all) do
|
42
42
|
Automatic.user_dir = File.join(APP_ROOT, "spec/user_dir")
|
43
43
|
end
|
@@ -16,6 +16,7 @@ describe Automatic::Plugin::SubscriptionLink do
|
|
16
16
|
Automatic::Plugin::SubscriptionLink.new(
|
17
17
|
{ 'urls' => [] })
|
18
18
|
}
|
19
|
+
|
19
20
|
its(:run) { should be_empty }
|
20
21
|
end
|
21
22
|
|
@@ -25,6 +26,7 @@ describe Automatic::Plugin::SubscriptionLink do
|
|
25
26
|
{ 'urls' => ["invalid_url"] }
|
26
27
|
)
|
27
28
|
}
|
29
|
+
|
28
30
|
its(:run) { should be_empty }
|
29
31
|
end
|
30
32
|
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Name:: Automatic::Plugin::Subscription::Tumblr
|
3
|
+
# Author:: 774 <http://id774.net>
|
4
|
+
# Created:: Oct 16, 2012
|
5
|
+
# Updated:: Oct 16, 2012
|
6
|
+
# Copyright:: 774 Copyright (c) 2012
|
7
|
+
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|
8
|
+
|
9
|
+
require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper')
|
10
|
+
|
11
|
+
require 'subscription/tumblr'
|
12
|
+
|
13
|
+
describe Automatic::Plugin::SubscriptionTumblr do
|
14
|
+
context "with empty URLs" do
|
15
|
+
subject {
|
16
|
+
Automatic::Plugin::SubscriptionTumblr.new(
|
17
|
+
{ 'urls' => [] })
|
18
|
+
}
|
19
|
+
|
20
|
+
its(:run) { should be_empty }
|
21
|
+
end
|
22
|
+
|
23
|
+
context "with URLs whose invalid URL" do
|
24
|
+
subject {
|
25
|
+
Automatic::Plugin::SubscriptionTumblr.new(
|
26
|
+
{ 'urls' => ["invalid_url"] }
|
27
|
+
)
|
28
|
+
}
|
29
|
+
|
30
|
+
its(:run) { should be_empty }
|
31
|
+
end
|
32
|
+
|
33
|
+
context "with URLs whose valid URL" do
|
34
|
+
subject {
|
35
|
+
Automatic::Plugin::SubscriptionTumblr.new(
|
36
|
+
{ 'urls' => [
|
37
|
+
"http://reblog.id774.net"]
|
38
|
+
}
|
39
|
+
)
|
40
|
+
}
|
41
|
+
|
42
|
+
its(:run) { should have(1).item }
|
43
|
+
end
|
44
|
+
|
45
|
+
context "with URLs and Pages" do
|
46
|
+
subject {
|
47
|
+
Automatic::Plugin::SubscriptionTumblr.new(
|
48
|
+
{ 'urls' => [
|
49
|
+
"http://reblog.id774.net"],
|
50
|
+
'pages' => 10
|
51
|
+
}
|
52
|
+
)
|
53
|
+
}
|
54
|
+
|
55
|
+
its(:run) { should have(10).item }
|
56
|
+
end
|
57
|
+
end
|
@@ -16,6 +16,7 @@ describe Automatic::Plugin::SubscriptionTwitter do
|
|
16
16
|
Automatic::Plugin::SubscriptionTwitter.new(
|
17
17
|
{ 'urls' => [] })
|
18
18
|
}
|
19
|
+
|
19
20
|
its(:run) { should be_empty }
|
20
21
|
end
|
21
22
|
|
@@ -25,6 +26,7 @@ describe Automatic::Plugin::SubscriptionTwitter do
|
|
25
26
|
{ 'urls' => ["invalid_url"] }
|
26
27
|
)
|
27
28
|
}
|
29
|
+
|
28
30
|
its(:run) { should be_empty }
|
29
31
|
end
|
30
32
|
|
@@ -11,12 +11,14 @@ plugins:
|
|
11
11
|
feeds:
|
12
12
|
- http://reblog.id774.net/rss
|
13
13
|
|
14
|
+
- module: FilterImageSource
|
15
|
+
|
16
|
+
- module: FilterTumblrResize
|
17
|
+
|
14
18
|
- module: StorePermalink
|
15
19
|
config:
|
16
20
|
db: test_image.db
|
17
21
|
|
18
|
-
- module: FilterImageSource
|
19
|
-
|
20
22
|
- module: StoreTargetLink
|
21
23
|
config:
|
22
24
|
path: /tmp
|
@@ -6,19 +6,18 @@ global:
|
|
6
6
|
level: info
|
7
7
|
|
8
8
|
plugins:
|
9
|
-
- module:
|
9
|
+
- module: SubscriptionTumblr
|
10
10
|
config:
|
11
|
-
|
12
|
-
- http://reblog.id774.net
|
11
|
+
urls:
|
12
|
+
- http://reblog.id774.net
|
13
|
+
pages: 2
|
14
|
+
|
15
|
+
- module: FilterImage
|
13
16
|
|
14
17
|
- module: StorePermalink
|
15
18
|
config:
|
16
19
|
db: test_tumblr.db
|
17
20
|
|
18
|
-
- module: FilterImageSource
|
19
|
-
|
20
|
-
- module: FilterTumblrResize
|
21
|
-
|
22
21
|
- module: StoreTargetLink
|
23
22
|
config:
|
24
23
|
path: /tmp
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: automatic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 12.
|
4
|
+
version: 12.10.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sqlite3
|
@@ -254,6 +254,7 @@ files:
|
|
254
254
|
- plugins/store/target_link.rb
|
255
255
|
- plugins/subscription/feed.rb
|
256
256
|
- plugins/subscription/link.rb
|
257
|
+
- plugins/subscription/tumblr.rb
|
257
258
|
- plugins/subscription/twitter.rb
|
258
259
|
- script/bootstrap
|
259
260
|
- script/build
|
@@ -279,13 +280,13 @@ files:
|
|
279
280
|
- spec/plugins/store/target_link_spec.rb
|
280
281
|
- spec/plugins/subscription/feed_spec.rb
|
281
282
|
- spec/plugins/subscription/link_spec.rb
|
283
|
+
- spec/plugins/subscription/tumblr_spec.rb
|
282
284
|
- spec/plugins/subscription/twitter_spec.rb
|
283
285
|
- spec/spec_helper.rb
|
284
286
|
- spec/user_dir/plugins/store/mock.rb
|
285
287
|
- test/fixtures/sampleOPML.xml
|
286
288
|
- test/integration/test_activerecord.yml
|
287
289
|
- test/integration/test_fulltext.yml
|
288
|
-
- test/integration/test_get_image.yml
|
289
290
|
- test/integration/test_googlealert.yml
|
290
291
|
- test/integration/test_hatenabookmark.yml
|
291
292
|
- test/integration/test_ignore.yml
|
@@ -1,24 +0,0 @@
|
|
1
|
-
global:
|
2
|
-
timezone: Asia/Tokyo
|
3
|
-
cache:
|
4
|
-
base: /tmp
|
5
|
-
log:
|
6
|
-
level: info
|
7
|
-
|
8
|
-
plugins:
|
9
|
-
- module: SubscriptionLink
|
10
|
-
config:
|
11
|
-
urls:
|
12
|
-
- http://reblog.id774.net/
|
13
|
-
|
14
|
-
- module: FilterImage
|
15
|
-
|
16
|
-
- module: StorePermalink
|
17
|
-
config:
|
18
|
-
db: test_link.db
|
19
|
-
|
20
|
-
- module: StoreTargetLink
|
21
|
-
config:
|
22
|
-
path: /tmp
|
23
|
-
interval: 2
|
24
|
-
|