2011-02-23 5 views
0

J'ai une tâche rake qui accepte un argument: scope (ci-dessous). j'appelle la tâche Rake comme ceci:Args n'étant pas transmis aux tâches Rake

rake podcast:generate_inventory["new"] 

Cette tâche utilisée pour passer le: champ arg parfaitement, cependant, j'ai remarqué aujourd'hui que le arg n'est plus passé. Est-ce que quelqu'un a une idée de pourquoi cela se passe?

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 

Répondre

1

On dirait que vous manquez le bit [:scope] dans votre définition de task :generate_inventory. Je soupçonne que l'ajout de cela prendra soin de tout.

Espérons que ça aide!

+0

Merci beaucoup Xavier. Travaillé comme un charme :) – lightyrs

Questions connexes