automatic 14.5.0 → 14.10.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f758274920596a6780c0d8976cc76a5a0344f84e
4
- data.tar.gz: 1611da3699eaf8e52c0405c8a46491e719c10637
3
+ metadata.gz: c4f4a46d1a0cd3682792e621973c10dc7c537bd2
4
+ data.tar.gz: e33c52947ef78c95c46ccf3a32df3153ee37606c
5
5
  SHA512:
6
- metadata.gz: 57cb29eaff31e98564961be7271cd3bd6f4591237fd13cd99098e693f41bc8238ba86a648e510bc911e2fa28bacaa3bc207c68221bf200cb6743e3a945842171
7
- data.tar.gz: 677ebbbd71a1b4396ef571ca05878a144890841f7f52cfa2635c05f194a79acf7a5a0e5ca2964b0c7f20b7f8433cdd1efd561669d29380ad1f0c28bb1bf843da
6
+ metadata.gz: d6540fcf48d19633a23ef3e0a56da11482c9be88a3a97225f4103547f783e68fc9a5313780269c82d492aad8327876e2f7f280d73d67e05a9c940a42812eae73
7
+ data.tar.gz: 764359815342acb9cdc60b7fa927ef3b84981333f8c064f64a2a663b72cdfa0a9183df8972d1062161839f27f6807855324e806754c6a80491dbc8cb76cae1ed
data/VERSION CHANGED
@@ -1 +1 @@
1
- 14.5.0
1
+ 14.10.1
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: automatic 14.5.0 ruby lib
5
+ # stub: automatic 14.10.1 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "automatic"
9
- s.version = "14.5.0"
9
+ s.version = "14.10.1"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["id774"]
14
- s.date = "2014-05-31"
14
+ s.date = "2014-10-23"
15
15
  s.description = "Ruby framework for the general-purpose automatic processing"
16
16
  s.email = "idnanashi@gmail.com"
17
17
  s.executables = ["automatic"]
@@ -47,8 +47,11 @@ Gem::Specification.new do |s|
47
47
  "plugins/custom_feed/svn_log.rb",
48
48
  "plugins/filter/absolute_uri.rb",
49
49
  "plugins/filter/accept.rb",
50
+ "plugins/filter/clear.rb",
51
+ "plugins/filter/description_link.rb",
50
52
  "plugins/filter/full_feed.rb",
51
53
  "plugins/filter/github_feed.rb",
54
+ "plugins/filter/google_news.rb",
52
55
  "plugins/filter/ignore.rb",
53
56
  "plugins/filter/image.rb",
54
57
  "plugins/filter/image_source.rb",
@@ -97,8 +100,11 @@ Gem::Specification.new do |s|
97
100
  "spec/plugins/custom_feed/svn_log_spec.rb",
98
101
  "spec/plugins/filter/absolute_uri_spec.rb",
99
102
  "spec/plugins/filter/accept_spec.rb",
103
+ "spec/plugins/filter/clear_spec.rb",
104
+ "spec/plugins/filter/description_link_spec.rb",
100
105
  "spec/plugins/filter/full_feed_spec.rb",
101
106
  "spec/plugins/filter/github_feed_spec.rb",
107
+ "spec/plugins/filter/google_news_spec.rb",
102
108
  "spec/plugins/filter/ignore_spec.rb",
103
109
  "spec/plugins/filter/image_source_spec.rb",
104
110
  "spec/plugins/filter/image_spec.rb",
@@ -141,8 +147,10 @@ Gem::Specification.new do |s|
141
147
  "test/integration/test_activerecord.yml",
142
148
  "test/integration/test_add_pocket.yml",
143
149
  "test/integration/test_chan_toru.yml",
150
+ "test/integration/test_descriptionlink.yml",
144
151
  "test/integration/test_fluentd.yml",
145
152
  "test/integration/test_fulltext.yml",
153
+ "test/integration/test_google_news.yml",
146
154
  "test/integration/test_googlealert.yml",
147
155
  "test/integration/test_hatenabookmark.yml",
148
156
  "test/integration/test_ignore.yml",
@@ -1,3 +1,18 @@
1
+ === 14.10.0 / 2014-10-23
2
+
3
+ * Using Logger
4
+
5
+ * Improvement File Saving Plugin
6
+
7
+ * Store::FullText will ignore duplicated titled entry.
8
+
9
+ * Added new plugins.
10
+
11
+ * Filter::Clear
12
+ * Filter::GoogleNews
13
+ * Filter::DescriptionLink
14
+
15
+
1
16
  === 14.5.0 / 2014-05-31
2
17
 
