automatic 13.1.0 → 13.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/README.md +1 -1
  2. data/VERSION +1 -1
  3. data/assets/siteinfo/items_all.json +52139 -0
  4. data/automatic.gemspec +16 -5
  5. data/bin/automatic +2 -2
  6. data/bin/automatic-config +8 -2
  7. data/doc/ChangeLog +19 -0
  8. data/doc/PLUGINS +79 -18
  9. data/doc/PLUGINS.ja +79 -17
  10. data/doc/README +10 -15
  11. data/doc/README.ja +10 -15
  12. data/lib/automatic.rb +2 -2
  13. data/plugins/filter/full_feed.rb +76 -0
  14. data/plugins/filter/ignore.rb +4 -12
  15. data/plugins/filter/{reverse.rb → sort.rb} +12 -6
  16. data/plugins/publish/instapaper.rb +77 -0
  17. data/plugins/store/target_link.rb +6 -2
  18. data/plugins/subscription/feed.rb +6 -2
  19. data/plugins/subscription/google_reader_star.rb +63 -0
  20. data/plugins/subscription/link.rb +6 -2
  21. data/plugins/subscription/tumblr.rb +14 -10
  22. data/plugins/subscription/twitter.rb +6 -2
  23. data/spec/lib/automatic_spec.rb +2 -2
  24. data/spec/plugins/filter/full_feed_spec.rb +48 -0
  25. data/spec/plugins/filter/ignore_spec.rb +184 -15
  26. data/spec/plugins/filter/sort_spec.rb +189 -0
  27. data/spec/plugins/publish/instapaper_spec.rb +56 -0
  28. data/spec/plugins/store/target_link_spec.rb +17 -1
  29. data/spec/plugins/subscription/feed_spec.rb +28 -1
  30. data/spec/plugins/subscription/google_reader_star_spec.rb +45 -0
  31. data/spec/plugins/subscription/link_spec.rb +29 -2
  32. data/spec/plugins/subscription/tumblr_spec.rb +17 -2
  33. data/spec/plugins/subscription/twitter_spec.rb +29 -2
  34. data/test/integration/test_absoluteurl.yml +25 -0
  35. data/test/integration/test_fulltext.yml +7 -1
  36. data/test/integration/test_googlestar.yml +19 -0
  37. data/test/integration/test_image2local.yml +4 -1
  38. data/test/integration/{test_reverse.yml → test_instapaper.yml} +9 -2
  39. data/test/integration/test_link2local.yml +34 -0
  40. data/test/integration/test_sort.yml +36 -0
  41. data/test/integration/test_tumblr2local.yml +16 -4
  42. metadata +16 -5
  43. data/spec/plugins/filter/reverse_spec.rb +0 -54
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 = "13.1.0"
8
+ s.version = "13.2.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 = "2013-01-08"
12
+ s.date = "2013-02-13"
13
13
  s.description = "Ruby General Automation Framework"
14
14
  s.email = "idnanashi@gmail.com"
15
15
  s.executables = ["automatic", "automatic-config"]
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
21
21
  "README.md",
22
22
  "Rakefile",
23
23
  "VERSION",
24
+ "assets/siteinfo/items_all.json",
24
25
  "automatic.gemspec",
25
26
  "bin/automatic",
26
27
  "bin/automatic-config",
@@ -42,15 +43,17 @@ Gem::Specification.new do |s|
42
43
  "lib/automatic/recipe.rb",
43
44
  "plugins/custom_feed/svn_log.rb",
44
45
  "plugins/filter/absolute_uri.rb",
46
+ "plugins/filter/full_feed.rb",
45
47
  "plugins/filter/ignore.rb",
46
48
  "plugins/filter/image.rb",
47
49
  "plugins/filter/image_source.rb",
48
- "plugins/filter/reverse.rb",
50
+ "plugins/filter/sort.rb",
49
51
  "plugins/filter/tumblr_resize.rb",
50
52
  "plugins/notify/ikachan.rb",
51
53
  "plugins/publish/console.rb",
52
54
  "plugins/publish/google_calendar.rb",
