-
Notifications
You must be signed in to change notification settings - Fork 7
/
Rakefile
42 lines (37 loc) · 1.05 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
require "bundler/gem_tasks"
require "rake/testtask"
task default: :test
Rake::TestTask.new do |t|
t.libs << "test"
t.pattern = "test/**/*_test.rb"
end
task :update, [:file] do |t, args|
require "csv"
codes = {}
CSV.foreach(args.file, headers: true) do |row|
size = row["SIZE"].strip =~ /all.+sizes/i ? nil : row["SIZE"]
name = [size, row["VARIETY"], row["COMMODITY"].capitalize].join(" ")
name = name.gsub(/\s+/, " ").strip
codes[row["PLU"].to_i] = name
end
codes.merge!(
3281 => "Orange Seedless Watermelon",
3283 => "Honeycrisp Apples",
3308 => "Watermelon",
3421 => "Mini Seedless Watermelon",
4011 => "Bananas",
4031 => "Seeded Watermelon",
4032 => "Seedless Watermelon",
4088 => "Red Bell Peppers",
4234 => "Nino Bananas",
4331 => "Mickey Lee/Sugar Baby Watermelon",
4340 => "Yellow Seeded Watermelon",
4341 => "Yellow Seedless Watermelon"
)
CSV.open("plu_codes.csv", "wb") do |csv|
csv << ["PLU Code", "Name"]
codes.each do |plu, name|
csv << [plu, name]
end
end
end