Sha256: 5a9ba5de8b4e46c05a62ff5a40c1bc085944275d25534aa1cb8435c59f76514f
Contents?: true
Size: 790 Bytes
Versions: 3
Compression:
Stored size: 790 Bytes
Contents
namespace :usda do desc 'Import the latest USDA nutrition data' task import: :environment do UsdaNutrientDatabase::Importer.new('tmp/usda', 'sr25').import end [ 'Weights', 'Footnotes', 'FoodGroups', 'Foods', 'FoodsNutrients', 'Nutrients', 'SourceCodes' ].each do |importer_name| desc "Import the USDA #{importer_name} table" task "import_#{importer_name.downcase}" => :environment do download_and_import(importer_name) end end def download_and_import(importer_name) UsdaNutrientDatabase::Import::Downloader.new('tmp/usda', 'sr25'). tap do |downloader| downloader.download_and_unzip "UsdaNutrientDatabase::Import::#{importer_name}".constantize. new('tmp/usda/sr25').import downloader.cleanup end end end
Version data entries
3 entries across 3 versions & 1 rubygems