53
55
  "plugins/publish/hatena_bookmark.rb",
56
+ "plugins/publish/instapaper.rb",
54
57
  "plugins/publish/mail.rb",
55
58
  "plugins/publish/smtp.rb",
56
59
  "plugins/store/database.rb",
@@ -58,6 +61,7 @@ Gem::Specification.new do |s|
58
61
  "plugins/store/permalink.rb",
59
62
  "plugins/store/target_link.rb",
60
63
  "plugins/subscription/feed.rb",
64
+ "plugins/subscription/google_reader_star.rb",
61
65
  "plugins/subscription/link.rb",
62
66
  "plugins/subscription/tumblr.rb",
63
67
  "plugins/subscription/twitter.rb",
@@ -69,35 +73,42 @@ Gem::Specification.new do |s|
69
73
  "spec/lib/automatic_spec.rb",
70
74
  "spec/plugins/custom_feed/svn_log_spec.rb",
71
75
  "spec/plugins/filter/absolute_uri_spec.rb",
76
+ "spec/plugins/filter/full_feed_spec.rb",
72
77
  "spec/plugins/filter/ignore_spec.rb",
73
78
  "spec/plugins/filter/image_source_spec.rb",
74
79
  "spec/plugins/filter/image_spec.rb",
75
- "spec/plugins/filter/reverse_spec.rb",
80
+ "spec/plugins/filter/sort_spec.rb",
76
81
  "spec/plugins/filter/tumblr_resize_spec.rb",
77
82
  "spec/plugins/notify/ikachan_spec.rb",
78
83
  "spec/plugins/publish/console_spec.rb",
79
84
  "spec/plugins/publish/google_calendar_spec.rb",
80
85
  "spec/plugins/publish/hatena_bookmark_spec.rb",
86
+ "spec/plugins/publish/instapaper_spec.rb",
81
87
  "spec/plugins/publish/mail_spec.rb",
82
88
  "spec/plugins/publish/smtp_spec.rb",
83
89
  "spec/plugins/store/full_text_spec.rb",
84
90
  "spec/plugins/store/permalink_spec.rb",
85
91
  "spec/plugins/store/target_link_spec.rb",
86
92
  "spec/plugins/subscription/feed_spec.rb",
93
+ "spec/plugins/subscription/google_reader_star_spec.rb",
87
94
  "spec/plugins/subscription/link_spec.rb",
88
95
  "spec/plugins/subscription/tumblr_spec.rb",
89
96
  "spec/plugins/subscription/twitter_spec.rb",
90
97
  "spec/spec_helper.rb",
91
98
  "spec/user_dir/plugins/store/mock.rb",
92
99
  "test/fixtures/sampleOPML.xml",
100
+ "test/integration/test_absoluteurl.yml",
93
101
  "test/integration/test_activerecord.yml",
94
102
  "test/integration/test_fulltext.yml",
95
103
  "test/integration/test_googlealert.yml",
104
+ "test/integration/test_googlestar.yml",
96
105
  "test/integration/test_hatenabookmark.yml",
97
106
  "test/integration/test_ignore.yml",
98
107
  "test/integration/test_ignore2.yml",
99
108
  "test/integration/test_image2local.yml",
100
- "test/integration/test_reverse.yml",
109
+ "test/integration/test_instapaper.yml",
110
+ "test/integration/test_link2local.yml",
111
+ "test/integration/test_sort.yml",
101
112
  "test/integration/test_svnlog.yml",
102
113
  "test/integration/test_tumblr2local.yml",
103
114
  "vendor/.gitkeep"
data/bin/automatic CHANGED
@@ -3,7 +3,7 @@
3
3
  # Name:: Automatic::Ruby
4
4
  # Author:: 774 <http://id774.net>
5
5
  # Created:: Feb 18, 2012
6
- # Updated:: Mar 16, 2012
6
+ # Updated:: Jan 22, 2013
7
7
  # Copyright:: 774 Copyright (c) 2012
8
8
  # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
9
9
 