3
18
  * Update to activesupport/record 4.1.
@@ -216,6 +216,18 @@ SubscriptionChanToru
216
216
  retry: RETRY_COUNT
217
217
 
218
218
 
219
+ FilterClear
220
+ -----------
221
+ [Path]
222
+ /plugins/filter/clear.rb
223
+
224
+ [Abstract]
225
+ Clear Pipeline.
226
+
227
+ [Syntax]
228
+ - module: FilterClear
229
+
230
+
219
231
  FilterSort
220
232
  ----------
221
233
  [Path]
@@ -381,6 +393,34 @@ FilterTumblrResize
381
393
  - module: FilterTumblrResize
382
394
 
383
395
 
396
+ FilterDescriptionLink
397
+ ---------------------
398
+ [Path]
399
+ /plugins/filter/description_link.rb
400
+
401
+ [Abstract]
402
+ Pickup http or https URL from description.
403
+ Re-write link to the URL.
404
+
405
+ [Syntax]
406
+ - module: FilterDescriptionLink
407
+ config:
408
+ clear_description: 1 # Set empty to description.
409
+ get_title: 1 # Get title after re-write link.
410
+
411
+
412
+ FilterGoogleNews
413
+ ----------------
414
+ [Path]
415
+ /plugins/filter/google_news.rb
416
+
417
+ [Abstract]
418
+ Re-write Google News link to a new link of the redirect.
419
+
420
+ [Syntax]
421
+ - module: FilterGoogleNews
422
+
423
+
384
424
  StorePermalink
385
425
  --------------
386
426
  [Path]
@@ -216,6 +216,18 @@ SubscriptionChanToru
216
216
  retry: エラー時のリトライ回数 (回数, 省略時 0)
217
217
 
218
218
 
219
+ FilterClear
220
+ -----------
221
+ [パス]
222
+ /plugins/filter/clear.rb
223
+
224
+ [概要]
225
+ パイプラインをカラにする
226
+
227
+ [レシピ記法]
228
+ - module: FilterClear
229
+
230
+
219
231
  FilterSort
220
232
  ----------
221
233
  [パス]
@@ -382,6 +394,36 @@ FilterTumblrResize
382
394
  - module: FilterTumblrResize
383
395
 
384
396
 
397
+ FilterDescriptionLink
398
+ ---------------------
399
+ [パス]
400
+ /plugins/filter/description_link.rb
401
+
402
+ [概要]
403
+ 日付の昇順にソートする
404
+ もし config で sort に desc が指定されると
405
+ 昇順ではなく降順にソートする
406
+
407
+ [レシピ記法]
408
+ - module: FilterDescriptionLink
409
+ config:
410
+ clear_description: 1 # Set empty to description.
411
+ get_title: 1 # Get title after re-write link.
412
+
413
+
414
+ FilterGoogleNews
415
+ ----------------
416
+ [パス]
417
+ /plugins/filter/google_news.rb
418
+
419
+ [概要]
420
+ Google News のリンクを
421
+ リダイレクト先のものに書き換える
422
+
423
+ [レシピ記法]
424
+ - module: FilterGoogleNews
425
+
426
+
385
427
  StorePermalink
386
428
  --------------
387
429
  [パス]
@@ -2,10 +2,12 @@
2
2
  # Name:: Automatic::Log
3
3
  # Author:: 774 <http://id774.net>
4
4
  # Created:: Feb 20, 2012
5
- # Updated:: Mar 11, 2012
6
- # Copyright:: Copyright (c) 2012-2013 Automatic Ruby Developers.
5
+ # Updated:: Oct 09, 2014
6
+ # Copyright:: Copyright (c) 2012-2014 Automatic Ruby Developers.
7
7
  # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
8
8
 
9
+ require 'logger'
10
+
9
11
  module Automatic
10
12
  module Log
11
13
  LOG_LEVELS = ['info', 'warn', 'error', 'none']
@@ -14,13 +16,16 @@ module Automatic
14
16
  @level = level
15
17
  end
16
18
 
17
- def self.puts(level, message)
19
+ def self.logger
20
+ @logger ||= Logger.new(STDOUT)
21
+ end
22
+
23
+ def self.puts(level = :info, message)
18
24
  if LOG_LEVELS.index(@level).to_i > LOG_LEVELS.index(level).to_i
19
25
  return
20
26
  end
21
- t = Time.now.strftime("%Y/%m/%d %X")
22
- print log = "#{t} [#{level}] #{message}\n"
23
- return log
27
+ logger.send(level, message)
24
28
  end
29
+
25
30
  end
26
31
  end
