LoginSignup
23
22

More than 5 years have passed since last update.

Rake タスクがどこで定義されているか調べる

Last updated at Posted at 2013-03-25

Rails の rake assets:precompile のソースが見たかったので、調べてみた。

irb (pry でも可) 起動。

$ irb

load で Rakefile を読み込む。

require "rake"
load "Rakefile"

あとは、

  1. Rake::Task.[] でタスク名からタスクを探して
  2. actions メソッドで実行される Proc の配列を取得し
  3. source_location で定義した場所を得る
Rake::Task["assets:precompile"].actions.map(&:source_location)

これは Rails アプリケーションの例だが、もちろんそれ以外でも使える。

ちなみに Rake::Task.tasks で、定義されたタスクの一覧を確認することができる。

23
22
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
23
22