@@ -27,8 +27,8 @@ parser = OptionParser.new { |parser|
27
27
  }
28
28
 
29
29
  begin
30
+ Automatic::Log.puts("info", "Loading #{recipe_path}") unless recipe_path.empty?
30
31
  parser.parse!
31
- puts "Loading #{recipe_path}" unless recipe_path.empty?
32
32
  rescue OptionParser::ParseError => err
33
33
  $stderr.puts err.message
34
34
  $stderr.puts parser.help
data/bin/automatic-config CHANGED
@@ -4,8 +4,8 @@
4
4
  # Author:: kzgs
5
5
  # 774 <http://id774.net>
6
6
  # Created:: Mar 11, 2012
7
- # Updated:: Dec 20, 2012
8
- # Copyright:: kzgs Copyright (c) 2012
7
+ # Updated:: Jan 24, 2013
8
+ # Copyright:: kzgs Copyright (c) 2012-2013
9
9
  # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
10
10
 
11
11
  root_dir = File.expand_path("..", File.dirname(__FILE__))
@@ -36,6 +36,12 @@ subparsers = {
36
36
  puts "Creating #{dir}"
37
37
  end
38
38
  }
39
+ dir = (File.expand_path('~/.automatic/assets'))
40
+ unless File.exist?(dir)
41
+ FileUtils.mkdir_p(dir)
42
+ FileUtils.cp_r(root_dir + '/assets/siteinfo', dir + '/siteinfo')
43
+ puts "Creating #{dir}"
44
+ end
39
45
  dir = (File.expand_path('~/.automatic/config'))
40
46
  unless File.exist?(dir)
41
47
  FileUtils.mkdir_p(dir)
data/doc/ChangeLog CHANGED
@@ -1,3 +1,22 @@
1
+ === 13.2.0 / 2013-02-13
2
+
3
+ * All subscription and download plugins implemented retry function.
4
+
5
+ * Plugin Filter::Ignore has become item-based filter.
6
+
7
+ * Plugin Filter::Reverse renamed to Filter::Sort.
8
+
9
+ * Added new plugins.
10
+
11
+ * Subscription::GoogleReaderStar
12
+ * Filter::FullFeed
13
+ * Publish::Instapaper
14
+
15
+ * Improvement tests.
16
+
17
+ * And other minor bug fix.
18
+
19
+
1
20
  === 13.1.0 / 2013-01-08
2
21
 
3
22
  * Fix interval bugs.
data/doc/PLUGINS CHANGED
@@ -16,6 +16,8 @@ SubscriptionFeed
16
16
  feeds:
17
17
  - FEED
18
18
  - FEED ...
19
+ retry: RETRY_COUNT
20
+ interval: INTERVAL_FOR_RETRY (in seconds.)
19
21
 
20
22
 
21
23
  SubscriptionLink
@@ -33,54 +35,76 @@ SubscriptionLink
33
35
  - URL
34
36
  - URL ...
35
37
  interval: INTERVAL_FOR_SCRAPING (in seconds.)
38
+ retry: RETRY_COUNT
36
39
 
37
40
 
38
- SubscriptionTwitter
39
- -------------------
41
+ SubscriptionTumblr
42
+ ------------------
40
43
  [Path]
41
- /plugins/subscription/twitter.rb
44
+ /plugins/subscription/tumblr.rb
42
45
 
43
46
  [Abstract]
44
- Subscribe twitter and extract there statuses and the links.
47
+ Subscribe tumblr and extract the links.
48
+ If pages specified, including past pages.
45
49
 
46
50
  [Syntax]
47
- - module: SubscriptionTwittter
51
+ - module: SubscriptionTumblr
48
52
  config:
49
53
  urls:
50
54
  - URL
51
55
  - URL ...
56
+ pages: PAGES
52
57
  interval: INTERVAL_FOR_SCRAPING (in seconds.)
58
+ retry: RETRY_COUNT
53
59
 
54
60
 
55
- SubscriptionTumblr
56
- ------------------
61
+ SubscriptionGoogleReaderStar
62
+ ----------------------------
57
63
  [Path]