@@ -1,3 +1,3 @@
1
1
  module Automatic
2
- VERSION = "14.5.0"
2
+ VERSION = "14.10.1"
3
3
  end
@@ -0,0 +1,20 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Name:: Automatic::Plugin::Filter::Clear
3
+ # Author:: 774 <http://id774.net>
4
+ # Created:: Oct 20, 2014
5
+ # Updated:: Oct 20, 2014
6
+ # Copyright:: Copyright (c) 2014 Automatic Ruby Developers.
7
+ # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
8
+
9
+ module Automatic::Plugin
10
+ class FilterClear
11
+ def initialize(config, pipeline=[])
12
+ @config = config
13
+ @pipeline = pipeline
14
+ end
15
+
16
+ def run
17
+ []
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,74 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Name:: Automatic::Plugin::Filter::DescriptionLink
3
+ # Author:: 774 <http://id774.net>
4
+ # Created:: Oct 03, 2014
5
+ # Updated:: Oct 16, 2014
6
+ # Copyright:: Copyright (c) 2014 Automatic Ruby Developers.
7
+ # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
8
+
9
+ module Automatic::Plugin
10
+ class FilterDescriptionLink
11
+ require 'uri'
12
+ require 'nkf'
13
+
14
+ def initialize(config, pipeline=[])
15
+ @config = config
16
+ @pipeline = pipeline
17
+ end
18
+
19
+ def run
20
+ @return_feeds = []
21
+ @pipeline.each {|feeds|
22
+ new_feeds = []
23
+ unless feeds.nil?
24
+ feeds.items.each {|feed|
25
+ new_feeds << rewrite_link(feed)
26
+ }
27
+ end
28
+ @return_feeds << Automatic::FeedMaker.create_pipeline(new_feeds)
29
+ }
30
+ @return_feeds
31
+ end
32
+
33
+ private
34
+
35
+ def get_title(url)
36
+ new_title = nil
37
+ if url.class == String
38
+ url.gsub!(Regexp.new("[^#{URI::PATTERN::ALNUM}\/\:\?\=&~,\.\(\)#]")) {|match| ERB::Util.url_encode(match)}
39
+ begin
40
+ read_data = NKF.nkf("--utf8", open(url).read)
41
+ get_text = Nokogiri::HTML.parse(read_data, nil, 'utf8').xpath('//title').text
42
+ new_title = get_text if get_text.class == String
43
+ rescue
44
+ Automatic::Log.puts("warn", "Failed in get title for: #{url}")
45
+ end
46
+ end
47
+
48
+ new_title
49
+ end
50
+
51
+ def rewrite_link(feed)
52
+ new_link = URI.extract(feed.description, %w{http https}).uniq.last
53
+ feed.link = new_link unless new_link.nil?
54
+
55
+ if @config.class == Hash
56
+ if @config['clear_description'] == 1
57
+ feed.description = ""
58
+ end
59
+
60
+ if @config['get_title'] == 1
61
+ begin
62
+ new_title = get_title(feed.link)
63
+ feed.title = new_title unless new_title.nil?
64
+ rescue OpenURI::HTTPError
65
+ Automatic::Log.puts("warn", "404 Not Found in get title process.")
66
+ end
67
+ end
68
+ end
69
+
70
+ feed
71
+ end
72
+ end
73
+ end
74
+
@@ -0,0 +1,50 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Name:: Automatic::Plugin::Filter::GoogleNews
3
+ # Author:: 774 <http://id774.net>
4
+ # Created:: Oct 12, 2014
5
+ # Updated:: Oct 14, 2014
6
+ # Copyright:: Copyright (c) 2014 Automatic Ruby Developers.
7
+ # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
8
+
9
+ module Automatic::Plugin
10
+ class FilterGoogleNews
11
+ require 'uri'
12
+ require 'nkf'
13
+
14
+ def initialize(config, pipeline=[])
15
+ @config = config
16
+ @pipeline = pipeline
17
+ end
18
+
19
+ def run
20
+ @return_feeds = []
21
+ @pipeline.each {|feeds|
22
+ new_feeds = []
23
+ unless feeds.nil?
24
+ feeds.items.each {|feed|
25
+ new_feeds << rewrite_link(feed) unless feed.link.nil?
26
+ }
27
+ end
28
+ @return_feeds << Automatic::FeedMaker.create_pipeline(new_feeds)
29
+ }
30
+ @return_feeds
31
+ end
32
+
33
+ private
34
+
35
+ def rewrite_link(feed)
36
+ if feed.link.class == String
37
+ if feed.link.index("http://news.google.com")
38
+ matched = feed.link.match(/(&url=)/)
39
+ unless matched.nil?
40
+ new_link = matched.post_match
41
+ feed.link = new_link unless new_link.nil?
42
+ end
43
+ end
44
+ end
45
+
46
+ feed
47
+ end
48
+ end
49
+ end
50
+
@@ -4,7 +4,7 @@
4
4
  # 774 <http://id774.net>
