Rackとは、Rubyで実装したアプリケーションとウェブサーバとを繋ぐインターフェースです。Rackプロトコルに従って実装したアプリケーションは、利用するウェブサーバを自由に選択する事が可能となります。 Rackの開発元へは、以下のリンクから。 Rack: a Ruby Webserver Interface Rackプロトコルについて、簡単に説明します。 Rackプロトコルに従ったアプリケーションとは、環境変数envを引数にとるメソッドcallを持つRubyオブジェクト(インスタンス)を意味します。callは、3つの要素を持つArrayオブジェクトを返します。これは順に、『HTTPステータスコード』『HTTPレスポンスヘッダ』『HTTPボディ』となります。 環境変数 アプリケーションは、環境変数を読み書きする事で、入出力操作等を行える様になります。環境変数は、いわゆるCGI環境変数や、R
Ruby on Rails のMetalを使ったコードのテストですが、RailsのIntegrationTestでテストできます。→ここを参照 しかし、一度RSpecを知ってしまうと従来のUnitTestには戻れません ^^); そこで Rack用のテスティングフレームワーク Rack::Test を使えば RSpec で Metal のテストが書けそうだと思い試してみました。 require(File.dirname(__FILE__) + "/../../config/environment") unless defined?(Rails) class Hello def self.call(env) request = Rack::Request.new(env) if env["PATH_INFO"] =~ /^\/hello/ [200, {"Content-Type" => "
rack-logo posted by (C)komagata komagataです。 仕事でも使う必要が出てきたのでRubyの勉強をしています。WebアプリケーションでRubyを使おうとしていきなり躓いたのがApache、WEBrick、Mongrel等、実行環境毎の設定やAPIの違いです。 Rubyを普段使っている人には常識過ぎるのか情報が少なく、FastCGIで単に「Hello, World」を表示させるのにも一苦労でした。(Railsでは簡単に動くのが悔しい) そんな実行環境毎のAPIの差を吸収してくれるRackというライブラリを知ったので試してみました。 RackはRuby版WSGIと呼ばれているそうです。WSGIとはWeb Server Gateway Interfaceの略でWeb ServerとWeb Applicationの間のInterfaceを定めたPython界の仕
Ruby, Rack, Passenger私が作るサービスは大概小粒なので、今まではほぼ Apache2 + Ruby + Rack + FastCGI で動かしていましたが、mod_passenger も Rack でアドホックなサービスを作れるらしい、と知ったので試してみました。ちなみに、Merb とか Ramaze とか Camping とかの Rails 以外のフレームワークを mod_passenger で動かす場合も、どうも mod_passenger + Rack がベースとなっているようなので、知っていて損は無いと思います。 FastCGI vs mod_passenger結論から。比較対象FastCGImod_passenger速度(req/sec)*1900前後1100前後開発の楽さ基本的に CGI で開発し FastCGI へ移行。*2 FastCGI の時は err
OpenLayers.Layer.TMS を研究するために、rack で TMS 対応サイトを作りました。これから TMS サーバを作るつもりです。 rack を使った理由 アパッチを使うと、アパッチ依存の知識が前提になり、教育が難しくなります。Ruby と gems さえインストールされていればすぐに使えて、ログを標準出力で観察でき、必要な時だけサーバを立ち上げ、知識を得たらすぐに綺麗にサーバを撤収できる、rack を使うことにしました。 メインストリーム IT から離れた業務分野に浸透中で、かつ Web によって世界を良くする手法を開発したいとお考えのITエンジニアのみなさん(うまいこというと、ITゲリラ戦士の皆さん)に、この rack を使う手法をおすすめしたいと思ったりしています*1。 前提知識 コマンドプロンプトなどのCUI Ruby HTMLとJavaScript 準備 sud
Rack provides an minimal interface between webservers supporting Ruby and Ruby frameworks. RackはRubyをサポートするウェブサーバ群とRubyフレームワークとの間の最小のインターフェースを提供する。 Rack: a Ruby Webserver Interface File: SPEC この仕様はRackプロトコルの形式化を目的とする。あなたは、そのためにRack::Lintを適用する事ができる(そしてそうすべき)。あなたがミドルウェアを開発する際、必ずすべての誤りを捕捉する前後にLintしなさい。 Rackアプリケーション Rackアプリケーションはcallに応えるRubyオブジェクト(classではない)。それは1つの引数environmentをとり、3つの値(statusとheadersと
はてなグループの終了日を2020年1月31日(金)に決定しました 以下のエントリの通り、今年末を目処にはてなグループを終了予定である旨をお知らせしておりました。 2019年末を目処に、はてなグループの提供を終了する予定です - はてなグループ日記 このたび、正式に終了日を決定いたしましたので、以下の通りご確認ください。 終了日: 2020年1月31日(金) エクスポート希望申請期限:2020年1月31日(金) 終了日以降は、はてなグループの閲覧および投稿は行えません。日記のエクスポートが必要な方は以下の記事にしたがって手続きをしてください。 はてなグループに投稿された日記データのエクスポートについて - はてなグループ日記 ご利用のみなさまにはご迷惑をおかけいたしますが、どうぞよろしくお願いいたします。 2020-06-25 追記 はてなグループ日記のエクスポートデータは2020年2月28
■ [ruby][rack] 5分でわかるRack RackはRubyのためのWebサーバインターフェイスだ。 RubyでWebっていうとRailsが有名だけど、実はRails以外にもいろんなRuby用のWebアプリ用フレームワークが存在する。 Ramaze Merb Camping Waves などなど…。 一方Webを実際に動かすにはWebサーバが必要だ。RubyのためのWebサーバも、これまたいろんなものがある。 Apache(CGI, FastCGI..) WEBrick Mongrel Ebb Thin などなど…。 ここで問題が一つ。それは「フレームワークが増えるたびに、いろんなサーバをサポートするためのコードが必要になる」ってとこだ。 各フレームワークの作者がみんなそれぞれにCGIやMongrelに対応するためのコードを書いてるなんて、無駄だと思わないか? RackはWebア
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く