automatic 13.5.0 → 13.6.0
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/Gemfile +11 -5
- data/README.md +4 -6
- data/VERSION +1 -1
- data/automatic.gemspec +61 -18
- data/doc/ChangeLog +25 -0
- data/doc/PLUGINS +202 -12
- data/doc/PLUGINS.ja +221 -30
- data/doc/README +1 -1
- data/doc/README.ja +1 -1
- data/lib/automatic.rb +3 -3
- data/lib/automatic/feed_parser.rb +2 -2
- data/lib/automatic/log.rb +12 -2
- data/lib/automatic/pipeline.rb +1 -1
- data/lib/automatic/recipe.rb +5 -2
- data/plugins/custom_feed/svn_log.rb +3 -3
- data/plugins/filter/absolute_uri.rb +8 -4
- data/plugins/filter/accept.rb +61 -0
- data/plugins/filter/full_feed.rb +4 -5
- data/plugins/filter/github_feed.rb +36 -0
- data/plugins/filter/ignore.rb +1 -1
- data/plugins/filter/image.rb +1 -1
- data/plugins/filter/image_source.rb +34 -10
- data/plugins/filter/one.rb +1 -1
- data/plugins/filter/rand.rb +1 -1
- data/plugins/filter/sanitize.rb +50 -0
- data/plugins/filter/sort.rb +1 -1
- data/plugins/filter/tumblr_resize.rb +1 -1
- data/plugins/publish/console.rb +3 -3
- data/plugins/publish/console_link.rb +30 -0
- data/plugins/publish/eject.rb +42 -0
- data/plugins/publish/fluentd.rb +42 -0
- data/plugins/publish/google_calendar.rb +3 -3
- data/plugins/publish/hatena_bookmark.rb +1 -1
- data/plugins/publish/hipchat.rb +45 -0
- data/plugins/publish/instapaper.rb +2 -1
- data/plugins/publish/memcached.rb +44 -0
- data/plugins/publish/pocket.rb +1 -1
- data/plugins/publish/twitter.rb +1 -1
- data/plugins/store/database.rb +3 -3
- data/plugins/store/full_text.rb +2 -2
- data/plugins/store/permalink.rb +1 -1
- data/plugins/store/target_link.rb +3 -2
- data/plugins/subscription/chan_toru.rb +56 -0
- data/plugins/subscription/feed.rb +1 -1
- data/plugins/subscription/g_guide.rb +48 -0
- data/plugins/subscription/google_reader_star.rb +3 -3
- data/plugins/subscription/link.rb +2 -2
- data/plugins/subscription/pocket.rb +49 -0
- data/plugins/subscription/text.rb +3 -12
- data/plugins/subscription/tumblr.rb +7 -1
- data/plugins/subscription/twitter.rb +1 -1
- data/plugins/subscription/twitter_search.rb +50 -0
- data/plugins/subscription/weather.rb +7 -41
- data/script/build +3 -0
- data/spec/fixtures/sampleRecipe.yml +1 -1
- data/spec/lib/automatic/log_spec.rb +31 -0
- data/spec/lib/automatic/pipeline_spec.rb +1 -1
- data/spec/lib/automatic/recipe_spec.rb +1 -1
- data/spec/lib/automatic_spec.rb +3 -3
- data/spec/plugins/custom_feed/svn_log_spec.rb +1 -1
- data/spec/plugins/filter/absolute_uri_spec.rb +1 -1
- data/spec/plugins/filter/accept_spec.rb +331 -0
- data/spec/plugins/filter/full_feed_spec.rb +4 -6
- data/spec/plugins/filter/github_feed_spec.rb +54 -0
- data/spec/plugins/filter/ignore_spec.rb +1 -1
- data/spec/plugins/filter/image_source_spec.rb +17 -3
- data/spec/plugins/filter/image_spec.rb +1 -1
- data/spec/plugins/filter/one_spec.rb +1 -1
- data/spec/plugins/filter/rand_spec.rb +1 -1
- data/spec/plugins/filter/sanitize_spec.rb +153 -0
- data/spec/plugins/filter/sort_spec.rb +1 -1
- data/spec/plugins/filter/tumblr_resize_spec.rb +1 -1
- data/spec/plugins/notify/ikachan_spec.rb +1 -1
- data/spec/plugins/publish/console_spec.rb +1 -1
- data/spec/plugins/publish/eject_spec.rb +40 -0
- data/spec/plugins/publish/fluentd_spec.rb +39 -0
- data/spec/plugins/publish/google_calendar_spec.rb +1 -1
- data/spec/plugins/publish/hatena_bookmark_spec.rb +1 -1
- data/spec/plugins/publish/hipchat_spec.rb +69 -0
- data/spec/plugins/publish/instapaper_spec.rb +42 -28
- data/spec/plugins/publish/memcached_spec.rb +63 -0
- data/spec/plugins/publish/pocket_spec.rb +33 -33
- data/spec/plugins/publish/twitter_spec.rb +57 -19
- data/spec/plugins/store/full_text_spec.rb +6 -1
- data/spec/plugins/store/permalink_spec.rb +18 -19
- data/spec/plugins/store/target_link_spec.rb +1 -1
- data/spec/plugins/subscription/chan_toru_spec.rb +56 -0
- data/spec/plugins/subscription/feed_spec.rb +1 -1
- data/spec/plugins/subscription/g_guide_spec.rb +76 -0
- data/spec/plugins/subscription/google_reader_star_spec.rb +1 -1
- data/spec/plugins/subscription/link_spec.rb +1 -1
- data/spec/plugins/subscription/pocket_spec.rb +57 -0
- data/spec/plugins/subscription/text_spec.rb +1 -14
- data/spec/plugins/subscription/tumblr_spec.rb +3 -2
- data/spec/plugins/subscription/twitter_search_spec.rb +57 -0
- data/spec/plugins/subscription/twitter_spec.rb +3 -2
- data/spec/plugins/subscription/weather_spec.rb +2 -15
- data/spec/spec_helper.rb +1 -0
- data/test/integration/test_chan_toru.yml +19 -0
- data/test/integration/test_fluentd.yml +20 -0
- data/test/integration/test_pocket.yml +21 -0
- data/test/integration/test_sanitize.yml +22 -0
- data/test/integration/test_twitter_search.yml +21 -0
- metadata +145 -24
- data/plugins/publish/mail.rb +0 -64
- data/plugins/publish/smtp.rb +0 -48
- data/spec/plugins/publish/mail_spec.rb +0 -53
- data/spec/plugins/publish/smtp_spec.rb +0 -49
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# Author:: 774 <http://id774.net>
|
|
4
4
|
# Created:: Jun 20, 2012
|
|
5
5
|
# Updated:: Apr 5, 2013
|
|
6
|
-
# Copyright::
|
|
6
|
+
# Copyright:: Copyright (c) 2012-2013 Automatic Ruby Developers.
|
|
7
7
|
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|
|
8
8
|
|
|
9
9
|
module Automatic::Plugin
|
|
@@ -17,7 +17,6 @@ module Automatic::Plugin
|
|
|
17
17
|
def run
|
|
18
18
|
@return_feeds = []
|
|
19
19
|
@pipeline.each {|feeds|
|
|
20
|
-
return_feed_items = []
|
|
21
20
|
unless feeds.nil?
|
|
22
21
|
feeds.items.each {|feed|
|
|
23
22
|
feed.link = rewrite(feed.link) unless feed.link.nil?
|
|
@@ -32,9 +31,14 @@ module Automatic::Plugin
|
|
|
32
31
|
def rewrite(string)
|
|
33
32
|
if /^http:\/\/.*$/ =~ string
|
|
34
33
|
return string
|
|
35
|
-
else
|
|
36
|
-
return @config['url'] + string
|
|
37
34
|
end
|
|
35
|
+
|
|
36
|
+
if /[^\/]$/ =~ @config['url']
|
|
37
|
+
@config['url'] = @config['url'] + '/'
|
|
38
|
+
end
|
|
39
|
+
string = @config['url'] + string.sub(/^\./,'').sub(/^\//,'')
|
|
40
|
+
string = URI.encode(string)
|
|
41
|
+
return string
|
|
38
42
|
end
|
|
39
43
|
end
|
|
40
44
|
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Name:: Automatic::Plugin::Filter::Accept
|
|
3
|
+
# Author:: soramugi <http://soramugi.net>
|
|
4
|
+
# Created:: Jun 4, 2013
|
|
5
|
+
# Updated:: Jun 4, 2013
|
|
6
|
+
# Copyright:: Copyright (c) 2012-2013 Automatic Ruby Developers.
|
|
7
|
+
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|
|
8
|
+
|
|
9
|
+
module Automatic::Plugin
|
|
10
|
+
class FilterAccept
|
|
11
|
+
def initialize(config, pipeline=[])
|
|
12
|
+
@config = config
|
|
13
|
+
@pipeline = pipeline
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def run
|
|
17
|
+
@return_feeds = []
|
|
18
|
+
@pipeline.each {|feeds|
|
|
19
|
+
new_feeds = []
|
|
20
|
+
unless feeds.nil?
|
|
21
|
+
feeds.items.each {|items|
|
|
22
|
+
new_feeds << items if contain(items) == true
|
|
23
|
+
}
|
|
24
|
+
end
|
|
25
|
+
@return_feeds << Automatic::FeedParser.create(new_feeds) if new_feeds.length > 0
|
|
26
|
+
}
|
|
27
|
+
@return_feeds
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
private
|
|
31
|
+
|
|
32
|
+
def contain(items)
|
|
33
|
+
detection = false
|
|
34
|
+
unless @config['title'].nil?
|
|
35
|
+
@config['title'].each {|e|
|
|
36
|
+
if items.title.include?(e.chomp)
|
|
37
|
+
detection = true
|
|
38
|
+
Automatic::Log.puts("info", "Contain by title: #{items.link}")
|
|
39
|
+
end
|
|
40
|
+
}
|
|
41
|
+
end
|
|
42
|
+
unless @config['link'].nil?
|
|
43
|
+
@config['link'].each {|e|
|
|
44
|
+
if items.link.include?(e.chomp)
|
|
45
|
+
detection = true
|
|
46
|
+
Automatic::Log.puts("info", "Contain by link: #{items.link}")
|
|
47
|
+
end
|
|
48
|
+
}
|
|
49
|
+
end
|
|
50
|
+
unless @config['description'].nil?
|
|
51
|
+
@config['description'].each {|e|
|
|
52
|
+
if items.description.include?(e.chomp)
|
|
53
|
+
detection = true
|
|
54
|
+
Automatic::Log.puts("info", "Contain by description: #{items.link}")
|
|
55
|
+
end
|
|
56
|
+
}
|
|
57
|
+
end
|
|
58
|
+
detection
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
data/plugins/filter/full_feed.rb
CHANGED
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
# Author:: progd <http://d.hatena.ne.jp/progd/20120429/automatic_ruby_filter_full_feed>
|
|
4
4
|
# 774 <http://id774.net>
|
|
5
5
|
# Created:: Apr 29, 2012
|
|
6
|
-
# Updated::
|
|
7
|
-
# Copyright::
|
|
8
|
-
# 774 Copyright (c) 2012-2013
|
|
6
|
+
# Updated:: Jun 23, 2013
|
|
7
|
+
# Copyright:: Copyright (c) 2012-2013 Automatic Ruby Developers.
|
|
9
8
|
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|
|
10
9
|
|
|
11
10
|
module Automatic::Plugin
|
|
@@ -38,7 +37,7 @@ module Automatic::Plugin
|
|
|
38
37
|
|
|
39
38
|
def get_siteinfo
|
|
40
39
|
Automatic::Log.puts(:info, "Loading siteinfo from #{@config['siteinfo']}")
|
|
41
|
-
siteinfo = JSON.load(open(File.join(assets_dir, @config['siteinfo'])).read)
|
|
40
|
+
siteinfo = JSON.load(open(File.join(assets_dir, @config['siteinfo'])).read.force_encoding("UTF-8"))
|
|
42
41
|
siteinfo.select! { |info| SITEINFO_TYPES.include? (info['data']['type']) }
|
|
43
42
|
siteinfo.sort! { |a, b|
|
|
44
43
|
atype, btype = a['data']['type'], b['data']['type']
|
|
@@ -58,7 +57,7 @@ module Automatic::Plugin
|
|
|
58
57
|
|
|
59
58
|
def fulltext(feed)
|
|
60
59
|
return feed unless feed.link
|
|
61
|
-
@siteinfo.each {
|
|
60
|
+
@siteinfo.each {|info|
|
|
62
61
|
begin
|
|
63
62
|
if feed.link.match(info['data']['url'])
|
|
64
63
|
Automatic::Log.puts(:info, "Siteinfo matched: #{info['data']['url']}")
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Name:: Automatic::Plugin::Filter::GithubFeed
|
|
3
|
+
# Author:: Kohei Hasegawa <http://github.com/banyan>
|
|
4
|
+
# Created:: Jun 6, 2013
|
|
5
|
+
# Updated:: Jun 6, 2013
|
|
6
|
+
# Copyright:: Copyright (c) 2012-2013 Automatic Ruby Developers.
|
|
7
|
+
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|
|
8
|
+
|
|
9
|
+
module Automatic::Plugin
|
|
10
|
+
class FilterGithubFeed
|
|
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
|
+
dummyFeeds = []
|
|
21
|
+
unless feeds.nil?
|
|
22
|
+
feeds.items.each {|feed|
|
|
23
|
+
Automatic::Log.puts("info", "Invoked: FilterGithubFeed")
|
|
24
|
+
dummy = Hashie::Mash.new
|
|
25
|
+
dummy.title = feed.title.content
|
|
26
|
+
dummy.link = feed.id.content
|
|
27
|
+
dummy.description = feed.content.content
|
|
28
|
+
dummyFeeds << dummy
|
|
29
|
+
}
|
|
30
|
+
end
|
|
31
|
+
@return_feeds << Automatic::FeedParser.create(dummyFeeds)
|
|
32
|
+
}
|
|
33
|
+
@pipeline = @return_feeds
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
data/plugins/filter/ignore.rb
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# Author:: 774 <http://id774.net>
|
|
4
4
|
# Created:: Feb 22, 2012
|
|
5
5
|
# Updated:: Apr 5, 2013
|
|
6
|
-
# Copyright::
|
|
6
|
+
# Copyright:: Copyright (c) 2012-2013 Automatic Ruby Developers.
|
|
7
7
|
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|
|
8
8
|
|
|
9
9
|
module Automatic::Plugin
|
data/plugins/filter/image.rb
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# Author:: 774 <http://id774.net>
|
|
4
4
|
# Created:: Sep 18, 2012
|
|
5
5
|
# Updated:: Apr 5, 2013
|
|
6
|
-
# Copyright::
|
|
6
|
+
# Copyright:: Copyright (c) 2012-2013 Automatic Ruby Developers.
|
|
7
7
|
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|
|
8
8
|
|
|
9
9
|
module Automatic::Plugin
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# Author:: 774 <http://id774.net>
|
|
4
4
|
# Created:: Feb 28, 2012
|
|
5
5
|
# Updated:: Apr 5, 2013
|
|
6
|
-
# Copyright::
|
|
6
|
+
# Copyright:: Copyright (c) 2012-2013 Automatic Ruby Developers.
|
|
7
7
|
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|
|
8
8
|
|
|
9
9
|
module Automatic::Plugin
|
|
@@ -19,29 +19,53 @@ module Automatic::Plugin
|
|
|
19
19
|
def run
|
|
20
20
|
@return_feeds = []
|
|
21
21
|
@pipeline.each {|feeds|
|
|
22
|
-
|
|
22
|
+
dummyFeeds = Array.new
|
|
23
23
|
unless feeds.nil?
|
|
24
24
|
feeds.items.each {|feed|
|
|
25
|
-
arr = rewrite_link(feed
|
|
25
|
+
arr = rewrite_link(feed)
|
|
26
26
|
if arr.length > 0
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
arr.each {|link|
|
|
28
|
+
Automatic::Log.puts("info", "Parsing: #{link}")
|
|
29
|
+
dummy = Hashie::Mash.new
|
|
30
|
+
dummy.title = 'FilterImageSource'
|
|
31
|
+
dummy.link = link
|
|
32
|
+
dummyFeeds << dummy
|
|
33
|
+
}
|
|
30
34
|
end
|
|
31
35
|
}
|
|
32
36
|
end
|
|
33
|
-
@return_feeds <<
|
|
37
|
+
@return_feeds << Automatic::FeedParser.create(dummyFeeds)
|
|
34
38
|
}
|
|
35
|
-
@return_feeds
|
|
39
|
+
@pipeline = @return_feeds
|
|
36
40
|
end
|
|
37
41
|
|
|
38
42
|
private
|
|
39
|
-
|
|
43
|
+
|
|
44
|
+
def rewrite_link(feed)
|
|
40
45
|
array = Array.new
|
|
41
|
-
|
|
46
|
+
feed.description.scan(/<img src="(.*?)"/) {|matched|
|
|
42
47
|
array = array | matched
|
|
43
48
|
}
|
|
49
|
+
if array.length === 0 && feed.link != nil
|
|
50
|
+
array = imgs(feed.link)
|
|
51
|
+
end
|
|
44
52
|
array
|
|
45
53
|
end
|
|
54
|
+
|
|
55
|
+
def imgs(link)
|
|
56
|
+
images = Array.new
|
|
57
|
+
html = open(link).read
|
|
58
|
+
unless html.nil?
|
|
59
|
+
doc = Nokogiri::HTML(html)
|
|
60
|
+
(doc/:img).each {|img|
|
|
61
|
+
image = img[:src]
|
|
62
|
+
unless /^http/ =~ image
|
|
63
|
+
image = link.sub(/\/([^\/]+)$/, image.sub(/^\./,''))
|
|
64
|
+
end
|
|
65
|
+
images << image
|
|
66
|
+
}
|
|
67
|
+
end
|
|
68
|
+
images
|
|
69
|
+
end
|
|
46
70
|
end
|
|
47
71
|
end
|
data/plugins/filter/one.rb
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# Author:: soramugi <http://soramugi.net>
|
|
4
4
|
# Created:: May 8, 2013
|
|
5
5
|
# Updated:: May 8, 2013
|
|
6
|
-
# Copyright::
|
|
6
|
+
# Copyright:: Copyright (c) 2012-2013 Automatic Ruby Developers.
|
|
7
7
|
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|
|
8
8
|
|
|
9
9
|
module Automatic::Plugin
|
data/plugins/filter/rand.rb
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# 774 <http://id774.net>
|
|
5
5
|
# Created:: Mar 6, 2013
|
|
6
6
|
# Updated:: Mar 7, 2013
|
|
7
|
-
# Copyright::
|
|
7
|
+
# Copyright:: Copyright (c) 2012-2013 Automatic Ruby Developers.
|
|
8
8
|
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|
|
9
9
|
|
|
10
10
|
module Automatic::Plugin
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Name:: Automatic::Plugin::Filter::Sanitize
|
|
3
|
+
# Author:: 774 <http://id774.net>
|
|
4
|
+
# Created:: Jun 20, 2013
|
|
5
|
+
# Updated:: Jun 24, 2013
|
|
6
|
+
# Copyright:: Copyright (c) 2012-2013 Automatic Ruby Developers.
|
|
7
|
+
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|
|
8
|
+
|
|
9
|
+
module Automatic::Plugin
|
|
10
|
+
class FilterSanitize
|
|
11
|
+
require 'sanitize'
|
|
12
|
+
|
|
13
|
+
def initialize(config, pipeline=[])
|
|
14
|
+
@config = config
|
|
15
|
+
@pipeline = pipeline
|
|
16
|
+
case @config['mode']
|
|
17
|
+
when "basic"
|
|
18
|
+
@mode = Sanitize::Config::BASIC
|
|
19
|
+
when "relaxed"
|
|
20
|
+
@mode = Sanitize::Config::RELAXED
|
|
21
|
+
else
|
|
22
|
+
@mode = Sanitize::Config::RESTRICTED
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def run
|
|
27
|
+
@return_feeds = []
|
|
28
|
+
@pipeline.each {|feeds|
|
|
29
|
+
return_feed_items = []
|
|
30
|
+
unless feeds.nil?
|
|
31
|
+
feeds.items.each {|feed|
|
|
32
|
+
feed = sanitize(feed)
|
|
33
|
+
}
|
|
34
|
+
@return_feeds << feeds
|
|
35
|
+
end
|
|
36
|
+
}
|
|
37
|
+
@return_feeds
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
def sanitize(feed)
|
|
42
|
+
begin
|
|
43
|
+
feed.description = Sanitize.clean(feed.description, @mode) unless feed.description.nil?
|
|
44
|
+
rescue
|
|
45
|
+
Automatic::Log.puts("warn", "Undefined field detected in feed.")
|
|
46
|
+
end
|
|
47
|
+
feed
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
data/plugins/filter/sort.rb
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# Author:: 774 <http://id774.net>
|
|
4
4
|
# Created:: Mar 23, 2012
|
|
5
5
|
# Updated:: Jan 23, 2013
|
|
6
|
-
# Copyright::
|
|
6
|
+
# Copyright:: Copyright (c) 2012-2013 Automatic Ruby Developers.
|
|
7
7
|
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|
|
8
8
|
|
|
9
9
|
module Automatic::Plugin
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# Author:: 774 <http://id774.net>
|
|
4
4
|
# Created:: Feb 28, 2012
|
|
5
5
|
# Updated:: Apr 5, 2013
|
|
6
|
-
# Copyright::
|
|
6
|
+
# Copyright:: Copyright (c) 2012-2013 Automatic Ruby Developers.
|
|
7
7
|
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|
|
8
8
|
|
|
9
9
|
module Automatic::Plugin
|
data/plugins/publish/console.rb
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# Author:: 774 <http://id774.net>
|
|
4
4
|
# Created:: Feb 23, 2012
|
|
5
5
|
# Updated:: Feb 24, 2012
|
|
6
|
-
# Copyright::
|
|
6
|
+
# Copyright:: Copyright (c) 2012-2013 Automatic Ruby Developers.
|
|
7
7
|
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|
|
8
8
|
|
|
9
9
|
module Automatic::Plugin
|
|
@@ -17,9 +17,9 @@ module Automatic::Plugin
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def run
|
|
20
|
-
@pipeline.each {
|
|
20
|
+
@pipeline.each {|feeds|
|
|
21
21
|
unless feeds.nil?
|
|
22
|
-
feeds.items.each {
|
|
22
|
+
feeds.items.each {|feed|
|
|
23
23
|
@output.puts("info", feed.pretty_inspect)
|
|
24
24
|
}
|
|
25
25
|
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Name:: Automatic::Plugin::Publish::ConsoleLink
|
|
3
|
+
# Author:: soramugi <http://soramugi.net>
|
|
4
|
+
# Created:: Jun 02, 2013
|
|
5
|
+
# Updated:: Jun 02, 2013
|
|
6
|
+
# Copyright:: Copyright (c) 2012-2013 Automatic Ruby Developers.
|
|
7
|
+
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|
|
8
|
+
|
|
9
|
+
module Automatic::Plugin
|
|
10
|
+
class PublishConsoleLink
|
|
11
|
+
require 'pp'
|
|
12
|
+
|
|
13
|
+
def initialize(config, pipeline=[])
|
|
14
|
+
@config = config
|
|
15
|
+
@pipeline = pipeline
|
|
16
|
+
@output = STDOUT
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def run
|
|
20
|
+
@pipeline.each {|feeds|
|
|
21
|
+
unless feeds.nil?
|
|
22
|
+
feeds.items.each {|feed|
|
|
23
|
+
@output.puts("info", feed.link)
|
|
24
|
+
}
|
|
25
|
+
end
|
|
26
|
+
}
|
|
27
|
+
@pipeline
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Name:: Automatic::Plugin::Publish::Eject
|
|
3
|
+
# Author:: soramugi <http://soramugi.net>
|
|
4
|
+
# Created:: Jun 9, 2013
|
|
5
|
+
# Updated:: Jun 9, 2013
|
|
6
|
+
# Copyright:: Copyright (c) 2012-2013 Automatic Ruby Developers.
|
|
7
|
+
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|
|
8
|
+
|
|
9
|
+
module Automatic::Plugin
|
|
10
|
+
class PublishEject
|
|
11
|
+
|
|
12
|
+
def initialize(config, pipeline=[])
|
|
13
|
+
@config = config
|
|
14
|
+
@pipeline = pipeline
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def run
|
|
18
|
+
@pipeline.each {|feeds|
|
|
19
|
+
unless feeds.nil?
|
|
20
|
+
feeds.items.each {|feed|
|
|
21
|
+
unless feed.link.nil?
|
|
22
|
+
`#{eject_cmd}`
|
|
23
|
+
Automatic::Log.puts('info', "Eject: #{feed.link}")
|
|
24
|
+
|
|
25
|
+
interval = @config['interval'].to_i unless @config['interval'].nil? unless @config.nil?
|
|
26
|
+
sleep 3 if interval.nil?
|
|
27
|
+
end
|
|
28
|
+
}
|
|
29
|
+
end
|
|
30
|
+
}
|
|
31
|
+
@pipeline
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def eject_cmd
|
|
35
|
+
if `type -P eject` != '' # linux
|
|
36
|
+
'eject ; eject -t'
|
|
37
|
+
elsif `type -P drutil` != '' # mac
|
|
38
|
+
'drutil tray eject ; drutil tray close'
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Name:: Automatic::Plugin::Publish::Fluentd
|
|
3
|
+
# Author:: 774 <http://id774.net>
|
|
4
|
+
# Created:: Jun 21, 2013
|
|
5
|
+
# Updated:: Jun 25, 2013
|
|
6
|
+
# Copyright:: Copyright (c) 2012-2013 Automatic Ruby Developers.
|
|
7
|
+
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|
|
8
|
+
|
|
9
|
+
module Automatic::Plugin
|
|
10
|
+
class PublishFluentd
|
|
11
|
+
require 'fluent-logger'
|
|
12
|
+
|
|
13
|
+
def initialize(config, pipeline=[])
|
|
14
|
+
@config = config
|
|
15
|
+
@pipeline = pipeline
|
|
16
|
+
@fluentd = Fluent::Logger::FluentLogger.open(nil,
|
|
17
|
+
host = @config['host'],
|
|
18
|
+
port = @config['port'])
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def run
|
|
22
|
+
@pipeline.each {|feeds|
|
|
23
|
+
unless feeds.nil?
|
|
24
|
+
feeds.items.each {|feed|
|
|
25
|
+
begin
|
|
26
|
+
@fluentd.post(@config['tag'], {
|
|
27
|
+
:title => feed.title,
|
|
28
|
+
:link => feed.link,
|
|
29
|
+
:description => feed.description,
|
|
30
|
+
:content => feed.content_encoded,
|
|
31
|
+
:created_at => Time.now.strftime("%Y/%m/%d %X")
|
|
32
|
+
})
|
|
33
|
+
rescue
|
|
34
|
+
Automatic::Log.puts("warn", "Skip feed due to fault in forward.")
|
|
35
|
+
end
|
|
36
|
+
}
|
|
37
|
+
end
|
|
38
|
+
}
|
|
39
|
+
@pipeline
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|