5
5
  # soramugi <http://soramugi.net>
6
6
  # Created:: Feb 27, 2012
7
- # Updated:: Feb 21, 2014
7
+ # Updated:: Oct 09, 2014
8
8
  # Copyright:: Copyright (c) 2012-2014 Automatic Ruby Developers.
9
9
  # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
10
10
 
@@ -21,7 +21,12 @@ module Automatic::Plugin
21
21
  new_feeds = []
22
22
  feeds.items.each {|feed|
23
23
  unless feed.link.nil?
24
- unless existing_records.detect {|b| b.try(unique_key) == feed.link }
24
+ if unique_keys.length > 1
25
+ detection = existing_records.detect {|b| b.try(unique_keys[0]) == feed.link || b.try(unique_keys[1]) == feed.title }
26
+ else
27
+ detection = existing_records.detect {|b| b.try(unique_keys[0]) == feed.link }
28
+ end
29
+ unless detection
25
30
  yield(feed)
26
31
  new_feeds << feed
27
32
  end
@@ -2,8 +2,8 @@
2
2
  # Name:: Automatic::Plugin::Store::FullText
3
3
  # Author:: 774 <http://id774.net>
4
4
  # Created:: Feb 26, 2012
5
- # Updated:: Jun 14, 2012
6
- # Copyright:: Copyright (c) 2012-2013 Automatic Ruby Developers.
5
+ # Updated:: Oct 09, 2014
6
+ # Copyright:: Copyright (c) 2012-2014 Automatic Ruby Developers.
7
7
  # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
8
8
 
9
9
  require 'plugins/store/database'
@@ -30,8 +30,8 @@ module Automatic::Plugin
30
30
  }
31
31
  end
32
32
 
33
- def unique_key
34
- :link
33
+ def unique_keys
34
+ [:link, :title]
35
35
  end
36
36
 
37
37
  def model_class
@@ -3,8 +3,8 @@
3
3
  # Name:: Automatic::Plugin::Store::Permalink
4
4
  # Author:: 774 <http://id774.net>
5
5
  # Created:: Feb 22, 2012
6
- # Updated:: Sep 18, 2012
7
- # Copyright:: Copyright (c) 2012-2013 Automatic Ruby Developers.
6
+ # Updated:: Oct 09, 2014
7
+ # Copyright:: Copyright (c) 2012-2014 Automatic Ruby Developers.
8
8
  # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
9
9
 
10
10
  require 'plugins/store/database'
@@ -28,8 +28,8 @@ module Automatic::Plugin
28
28
  }
29
29
  end
30
30
 
31
- def unique_key
32
- :url
31
+ def unique_keys
32
+ [:url]
33
33
  end
34
34
 
35
35
  def model_class
@@ -1,9 +1,10 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Name:: Auaotmatic::Log
3
3
  # Author:: soramugi
4
+ # 774 <http://id774.net>
4
5
  # Created:: May 19, 2013
5
- # Updated:: May 19, 2013
6
- # Copyright:: Copyright (c) 2012-2013 Automatic Ruby Developers.
6
+ # Updated:: Oct 09, 2014
7
+ # Copyright:: Copyright (c) 2012-2014 Automatic Ruby Developers.
7
8
  # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
8
9
 
9
10
  require File.expand_path(File.join(File.dirname(__FILE__) ,'../../spec_helper'))
@@ -3,7 +3,7 @@
3
3
  # Author:: kzgs
4
4
  # 774 <http://id774.net>
5
5
  # Created:: Mar 9, 2012
6
- # Updated:: May 31, 2014
6
+ # Updated:: Oct 23, 2014
7
7
  # Copyright:: Copyright (c) 2012-2014 Automatic Ruby Developers.
8
8
  # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
9
9
 
@@ -27,7 +27,7 @@ describe Automatic do
27
27
  describe "#version" do
28
28
  subject { Automatic.const_get(:VERSION) }
29
29
 
30
- it { expect(subject).to eq "14.5.0" }
30
+ it { expect(subject).to eq "14.10.1" }
31
31
  end
32
32
 
33
33
  describe "#(root)_dir" do
