Skip to content
yagihiro edited this page Sep 13, 2010 · 27 revisions

Welcome to the LWR::Simple libray’s wiki!

LWR::Simple は ruby むけのもうひとつの LWP::Simple といったかんじのライブラリです.

解説

LWP::Simple がそうであるように, LWR::Simple もワンライナーで活躍するようなシーンを想定したインターフェイスになっています. というよりも インターフェイスは LWP::Simple そのものです.

# example. 1
$ ruby -rlwr-simple -e 'getprint "http://www.sn.no"'

# example. 2
$ ruby -rlwr-simple -e 'get("http://www.ruby-lang.org/ja/").scan(/<a.*href="(.+?)"/) {|refs| puts(refs[0])}'

機能

LWP::Simple 同様, 以下 5 つのモジュール関数を提供しています.

  • LWR::Simple.get()
  • LWR::Simple.head()
  • LWR::Simple.getprint()
  • LWR::Simple.getstore()
  • LWR::Simple.mirror()

LWR::Simple はワンライナーで活躍するシーンを想定しているため, 上記のモジュール関数をグローバル関数としても提供しています.
そのため, 以下のように記述することが可能です.


$ ruby -rlwr-simple -e ‘getprint “http://www.sn.no”’

問題点

いまのところありません.

要求

ruby 1.8.6 以上で動作確認しています.
おそらく (net/http に依存している関係上) ruby 1.8.3 以上であれば動作します.

インストール

gem ユーザ向け:

gem install lwr-simple

git ユーザ向け:

git clone git://github.com/yagihiro/lwr-simple.git cd lwr-simple rake gem rake install_gem

ライセンス

Copyright © 2008 Hiroki Yagita

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
‘Software’), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

作者

八木田 寛樹