239 文字
1 分
Webサイトの更新を逐一知るためのスクリプト

概要#

  • Rubyを仕事で書き始めて1ヶ月半が経過しました。
  • ほんと、gemのおかげで書くコードが少なくて大変助かっております。
  • ということで、そのgemに貢献するためにも、ある程度汎用性のある機能が出来たらgem作っていこうと思っています。

作ったもの#

gem

使い方#

Installation#

Add this line to your application’s Gemfile:

gem 'web_update_checker'

And then execute:

Terminal window
$ bundle

Or install it yourself as:

Terminal window
$ gem install web_update_checker

Usage#

main.rb

regex = /<h1>(.*)<\/h1>/
mail = Mail.new do
subject 'Web site is updated!'
body @url
end
mail.delivery_method :smtp, {
address: 'localhost',
port: 25,
}
url = 'http://example.com/'
WebUpdateChecker::Checker.new(url, regex, mail).execute

Execute like a following CLI

Terminal window
% while [ true ]; do; ruby main.rb; sleep 30; done
Webサイトの更新を逐一知るためのスクリプト
https://blog.teraren.com/posts/gem/
作者
Yuki Matsukura
公開日
2014-02-16
ライセンス
CC BY-NC-SA 4.0

コメント