@@ -0,0 +1,49 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Name:: Automatic::Plugin::Filter::Clear
3
+ # Author:: 774 <http://id774.net>
4
+ # Created:: Oct 20, 2014
5
+ # Updated:: Oct 20, 2014
6
+ # Copyright:: Copyright (c) 2014 Automatic Ruby Developers.
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/clear'
12
+
13
+ describe Automatic::Plugin::FilterClear do
14
+
15
+ context "should be cleared" do
16
+ subject {
17
+ Automatic::Plugin::FilterClear.new({
18
+ },
19
+ AutomaticSpec.generate_pipeline {
20
+ feed {
21
+ item "http://hogefuga.com", "",
22
+ "aaaabbbccc"
23
+ }
24
+ feed {
25
+ item "http://aaaabbbccc.com", "",
26
+ "hogefugahoge"
27
+ }
28
+ feed {
29
+ item "http://aaabbbccc.com", "",
30
+ "aaaaaaaaaacccdd"
31
+ }
32
+ feed {
33
+ item "http://aaccc.com", "",
34
+ "aaaabbbccc"
35
+ item "http://aabbccc.com", "",
36
+ "aabbbccc"
37
+ }
38
+ feed {
39
+ item "http://cccddd.com", "",
40
+ "aabbbcccdd"
41
+ }
42
+ }
43
+ )}
44
+
45
+ describe "#run" do
46
+ its(:run) { should have(0).feeds }
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,138 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Name:: Automatic::Plugin::Filter::DescriptionLink
3
+ # Author:: 774 <http://id774.net>
4
+ # Created:: Oct 03, 2014
5
+ # Updated:: Oct 03, 2014
6
+ # Copyright:: Copyright (c) 2014 Automatic Ruby Developers.
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/description_link'
12
+
13
+ describe Automatic::Plugin::FilterDescriptionLink do
14
+
15
+ context "It should be rewrite link based on the description" do
16
+
17
+ subject {
18
+ Automatic::Plugin::FilterDescriptionLink.new(
19
+ {},
20
+ AutomaticSpec.generate_pipeline {
21
+ feed {
22
+ item "http://test1.id774.net",
23
+ "dummy title",
24
+ "aaa bbb ccc http://test2.id774.net ddd eee",
25
+ "Mon, 07 Mar 2011 15:54:11 +0900"
26
+ }
27
+ }
28
+ )
29
+ }
30
+
31
+ describe "#run" do
32
+ its(:run) { should have(1).feeds }
33
+
34
+ specify {
35
+ subject.run
36
+ subject.instance_variable_get(:@pipeline)[0].items[0].link.
37
+ should == "http://test2.id774.net"
38
+ subject.instance_variable_get(:@pipeline)[0].items[0].description.
39
+ should == "aaa bbb ccc http://test2.id774.net ddd eee"
40
+ }
41
+ end
42
+ end
43
+
44
+ context "It should be empty description if clear_description specified" do
45
+
46
+ subject {
47
+ Automatic::Plugin::FilterDescriptionLink.new({
48
+ 'clear_description' => 1,
49
+ },
50
+ AutomaticSpec.generate_pipeline {
51
+ feed {
52
+ item "http://test1.id774.net",
53
+ "dummy title",
54
+ "aaa bbb ccc http://test2.id774.net ddd eee",
55
+ "Mon, 07 Mar 2011 15:54:11 +0900"
56
+ }
57
+ }
58
+ )
59
+ }
60
+
61
+ describe "#run" do
62
+ its(:run) { should have(1).feeds }
63
+
64
+ specify {
65
+ subject.run
66
+ subject.instance_variable_get(:@pipeline)[0].items[0].link.
67
+ should == "http://test2.id774.net"
68
+ subject.instance_variable_get(:@pipeline)[0].items[0].description.
69
+ should == ""
70
+ }
71
+ end
72
+ end
73
+
74
+ context "It should be got title if get_title specified" do
75
+
76
+ subject {
77
+ Automatic::Plugin::FilterDescriptionLink.new({
78
+ 'get_title' => 1,
79
+ },
80
+ AutomaticSpec.generate_pipeline {
81
+ feed {
82
+ item "http://test1.id774.net",
83
+ "dummy title",
84
+ "aaa bbb ccc http://blog.id774.net/post/2014/10/01/531/ ddd eee",
85
+ "Mon, 07 Mar 2011 15:54:11 +0900"
86
+ }
87
+ }
88
+ )
89
+ }
90
+
91
+ describe "#run" do
92
+ its(:run) { should have(1).feeds }
93
+
94
+ specify {
95
+ subject.run
96
+ subject.instance_variable_get(:@pipeline)[0].items[0].link.
97
+ should == "http://blog.id774.net/post/2014/10/01/531/"
98
+ subject.instance_variable_get(:@pipeline)[0].items[0].title.
99
+ should == "二穂様は俺の嫁 | 774::Blog"
100
+ subject.instance_variable_get(:@pipeline)[0].items[0].description.
101
+ should == "aaa bbb ccc http://blog.id774.net/post/2014/10/01/531/ ddd eee"
102
+ }
103
+ end
104
+ end
105
+
106
+ context "It should be handling error if 404 Not Found" do
107
+
108
+ subject {
109
+ Automatic::Plugin::FilterDescriptionLink.new({
110
+ 'get_title' => 1,
111
+ },
112
+ AutomaticSpec.generate_pipeline {
113
+ feed {
114
+ item "http://test1.id774.net",
115
+ "dummy title",
116
+ "aaa bbb ccc http://blog.id774.net/post/2014/10/01/532/ ddd eee",
117
+ "Mon, 07 Mar 2011 15:54:11 +0900"
118
+ }
119
+ }
120
+ )
121
+ }
122
+
123
+ describe "#run" do
124
+ its(:run) { should have(1).feeds }
125
+
126
+ specify {
127
+ subject.run
128
+ subject.instance_variable_get(:@pipeline)[0].items[0].link.
129
+ should == "http://blog.id774.net/post/2014/10/01/532/"
130
+ subject.instance_variable_get(:@pipeline)[0].items[0].title.
131
+ should == "dummy title"
132
+ subject.instance_variable_get(:@pipeline)[0].items[0].description.
133
+ should == "aaa bbb ccc http://blog.id774.net/post/2014/10/01/532/ ddd eee"
134
+ }
135
+ end
136
+ end
137
+
138
+ end
@@ -0,0 +1,69 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Name:: Automatic::Plugin::Filter::GoogleNews
3
+ # Author:: 774 <http://id774.net>
4
+ # Created:: Oct 12, 2014
5
+ # Updated:: Oct 12, 2014
6
+ # Copyright:: Copyright (c) 2014 Automatic Ruby Developers.
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/google_news'
12
+
13
+ describe Automatic::Plugin::FilterGoogleNews do
14
+
15
+ context "It should be not rewrite link other urls" do
16
+
17
+ subject {
18
+ Automatic::Plugin::FilterGoogleNews.new(
19
+ {},
20
+ AutomaticSpec.generate_pipeline {
21
+ feed {
22
+ item "http://test1.id774.net",
23
+ "dummy title",
24
+ "aaa bbb ccc http://test2.id774.net ddd eee",
25
+ "Mon, 07 Mar 2011 15:54:11 +0900"
26
+ }
27
+ }
28
+ )
29
+ }
30
+
31
+ describe "#run" do
32
+ its(:run) { should have(1).feeds }
33
+
34
+ specify {
35
+ subject.run
36
+ subject.instance_variable_get(:@pipeline)[0].items[0].link.
37
+ should == "http://test1.id774.net"
38
+ }
39
+ end
40
+ end
41
+
42
+ context "It should be rewrite link for google news urls" do
43
+
44
+ subject {
45
+ Automatic::Plugin::FilterGoogleNews.new(
46
+ {},
47
+ AutomaticSpec.generate_pipeline {
48
+ feed {
49
+ item "http://news.google.com/news/url?sa=t&fd=R&ct2=us&usg=AFQjCNGhIFo1illQ6jFyVGPZtfkttFaJYQ&clid=c3a7d30bb8a4878e06b80cf16b898331&cid=52779138313507&ei=Pts3VLDAD4X7kgWO9oGIBg&url=http://www.yomiuri.co.jp/world/20141010-OYT1T50090.html",
50
+ "dummy title",
51
+ "aaa bbb ccc http://test2.id774.net ddd eee",
52
+ "Mon, 07 Mar 2011 15:54:11 +0900"
53
+ }
54
+ }
55
+ )
56
+ }
57
+
58
+ describe "#run" do
59
+ its(:run) { should have(1).feeds }
60
+
61
+ specify {
62
+ subject.run
63
+ subject.instance_variable_get(:@pipeline)[0].items[0].link.
64
+ should == "http://www.yomiuri.co.jp/world/20141010-OYT1T50090.html"
65
+ }
66
+ end
67
+ end
68
+
69
+ end
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Name:: Automatic::Plugin::Store::FullText
3
3
  # Author:: 774 <http://id774.net>
