automatic 12.4.0 → 12.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 +1 -0
- data/README.md +8 -5
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/automatic.gemspec +32 -9
- data/bin/automatic +3 -3
- data/bin/automatic-config +34 -17
- data/config/feed2console.yml +1 -2
- data/config/html2console.yml +16 -0
- data/doc/ChangeLog +38 -3
- data/doc/PLUGINS +191 -14
- data/doc/PLUGINS.ja +187 -10
- data/doc/README +70 -42
- data/doc/README.ja +64 -58
- data/lib/automatic/opml.rb +2 -1
- data/lib/automatic/pipeline.rb +3 -3
- data/lib/automatic/recipe.rb +6 -1
- data/lib/automatic.rb +6 -6
- data/plugins/extract/link.rb +32 -0
- data/plugins/filter/ignore.rb +7 -16
- data/plugins/filter/image_link.rb +37 -0
- data/plugins/filter/{image.rb → image_source.rb} +6 -7
- data/plugins/filter/reverse.rb +3 -4
- data/plugins/filter/tumblr_resize.rb +3 -4
- data/plugins/notify/ikachan.rb +1 -2
- data/plugins/publish/console.rb +0 -1
- data/plugins/publish/dump.rb +24 -0
- data/plugins/publish/google_calendar.rb +0 -2
- data/plugins/publish/hatena_bookmark.rb +2 -3
- data/plugins/store/{store_database.rb → database.rb} +32 -7
- data/plugins/store/full_text.rb +5 -5
- data/plugins/store/link.rb +47 -0
- data/plugins/store/permalink.rb +7 -7
- data/plugins/store/target.rb +41 -0
- data/plugins/subscription/feed.rb +0 -1
- data/plugins/subscription/uri.rb +31 -0
- data/script/build +18 -4
- data/spec/fixtures/extractLink.html +14 -0
- data/spec/fixtures/filterImageLink.html +34 -0
- data/spec/fixtures/publishDump.html +14 -0
- data/{config/default.yml → spec/fixtures/sampleRecipe.yml} +8 -10
- data/spec/fixtures/storeLink.html +34 -0
- data/spec/fixtures/storeLink2.html +36 -0
- data/spec/fixtures/storeTarget.html +11 -0
- data/spec/fixtures/storeTarget2.html +11 -0
- data/spec/lib/automatic/pipeline_spec.rb +27 -14
- data/spec/lib/automatic/recipe_spec.rb +35 -0
- data/spec/lib/automatic_spec.rb +21 -14
- data/spec/plugins/extract/link_spec.rb +38 -0
- data/spec/plugins/filter/ignore_spec.rb +59 -3
- data/spec/plugins/filter/image_link_spec.rb +51 -0
- data/spec/plugins/filter/{image_spec.rb → image_source_spec.rb} +29 -9
- data/spec/plugins/filter/reverse_spec.rb +0 -1
- data/spec/plugins/filter/tumblr_resize_spec.rb +7 -0
- data/spec/plugins/publish/console_spec.rb +9 -2
- data/spec/plugins/publish/dump_spec.rb +32 -0
- data/spec/plugins/publish/google_calendar_spec.rb +2 -1
- data/spec/plugins/publish/hatena_bookmark_spec.rb +2 -1
- data/spec/plugins/publish/mail_spec.rb +9 -1
- data/spec/plugins/publish/smtp_spec.rb +9 -1
- data/spec/plugins/store/full_text_spec.rb +15 -5
- data/spec/plugins/store/link_spec.rb +47 -0
- data/spec/plugins/store/permalink_spec.rb +9 -2
- data/spec/plugins/store/target_link_spec.rb +17 -3
- data/spec/plugins/store/target_spec.rb +41 -0
- data/spec/plugins/subscription/feed_spec.rb +14 -4
- data/spec/plugins/subscription/uri_spec.rb +43 -0
- data/spec/spec_helper.rb +31 -8
- data/spec/user_dir/plugins/store/mock.rb +4 -0
- data/test/integration/test_activerecord.yml +1 -1
- data/test/integration/test_fulltext.yml +1 -1
- data/test/integration/test_get_image.yml +26 -0
- data/test/integration/test_hatenabookmark.yml +1 -1
- data/test/integration/test_ignore.yml +1 -1
- data/test/integration/test_ignore2.yml +1 -1
- data/test/integration/test_image2local.yml +1 -1
- data/test/integration/test_reverse.yml +1 -1
- data/test/integration/test_tumblr2local.yml +1 -1
- metadata +45 -9
- data/spec/lib/pipeline_spec.rb +0 -67
- data/test/integration/test_mail.yml +0 -21
data/doc/README
CHANGED
@@ -25,31 +25,42 @@ Installation
|
|
25
25
|
[Stable]
|
26
26
|
$ gem install automatic
|
27
27
|
|
28
|
+
$ automatic-config scaffold
|
29
|
+
(Make ~/.automatic on your home directory.)
|
30
|
+
|
31
|
+
|
28
32
|
[Development]
|
29
33
|
$ git clone git://github.com/id774/automaticruby.git
|
30
34
|
|
31
|
-
|
32
|
-
If the ruby 1.9, put following command.
|
35
|
+
$ cd automaticruby
|
33
36
|
$ script/bootstrap
|
34
37
|
|
35
|
-
If the ruby 1.8, necessary to manually install the gems in the Gemfile.
|
36
|
-
|
37
38
|
|
38
39
|
===========
|
39
40
|
Get Started
|
40
41
|
===========
|
41
42
|
|
42
|
-
|
43
|
+
Create of any recipe (see below).
|
43
44
|
$ automatic -c your_recipe.yml
|
44
45
|
|
45
46
|
-c option to run with the manual. If there is no problem
|
46
47
|
to automate, register it to cron.
|
47
48
|
|
49
|
+
If you specify the-c argument of a simple file name, load
|
50
|
+
the file located in ~ /.automatic/config. If not exist,
|
51
|
+
load file as specified in the path.
|
52
|
+
|
53
|
+
If ~/.automatic/db exists, plug-ins save the file to this
|
54
|
+
directory.
|
55
|
+
|
56
|
+
If ~/.automatic/plugins exists, the plug-ins be loaded
|
57
|
+
as well.
|
58
|
+
|
48
59
|
|
49
60
|
This is the easy recipe to simply output blog's feed to
|
50
61
|
only console. It can be used to check the operation of
|
51
62
|
this software.
|
52
|
-
$ automatic -c config/feed2console.yml
|
63
|
+
$ automatic -c ~/automatic/config/example/feed2console.yml
|
53
64
|
|
54
65
|
|
55
66
|
=======
|
@@ -62,12 +73,10 @@ of associated plug-ins.
|
|
62
73
|
|
63
74
|
This YAML file is called "Recipe".
|
64
75
|
|
65
|
-
|
66
|
-
the config/default.yml is called. You can use -c option for
|
67
|
-
specify a file name.
|
76
|
+
You can use -c option for specify a file name.
|
68
77
|
|
69
78
|
[Example]
|
70
|
-
$ automatic -c
|
79
|
+
$ automatic -c your_recipe.yml
|
71
80
|
|
72
81
|
|
73
82
|
=====================
|
@@ -191,10 +200,9 @@ Directory and file structure
|
|
191
200
|
| +-- automatic-config
|
192
201
|
| The tool for the auxiliary.
|
193
202
|
|
|
194
|
-
|
195
|
-
|
|
196
|
-
|
|
197
|
-
| To describe the recipe information in the form of yaml.
|
203
|
+
+-- config
|
204
|
+
|
|
205
|
+
| Describe the recipe information in the form of yaml.
|
198
206
|
| They called in the argument -c option of Automatic Ruby.
|
199
207
|
| If you write a new recipe, locate it in the config directory.
|
200
208
|
|
|
@@ -207,6 +215,9 @@ Directory and file structure
|
|
207
215
|
| +-- customfeed
|
208
216
|
| | Plug-ins to generate a custom feed.
|
209
217
|
| |
|
218
|
+
| +-- extract
|
219
|
+
| | Plug-ins to extract the information.
|
220
|
+
| |
|
210
221
|
| +-- filter
|
211
222
|
| | Plug-ins to filter the information.
|
212
223
|
| |
|
@@ -228,29 +239,26 @@ Directory and file structure
|
|
228
239
|
| | To the definition of automatic module.
|
229
240
|
| |
|
230
241
|
| +-+ automatic
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
| |
|
248
|
-
| +-- config
|
242
|
+
| |
|
243
|
+
| +-- environment.rb
|
244
|
+
| | Read the environmental information.
|
245
|
+
| |
|
246
|
+
| +-- pipeline.rb
|
247
|
+
| | To use an object called a pipeline
|
248
|
+
| | sequentially processing plug-ins in recipes.
|
249
|
+
| |
|
250
|
+
| +-- feed_parser.rb
|
251
|
+
| | To parse the feed.
|
252
|
+
| |
|
253
|
+
| +-- log.rb
|
254
|
+
| | To output logs.
|
255
|
+
| |
|
256
|
+
| +-- recipe.rb
|
257
|
+
| Read a recipes.
|
249
258
|
|
|
250
|
-
|
251
|
-
|
|
252
|
-
|
|
253
|
-
| Have been collected in the plug-in Store::Permalink.
|
259
|
+
+-- db
|
260
|
+
|
|
261
|
+
| If ~/.automatic/db not exist, save db file here.
|
254
262
|
|
|
255
263
|
+-+ script
|
256
264
|
| |
|
@@ -282,6 +290,9 @@ Directory and file structure
|
|
282
290
|
+-- COPYING
|
283
291
|
| The license for this software.
|
284
292
|
|
|
293
|
+
+-- ChangeLog
|
294
|
+
| Update history.
|
295
|
+
|
|
285
296
|
+-- PLUGINS
|
286
297
|
| Documentation for plug-ins.
|
287
298
|
|
|
@@ -303,6 +314,9 @@ https://github.com/id774/automaticruby/issues
|
|
303
314
|
RubyForge
|
304
315
|
http://rubyforge.org/projects/automatic/
|
305
316
|
|
317
|
+
RubyGems.org
|
318
|
+
https://rubygems.org/gems/automatic
|
319
|
+
|
306
320
|
CI
|
307
321
|
http://jenkins.id774.net/jenkins/
|
308
322
|
|
@@ -353,6 +367,11 @@ pipeline backs again as the return value.
|
|
353
367
|
|
354
368
|
This mechanism called "Automatic::Pipeline".
|
355
369
|
|
370
|
+
The contents of the pipeline is the object of your choice.
|
371
|
+
You can be stored in a format RSS, HTML, and various other
|
372
|
+
in pipeline. However, when combined with the plug-in, it's
|
373
|
+
necessary to input data format of the previous plug-ins
|
374
|
+
and plug-in output of the next match.
|
356
375
|
|
357
376
|
|
358
377
|
=============================
|
@@ -375,6 +394,11 @@ Run an instance method is called automatically. The return value
|
|
375
394
|
is on the instance variable @pipeline. And then, be handed over
|
376
395
|
to the next plug-in in the recipe.
|
377
396
|
|
397
|
+
@pipeline's data format should be combined. If the preceding
|
398
|
+
plug-in will return an RSS feed, you need to write handle the
|
399
|
+
RSS feed. If the one will return as HTML, you need to write
|
400
|
+
code to handle HTML.
|
401
|
+
|
378
402
|
|
379
403
|
=========
|
380
404
|
Unit Test
|
@@ -426,19 +450,22 @@ automatic-config is the auxiliary tool.
|
|
426
450
|
|
427
451
|
[Syntax]
|
428
452
|
$ automatic-config
|
429
|
-
|
453
|
+
Show list of sub-command.
|
430
454
|
|
431
455
|
$ automatic-config scaffold
|
432
|
-
|
456
|
+
Make ~/.automatic directory in your home directory.
|
457
|
+
|
458
|
+
$ automatic-config unscaffold
|
459
|
+
Delete ~/.automatic directory.
|
433
460
|
|
434
461
|
$ automatic-config autodiscovery <url>
|
435
462
|
Return the URL of the feed of target detected by auto discovery.
|
436
463
|
(ex.)
|
437
|
-
$ automatic-config autodiscovery http://blog.id774.net/
|
438
|
-
["http://blog.id774.net/
|
464
|
+
$ automatic-config autodiscovery http://blog.id774.net/post
|
465
|
+
["http://blog.id774.net/post/feed/", "http://blog.id774.net/post/comments/feed/"]
|
439
466
|
|
440
467
|
$ automatic-config opmlparser <opml path>
|
441
|
-
|
468
|
+
Output the URLs to parse the OPML file.
|
442
469
|
(ex.)
|
443
470
|
$ automatic-config opmlparser opml.xml > feeds.txt
|
444
471
|
|
@@ -451,7 +478,7 @@ $ automatic-config inspect <url>
|
|
451
478
|
This inspects verify the target subscriptionable.
|
452
479
|
|
453
480
|
$ automatic-config log <level> <message>
|
454
|
-
|
481
|
+
Output log messages in the form of Automatic Ruby.
|
455
482
|
|
456
483
|
|
457
484
|
|
@@ -486,6 +513,7 @@ activerecord
|
|
486
513
|
gcalapi
|
487
514
|
xml-simple
|
488
515
|
feedbag
|
516
|
+
nokogiri
|
489
517
|
|
490
518
|
For more information, see Gemfile.
|
491
519
|
|
data/doc/README.ja
CHANGED
@@ -26,16 +26,16 @@ $ automatic -v
|
|
26
26
|
[安定版]
|
27
27
|
$ gem install automatic
|
28
28
|
|
29
|
+
$ automatic-config scaffold
|
30
|
+
(ホームディレクトリに ~/.automatic を生成する)
|
31
|
+
|
29
32
|
|
30
33
|
[開発版]
|
31
34
|
$ git clone git://github.com/id774/automaticruby.git
|
32
35
|
|
33
|
-
|
36
|
+
$ cd automaticruby
|
34
37
|
$ script/bootstrap
|
35
38
|
|
36
|
-
ruby 1.8 の場合
|
37
|
-
Gemfile にある必要な gem を手動でインストールする
|
38
|
-
|
39
39
|
|
40
40
|
============
|
41
41
|
実行してみる
|
@@ -47,16 +47,26 @@ $ automatic -c your_recipe.yml
|
|
47
47
|
-c オプション付きで手動実行し、問題がなければ
|
48
48
|
cron に登録するなどして自動化する。
|
49
49
|
|
50
|
+
単純なファイル名を -c の引数に指定した場合 ~/.automatic/config
|
51
|
+
にある同名のファイルがあれば優先的に読み込まれる。無い場合は指定通りの
|
52
|
+
パスにあるファイルが読み込まれる。
|
53
|
+
|
54
|
+
~/.automatic/db が存在する場合、データベースを生成するタイプの
|
55
|
+
プラグインはこのディレクトリにファイルを保存する。
|
50
56
|
|
51
|
-
|
52
|
-
|
53
|
-
|
57
|
+
~/.automatic/plugins が存在する場合、本体付属のプラグインと
|
58
|
+
同様にそれらも読み込まれる。
|
59
|
+
|
60
|
+
|
61
|
+
試しに実行するなら以下を実行すると良い。
|
62
|
+
$ automatic -c ~/.automatic/config/example/feed2console.yml
|
54
63
|
|
55
64
|
これは、ブログのフィードを単純にコンソール出力するだけの
|
56
65
|
簡単なレシピである。
|
57
66
|
本ソフトウェアの動作確認に使うことができる。
|
58
67
|
|
59
68
|
|
69
|
+
|
60
70
|
==========
|
61
71
|
レシピとは
|
62
72
|
==========
|
@@ -68,11 +78,10 @@ $ automatic -c config/feed2console.yml
|
|
68
78
|
この YAML ファイルをレシピと呼ぶ。
|
69
79
|
|
70
80
|
automatic.rb 起動時に -c オプションの引数にレシピの
|
71
|
-
|
72
|
-
された場合は config/default.yml が呼ばれる。
|
81
|
+
ファイル名を指定することができる。
|
73
82
|
|
74
83
|
[起動例]
|
75
|
-
$ automatic -c
|
84
|
+
$ automatic -c your_recipe.yml
|
76
85
|
|
77
86
|
|
78
87
|
================
|
@@ -156,21 +165,6 @@ plugins:
|
|
156
165
|
ことができる。
|
157
166
|
|
158
167
|
|
159
|
-
==========
|
160
|
-
プラグイン
|
161
|
-
==========
|
162
|
-
|
163
|
-
プラグインは後述する plugins ディレクトリにあるものが読み込まれる。
|
164
|
-
|
165
|
-
~/.automatic/plugins が存在する場合、それらも同様に読み込まれる。
|
166
|
-
|
167
|
-
自作したプラグインはホームディレクトリに置くと良い。
|
168
|
-
(プラグインの作り方は後述する)
|
169
|
-
|
170
|
-
以下のコマンドで自作したプラグインのためのサブディレクトリを自動生成できる。
|
171
|
-
$ automatic-config scaffold
|
172
|
-
(automatic-config の説明は後述する)
|
173
|
-
|
174
168
|
|
175
169
|
==========================
|
176
170
|
ディレクトリとファイル構成
|
@@ -186,12 +180,9 @@ $ automatic-config scaffold
|
|
186
180
|
| 利用を補助するためのツール
|
187
181
|
|
|
188
182
|
+- config
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
| YAML 形式でプラグインの情報を記述する
|
193
|
-
| automatic.rb の -c オプションの引数で
|
194
|
-
| 任意のファイル名をレシピとして指定できる
|
183
|
+
| YAML 形式でプラグインの情報を記述する
|
184
|
+
| automatic.rb の -c オプションの引数で
|
185
|
+
| 任意のファイル名をレシピとして指定できる
|
195
186
|
|
|
196
187
|
| 新しくレシピを書いた場合は config ディレクトリに置く
|
197
188
|
|
|
@@ -204,6 +195,9 @@ $ automatic-config scaffold
|
|
204
195
|
| +- customfeed
|
205
196
|
| | カスタムフィードを生成するプラグイン
|
206
197
|
| |
|
198
|
+
| +- extract
|
199
|
+
| | 情報を抽出するプラグイン
|
200
|
+
| |
|
207
201
|
| +- filter
|
208
202
|
| | 情報をフィルタリングするプラグイン
|
209
203
|
| |
|
@@ -225,30 +219,27 @@ $ automatic-config scaffold
|
|
225
219
|
| | Automatic モジュールの定義をする
|
226
220
|
| |
|
227
221
|
| +- automatic
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
| |
|
245
|
-
| +- config
|
222
|
+
| |
|
223
|
+
| +- environment.rb
|
224
|
+
| | 環境情報を読み込む
|
225
|
+
| |
|
226
|
+
| +- pipeline.rb
|
227
|
+
| | パイプラインと呼ばれるオブジェクトを利用し
|
228
|
+
| | レシピに書かれたプラグインに処理を順次受け渡す
|
229
|
+
| |
|
230
|
+
| +- feed_parser.rb
|
231
|
+
| | フィードを解析する
|
232
|
+
| |
|
233
|
+
| +- log.rb
|
234
|
+
| | ログを出力する
|
235
|
+
| |
|
236
|
+
| +- recipe.rb
|
237
|
+
| レシピを読み込む
|
246
238
|
|
|
247
239
|
+- db
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
| ブックマークが保存される
|
240
|
+
|
|
241
|
+
| ~/.automatic/db が無い場合、ここにデータベースが
|
242
|
+
| 保存される
|
252
243
|
|
|
253
244
|
+- script
|
254
245
|
| |
|
@@ -259,9 +250,6 @@ $ automatic-config scaffold
|
|
259
250
|
| bundle install 等の環境設定をおこなう
|
260
251
|
| (ruby 1.9 以上のみ)
|
261
252
|
|
|
262
|
-
+- utils
|
263
|
-
| 補助的なツールのためのディレクトリ
|
264
|
-
|
|
265
253
|
+- spec
|
266
254
|
| ユニットテスト用ディレクトリ
|
267
255
|
|
|
@@ -307,6 +295,9 @@ https://github.com/id774/automaticruby/issues
|
|
307
295
|
RubyForge
|
308
296
|
http://rubyforge.org/projects/automatic/
|
309
297
|
|
298
|
+
RubyGems.org
|
299
|
+
https://rubygems.org/gems/automatic
|
300
|
+
|
310
301
|
CI
|
311
302
|
http://jenkins.id774.net/jenkins/
|
312
303
|
|
@@ -382,6 +373,11 @@ Automatic::Pipeline とは
|
|
382
373
|
|
383
374
|
この機構を本フレームワークでは Automatic::Pipeline と呼ぶ。
|
384
375
|
|
376
|
+
pipeline の中身は任意のオブジェクトである。
|
377
|
+
RSS 、 HTML 、その他様々なフォーマットを格納して良い。
|
378
|
+
ただし、プラグインを組み合わせるとき前のプラグインの出力と
|
379
|
+
次のプラグインの入力のデータフォーマットが一致する必要がある。
|
380
|
+
|
385
381
|
|
386
382
|
====================
|
387
383
|
プラグインの実装規約
|
@@ -402,6 +398,12 @@ end
|
|
402
398
|
戻り値はインスタンス変数 @pipeline に渡り、レシピで
|
403
399
|
定義された次のプラグインに引き渡される。
|
404
400
|
|
401
|
+
複数のプラグインを組み合わせるとき @pipeline の
|
402
|
+
データフォーマットが一致している必要がある。
|
403
|
+
たとえば先行するプラグインが RSS フィードを返す場合は
|
404
|
+
RSS フィードを処理する。 HTML を返す場合は HTML を処理
|
405
|
+
するコードを記述する必要がある。
|
406
|
+
|
405
407
|
|
406
408
|
==============
|
407
409
|
ユニットテスト
|
@@ -460,11 +462,14 @@ $ automatic-config
|
|
460
462
|
$ automatic-config scaffold
|
461
463
|
ホームディレクトリに ~/.automatic ディレクトリを生成する。
|
462
464
|
|
465
|
+
$ automatic-config unscaffold
|
466
|
+
ホームディレクトリの ~/.automatic ディレクトリを削除する。
|
467
|
+
|
463
468
|
$ automatic-config autodiscovery <url>
|
464
469
|
対象の URL をオートディスカバリで探知しフィードの URL を返す。
|
465
470
|
(例)
|
466
|
-
$ automatic-config autodiscovery http://blog.id774.net/
|
467
|
-
["http://blog.id774.net/
|
471
|
+
$ automatic-config autodiscovery http://blog.id774.net/post
|
472
|
+
["http://blog.id774.net/post/feed/", "http://blog.id774.net/post/comments/feed/"]
|
468
473
|
|
469
474
|
$ automatic-config opmlparser <opml path>
|
470
475
|
OPML ファイルを解析し URL を出力する。
|
@@ -515,6 +520,7 @@ activerecord
|
|
515
520
|
gcalapi
|
516
521
|
xml-simple
|
517
522
|
feedbag
|
523
|
+
nokogiri
|
518
524
|
|
519
525
|
詳細は Gemfile を参照
|
520
526
|
|
data/lib/automatic/opml.rb
CHANGED
data/lib/automatic/pipeline.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
1
|
# -*- coding: utf-8 -*-
|
3
2
|
# Name:: Automatic::Pipeline
|
4
3
|
# Author:: 774 <http://id774.net>
|
@@ -20,8 +19,9 @@ module Automatic
|
|
20
19
|
Automatic.plugins_dir + "/*"].each{ |dir|
|
21
20
|
subdir = File.basename dir
|
22
21
|
if /#{subdir}_(.*)$/ =~ module_name.underscore
|
23
|
-
path = dir + "/#{$1}.rb"
|
24
|
-
return Automatic::Plugin.autoload module_name.to_sym,
|
22
|
+
path = dir + "/#{$1}.rb"
|
23
|
+
return Automatic::Plugin.autoload module_name.to_sym,
|
24
|
+
path.to_s if File.exists? path
|
25
25
|
end
|
26
26
|
}
|
27
27
|
raise NoPluginError, "unknown plugin named #{module_name}"
|
data/lib/automatic/recipe.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
# Name:: Automatic::Recipe
|
2
3
|
# Author:: ainame
|
4
|
+
# 774 <http://id774.net>
|
3
5
|
# Created:: Feb 18, 2012
|
4
|
-
# Updated::
|
6
|
+
# Updated:: Jun 14, 2012
|
5
7
|
# Copyright:: 774 Copyright (c) 2012
|
6
8
|
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|
7
9
|
|
@@ -17,6 +19,9 @@ module Automatic
|
|
17
19
|
end
|
18
20
|
|
19
21
|
def load_recipe(path)
|
22
|
+
dir = File.join((File.expand_path('~/.automatic/config/')), path)
|
23
|
+
path = dir if File.exist?(dir)
|
24
|
+
Automatic::Log.puts("info", "Loading: #{path}")
|
20
25
|
@procedure = Hashie::Mash.new(YAML.load(File.read(path)))
|
21
26
|
end
|
22
27
|
|
data/lib/automatic.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
|
1
|
+
# -*- coding: utf-8 -*-
|
2
2
|
# Name:: Automatic::Ruby
|
3
3
|
# Author:: 774 <http://id774.net>
|
4
|
-
# Version:: 12.
|
4
|
+
# Version:: 12.6.0
|
5
5
|
# Created:: Feb 18, 2012
|
6
|
-
# Updated::
|
6
|
+
# Updated:: Jun 18, 2012
|
7
7
|
# Copyright:: 774 Copyright (c) 2012
|
8
8
|
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|
9
9
|
|
@@ -14,7 +14,7 @@ module Automatic
|
|
14
14
|
require 'automatic/log'
|
15
15
|
require 'automatic/feed_parser'
|
16
16
|
|
17
|
-
VERSION = "12.
|
17
|
+
VERSION = "12.6.0"
|
18
18
|
USER_DIR = "/.automatic"
|
19
19
|
|
20
20
|
class << self
|
@@ -25,7 +25,7 @@ module Automatic
|
|
25
25
|
self.user_dir = args[:user_dir]
|
26
26
|
Automatic::Pipeline.run(args[:recipe])
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
def plugins_dir
|
30
30
|
File.join(@root_dir, "plugins")
|
31
31
|
end
|
@@ -40,7 +40,7 @@ module Automatic
|
|
40
40
|
|
41
41
|
def user_dir=(_user_dir)
|
42
42
|
if ENV["AUTOMATIC_RUBY_ENV"] == "test" && !(_user_dir.nil?)
|
43
|
-
@user_dir = _user_dir
|
43
|
+
@user_dir = _user_dir
|
44
44
|
else
|
45
45
|
@user_dir = File.expand_path("~/") + USER_DIR
|
46
46
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Name:: Automatic::Plugin::Extract::Link
|
3
|
+
# Author:: 774 <http://id774.net>
|
4
|
+
# Created:: May 24, 2012
|
5
|
+
# Updated:: Jun 13, 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 ExtractLink
|
11
|
+
require 'nokogiri'
|
12
|
+
|
13
|
+
def initialize(config, pipeline=[])
|
14
|
+
@config = config
|
15
|
+
@pipeline = pipeline
|
16
|
+
end
|
17
|
+
|
18
|
+
def run
|
19
|
+
@return_html = []
|
20
|
+
@pipeline.each {|html|
|
21
|
+
img_url = ""
|
22
|
+
unless html.nil?
|
23
|
+
doc = Nokogiri::HTML(html)
|
24
|
+
(doc/:a).each {|link|
|
25
|
+
@return_html << link[:href]
|
26
|
+
}
|
27
|
+
end
|
28
|
+
}
|
29
|
+
@return_html
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/plugins/filter/ignore.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
1
|
# -*- coding: utf-8 -*-
|
3
2
|
# Name:: Automatic::Plugin::Filter::Ignore
|
4
3
|
# Author:: 774 <http://id774.net>
|
5
4
|
# Created:: Feb 22, 2012
|
6
|
-
# Updated::
|
5
|
+
# Updated:: Jun 14, 2012
|
7
6
|
# Copyright:: 774 Copyright (c) 2012
|
8
7
|
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
|
9
8
|
|
@@ -16,18 +15,10 @@ module Automatic::Plugin
|
|
16
15
|
|
17
16
|
def exclude(items)
|
18
17
|
detection = false
|
19
|
-
unless @config['title'].nil?
|
20
|
-
@config['title'].each {|e|
|
21
|
-
if items.title.include?(e.chomp)
|
22
|
-
detection = true
|
23
|
-
Automatic::Log.puts("info", "Excluded by title: #{items.link}")
|
24
|
-
end
|
25
|
-
}
|
26
|
-
end
|
27
18
|
unless @config['link'].nil?
|
28
19
|
@config['link'].each {|e|
|
29
20
|
if items.link.include?(e.chomp)
|
30
|
-
detection = true
|
21
|
+
detection = true
|
31
22
|
Automatic::Log.puts("info", "Excluded by link: #{items.link}")
|
32
23
|
end
|
33
24
|
}
|
@@ -35,7 +26,7 @@ module Automatic::Plugin
|
|
35
26
|
unless @config['exclude'].nil?
|
36
27
|
@config['exclude'].each {|e|
|
37
28
|
if items.link.include?(e.chomp)
|
38
|
-
detection = true
|
29
|
+
detection = true
|
39
30
|
Automatic::Log.puts("info", "Excluded by link: #{items.link}")
|
40
31
|
end
|
41
32
|
}
|
@@ -43,7 +34,7 @@ module Automatic::Plugin
|
|
43
34
|
unless @config['description'].nil?
|
44
35
|
@config['description'].each {|e|
|
45
36
|
if items.description.include?(e.chomp)
|
46
|
-
detection = true
|
37
|
+
detection = true
|
47
38
|
Automatic::Log.puts("info", "Excluded by description: #{items.link}")
|
48
39
|
end
|
49
40
|
}
|
@@ -52,7 +43,7 @@ module Automatic::Plugin
|
|
52
43
|
end
|
53
44
|
|
54
45
|
def run
|
55
|
-
return_feeds = []
|
46
|
+
@return_feeds = []
|
56
47
|
@pipeline.each {|feeds|
|
57
48
|
ignore = false
|
58
49
|
unless feeds.nil?
|
@@ -60,9 +51,9 @@ module Automatic::Plugin
|
|
60
51
|
ignore = true if exclude(items)
|
61
52
|
}
|
62
53
|
end
|
63
|
-
return_feeds << feeds unless ignore
|
54
|
+
@return_feeds << feeds unless ignore
|
64
55
|
}
|
65
|
-
return_feeds
|
56
|
+
@return_feeds
|
66
57
|
end
|
67
58
|
end
|
68
59
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Name:: Automatic::Plugin::Filter::ImageLink
|
3
|
+
# Author:: 774 <http://id774.net>
|
4
|
+
# Created:: May 24, 2012
|
5
|
+
# Updated:: Jun 13, 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 FilterImageLink
|
11
|
+
def initialize(config, pipeline=[])
|
12
|
+
@config = config
|
13
|
+
@pipeline = pipeline
|
14
|
+
end
|
15
|
+
|
16
|
+
def run
|
17
|
+
@return_html = []
|
18
|
+
@pipeline.each {|html|
|
19
|
+
unless html.nil?
|
20
|
+
html.scan(/(.*?\.jp.*g$)/i) { |matched|
|
21
|
+
@return_html << matched.join(" ")
|
22
|
+
}
|
23
|
+
html.scan(/(.*?\.png$)/i) { |matched|
|
24
|
+
@return_html << matched.join(" ")
|
25
|
+
}
|
26
|
+
html.scan(/(.*?\.gif$)/i) { |matched|
|
27
|
+
@return_html << matched.join(" ")
|
28
|
+
}
|
29
|
+
html.scan(/(.*?\.tiff$)/i) { |matched|
|
30
|
+
@return_html << matched.join(" ")
|
31
|
+
}
|
32
|
+
end
|
33
|
+
}
|
34
|
+
@return_html
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|