开发者

Args not being passed through to Rake tasks

I have a rake task that accepts an argument, :scope (below). I call the rake task like this:

rake podcast:generate_inventory["new"]

This task used to pass the :scope arg perfectly, however, I noti开发者_如何学Cced today that the arg is no longer being passed. Does anyone have any idea why this is happening?

namespace :podcast do

  task :itunes_top_300, [:scope] => :environment do |t,args|
    Podcast.podcast_logger.info("BEGIN: #{Time.now}")
    if args[:scope] == "new"
      Podcast.podcast_logger.info("NEW PODCASTS ONLY")
    end
    Podcast.itunes_top_rss
  end

  task :itunes_genres_top_300 => :itunes_top_300 do
    Podcast.itunes_genre_rss
  end

  task :site_and_feed_discovery, [:scope] => :itunes_genres_top_300 do |t,args|
    if args[:scope] == "new"
      Podcast.site_and_feed_discovery(:new_podcasts_only => true)
    else
      Podcast.site_and_feed_discovery
    end
  end

  task :social_discovery, [:scope] => :site_and_feed_discovery do |t,args|
    if args[:scope] == "new"
      Podcast.social_discovery(:new_podcasts_only => true)
    else
      Podcast.social_discovery
    end
  end

  task :fetch_episodes => :social_discovery do |t,args|
    Episode.episode_logger.info("BEGIN: #{Time.now}")
    Podcast.fetch_episodes
    Episode.episode_logger.info("END: #{Time.now}")
  end

  task :generate_inventory => :fetch_episodes do |t,args|
    Podcast.podcast_logger.info("Successful Rake")
    Podcast.podcast_logger.info("END #{Time.now}")
    Rake::Task['maintenance:daily'].invoke
  end
end


Looks like you're missing the [:scope] bit in your definition of task :generate_inventory. I suspect adding that back in will take care of everything.

Hope that helps!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