4
- # Updated:: Jun 14, 2012
5
- # Copyright:: Copyright (c) 2012-2013 Automatic Ruby Developers.
4
+ # Updated:: Oct 16, 2014
5
+ # Copyright:: Copyright (c) 2012-2014 Automatic Ruby Developers.
6
6
  # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
7
7
 
8
8
  require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper')
@@ -26,13 +26,20 @@ describe Automatic::Plugin::StoreFullText do
26
26
  it "should store 1 record for the new blog entry" do
27
27
  instance = Automatic::Plugin::StoreFullText.new({"db" => @db_filename},
28
28
  AutomaticSpec.generate_pipeline {
29
- feed { item "http://blog.id774.net/blogs/feed/" }
29
+ feed {
30
+ item "http://blog.id774.net/blogs/feed/",
31
+ "dummy title",
32
+ "aaa bbb ccc http://test2.id774.net ddd eee",
33
+ "Mon, 07 Mar 2011 15:54:11 +0900"
34
+ }
30
35
  }
31
36
  )
32
37
 
38
+ Automatic::Plugin::Blog.count.should eq 0
33
39
  lambda {
34
40
  instance.run.should have(1).feed
35
41
  }.should change(Automatic::Plugin::Blog, :count).by(1)
42
+ Automatic::Plugin::Blog.count.should eq 1
36
43
  end
