automatic 12.6.0 → 12.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/automatic.gemspec +10 -22
- data/bin/automatic-config +4 -4
- data/doc/ChangeLog +30 -1
- data/doc/PLUGINS +46 -178
- data/doc/PLUGINS.ja +46 -177
- data/doc/README +2 -10
- data/doc/README.ja +2 -9
- data/lib/automatic.rb +2 -3
- data/plugins/custom_feed/svn_log.rb +0 -1
- data/plugins/filter/absolute_uri.rb +39 -0
- data/plugins/filter/image.rb +46 -0
- data/plugins/filter/reverse.rb +0 -1
- data/plugins/store/database.rb +8 -23
- data/plugins/store/full_text.rb +4 -4
- data/plugins/store/permalink.rb +12 -9
- data/plugins/store/target_link.rb +3 -2
- data/plugins/subscription/link.rb +55 -0
- data/plugins/subscription/twitter.rb +57 -0
- data/script/build +1 -1
- data/spec/lib/automatic_spec.rb +3 -2
- data/spec/plugins/custom_feed/svn_log_spec.rb +1 -1
- data/spec/plugins/filter/absolute_uri_spec.rb +61 -0
- data/spec/plugins/filter/image_source_spec.rb +1 -1
- data/spec/plugins/filter/image_spec.rb +65 -0
- data/spec/plugins/publish/google_calendar_spec.rb +1 -1
- data/spec/plugins/store/full_text_spec.rb +0 -1
- data/spec/plugins/store/permalink_spec.rb +52 -3
- data/spec/plugins/store/target_link_spec.rb +1 -2
- data/spec/plugins/subscription/feed_spec.rb +0 -1
- data/spec/plugins/subscription/{uri_spec.rb → link_spec.rb} +9 -10
- data/spec/plugins/subscription/twitter_spec.rb +42 -0
- data/spec/spec_helper.rb +12 -26
- data/spec/user_dir/plugins/store/mock.rb +1 -1
- data/test/integration/test_get_image.yml +4 -6
- data/test/integration/test_image2local.yml +1 -1
- metadata +10 -22
- data/config/html2console.yml +0 -16
- data/plugins/extract/link.rb +0 -32
- data/plugins/filter/image_link.rb +0 -37
- data/plugins/publish/dump.rb +0 -24
- data/plugins/store/link.rb +0 -47
- data/plugins/store/target.rb +0 -41
- data/plugins/subscription/uri.rb +0 -31
- data/spec/fixtures/extractLink.html +0 -14
- data/spec/fixtures/filterImageLink.html +0 -34
- data/spec/fixtures/publishDump.html +0 -14
- data/spec/fixtures/storeLink.html +0 -34
- data/spec/fixtures/storeLink2.html +0 -36
- data/spec/fixtures/storeTarget.html +0 -11
- data/spec/fixtures/storeTarget2.html +0 -11
- data/spec/plugins/extract/link_spec.rb +0 -38
- data/spec/plugins/filter/image_link_spec.rb +0 -51
- data/spec/plugins/publish/dump_spec.rb +0 -32
- data/spec/plugins/store/link_spec.rb +0 -47
- data/spec/plugins/store/target_spec.rb +0 -41
@@ -0,0 +1,46 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Name:: Automatic::Plugin::Filter::Image
|
3
|
+
# Author:: 774 <http://id774.net>
|
4
|
+
# Created:: Sep 18, 2012
|
5
|
+
# Updated:: Sep 18, 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 FilterImage
|
11
|
+
|
12
|
+
def initialize(config, pipeline=[])
|
13
|
+
@config = config
|
14
|
+
@pipeline = pipeline
|
15
|
+
end
|
16
|
+
|
17
|
+
def run
|
18
|
+
@return_feeds = []
|
19
|
+
@pipeline.each {|feeds|
|
20
|
+
return_feed_items = []
|
21
|
+
unless feeds.nil?
|
22
|
+
feeds.items.each {|feed|
|
23
|
+
unless feed.link.nil?
|
24
|
+
image_link = nil
|
25
|
+
feed.link.scan(/(.*?\.jp.*g$)/i) { |matched|
|
26
|
+
image_link = matched.join(" ")
|
27
|
+
}
|
28
|
+
feed.link.scan(/(.*?\.png$)/i) { |matched|
|
29
|
+
image_link = matched.join(" ")
|
30
|
+
}
|
31
|
+
feed.link.scan(/(.*?\.gif$)/i) { |matched|
|
32
|
+
image_link = matched.join(" ")
|
33
|
+
}
|
34
|
+
feed.link.scan(/(.*?\.tiff$)/i) { |matched|
|
35
|
+
image_link = matched.join(" ")
|
36
|
+
}
|
37
|
+
feed.link = image_link
|
38
|
+
end
|
39
|
+
}
|
40
|
+
@return_feeds << feeds
|
41
|
+
end
|
42
|
+
}
|
43
|
+
@return_feeds
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/plugins/filter/reverse.rb
CHANGED
data/plugins/store/database.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# Author:: kzgs
|
4
4
|
# 774 <http://id774.net>
|
5
5
|
# Created:: Feb 27, 2012
|
6
|
-
# Updated::
|
6
|
+
# Updated:: Sep 18, 2012
|
7
7
|
# Copyright:: kzgs Copyright (c) 2012
|
8
8
|
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|
9
9
|
|
@@ -11,23 +11,6 @@ require 'active_record'
|
|
11
11
|
|
12
12
|
module Automatic::Plugin
|
13
13
|
module Database
|
14
|
-
def for_each_new_link
|
15
|
-
prepare_database
|
16
|
-
existing_records = model_class.find(:all)
|
17
|
-
@return_html = []
|
18
|
-
@pipeline.each { |link|
|
19
|
-
unless link.nil?
|
20
|
-
new_link = false
|
21
|
-
unless existing_records.detect { |b| b.try(unique_key) == link }
|
22
|
-
yield(link)
|
23
|
-
new_link = true
|
24
|
-
end
|
25
|
-
@return_html << link if new_link
|
26
|
-
end
|
27
|
-
}
|
28
|
-
@return_html
|
29
|
-
end
|
30
|
-
|
31
14
|
def for_each_new_feed
|
32
15
|
prepare_database
|
33
16
|
existing_records = model_class.find(:all)
|
@@ -36,9 +19,11 @@ module Automatic::Plugin
|
|
36
19
|
unless feeds.nil?
|
37
20
|
new_feed = false
|
38
21
|
feeds.items.each { |feed|
|
39
|
-
unless
|
40
|
-
|
41
|
-
|
22
|
+
unless feed.link.nil?
|
23
|
+
unless existing_records.detect { |b| b.try(unique_key) == feed.link }
|
24
|
+
yield(feed)
|
25
|
+
new_feed = true
|
26
|
+
end
|
42
27
|
end
|
43
28
|
}
|
44
29
|
@return_feeds << feeds if new_feed
|
@@ -60,9 +45,9 @@ module Automatic::Plugin
|
|
60
45
|
def db_dir
|
61
46
|
dir = (File.expand_path('~/.automatic/db'))
|
62
47
|
if File.directory?(dir)
|
63
|
-
|
48
|
+
dir
|
64
49
|
else
|
65
|
-
|
50
|
+
File.join(File.dirname(__FILE__), '..', '..', 'db')
|
66
51
|
end
|
67
52
|
end
|
68
53
|
|
data/plugins/store/full_text.rb
CHANGED
@@ -21,7 +21,7 @@ module Automatic::Plugin
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def column_definition
|
24
|
-
|
24
|
+
{
|
25
25
|
:title => :string,
|
26
26
|
:link => :string,
|
27
27
|
:description => :string,
|
@@ -31,15 +31,15 @@ module Automatic::Plugin
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def unique_key
|
34
|
-
|
34
|
+
:link
|
35
35
|
end
|
36
36
|
|
37
37
|
def model_class
|
38
|
-
|
38
|
+
Automatic::Plugin::Blog
|
39
39
|
end
|
40
40
|
|
41
41
|
def run
|
42
|
-
|
42
|
+
for_each_new_feed { |feed|
|
43
43
|
begin
|
44
44
|
Blog.create(
|
45
45
|
:title => feed.title,
|
data/plugins/store/permalink.rb
CHANGED
@@ -3,9 +3,10 @@
|
|
3
3
|
# Name:: Automatic::Plugin::Store::Permalink
|
4
4
|
# Author:: 774 <http://id774.net>
|
5
5
|
# Created:: Feb 22, 2012
|
6
|
-
# Updated::
|
6
|
+
# Updated:: Sep 18, 2012
|
7
7
|
# Copyright:: 774 Copyright (c) 2012
|
8
8
|
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|
9
|
+
|
9
10
|
require 'plugins/store/database'
|
10
11
|
|
11
12
|
module Automatic::Plugin
|
@@ -21,26 +22,28 @@ module Automatic::Plugin
|
|
21
22
|
end
|
22
23
|
|
23
24
|
def column_definition
|
24
|
-
|
25
|
+
{
|
25
26
|
:url => :string,
|
26
27
|
:created_at => :string
|
27
28
|
}
|
28
29
|
end
|
29
30
|
|
30
31
|
def unique_key
|
31
|
-
|
32
|
+
:url
|
32
33
|
end
|
33
34
|
|
34
35
|
def model_class
|
35
|
-
|
36
|
+
Automatic::Plugin::Permalink
|
36
37
|
end
|
37
38
|
|
38
39
|
def run
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
40
|
+
for_each_new_feed {|feed|
|
41
|
+
unless feed.link.nil?
|
42
|
+
Permalink.create(
|
43
|
+
:url => feed.link,
|
44
|
+
:created_at => Time.now.strftime("%Y/%m/%d %X"))
|
45
|
+
Automatic::Log.puts("info", "Saving: #{feed.link}")
|
46
|
+
end
|
44
47
|
}
|
45
48
|
end
|
46
49
|
end
|
@@ -7,9 +7,10 @@
|
|
7
7
|
# Copyright:: 774 Copyright (c) 2012
|
8
8
|
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|
9
9
|
|
10
|
+
require 'open-uri'
|
11
|
+
|
10
12
|
module Automatic::Plugin
|
11
13
|
class StoreTargetLink
|
12
|
-
require 'open-uri'
|
13
14
|
|
14
15
|
def initialize(config, pipeline=[])
|
15
16
|
@config = config
|
@@ -33,11 +34,11 @@ module Automatic::Plugin
|
|
33
34
|
unless feed.link.nil?
|
34
35
|
Automatic::Log.puts("info", "Get: #{feed.link}")
|
35
36
|
wget(feed.link)
|
37
|
+
sleep @config['interval'].to_i
|
36
38
|
end
|
37
39
|
rescue
|
38
40
|
Automatic::Log.puts("error", "Error found during file download.")
|
39
41
|
end
|
40
|
-
sleep @config['interval'].to_i
|
41
42
|
}
|
42
43
|
end
|
43
44
|
}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Name:: Automatic::Plugin::Subscription::Link
|
3
|
+
# Author:: 774 <http://id774.net>
|
4
|
+
# Created:: Sep 18, 2012
|
5
|
+
# Updated:: Sep 18, 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 SubscriptionLink
|
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 run
|
21
|
+
@return_feed = []
|
22
|
+
@config['urls'].each {|url|
|
23
|
+
begin
|
24
|
+
Automatic::Log.puts("info", "Parsing: #{url}")
|
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
|
48
|
+
rescue
|
49
|
+
Automatic::Log.puts("error", "Fault in parsing: #{url}")
|
50
|
+
end
|
51
|
+
}
|
52
|
+
@return_feed
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Name:: Automatic::Plugin::Subscription::Twitter
|
3
|
+
# Author:: 774 <http://id774.net>
|
4
|
+
# Created:: Sep 9, 2012
|
5
|
+
# Updated:: Sep 9, 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 SubscriptionTwitter
|
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 run
|
21
|
+
@return_feed = []
|
22
|
+
@config['urls'].each {|url|
|
23
|
+
begin
|
24
|
+
Automatic::Log.puts("info", "Parsing: #{url}")
|
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
|
50
|
+
rescue
|
51
|
+
Automatic::Log.puts("error", "Fault in parsing: #{url}")
|
52
|
+
end
|
53
|
+
}
|
54
|
+
@return_feed
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/script/build
CHANGED
data/spec/lib/automatic_spec.rb
CHANGED
@@ -3,11 +3,12 @@
|
|
3
3
|
# Author:: kzgs
|
4
4
|
# 774 <http://id774.net>
|
5
5
|
# Created:: Mar 9, 2012
|
6
|
-
# Updated::
|
6
|
+
# Updated:: Jun 18, 2012
|
7
7
|
# Copyright:: kzgs Copyright (c) 2012
|
8
8
|
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|
9
9
|
|
10
10
|
require File.expand_path(File.join(File.dirname(__FILE__), '../spec_helper'))
|
11
|
+
|
11
12
|
require 'automatic'
|
12
13
|
|
13
14
|
describe Automatic do
|
@@ -25,7 +26,7 @@ describe Automatic do
|
|
25
26
|
|
26
27
|
describe "#version" do
|
27
28
|
specify {
|
28
|
-
Automatic.const_get(:VERSION).should == "12.
|
29
|
+
Automatic.const_get(:VERSION).should == "12.9.1"
|
29
30
|
}
|
30
31
|
end
|
31
32
|
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Name:: Automatic::Plugin::Filter::AbsoluteURI
|
3
|
+
# Author:: 774 <http://id774.net>
|
4
|
+
# Created:: Jun 20, 2012
|
5
|
+
# Updated:: Sep 18, 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 'filter/absolute_uri'
|
12
|
+
|
13
|
+
describe Automatic::Plugin::FilterAbsoluteURI do
|
14
|
+
context "with feed contain link tag" do
|
15
|
+
subject {
|
16
|
+
Automatic::Plugin::FilterAbsoluteURI.new({
|
17
|
+
'url' => "http://id774.net/images/",
|
18
|
+
},
|
19
|
+
AutomaticSpec.generate_pipeline {
|
20
|
+
feed {
|
21
|
+
item "http://id774.net/images/link_1.jpg"
|
22
|
+
item "link_2.jpg"
|
23
|
+
item "link_3.JPG"
|
24
|
+
item "http://id774.net/images/link_4.png"
|
25
|
+
item "link_5.jpeg"
|
26
|
+
item "http://id774.net/images/link_6.PNG"
|
27
|
+
item "link_8.gif"
|
28
|
+
item "http://id774.net/images/link_9.GIF"
|
29
|
+
item "link_10.tiff"
|
30
|
+
item "http://id774.net/images/link_11.TIFF"
|
31
|
+
}})}
|
32
|
+
|
33
|
+
describe "#run" do
|
34
|
+
its(:run) { should have(1).feeds }
|
35
|
+
|
36
|
+
specify {
|
37
|
+
subject.run
|
38
|
+
subject.instance_variable_get(:@return_feeds)[0].items[0].link.
|
39
|
+
should == "http://id774.net/images/link_1.jpg"
|
40
|
+
subject.instance_variable_get(:@return_feeds)[0].items[1].link.
|
41
|
+
should == "http://id774.net/images/link_2.jpg"
|
42
|
+
subject.instance_variable_get(:@return_feeds)[0].items[2].link.
|
43
|
+
should == "http://id774.net/images/link_3.JPG"
|
44
|
+
subject.instance_variable_get(:@return_feeds)[0].items[3].link.
|
45
|
+
should == "http://id774.net/images/link_4.png"
|
46
|
+
subject.instance_variable_get(:@return_feeds)[0].items[4].link.
|
47
|
+
should == "http://id774.net/images/link_5.jpeg"
|
48
|
+
subject.instance_variable_get(:@return_feeds)[0].items[5].link.
|
49
|
+
should == "http://id774.net/images/link_6.PNG"
|
50
|
+
subject.instance_variable_get(:@return_feeds)[0].items[6].link.
|
51
|
+
should == "http://id774.net/images/link_8.gif"
|
52
|
+
subject.instance_variable_get(:@return_feeds)[0].items[7].link.
|
53
|
+
should == "http://id774.net/images/link_9.GIF"
|
54
|
+
subject.instance_variable_get(:@return_feeds)[0].items[8].link.
|
55
|
+
should == "http://id774.net/images/link_10.tiff"
|
56
|
+
subject.instance_variable_get(:@return_feeds)[0].items[9].link.
|
57
|
+
should == "http://id774.net/images/link_11.TIFF"
|
58
|
+
}
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# Name:: Automatic::Plugin::Filter::ImageSource
|
3
3
|
# Author:: kzgs
|
4
4
|
# 774 <http://id774.net>
|
5
|
-
# Created:: Mar
|
5
|
+
# Created:: Mar 1, 2012
|
6
6
|
# Updated:: Jun 14, 2012
|
7
7
|
# Copyright:: kzgs Copyright (c) 2012
|
8
8
|
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|