-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRakefile
45 lines (35 loc) · 876 Bytes
/
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
43
44
require_relative 'main'
require 'sinatra/activerecord/rake'
require_relative 'places'
require_relative 'wwoz'
namespace :scrape do
desc "Scrape Google Places"
task :google_places do
g = GooglePlaceGridSearch.new
g.grid(5)
end
desc "Scrape WWOZ"
task :wwoz do
w = WWOZLivewire.new
w.scrape
end
end
namespace :util do
desc "Digest location names"
task :digest_names do
Location.all.each { |l| l.digest_name; l.save }
end
desc "Export locations to json"
task :export_locations do
File.open("locations.json", 'w') do |f|
f.write(ActiveSupport::JSON.encode(Location.all))
end
end
desc "import locations from json"
task :import_locations do
File.open("locations.json", 'r') do |f|
locs = ActiveSupport::JSON.decode(f.read)
locs.map { |l| Location.new(l['location']).save }
end
end
end