58
- /plugins/subscription/tumblr.rb
64
+ /plugins/subscription/google_reader_star.rb
59
65
 
60
66
  [Abstract]
61
- Subscribe tumblr and extract the links.
62
- If pages specified, including past pages.
67
+ Subscribe to Google reader star feed.
63
68
 
64
69
  [Syntax]
65
- - module: SubscriptionTumblr
70
+ - module: SubscriptionGoogleReaderStar
71
+ config:
72
+ feeds:
73
+ - FEED
74
+ - FEED ...
75
+
76
+
77
+ SubscriptionTwitter
78
+ -------------------
79
+ [Path]
80
+ /plugins/subscription/twitter.rb
81
+
82
+ [Abstract]
83
+ Subscribe twitter and extract there statuses and the links.
84
+
85
+ [Syntax]
86
+ - module: SubscriptionTwittter
66
87
  config:
67
88
  urls:
68
89
  - URL
69
90
  - URL ...
70
- pages: PAGES
71
91
  interval: INTERVAL_FOR_SCRAPING (in seconds.)
92
+ retry: RETRY_COUNT
72
93
 
73
94
 
74
- FilterReverse
75
- -------------
95
+ FilterSort
96
+ ----------
76
97
  [Path]
77
- /plugins/filter/reverse.rb
98
+ /plugins/filter/sort.rb
78
99
 
79
100
  [Abstract]
80
- Sort feed by date asc.
101
+ Sort feed by date asc or desc.
102
+ If desc is specified, it's sort feed by date desc.
81
103
 
82
104
  [Syntax]
83
- - module: FilterReverse
105
+ - module: FilterSort
106
+ config:
107
+ sort: asc or desc
84
108
 
85
109
 
86
110
  FilterIgnore
@@ -94,7 +118,10 @@ FilterIgnore
94
118
  [Syntax]
95
119
  - module: FilterIgnore
96
120
  config:
97
- exclude:
121
+ link:
122
+ - KEYWORD
123
+ - KEYWORD ...
124
+ description:
98
125
  - KEYWORD
99
126
  - KEYWORD ...
100
127
 
@@ -125,6 +152,20 @@ FilterImageSource
125
152
  - module: FilterImageSource
126
153
 
127
154
 
155
+ FilterFullFeed
156
+ --------------
157
+ [Path]
158
+ /plugins/filter/full_feed.rb
159
+
160
+ [Abstract]
161
+ Get full text of feed entry.
162
+
163
+ [Syntax]
164
+ - module: FilterFeed
165
+ config:
166
+ siteinfo: your siteinfo file's path
167
+
168
+
128
169
  FilterAbsoluteURI
129
170
  -----------------
130
171
  [Path]
@@ -200,6 +241,7 @@ StoreTargetLink
200
241
  - Module: StoreTargetLink
201
242
  config:
202
243
  path: SAVE_TO_PATH
244
+ retry: RETRY_COUNT
203
245
  interval: INTERVAL_FOR_DOWNLOAD (in seconds.)
204
246
 
205
247
 
@@ -235,6 +277,25 @@ PublishHatenaBookmark
235
277
  interval: INTERVAL_FOR_BOOKMARK (in seconds.)
236
278
 
237
279
 
280
+ PublishInstapaper
281
+ -----------------
282
+ [Path]
283
+ /plugins/publish/instapaper.rb
284
+
285
+ [Abstract]
286
+ Register an appointment to Instapaper.
287
+
288
+ [Description]
289
+ Submission to Instapaper API.
290
+
291
+ [Syntax]
292
+ - module: PublishInstapaper
293
+ config:
294
+ email: INSTAPAPER_ACCOUNT
295
+ password: PASSWORD
296
+ interval: INTERVAL
297
+
298
+
238
299
  PublishGoogleCalendar
239
300
  ---------------------
240
301
  [Path]
data/doc/PLUGINS.ja CHANGED
@@ -16,6 +16,8 @@ SubscriptionFeed
16
16
  feeds:
17
17
  - フィード名
18
18
  - フィード名 ...
