2024-01-24 00:51:37 -08:00
|
|
|
namespace :pets do
|
|
|
|
desc "Load a pet's viewer data"
|
|
|
|
task :load, [:name] => [:environment] do |task, args|
|
2024-10-18 17:40:31 -07:00
|
|
|
pp Neopets::CustomPets.fetch_viewer_data(args[:name])
|
2024-01-24 00:51:37 -08:00
|
|
|
end
|
2024-09-13 18:59:17 -07:00
|
|
|
|
|
|
|
desc "Find pets that were, last we saw, of the given color and species"
|
|
|
|
task :find, [:color_name, :species_name] => [:environment] do |task, args|
|
|
|
|
begin
|
|
|
|
pt = PetType.matching_name(args.color_name, args.species_name).first!
|
|
|
|
rescue ActiveRecord::RecordNotFound
|
|
|
|
abort "Could not find pet type for " +
|
2024-10-18 17:40:31 -07:00
|
|
|
"#{args.color_name} #{args.species_name}"
|
2024-09-13 18:59:17 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
limit = ENV.fetch("LIMIT", 10)
|
|
|
|
|
|
|
|
pt.pets.limit(limit).order(id: :desc).pluck(:name).each do |pet_name|
|
|
|
|
puts "- #{pet_name} (https://www.neopets.com/petlookup.phtml?pet=#{pet_name})"
|
|
|
|
end
|
|
|
|
end
|
2024-01-24 00:51:37 -08:00
|
|
|
end
|