Velocipede's User, Sales, and Bike Inventory Web App
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
785 B

namespace :import do
namespace :bikes do
# Imports bikes info from CSV file
task :csv, [:file] => :environment do |t, args|
file = args[:file]
next puts "Usage: rake #{t.name}[$csv_file_path]" unless file
next puts "File #{file} does not exist or is unreachable" unless File.readable? file
pp BikeCsvImporter.new(file).run
end
# Analyze a single field from CSV file
task :analyze_csv, [:file, :field] => :environment do |t, args|
file, field = args.values_at :file, :field
next puts "Usage: rake #{t.name}[$csv_file_path[,\"$field_name\"]]" unless file
next puts "File #{file} does not exist or is unreachable" unless File.readable? file
pp BikeCsvImporter.new(file).analyze field ? [field] : []
end
end
end