Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

hook の仕組みを見直す

#11

hook の仕組みを見直す必要があると思ってます。 どのタイミングでどういう hook が呼ばれるのか(呼ばれてほしいか)を一度整理する必要あり。

hook の種類よってコールされる proc の種類も変わってくると思われるので、その辺も整理する必要あり。

移行が大変。。

Reported by jugyo · January 16th, 2009 @ 09:08 PM

State: resolved
Milestone: none
Assigned to: jugyo jugyo

Activity

  1. jugyo
    jugyo
    • Tag set to enhancement
    • Assigned user set to jugyo

    現状の hook 周りの動作と未実装のところを簡単に絵にしてみました。 青いところが hook が呼ばれるポイントです。

    Picture_2.png

    filter が抜けてるな。

    January 24th, 2009 @ 09:51 PM

  2. jugyo
    jugyo

    コマンドの実行前と実行後の hook の処理を実装した。

    Picture_1.png

    January 25th, 2009 @ 05:39 PM

  3. jugyo
    jugyo

    追加した順に hook が呼ばれるようにする必要があるなー。

    January 25th, 2009 @ 05:47 PM

  4. jugyo
    jugyo

    hook の定義の仕方ですが、新しいやり方は以下のようになります。

    
    Termtter::Client.register_hook(
      :name => :modify_arg_hook_sample,
      :points => [:modify_arg_for_update],
      :exec_proc => proc {|cmd, arg| arg + '\(^o^)/'}
    )
    

    :name は一意である必要があります。 同じ :name の hook を複数定義することはできません。 もし同じ :name の hook が複数定義されていた場合は、後に定義されたものだけが有効になります(上書きされる形になります)。

    :points には hook が呼び出されるポイントを指定します。 複数指定できます。

    :exec_proc には hook の処理を書きます。 hook によってブロックに渡される引数が違ってきます(これはちゃんとドキュメント化する必要があるなぁ)。 hook によってはブロックの戻り値を利用するものもあります。

    hook の仕様はこれで完全に決定というわけではなくて、もっとこうしてほしいとか、要望があれば検討しますー。

    January 25th, 2009 @ 06:36 PM

  5. jugyo
    jugyo
    • State changed from new to resolved

    とりあえず実装できたので。

    February 27th, 2009 @ 10:21 AM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.