19
+ retry: エラー時のリトライ回数 (回数, 省略時 0)
20
+ interval: エラー時のリトライ間隔 (秒数, 省略可)
19
21
 
20
22
 
21
23
  SubscriptionLink
@@ -33,54 +35,77 @@ SubscriptionLink
33
35
  - URL
34
36
  - URL ...
35
37
  interval: スクレイピングの間隔 (秒数, 省略可)
38
+ retry: エラー時のリトライ回数 (回数, 省略時 0)
36
39
 
37
40
 
38
- SubscriptionTwitter
39
- -------------------
41
+ SubscriptionTumblr
42
+ ------------------
40
43
  [パス]
41
- /plugins/subscription/link.rb
44
+ /plugins/subscription/tumblr.rb
42
45
 
43
46
  [概要]
44
- Twitter を購読し、発言とそのリンクを抽出する
47
+ Tumblr を購読し、リンクを抽出する
48
+ pages が指定された場合、過去のページも遡って購読する
45
49
 
46
50
  [レシピ記法]
47
- - module: SubscriptionTwitter
51
+ - module: SubscriptionTumblr
48
52
  config:
49
53
  urls:
50
54
  - URL
51
55
  - URL ...
56
+ pages: PAGES
52
57
  interval: スクレイピングの間隔 (秒数, 省略可)
58
+ retry: エラー時のリトライ回数 (回数, 省略時 0)
53
59
 
54
60
 
55
- SubscriptionTumblr
56
- ------------------
61
+ SubscriptionGoogleReaderStar
62
+ ----------------------------
57
63
  [パス]
58
- /plugins/subscription/tumblr.rb
64
+ /plugins/subscription/google_reader_star.rb
59
65
 
60
66
  [概要]
61
- Tumblr を購読し、リンクを抽出する
62
- pages が指定された場合、過去のページも遡って購読する
67
+ Google リーダーのスターフィードを購読する
63
68
 
64
69
  [レシピ記法]
65
- - module: SubscriptionTumblr
70
+ - module: SubscriptionGoogleReaderStar
71
+ config:
72
+ feeds:
73
+ - フィード名
74
+ - フィード名 ...
75
+
76
+
77
+ SubscriptionTwitter
78
+ -------------------
79
+ [パス]
80
+ /plugins/subscription/link.rb
81
+
82
+ [概要]
83
+ Twitter を購読し、発言とそのリンクを抽出する
84
+
85
+ [レシピ記法]
86
+ - module: SubscriptionTwitter
66
87
  config:
67
88
  urls:
68
89
  - URL
69
90
  - URL ...
70
- pages: PAGES
71
91
  interval: スクレイピングの間隔 (秒数, 省略可)
92
+ retry: エラー時のリトライ回数 (回数, 省略時 0)
72
93
 
73
94
 
74
- FilterReverse
75
- -------------
95
+ FilterSort
96
+ ----------
76
97
  [パス]
77
- /plugins/filter/reverse.rb
98
+ /plugins/filter/sort.rb
78
99
 
79
100
  [概要]
80
101
  日付の昇順にソートする
102
+ もし config で sort に desc が指定されると
103
+ 昇順ではなく降順にソートする
81
104
 
82
105
  [レシピ記法]
83
- - module: FilterReverse
106
+ - module: FilterSort
107
+ config:
108
+ sort: asc or desc
84
109
 
85
110
 
86
111
  FilterIgnore
@@ -94,7 +119,10 @@ FilterIgnore
94
119
  [レシピ記法]
95
120
  - module: FilterIgnore
96
121
  config:
97
- exclude:
122
+ link:
123
+ - 無視キーワード
124
+ - 無視キーワード ...
125
+ description:
98
126
  - 無視キーワード
99
127
  - 無視キーワード ...
100
128
 
@@ -125,6 +153,20 @@ FilterImageSource
125
153
  - module: FilterImageSource
126
154
 
127
155
 
