forked from sosedoff/opentable
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
27 lines (22 loc) · 712 Bytes
/
Rakefile
File metadata and controls
27 lines (22 loc) · 712 Bytes
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
task :environment do
require './boot'
end
namespace :opentable do
desc 'Flush all OpenTable data'
task :flush => :environment do
Restaurant.delete_all
end
desc 'Download data snapshot'
task :download => :environment do
config = YAML.load_file('./config/opentable.yml')
downloader = OpenTable::Downloader.new(config)
downloader.download_to('/tmp/opentable.xls', true)
end
desc 'Import and update a fresh OpenTable data'
task :import => :environment do
countries = %w(US CA MX)
parser = OpenTable::Parser.new('/tmp/opentable.xls')
results = parser.parse { |row| countries.include?(row['country']) }
records = Restaurant.import_records(results)
end
end