Make rake task from gem available everywhere?

后端 未结 5 1963
独厮守ぢ
独厮守ぢ 2020-12-24 07:17

So I\'m writing a small gem and I have a \'/tasks\' dir in it with some specific rake tasks. How do I make those tasks available automatically everywhere, where the gem is r

5条回答
  •  遥遥无期
    2020-12-24 07:38

    You have to import those tasks in application's Rakefile. This is how it looks in mine (I am using bundler08 to manage my gems):

    %w(gem1 gem2 gem3).each do |g|
      Dir[File.dirname(__FILE__) + "/vendor/bundler_gems/**/#{g}*/tasks/*.rake"].each do |f|
        import f
      end
    end
    

提交回复
热议问题