156
+ FilterFullFeed
157
+ --------------
158
+ [パス]
159
+ /plugins/filter/full_feed.rb
160
+
161
+ [概要]
162
+ フィードの全文を取得する
163
+
164
+ [レシピ記法]
165
+ - module: FilterFeed
166
+ config:
167
+ siteinfo: siteinfo ファイル名
168
+
169
+
128
170
  FilterAbsoluteURI
129
171
  -----------------
130
172
  [パス]
@@ -199,6 +241,7 @@ StoreTargetLink
199
241
  - module: StoreTargetLink
200
242
  config:
201
243
  path: 保存先のフォルダ
244
+ retry: エラー時のリトライ回数 (回数, 省略時 0)
202
245
  interval: 保存する間隔 (秒)
203
246
 
204
247
 
@@ -234,6 +277,25 @@ PublishHatenaBookmark
234
277
  interval: はてブする間隔 (秒)
235
278
 
236
279
 
280
+ PublishInstapaper
281
+ -----------------
282
+ [パス]
283
+ /plugins/publish/instapaper.rb
284
+
285
+ [概要]
286
+ Instapaper に登録する
287
+
288
+ [説明]
289
+ Instapaper API へ送信する
290
+
291
+ [レシピ記法]
292
+ - module: PublishInstapaper
293
+ config:
294
+ email: Instapaper メールアドレス
295
+ password: パスワード
296
+ interval: 複数の予定の投稿間隔 (秒)
297
+
298
+
237
299
  PublishGoogleCalendar
238
300
  ---------------------
239
301
  [パス]
data/doc/README CHANGED
@@ -257,6 +257,11 @@ Directory and file structure
257
257
  |
258
258
  | If ~/.automatic/db not exist, save db file here.
259
259
  |
260
+ +-- assets
261
+ |
262
+ | There are some files that needed in a plug-ins.
263
+ | If ~/.automatic/assets exist, takes precedence it.
264
+ |
260
265
  +-+ script
261
266
  | |
262
267
  | +-- build
@@ -446,6 +451,8 @@ $ automatic-config
446
451
 
447
452
  $ automatic-config scaffold
448
453
  Make ~/.automatic directory in your home directory.
454
+ This operation makes 'plugins', 'db', 'config', 'assets' directories.
455
+ These takes precedence the origin directory.
449
456
 
450
457
  $ automatic-config unscaffold
451
458
  Delete ~/.automatic directory.
@@ -485,7 +492,7 @@ Update History
485
492
  TODO
486
493
  ====
487
494
 
488
- Refer to the issues of github
495
+ Refer to the issues of github.
489
496
  https://github.com/id774/automaticruby/issues
490
497
 
491
498
 
@@ -493,21 +500,9 @@ TODO
493
500
  Environment
494
501
  ===========
495
502
 
496
- ruby 1.8 or later
497
-
498
-
499
- The following packages depend on the gem.
500
-
501
- sqlite3
502
- activesupport
503
- hashie
504
- activerecord
505
- gcalapi
506
- xml-simple
507
- feedbag
508
- nokogiri
503
+ Ruby 1.8 - 2.0.
509
504
 
510
- For more information, see Gemfile.
505
+ Depend on the packages that described in Gemfile.
511
506
 
512
507
 
513
508
  =====
data/doc/README.ja CHANGED
@@ -234,10 +234,14 @@ plugins:
234
234
  | レシピを読み込む
235
235
  |
236
236
  +- db
237
- |
238
237
  | ~/.automatic/db が無い場合、ここにデータベースが
239
238
  | 保存される
240
239
  |
240
+ +- assets
241
+ | json ファイルなどプラグインの中で適宜必要とされる
242
+ | ファイルが格納される
243
+ | ~/.automatic/assets がある場合はそちらが優先される
244
+ |
241
245
  +- script
242
246
  | |
243
247
  | +- build
@@ -454,6 +458,9 @@ $ automatic-config
454
458
 
455
459
  $ automatic-config scaffold
456
460
  ホームディレクトリに ~/.automatic ディレクトリを生成する。
461
+ この操作により ~/.automatic の下に plugins, db, config, assets
462
+ ディレクトリが生成される。
463
+ これらは本体のそれぞれのディレクトリよりも優先される。
457
464
 
