Perlのフレームワーク「Ark」を入れてみた

インストールだけで結構面倒だった。
今後迷わないように、まとめる。
 
基本的なインストール方法は、ここを参照。
 
ついに出た!最新Perlフレームワーク「Ark」徹底解剖:第2回 Ark チュートリアル:基礎編|gihyo.jp … 技術評論社
http://gihyo.jp/dev/feature/01/perl_ark/0002
 
ダウンロードはここから。
今のところ最新のArk-0.1202.tar.gzをダウンロードした。
 
Downloads for typester's ark-perl - GitHub
http://github.com/typester/ark-perl/downloads
 

各種モジュールのインストール

cpan -t .

でmissingになったモジュールをひとつひとつ手動で入れる。
 
 

Net::OpenID::Consumerのインストールに失敗する

失敗というか、終わらない。
Math::BigInt::GMPが入っていないと、Crypt::DHのテストがCPU100%になって何時まで経っても終わらない。
デフォルトで使われるMath::BigInt::Calcは、遅いらしい。
 
インストール方法。

# cpan -i Math::BigInt
# cpan -i Math::BigInt::GMP
# cpan -i Crypt::DH
# cpan -i Net::OpenID::Consumer

 
Consumerの実装を知り、OpenIDを使ってみよう − @IT
http://www.atmarkit.co.jp/fsecurity/rensai/openid03/openid01.html
 

make testに失敗する

Test::Pod::Coverageが入ってると失敗しまくる。
入ってなくても、t/form.tで失敗する。
原因がよく解らない。
makeは成功してるっぽいから、強制インストールしちゃう。

# cpan -f -i .

 

ark.pl newappでadd_triggerが呼べないと怒られる

こんなエラー。

$ ark.pl newapp HelloWorld
Can't call method "add_trigger" on an undefined value at /usr/lib/perl5/site_perl/5.8.8/Module/Setup/Plugin.pm line 22.

 
/usr/lib/perl5/site_perl/5.8.8/Module/Setup/Plugin.pmを修正する。
 
Before

sub add_trigger {
    my($self, @args) = @_;
    $self->{context}->add_trigger(@args);
}

 
After

sub add_trigger {
    my($self, @args) = @_;
    $self->{context}->add_trigger(@args) if $self->{context};
}

 
ここを参考に。
 
ArkをインストールしてHelloWorld ≫ LandEscape Graphics
http://www.yokada.net/blog/1246
 

アプリケーション作成・起動

作成。
カレントディレクトリ以外にも、~/.arkhelperってディレクトリが作られる。

$ cd /tmp
$ ark.pl newapp HelloWorld

 
ホームディレクトリに作成されるもの。

$ find .arkhelper/
.arkhelper/
.arkhelper/newapp
.arkhelper/newapp/flavors
.arkhelper/newapp/flavors/default
.arkhelper/newapp/flavors/default/config.yaml
.arkhelper/newapp/flavors/default/additional
.arkhelper/newapp/flavors/default/additional/config.yaml
.arkhelper/newapp/flavors/default/template
.arkhelper/newapp/flavors/default/template/Makefile.PL
.arkhelper/newapp/flavors/default/template/lib
.arkhelper/newapp/flavors/default/template/lib/____var-module_path-var____.pm
.arkhelper/newapp/flavors/default/template/lib/____var-module_path-var____
.arkhelper/newapp/flavors/default/template/lib/____var-module_path-var____/Controller
.arkhelper/newapp/flavors/default/template/lib/____var-module_path-var____/Controller/Root.pm
.arkhelper/newapp/flavors/default/template/root
.arkhelper/newapp/flavors/default/template/tmp
.arkhelper/newapp/flavors/default/template/t
.arkhelper/newapp/flavors/default/template/t/00_compile.t
.arkhelper/newapp/flavors/default/plugins
.arkhelper/newapp/plugins

 
カレントディレクトリに作成されるもの。

HelloWorld/
HelloWorld/Makefile.PL
HelloWorld/lib
HelloWorld/lib/HelloWorld.pm
HelloWorld/lib/HelloWorld
HelloWorld/lib/HelloWorld/Controller
HelloWorld/lib/HelloWorld/Controller/Root.pm
HelloWorld/root
HelloWorld/tmp
HelloWorld/t
HelloWorld/t/00_compile.t

 
起動。
オプション-dを付けるとデバッグ表示。

$ cd HelloWorld/
$ ark.pl server -d
[debug] Loaded Path actions:
.-------------------------------------+--------------------------------------.
| Path                                | Private                              |
+-------------------------------------+--------------------------------------+
| /                                   | /index                               |
| /                                   | /default                             |
'-------------------------------------+--------------------------------------'

[debug] Setup finished
HTTP::Engine::Interface::ServerSimple : You can connect to your server at http://0.0.0.0:4423/

 
リクエスト送信。

$ curl -i http://127.0.0.1:4423/
HTTP/1.1 200 OK
Connection: close
Content-Length: 17
Content-Type: text/html
Status: 200

Ark Default Index

 
デバッグに表示される。

[debug] "GET" request for "/" from "127.0.0.1"
[debug] Arguments are ""
[debug] Request took 0.001758s (568.828/s)
.----------------------------------------------------------------+-----------.
| Action                                                         | Time      |
+----------------------------------------------------------------+-----------+
| /index                                                         | 0.000160s |
'----------------------------------------------------------------+-----------'