23
21

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

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
21
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
21

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?