458
465
  $ automatic-config unscaffold
459
466
  ホームディレクトリの ~/.automatic ディレクトリを削除する。
@@ -501,21 +508,9 @@ TODO
501
508
  動作環境
502
509
  ========
503
510
 
504
- Ruby 1.8 以降
505
-
506
-
507
- 以下の gem パッケージに依存
508
-
509
- sqlite3
510
- activesupport
511
- hashie
512
- activerecord
513
- gcalapi
514
- xml-simple
515
- feedbag
516
- nokogiri
511
+ Ruby 1.8 - 2.0
517
512
 
518
- 詳細は Gemfile を参照
513
+ Gemfile に記述された gem パッケージに依存
519
514
 
520
515
 
521
516
  ========
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:: Jan 8, 2013
5
+ # Updated:: Feb 13, 2013
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 = "13.1.0"
16
+ VERSION = "13.2.0"
17
17
  USER_DIR = "/.automatic"
18
18
 
19
19
  class << self
@@ -0,0 +1,76 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Name:: Automatic::Plugin::Filter::FullFeed
3
+ # Author:: progd <http://d.hatena.ne.jp/progd/20120429/automatic_ruby_filter_full_feed>
4
+ # 774 <http://id774.net>
5
+ # Created:: Apr 29, 2012
6
+ # Updated:: Jan 24, 2013
7
+ # Copyright:: progd
8
+ # 774 Copyright (c) 2012-2013
9
+ # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
10
+
11
+ module Automatic::Plugin
12
+
13
+ class FilterFullFeed
14
+ require 'nokogiri'
15
+
16
+ SITEINFO_TYPES = %w[SBM INDIVIDUAL IND SUBGENERAL SUB GENERAL GEN]
17
+
18
+ def initialize(config, pipeline=[])
19
+ @config = config
20
+ @pipeline = pipeline
21
+ @siteinfo = get_siteinfo
22
+ end
23
+
24
+ def get_siteinfo
25
+ Automatic::Log.puts(:info, "Loading siteinfo from #{@config['siteinfo']}")
26
+ siteinfo = JSON.load(open(File.join(assets_dir, @config['siteinfo'])).read)
27
+ siteinfo.select! { |info| SITEINFO_TYPES.include? (info['data']['type']) }
28
+ siteinfo.sort! { |a, b|
29
+ atype, btype = a['data']['type'], b['data']['type']
30
+ SITEINFO_TYPES.index(atype) <=> SITEINFO_TYPES.index(btype)
31
+ }
32
+ return siteinfo
33
+ end
34
+
35
+ def assets_dir
36
+ dir = (File.expand_path('~/.automatic/assets/siteinfo'))
37
+ if File.directory?(dir)
38
+ dir
39
+ else
40
+ File.join(File.dirname(__FILE__), '..', '..', 'assets', 'siteinfo')
41
+ end
42
+ end
43
+
44
+ def fulltext(feed)
45
+ return feed unless feed.link
46
+ @siteinfo.each { |info|
47
+ begin
48
+ if feed.link.match(info['data']['url'])
49
+ Automatic::Log.puts(:info, "Siteinfo matched: #{info['data']['url']}")
50
+ html = Nokogiri::HTML.parse(open(feed.link))
51
+ body = html.xpath(info['data']['xpath'])
52
+ feed.description = body.to_html.encode('UTF-8', :undef => :replace)
53
+ return feed
54
+ end
55
+ rescue
56
+ return feed
57
+ end
58
+ }
59
+ Automatic::Log.puts(:info, "Fulltext SITEINFO not found: #{feed.link}")
60
+ return feed
61
+ end
62
+
63
+ def run
64
+ @return_feeds = []
65
+ @pipeline.each {|feeds|
66
+ unless feeds.nil?
67
+ feeds.items.each {|feed|
68
+ feed = fulltext(feed)
69
+ }
70
+ end
71
+ @return_feeds << feeds
72
+ }
73
+ @return_feeds
74
+ end
75
+ end
76
+ end