37
44
 
38
45
  it "should not store record for the existent blog entry" do
@@ -42,10 +49,104 @@ describe Automatic::Plugin::StoreFullText do
42
49
  }
43
50
  )
44
51
 
52
+ Automatic::Plugin::Blog.count.should eq 0
45
53
  instance.run.should have(1).feed
46
54
  lambda {
47
55
  instance.run.should have(0).feed
48
56
  }.should change(Automatic::Plugin::Blog, :count).by(0)
57
+ instance.run.should have(0).feed
58
+ Automatic::Plugin::Blog.count.should eq 1
59
+ end
60
+
61
+ it "should not store record for the existent blog link" do
62
+ instance = Automatic::Plugin::StoreFullText.new({"db" => @db_filename},
63
+ AutomaticSpec.generate_pipeline {
64
+ feed {
65
+ item "http://blog.id774.net/post/100",
66
+ "dummy title 1",
67
+ "aaa bbb ccc http://test2.id774.net ddd eee",
68
+ "Mon, 07 Mar 2011 15:54:11 +0900"
69
+ }
70
+ }
71
+ )
72
+ instance2 = Automatic::Plugin::StoreFullText.new({"db" => @db_filename},
73
+ AutomaticSpec.generate_pipeline {
74
+ feed {
75
+ item "http://blog.id774.net/post/100",
76
+ "dummy title 2",
77
+ "aaa bbb ccc http://test2.id774.net ddd eee",
78
+ "Mon, 07 Mar 2011 15:54:11 +0900"
79
+ }
80
+ }
81
+ )
82
+
83
+ Automatic::Plugin::Blog.count.should eq 0
84
+ instance.run.should have(1).feed
85
+ lambda {
86
+ instance2.run.should have(0).feed
87
+ }.should change(Automatic::Plugin::Blog, :count).by(0)
88
+ instance2.run.should have(0).feed
89
+ Automatic::Plugin::Blog.count.should eq 1
49
90
  end
50
91
 
92
+ it "should not store record for the existent blog title" do
93
+ instance = Automatic::Plugin::StoreFullText.new({"db" => @db_filename},
94
+ AutomaticSpec.generate_pipeline {
95
+ feed {
96
+ item "http://blog.id774.net/post/100",
97
+ "dummy title 1",
98
+ "aaa bbb ccc http://test2.id774.net ddd eee",
99
+ "Mon, 07 Mar 2011 15:54:11 +0900"
100
+ }
101
+ }
102
+ )
103
+ instance2 = Automatic::Plugin::StoreFullText.new({"db" => @db_filename},
104
+ AutomaticSpec.generate_pipeline {
105
+ feed {
106
+ item "http://blog.id774.net/post/200",
107
+ "dummy title 1",
108
+ "aaa bbb ccc http://test2.id774.net ddd eee",
109
+ "Mon, 07 Mar 2011 15:54:11 +0900"
110
+ }
111
+ }
112
+ )
113
+
114
+ Automatic::Plugin::Blog.count.should eq 0
115
+ instance.run.should have(1).feed
116
+ lambda {
117
+ instance2.run.should have(0).feed
118
+ }.should change(Automatic::Plugin::Blog, :count).by(0)
119
+ instance2.run.should have(0).feed
120
+ Automatic::Plugin::Blog.count.should eq 1
121
+ end
122
+
123
+ it "should store 2 records for the independent entries" do
124
+ instance = Automatic::Plugin::StoreFullText.new({"db" => @db_filename},
125
+ AutomaticSpec.generate_pipeline {
126
+ feed {
127
+ item "http://blog.id774.net/post/100",
128
+ "dummy title 1",
129
+ "aaa bbb ccc http://test2.id774.net ddd eee",
130
+ "Mon, 07 Mar 2011 15:54:11 +0900"
131
+ }
132
+ }
133
+ )
134
+ instance2 = Automatic::Plugin::StoreFullText.new({"db" => @db_filename},
135
+ AutomaticSpec.generate_pipeline {
136
+ feed {
137
+ item "http://blog.id774.net/post/200",
138
+ "dummy title 2",
139
+ "aaa bbb ccc http://test2.id774.net ddd eee",
140
+ "Mon, 07 Mar 2011 15:54:11 +0900"
141
+ }
142
+ }
143
+ )
144
+
145
+ Automatic::Plugin::Blog.count.should eq 0
146
+ instance.run.should have(1).feed
147
+ lambda {
148
+ instance2.run.should have(1).feed
149
+ }.should change(Automatic::Plugin::Blog, :count).by(1)
150
+ Automatic::Plugin::Blog.count.should eq 2
151
+ end
51
152
  end
