Thu Apr 27 16:54:12 2006 GMT
0.5.6から実装されたinclude,recipe,define_recipesの使い方
概要
Plaggerを使いこなすようになると、用途別にconfigを分割して複数の設定でPlaggerを実行するようになってくると思います。
そんなときに、殆ど共通なglobalや他のplugin設定を複数のファイルに同じ内容で書くのは手間でしょう。
また、数多くプラグインを使用するとconfigファイルが大きくなってしまい見通しが悪くなります。
includeを使うことで共通の設定を一つにまとめることができます。
recipeを使うことにより使用するpluginを見通しよく管理します。 そして、define_recipesを使ってrecipeで設定したpluginを使用する事ができます。
サンプル
複数のSNSを利用するための設定を例として取り上げます。
Yahoo360Jは一時間おき,Mixiは10分おき,Frepaは30おきと、ばらばらにアクセスさせたいケースで有効です。
config.y360j.yaml
include: - /home/plagger/config.base.yaml - /home/plagger/config.sns.yaml recipes: - y360j - publish
config.mixi.yaml
include: - /home/plagger/config.base.yaml - /home/plagger/config.sns.yaml recipes: - mixi - publish
config.frepa.yaml
include: - /home/plagger/config.base.yaml - /home/plagger/config.sns.yaml recipes: - frepa - publish
/home/plagger/config.base.yaml
global:
plugin_path:
- /home/plagger/plugins
template_path: /home/plagger/templates
timezone: Asia/Tokyo
plugins:
- module: Cache
config:
file: /home/plagger/cache
diff_mode: 1
define_recipes:
publish:
- module: Search::Rast
config:
encode: euc_jp
replace: 1
dir: /home/plagger/rast
- module: Publish::Gmail
rule:
- module: Rating
rate: '>= 0'
config:
mailto: plagger@example.com
mailfrom: plagger@example.jp
mailroute:
via: smtp
host: localhost
/home/plagger/config.sns.yaml
define_recipes:
mixi:
module: CustomFeed::Mixi
config:
email: mail
password: pass
fetch_body: 1
fetch_body_internal: 1.5
fetch_items: 10
frepa:
module: CustomFeed::Frepa
config:
livedoor_id: user
password: pass
fetch_body: 1
fetch_body_internal: 1.5
fetch_items: 10
y360j:
module: CustomFeed::Yahoo360JP
config:
username: user
password: pass
fetch_body: 10
fetch_blast: 10
やってることは、config.base.yamlを読むと必ずCacheプラグインでURLをキャッシュしつつ、それぞれのSNSサイトからFeedをとってきてRastのindexをつけ、gmailで内容を送る。
って感じです。