@@ -0,0 +1,21 @@
1
+ global:
2
+ timezone: Asia/Tokyo
3
+ cache:
4
+ base: /tmp
5
+ log:
6
+ level: info
7
+
8
+ plugins:
9
+ - module: SubscriptionFeed
10
+ config:
11
+ feeds:
12
+ - http://reblog.id774.net/rss
13
+
14
+ - module: FilterDescriptionLink
15
+
16
+ - module: StorePermalink
17
+ config:
18
+ db: test_description_link.db
19
+
20
+ #- module: PublishConsole
21
+
@@ -0,0 +1,21 @@
1
+ global:
2
+ timezone: Asia/Tokyo
3
+ cache:
4
+ base: /tmp
5
+ log:
6
+ level: info
7
+
8
+ plugins:
9
+ - module: SubscriptionFeed
10
+ config:
11
+ feeds:
12
+ - http://news.google.com/news?hl=ja&ned=us&ie=UTF-8&oe=UTF-8&output=rss
13
+
14
+ - module: FilterGoogleNews
15
+
16
+ - module: StorePermalink
17
+ config:
18
+ db: test_google_news.db
19
+
20
+ - module: PublishConsole
21
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: automatic
3
3
  version: !ruby/object:Gem::Version
4
- version: 14.5.0
4
+ version: 14.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - id774
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-31 00:00:00.000000000 Z
11
+ date: 2014-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -354,8 +354,11 @@ files:
354
354
  - plugins/custom_feed/svn_log.rb
355
355
  - plugins/filter/absolute_uri.rb
356
356
  - plugins/filter/accept.rb
357
+ - plugins/filter/clear.rb
358
+ - plugins/filter/description_link.rb
357
359
  - plugins/filter/full_feed.rb
358
360
  - plugins/filter/github_feed.rb
361
+ - plugins/filter/google_news.rb
359
362
  - plugins/filter/ignore.rb
360
363
  - plugins/filter/image.rb
361
364
  - plugins/filter/image_source.rb
@@ -404,8 +407,11 @@ files:
404
407
  - spec/plugins/custom_feed/svn_log_spec.rb
405
408
  - spec/plugins/filter/absolute_uri_spec.rb
406
409
  - spec/plugins/filter/accept_spec.rb
410
+ - spec/plugins/filter/clear_spec.rb
411
+ - spec/plugins/filter/description_link_spec.rb
407
412
  - spec/plugins/filter/full_feed_spec.rb
408
413
  - spec/plugins/filter/github_feed_spec.rb
414
+ - spec/plugins/filter/google_news_spec.rb
409
415
  - spec/plugins/filter/ignore_spec.rb
410
416
  - spec/plugins/filter/image_source_spec.rb
411
417
  - spec/plugins/filter/image_spec.rb
@@ -448,8 +454,10 @@ files:
448
454
  - test/integration/test_activerecord.yml
449
455
  - test/integration/test_add_pocket.yml
450
456
  - test/integration/test_chan_toru.yml
457
+ - test/integration/test_descriptionlink.yml
451
458
  - test/integration/test_fluentd.yml
452
459
  - test/integration/test_fulltext.yml
460
+ - test/integration/test_google_news.yml
453
461
  - test/integration/test_googlealert.yml
454
462
  - test/integration/test_hatenabookmark.yml
455
463
  - test/integration/test_ignore.yml